Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25f01a4

Browse files
committed
Minor style update (for the sake of consistency over the code and our PEP8 adaptation)
1 parent bdd2592 commit 25f01a4

19 files changed

Lines changed: 106 additions & 106 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _selectInjection():
113113

114114
if select.isdigit() and int(select) < len(kb.injections) and int(select) >= 0:
115115
index = int(select)
116-
elif select[0] in ( "Q", "q" ):
116+
elif select[0] in ("Q", "q"):
117117
raise SqlmapUserQuitException
118118
else:
119119
errMsg = "invalid choice"

lib/core/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,13 @@ def forgeQueryOutputLength(self, expression):
855855
else:
856856
query = expression
857857

858-
if ( select and re.search("\A(COUNT|LTRIM)\(", query, re.I) ) or len(query) <= 1:
858+
if (select and re.search("\A(COUNT|LTRIM)\(", query, re.I)) or len(query) <= 1:
859859
return query
860860

861861
if selectDistinctExpr:
862862
lengthExpr = "SELECT %s FROM (%s)" % (lengthQuery % query, expression)
863863

864-
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
864+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
865865
lengthExpr += " AS %s" % randomStr(lowercase=True)
866866
elif select:
867867
lengthExpr = expression.replace(query, lengthQuery % query, 1)

lib/core/option.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def _parseBurpLog(content):
307307
params = True
308308

309309
# Avoid proxy and connection type related headers
310-
elif key not in ( HTTPHEADER.PROXY_CONNECTION, HTTPHEADER.CONNECTION ):
310+
elif key not in (HTTPHEADER.PROXY_CONNECTION, HTTPHEADER.CONNECTION):
311311
conf.httpHeaders.append((getUnicode(key), getUnicode(value)))
312312

313313
if getPostReq and (params or cookie):
@@ -1050,11 +1050,11 @@ def _setHTTPAuthentication():
10501050

10511051
aTypeLower = conf.aType.lower()
10521052

1053-
if aTypeLower not in ( "basic", "digest", "ntlm" ):
1053+
if aTypeLower not in ("basic", "digest", "ntlm"):
10541054
errMsg = "HTTP authentication type value must be "
10551055
errMsg += "Basic, Digest or NTLM"
10561056
raise SqlmapSyntaxException(errMsg)
1057-
elif aTypeLower in ( "basic", "digest" ):
1057+
elif aTypeLower in ("basic", "digest"):
10581058
regExp = "^(.*?):(.*?)$"
10591059
errMsg = "HTTP %s authentication credentials " % aTypeLower
10601060
errMsg += "value must be in format username:password"
@@ -1715,8 +1715,8 @@ def _saveCmdline():
17151715
if value is None:
17161716
if datatype == "boolean":
17171717
value = "False"
1718-
elif datatype in ( "integer", "float" ):
1719-
if option in ( "threads", "verbose" ):
1718+
elif datatype in ("integer", "float"):
1719+
if option in ("threads", "verbose"):
17201720
value = "1"
17211721
elif option == "timeout":
17221722
value = "10"
@@ -1839,7 +1839,7 @@ def _setTorHttpProxySettings():
18391839

18401840
found = None
18411841

1842-
for port in (DEFAULT_TOR_HTTP_PORTS if not conf.torPort else (conf.torPort, )):
1842+
for port in (DEFAULT_TOR_HTTP_PORTS if not conf.torPort else (conf.torPort,)):
18431843
try:
18441844
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
18451845
s.connect((LOCALHOST, port))

lib/core/readlineng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
if PLATFORM == 'mac' and _readline:
3939
import commands
4040

41-
(status, result) = commands.getstatusoutput( "otool -L %s | grep libedit" % _readline.__file__ )
41+
(status, result) = commands.getstatusoutput("otool -L %s | grep libedit" % _readline.__file__)
4242

4343
if status == 0 and len(result) > 0:
4444
# We are bound to libedit - new in Leopard

lib/core/settings.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,43 +131,43 @@
131131
PYVERSION = sys.version.split()[0]
132132

133133
# Database management system specific variables
134-
MSSQL_SYSTEM_DBS = ( "Northwind", "master", "model", "msdb", "pubs", "tempdb" )
135-
MYSQL_SYSTEM_DBS = ( "information_schema", "mysql" ) # Before MySQL 5.0 only "mysql"
136-
PGSQL_SYSTEM_DBS = ( "information_schema", "pg_catalog", "pg_toast" )
137-
ORACLE_SYSTEM_DBS = ( "SYSTEM", "SYSAUX", "SYS" ) # These are TABLESPACE_NAME
138-
SQLITE_SYSTEM_DBS = ( "sqlite_master", "sqlite_temp_master" )
139-
ACCESS_SYSTEM_DBS = ( "MSysAccessObjects", "MSysACEs", "MSysObjects", "MSysQueries", "MSysRelationships", "MSysAccessStorage",\
140-
"MSysAccessXML", "MSysModules", "MSysModules2" )
141-
FIREBIRD_SYSTEM_DBS = ( "RDB$BACKUP_HISTORY", "RDB$CHARACTER_SETS", "RDB$CHECK_CONSTRAINTS", "RDB$COLLATIONS", "RDB$DATABASE",\
134+
MSSQL_SYSTEM_DBS = ("Northwind", "master", "model", "msdb", "pubs", "tempdb")
135+
MYSQL_SYSTEM_DBS = ("information_schema", "mysql") # Before MySQL 5.0 only "mysql"
136+
PGSQL_SYSTEM_DBS = ("information_schema", "pg_catalog", "pg_toast")
137+
ORACLE_SYSTEM_DBS = ("SYSTEM", "SYSAUX", "SYS") # These are TABLESPACE_NAME
138+
SQLITE_SYSTEM_DBS = ("sqlite_master", "sqlite_temp_master")
139+
ACCESS_SYSTEM_DBS = ("MSysAccessObjects", "MSysACEs", "MSysObjects", "MSysQueries", "MSysRelationships", "MSysAccessStorage",\
140+
"MSysAccessXML", "MSysModules", "MSysModules2")
141+
FIREBIRD_SYSTEM_DBS = ("RDB$BACKUP_HISTORY", "RDB$CHARACTER_SETS", "RDB$CHECK_CONSTRAINTS", "RDB$COLLATIONS", "RDB$DATABASE",\
142142
"RDB$DEPENDENCIES", "RDB$EXCEPTIONS", "RDB$FIELDS", "RDB$FIELD_DIMENSIONS", " RDB$FILES", "RDB$FILTERS",\
143143
"RDB$FORMATS", "RDB$FUNCTIONS", "RDB$FUNCTION_ARGUMENTS", "RDB$GENERATORS", "RDB$INDEX_SEGMENTS", "RDB$INDICES",\
144144
"RDB$LOG_FILES", "RDB$PAGES", "RDB$PROCEDURES", "RDB$PROCEDURE_PARAMETERS", "RDB$REF_CONSTRAINTS", "RDB$RELATIONS",\
145145
"RDB$RELATION_CONSTRAINTS", "RDB$RELATION_FIELDS", "RDB$ROLES", "RDB$SECURITY_CLASSES", "RDB$TRANSACTIONS", "RDB$TRIGGERS",\
146-
"RDB$TRIGGER_MESSAGES", "RDB$TYPES", "RDB$USER_PRIVILEGES", "RDB$VIEW_RELATIONS" )
147-
MAXDB_SYSTEM_DBS = ( "SYSINFO", "DOMAIN" )
148-
SYBASE_SYSTEM_DBS = ( "master", "model", "sybsystemdb", "sybsystemprocs" )
149-
DB2_SYSTEM_DBS = ( "NULLID", "SQLJ", "SYSCAT", "SYSFUN", "SYSIBM", "SYSIBMADM", "SYSIBMINTERNAL", "SYSIBMTS",\
150-
"SYSPROC", "SYSPUBLIC", "SYSSTAT", "SYSTOOLS" )
151-
152-
MSSQL_ALIASES = ( "microsoft sql server", "mssqlserver", "mssql", "ms" )
153-
MYSQL_ALIASES = ( "mysql", "my" )
154-
PGSQL_ALIASES = ( "postgresql", "postgres", "pgsql", "psql", "pg" )
155-
ORACLE_ALIASES = ( "oracle", "orcl", "ora", "or" )
156-
SQLITE_ALIASES = ( "sqlite", "sqlite3" )
157-
ACCESS_ALIASES = ( "msaccess", "access", "jet", "microsoft access" )
158-
FIREBIRD_ALIASES = ( "firebird", "mozilla firebird", "interbase", "ibase", "fb" )
159-
MAXDB_ALIASES = ( "maxdb", "sap maxdb", "sap db" )
160-
SYBASE_ALIASES = ( "sybase", "sybase sql server" )
161-
DB2_ALIASES = ( "db2", "ibm db2", "ibmdb2" )
146+
"RDB$TRIGGER_MESSAGES", "RDB$TYPES", "RDB$USER_PRIVILEGES", "RDB$VIEW_RELATIONS")
147+
MAXDB_SYSTEM_DBS = ("SYSINFO", "DOMAIN")
148+
SYBASE_SYSTEM_DBS = ("master", "model", "sybsystemdb", "sybsystemprocs")
149+
DB2_SYSTEM_DBS = ("NULLID", "SQLJ", "SYSCAT", "SYSFUN", "SYSIBM", "SYSIBMADM", "SYSIBMINTERNAL", "SYSIBMTS",\
150+
"SYSPROC", "SYSPUBLIC", "SYSSTAT", "SYSTOOLS")
151+
152+
MSSQL_ALIASES = ("microsoft sql server", "mssqlserver", "mssql", "ms")
153+
MYSQL_ALIASES = ("mysql", "my")
154+
PGSQL_ALIASES = ("postgresql", "postgres", "pgsql", "psql", "pg")
155+
ORACLE_ALIASES = ("oracle", "orcl", "ora", "or")
156+
SQLITE_ALIASES = ("sqlite", "sqlite3")
157+
ACCESS_ALIASES = ("msaccess", "access", "jet", "microsoft access")
158+
FIREBIRD_ALIASES = ("firebird", "mozilla firebird", "interbase", "ibase", "fb")
159+
MAXDB_ALIASES = ("maxdb", "sap maxdb", "sap db")
160+
SYBASE_ALIASES = ("sybase", "sybase sql server")
161+
DB2_ALIASES = ("db2", "ibm db2", "ibmdb2")
162162

163163
DBMS_DIRECTORY_DICT = dict((getattr(DBMS, _), getattr(DBMS_DIRECTORY_NAME, _)) for _ in dir(DBMS) if not _.startswith("_"))
164164

165165
SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES
166-
SUPPORTED_OS = ( "linux", "windows" )
166+
SUPPORTED_OS = ("linux", "windows")
167167

168-
USER_AGENT_ALIASES = ( "ua", "useragent", "user-agent" )
169-
REFERER_ALIASES = ( "ref", "referer", "referrer" )
170-
HOST_ALIASES = ( "host", )
168+
USER_AGENT_ALIASES = ("ua", "useragent", "user-agent")
169+
REFERER_ALIASES = ("ref", "referer", "referrer")
170+
HOST_ALIASES = ("host",)
171171

172172
# Items displayed in basic help (-h) output
173173
BASIC_HELP_ITEMS = (

lib/parse/banner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, banner, info):
3939
def _feedInfo(self, key, value):
4040
value = sanitizeStr(value)
4141

42-
if value in ( None, "None" ):
42+
if value in (None, "None"):
4343
return
4444

4545
self._info[key] = value

lib/parse/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, banner, info):
2929
def _feedInfo(self, key, value):
3030
value = sanitizeStr(value)
3131

32-
if value in ( None, "None" ):
32+
if value in (None, "None"):
3333
return
3434

3535
if key == "dbmsVersion":

lib/takeover/abstraction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def execCmd(self, cmd, silent=False):
4141
if self.webBackdoorUrl and not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
4242
self.webBackdoorRunCmd(cmd)
4343

44-
elif Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
44+
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
4545
self.udfExecCmd(cmd, silent=silent)
4646

4747
elif Backend.isDbms(DBMS.MSSQL):
@@ -57,7 +57,7 @@ def evalCmd(self, cmd, first=None, last=None):
5757
if self.webBackdoorUrl and not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
5858
retVal = self.webBackdoorRunCmd(cmd)
5959

60-
elif Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
60+
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
6161
retVal = self.udfEvalCmd(cmd, first, last)
6262

6363
elif Backend.isDbms(DBMS.MSSQL):
@@ -97,7 +97,7 @@ def shell(self):
9797
logger.info(infoMsg)
9898

9999
else:
100-
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
100+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
101101
infoMsg = "going to use injected sys_eval and sys_exec "
102102
infoMsg += "user-defined functions for operating system "
103103
infoMsg += "command execution"
@@ -136,7 +136,7 @@ def shell(self):
136136
if not command:
137137
continue
138138

139-
if command.lower() in ( "x", "q", "exit", "quit" ):
139+
if command.lower() in ("x", "q", "exit", "quit"):
140140
break
141141

142142
self.runCmd(command)
@@ -186,15 +186,15 @@ def initEnv(self, mandatory=True, detailed=False, web=False):
186186
warnMsg = "functionality requested probably does not work because "
187187
warnMsg += "the curent session user is not a database administrator"
188188

189-
if not conf.dbmsCred and Backend.getIdentifiedDbms() in ( DBMS.MSSQL, DBMS.PGSQL ):
189+
if not conf.dbmsCred and Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.PGSQL):
190190
warnMsg += ". You can try to use option '--dbms-cred' "
191191
warnMsg += "to execute statements as a DBA user if you "
192192
warnMsg += "were able to extract and crack a DBA "
193193
warnMsg += "password by any mean"
194194

195195
logger.warn(warnMsg)
196196

197-
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
197+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
198198
self.udfInjectSys()
199199
elif Backend.isDbms(DBMS.MSSQL):
200200
if mandatory:

lib/takeover/metasploit.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,52 +66,52 @@ def _initVars(self):
6666

6767
self._msfPayloadsList = {
6868
"windows": {
69-
1: ( "Meterpreter (default)", "windows/meterpreter" ),
70-
2: ( "Shell", "windows/shell" ),
71-
3: ( "VNC", "windows/vncinject" ),
69+
1: ("Meterpreter (default)", "windows/meterpreter"),
70+
2: ("Shell", "windows/shell"),
71+
3: ("VNC", "windows/vncinject"),
7272
},
7373
"linux": {
74-
1: ( "Shell (default)", "linux/x86/shell" ),
75-
2: ( "Meterpreter (beta)", "linux/x86/meterpreter" ),
74+
1: ("Shell (default)", "linux/x86/shell"),
75+
2: ("Meterpreter (beta)", "linux/x86/meterpreter"),
7676
}
7777
}
7878

7979
self._msfConnectionsList = {
8080
"windows": {
81-
1: ( "Reverse TCP: Connect back from the database host to this machine (default)", "reverse_tcp" ),
82-
2: ( "Reverse TCP: Try to connect back from the database host to this machine, on all ports between the specified and 65535", "reverse_tcp_allports" ),
83-
3: ( "Reverse HTTP: Connect back from the database host to this machine tunnelling traffic over HTTP", "reverse_http" ),
84-
4: ( "Reverse HTTPS: Connect back from the database host to this machine tunnelling traffic over HTTPS", "reverse_https" ),
85-
5: ( "Bind TCP: Listen on the database host for a connection", "bind_tcp" )
81+
1: ("Reverse TCP: Connect back from the database host to this machine (default)", "reverse_tcp"),
82+
2: ("Reverse TCP: Try to connect back from the database host to this machine, on all ports between the specified and 65535", "reverse_tcp_allports"),
83+
3: ("Reverse HTTP: Connect back from the database host to this machine tunnelling traffic over HTTP", "reverse_http"),
84+
4: ("Reverse HTTPS: Connect back from the database host to this machine tunnelling traffic over HTTPS", "reverse_https"),
85+
5: ("Bind TCP: Listen on the database host for a connection", "bind_tcp")
8686
},
8787
"linux": {
88-
1: ( "Reverse TCP: Connect back from the database host to this machine (default)", "reverse_tcp" ),
89-
2: ( "Bind TCP: Listen on the database host for a connection", "bind_tcp" ),
88+
1: ("Reverse TCP: Connect back from the database host to this machine (default)", "reverse_tcp"),
89+
2: ("Bind TCP: Listen on the database host for a connection", "bind_tcp"),
9090
}
9191
}
9292

9393
self._msfEncodersList = {
9494
"windows": {
95-
1: ( "No Encoder", "generic/none" ),
96-
2: ( "Alpha2 Alphanumeric Mixedcase Encoder", "x86/alpha_mixed" ),
97-
3: ( "Alpha2 Alphanumeric Uppercase Encoder", "x86/alpha_upper" ),
98-
4: ( "Avoid UTF8/tolower", "x86/avoid_utf8_tolower" ),
99-
5: ( "Call+4 Dword XOR Encoder", "x86/call4_dword_xor" ),
100-
6: ( "Single-byte XOR Countdown Encoder", "x86/countdown" ),
101-
7: ( "Variable-length Fnstenv/mov Dword XOR Encoder", "x86/fnstenv_mov" ),
102-
8: ( "Polymorphic Jump/Call XOR Additive Feedback Encoder", "x86/jmp_call_additive" ),
103-
9: ( "Non-Alpha Encoder", "x86/nonalpha" ),
104-
10: ( "Non-Upper Encoder", "x86/nonupper" ),
105-
11: ( "Polymorphic XOR Additive Feedback Encoder (default)", "x86/shikata_ga_nai" ),
106-
12: ( "Alpha2 Alphanumeric Unicode Mixedcase Encoder", "x86/unicode_mixed" ),
107-
13: ( "Alpha2 Alphanumeric Unicode Uppercase Encoder", "x86/unicode_upper" ),
95+
1: ("No Encoder", "generic/none"),
96+
2: ("Alpha2 Alphanumeric Mixedcase Encoder", "x86/alpha_mixed"),
97+
3: ("Alpha2 Alphanumeric Uppercase Encoder", "x86/alpha_upper"),
98+
4: ("Avoid UTF8/tolower", "x86/avoid_utf8_tolower"),
99+
5: ("Call+4 Dword XOR Encoder", "x86/call4_dword_xor"),
100+
6: ("Single-byte XOR Countdown Encoder", "x86/countdown"),
101+
7: ("Variable-length Fnstenv/mov Dword XOR Encoder", "x86/fnstenv_mov"),
102+
8: ("Polymorphic Jump/Call XOR Additive Feedback Encoder", "x86/jmp_call_additive"),
103+
9: ("Non-Alpha Encoder", "x86/nonalpha"),
104+
10: ("Non-Upper Encoder", "x86/nonupper"),
105+
11: ("Polymorphic XOR Additive Feedback Encoder (default)", "x86/shikata_ga_nai"),
106+
12: ("Alpha2 Alphanumeric Unicode Mixedcase Encoder", "x86/unicode_mixed"),
107+
13: ("Alpha2 Alphanumeric Unicode Uppercase Encoder", "x86/unicode_upper"),
108108
}
109109
}
110110

111111
self._msfSMBPortsList = {
112112
"windows": {
113-
1: ( "139/TCP", "139" ),
114-
2: ( "445/TCP (default)", "445" ),
113+
1: ("139/TCP", "139"),
114+
2: ("445/TCP (default)", "445"),
115115
}
116116
}
117117

@@ -584,7 +584,7 @@ def smb(self):
584584

585585
self._runMsfCliSmbrelay()
586586

587-
if Backend.getIdentifiedDbms() in ( DBMS.MYSQL, DBMS.PGSQL ):
587+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
588588
self.uncPath = "\\\\\\\\%s\\\\%s" % (self.lhostStr, self._randFile)
589589
else:
590590
self.uncPath = "\\\\%s\\%s" % (self.lhostStr, self._randFile)

0 commit comments

Comments
 (0)