3232IS_DBA_ELEM_NAME = "isDBA"
3333FILE_CONTENT_ELEM_NAME = "FileContent"
3434DB_ATTR = "db"
35- UNKNOWN_COLUMN_TYPE = "unknown"
35+ UNKNOWN_COLUMN_TYPE = "unknown"
3636USER_SETTINGS_ELEM_NAME = "UserSettings"
3737USER_SETTING_ELEM_NAME = "UserSetting"
3838USERS_ELEM_NAME = "Users"
7272SCHEME_NAME = "sqlmap.xsd"
7373SCHEME_NAME_ATTR = "xsi:noNamespaceSchemaLocation"
7474CHARACTERS_TO_ENCODE = range (32 ) + range (127 , 256 )
75- ENTITIES = {'"' :'"' ,"'" :"'" }
75+ ENTITIES = {'"' : '"' , "'" : "'" }
7676
7777class XMLDump :
7878 '''
@@ -86,7 +86,7 @@ def __init__(self):
8686 self .__root = None
8787 self .__doc = Document ()
8888
89- def __addToRoot (self ,element ):
89+ def __addToRoot (self , element ):
9090 '''
9191 Adds element to the root element
9292 '''
@@ -105,36 +105,36 @@ def __write(self, data, n=True):
105105
106106 kb .dataOutputFlag = True
107107
108- def __getRootChild (self ,elemName ):
108+ def __getRootChild (self , elemName ):
109109 '''
110110 Returns the child of the root with the described name
111111 '''
112112 elements = self .__root .getElementsByTagName (elemName )
113- if elements :
113+ if elements :
114114 return elements [0 ]
115115
116116 return elements
117117
118- def __createTextNode (self ,data ):
118+ def __createTextNode (self , data ):
119119 '''
120120 Creates a text node with utf8 data inside.
121121 The text is escaped to an fit the xml text Format.
122122 '''
123- if data is None :
123+ if data is None :
124124 return self .__doc .createTextNode (u'' )
125- else :
125+ else :
126126 escaped_data = saxutils .escape (data , ENTITIES )
127127 return self .__doc .createTextNode (escaped_data )
128128
129- def __createAttribute (self ,attrName ,attrValue ):
129+ def __createAttribute (self , attrName , attrValue ):
130130 '''
131131 Creates an attribute node with utf8 data inside.
132132 The text is escaped to an fit the xml text Format.
133133 '''
134134 attr = self .__doc .createAttribute (attrName )
135- if attrValue is None :
135+ if attrValue is None :
136136 attr .nodeValue = u''
137- else :
137+ else :
138138 attr .nodeValue = getUnicode (attrValue )
139139 return attr
140140
@@ -153,7 +153,7 @@ def string(self, header, data, sort=True):
153153
154154 if data :
155155 data = self .__formatString (data )
156- else :
156+ else :
157157 data = ""
158158
159159 elem = self .__doc .createElement (MESSAGE_ELEM )
@@ -168,7 +168,6 @@ def lister(self, header, elements, sort=True):
168168 lstElem = self .__doc .createElement (LST_ELEM_NAME )
169169 lstElem .setAttributeNode (self .__createAttribute (TYPE_ATTR , header ))
170170 if elements :
171-
172171 if sort :
173172 try :
174173 elements = set (elements )
@@ -185,7 +184,7 @@ def lister(self, header, elements, sort=True):
185184 memberElem .appendChild (self .__createTextNode (element ))
186185 elif isinstance (element , (list , tuple , set )):
187186 memberElem .setAttributeNode (self .__createAttribute (TYPE_ATTR , "list" ))
188- for e in element :
187+ for e in element :
189188 memberElemStr = self .__doc .createElement (MEMBER_ELEM )
190189 memberElemStr .setAttributeNode (self .__createAttribute (TYPE_ATTR , "string" ))
191190 memberElemStr .appendChild (self .__createTextNode (getUnicode (e )))
@@ -196,7 +195,7 @@ def lister(self, header, elements, sort=True):
196195 self .__addToRoot (listsElem )
197196 listsElem .appendChild (lstElem )
198197
199- def technic (self ,technicType ,data ):
198+ def technic (self , technicType , data ):
200199 '''
201200 Adds information about the technic used to extract data from the db
202201 '''
@@ -210,7 +209,7 @@ def technic(self,technicType,data):
210209 self .__addToRoot (technicsElem )
211210 technicsElem .appendChild (technicElem )
212211
213- def banner (self ,data ):
212+ def banner (self , data ):
214213 '''
215214 Adds information about the database banner to the xml.
216215 The banner contains information about the type and the version of the database.
@@ -219,7 +218,7 @@ def banner(self,data):
219218 bannerElem .appendChild (self .__createTextNode (data ))
220219 self .__addToRoot (bannerElem )
221220
222- def currentUser (self ,data ):
221+ def currentUser (self , data ):
223222 '''
224223 Adds information about the current database user to the xml
225224 '''
@@ -228,7 +227,7 @@ def currentUser(self,data):
228227 currentUserElem .appendChild (textNode )
229228 self .__addToRoot (currentUserElem )
230229
231- def currentDb (self ,data ):
230+ def currentDb (self , data ):
232231 '''
233232 Adds information about the current database is use to the xml
234233 '''
@@ -237,15 +236,15 @@ def currentDb(self,data):
237236 currentDBElem .appendChild (textNode )
238237 self .__addToRoot (currentDBElem )
239238
240- def dba (self ,isDBA ):
239+ def dba (self , isDBA ):
241240 '''
242241 Adds information to the xml that indicates whether the user has DBA privileges
243242 '''
244243 isDBAElem = self .__doc .createElement (IS_DBA_ELEM_NAME )
245244 isDBAElem .setAttributeNode (self .__createAttribute (VALUE_ATTR , getUnicode (isDBA )))
246245 self .__addToRoot (isDBAElem )
247246
248- def users (self ,users ):
247+ def users (self , users ):
249248 '''
250249 Adds a list of the existing users to the xml
251250 '''
@@ -325,7 +324,7 @@ def dbTables(self, dbTables):
325324 for db , tables in dbTables .items ():
326325 tables .sort (key = lambda x : x .lower ())
327326 dbElem = self .__doc .createElement (DATABASE_ELEM_NAME )
328- dbElem .setAttributeNode (self .__createAttribute (NAME_ATTR ,db ))
327+ dbElem .setAttributeNode (self .__createAttribute (NAME_ATTR , db ))
329328 dbTablesElem .appendChild (dbElem )
330329 for table in tables :
331330 tableElem = self .__doc .createElement (DB_TABLE_ELEM_NAME )
@@ -361,7 +360,7 @@ def dbTableColumns(self, tableColumns):
361360 colElem = self .__doc .createElement (COLUMN_ELEM_NAME )
362361 if colType is not None :
363362 colElem .setAttributeNode (self .__createAttribute (TYPE_ATTR , colType ))
364- else :
363+ else :
365364 colElem .setAttributeNode (self .__createAttribute (TYPE_ATTR , UNKNOWN_COLUMN_TYPE ))
366365 colElem .appendChild (self .__createTextNode (column ))
367366 tableElem .appendChild (colElem )
@@ -426,16 +425,16 @@ def dbColumns(self, dbColumns, colConsider, dbs):
426425 if tbl in printDbs [db ]:
427426 printDbs [db ][tbl ][col ] = dataType
428427 else :
429- printDbs [db ][tbl ] = { col : dataType }
428+ printDbs [db ][tbl ] = {col : dataType }
430429 else :
431430 printDbs [db ] = {}
432- printDbs [db ][tbl ] = { col : dataType }
431+ printDbs [db ][tbl ] = {col : dataType }
433432
434433 continue
435434
436435 self .dbTableColumns (printDbs )
437436
438- def query (self ,query ,queryRes ):
437+ def query (self , query , queryRes ):
439438 '''
440439 Adds details of an executed query to the xml.
441440 The query details are the query itself and it's results.
@@ -449,7 +448,7 @@ def query(self,query,queryRes):
449448 self .__addToRoot (queriesElem )
450449 queriesElem .appendChild (queryElem )
451450
452- def registerValue (self ,registerData ):
451+ def registerValue (self , registerData ):
453452 '''
454453 Adds information about an extracted registry key to the xml
455454 '''
@@ -474,8 +473,8 @@ def setOutputFile(self):
474473 '''
475474 Initiates the xml file from the configuration.
476475 '''
477- if (conf .xmlFile ) :
478- try :
476+ if (conf .xmlFile ):
477+ try :
479478 self .__outputFile = conf .xmlFile
480479 self .__root = None
481480
@@ -490,8 +489,8 @@ def setOutputFile(self):
490489
491490 if self .__root is None :
492491 self .__root = self .__doc .createElementNS (NAME_SPACE_ATTR , RESULTS_ELEM_NAME )
493- self .__root .setAttributeNode (self .__createAttribute (XMLNS_ATTR ,NAME_SPACE_ATTR ))
494- self .__root .setAttributeNode (self .__createAttribute (SCHEME_NAME_ATTR ,SCHEME_NAME ))
492+ self .__root .setAttributeNode (self .__createAttribute (XMLNS_ATTR , NAME_SPACE_ATTR ))
493+ self .__root .setAttributeNode (self .__createAttribute (SCHEME_NAME_ATTR , SCHEME_NAME ))
495494 self .__doc .appendChild (self .__root )
496495 except IOError :
497496 raise sqlmapFilePathException ("Wrong filename provided for saving the xml file: %s" % conf .xmlFile )
@@ -508,7 +507,7 @@ def finish(self, resultStatus, resultMsg=""):
508507 '''
509508 if ((self .__outputFP is not None ) and not (self .__outputFP .closed )):
510509 statusElem = self .__doc .createElement (STATUS_ELEM_NAME )
511- statusElem .setAttributeNode (self .__createAttribute (SUCESS_ATTR ,getUnicode (resultStatus )))
510+ statusElem .setAttributeNode (self .__createAttribute (SUCESS_ATTR , getUnicode (resultStatus )))
512511
513512 if not resultStatus :
514513 errorElem = self .__doc .createElement (ERROR_ELEM_NAME )
@@ -525,6 +524,7 @@ def finish(self, resultStatus, resultMsg=""):
525524 self .__write (prettyprint .formatXML (self .__doc , encoding = UNICODE_ENCODING ))
526525 self .__outputFP .close ()
527526
527+
528528def closeDumper (status , msg = "" ):
529529 """
530530 Closes the dumper of the session
0 commit comments