@@ -46,7 +46,6 @@ class Dump(object):
4646 """
4747 This class defines methods used to parse and output the results
4848 of SQL injection actions
49-
5049 """
5150
5251 def __init__ (self ):
@@ -85,8 +84,8 @@ def setOutputFile(self):
8584 def getOutputFile (self ):
8685 return self ._outputFile
8786
88- def singleString (self , data ):
89- self ._write (data )
87+ def singleString (self , data , content_type = None ):
88+ self ._write (data , content_type = content_type )
9089
9190 def string (self , header , data , content_type = None , sort = True ):
9291 kb .stickyLevel = None
@@ -161,16 +160,20 @@ def users(self, users):
161160 def userSettings (self , header , userSettings , subHeader , content_type = None ):
162161 self ._areAdmins = set ()
163162
164- if userSettings :
165- self ._write ("%s:" % header )
166-
167163 if isinstance (userSettings , (tuple , list , set )):
168164 self ._areAdmins = userSettings [1 ]
169165 userSettings = userSettings [0 ]
170166
171167 users = userSettings .keys ()
172168 users .sort (key = lambda x : x .lower () if isinstance (x , basestring ) else x )
173169
170+ if hasattr (conf , "api" ):
171+ self ._write (userSettings , content_type = content_type )
172+ return
173+
174+ if userSettings :
175+ self ._write ("%s:" % header )
176+
174177 for user in users :
175178 settings = userSettings [user ]
176179
@@ -196,8 +199,12 @@ def userSettings(self, header, userSettings, subHeader, content_type=None):
196199 def dbs (self , dbs ):
197200 self .lister ("available databases" , dbs , content_type = API_CONTENT_TYPE .DBS )
198201
199- def dbTables (self , dbTables , content_type = API_CONTENT_TYPE . TABLES ):
202+ def dbTables (self , dbTables ):
200203 if isinstance (dbTables , dict ) and len (dbTables ) > 0 :
204+ if hasattr (conf , "api" ):
205+ self ._write (dbTables , content_type = API_CONTENT_TYPE .TABLES )
206+ return
207+
201208 maxlength = 0
202209
203210 for tables in dbTables .values ():
@@ -230,12 +237,16 @@ def dbTables(self, dbTables, content_type=API_CONTENT_TYPE.TABLES):
230237
231238 self ._write ("+%s+\n " % lines )
232239 elif dbTables is None or len (dbTables ) == 0 :
233- self .singleString ("No tables found" )
240+ self .singleString ("No tables found" , content_type = API_CONTENT_TYPE . TABLES )
234241 else :
235- self .string ("tables" , dbTables )
242+ self .string ("tables" , dbTables , content_type = API_CONTENT_TYPE . TABLES )
236243
237- def dbTableColumns (self , tableColumns , content_type = API_CONTENT_TYPE . COLUMNS ):
244+ def dbTableColumns (self , tableColumns , content_type = None ):
238245 if isinstance (tableColumns , dict ) and len (tableColumns ) > 0 :
246+ if hasattr (conf , "api" ):
247+ self ._write (tableColumns , content_type = content_type )
248+ return
249+
239250 for db , tables in tableColumns .items ():
240251 if not db :
241252 db = "All"
@@ -301,8 +312,12 @@ def dbTableColumns(self, tableColumns, content_type=API_CONTENT_TYPE.COLUMNS):
301312 else :
302313 self ._write ("+%s+\n " % lines1 )
303314
304- def dbTablesCount (self , dbTables , content_type = API_CONTENT_TYPE . COUNT ):
315+ def dbTablesCount (self , dbTables ):
305316 if isinstance (dbTables , dict ) and len (dbTables ) > 0 :
317+ if hasattr (conf , "api" ):
318+ self ._write (dbTables , content_type = API_CONTENT_TYPE .COUNT )
319+ return
320+
306321 maxlength1 = len ("Table" )
307322 maxlength2 = len ("Entries" )
308323
@@ -343,7 +358,7 @@ def dbTablesCount(self, dbTables, content_type=API_CONTENT_TYPE.COUNT):
343358 else :
344359 logger .error ("unable to retrieve the number of entries for any table" )
345360
346- def dbTableValues (self , tableValues , content_type = API_CONTENT_TYPE . DUMP_TABLE ):
361+ def dbTableValues (self , tableValues ):
347362 replication = None
348363 rtable = None
349364 dumpFP = None
@@ -356,6 +371,10 @@ def dbTableValues(self, tableValues, content_type=API_CONTENT_TYPE.DUMP_TABLE):
356371 db = "All"
357372 table = tableValues ["__infos__" ]["table" ]
358373
374+ if hasattr (conf , "api" ):
375+ self ._write (tableValues , content_type = API_CONTENT_TYPE .DUMP_TABLE )
376+ return
377+
359378 if conf .dumpFormat == DUMP_FORMAT .SQLITE :
360379 replication = Replication ("%s%s%s.sqlite3" % (conf .dumpPath , os .sep , unsafeSQLIdentificatorNaming (db )))
361380 elif conf .dumpFormat in (DUMP_FORMAT .CSV , DUMP_FORMAT .HTML ):
@@ -549,7 +568,11 @@ def dbTableValues(self, tableValues, content_type=API_CONTENT_TYPE.DUMP_TABLE):
549568 dumpFP .close ()
550569 logger .info ("table '%s.%s' dumped to %s file '%s'" % (db , table , conf .dumpFormat , dumpFileName ))
551570
552- def dbColumns (self , dbColumnsDict , colConsider , dbs , content_type = API_CONTENT_TYPE .COLUMNS ):
571+ def dbColumns (self , dbColumnsDict , colConsider , dbs ):
572+ if hasattr (conf , "api" ):
573+ self ._write (dbColumnsDict , content_type = API_CONTENT_TYPE .COLUMNS )
574+ return
575+
553576 for column in dbColumnsDict .keys ():
554577 if colConsider == "1" :
555578 colConsiderStr = "s like '" + column + "' were"
0 commit comments