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

Skip to content

Commit b3bd414

Browse files
committed
removing of unused imports together with some general code refactoring
1 parent 386e98a commit b3bd414

104 files changed

Lines changed: 255 additions & 499 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_sqlmap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10-
import codecs
1110
import os
1211
import sys
1312
import time

lib/controller/checks.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@
88
"""
99

1010
import httplib
11-
import logging
1211
import re
1312
import socket
1413
import time
1514

1615
from lib.core.agent import agent
17-
from lib.core.common import aliasToDbmsEnum
1816
from lib.core.common import arrayizeValue
1917
from lib.core.common import Backend
2018
from lib.core.common import beep
2119
from lib.core.common import extractRegexResult
2220
from lib.core.common import findDynamicContent
2321
from lib.core.common import Format
2422
from lib.core.common import getComparePageRatio
25-
from lib.core.common import getCompiledRegex
2623
from lib.core.common import getLastRequestHTTPError
2724
from lib.core.common import getSortedInjectionTests
2825
from lib.core.common import getUnicode
@@ -36,13 +33,11 @@
3633
from lib.core.common import readInput
3734
from lib.core.common import showStaticWords
3835
from lib.core.common import singleTimeWarnMessage
39-
from lib.core.common import trimAlphaNum
4036
from lib.core.common import wasLastRequestDBMSError
4137
from lib.core.common import wasLastRequestHTTPError
4238
from lib.core.data import conf
4339
from lib.core.data import kb
4440
from lib.core.data import logger
45-
from lib.core.data import paths
4641
from lib.core.datatype import AttribDict
4742
from lib.core.datatype import InjectionDict
4843
from lib.core.enums import HTTPHEADER
@@ -51,7 +46,6 @@
5146
from lib.core.enums import PAYLOAD
5247
from lib.core.enums import PLACE
5348
from lib.core.exception import sqlmapConnectionException
54-
from lib.core.exception import sqlmapGenericException
5549
from lib.core.exception import sqlmapNoneDataException
5650
from lib.core.exception import sqlmapSilentQuitException
5751
from lib.core.exception import sqlmapUserQuitException
@@ -614,7 +608,7 @@ def heuristicCheckSqlInjection(place, parameter):
614608

615609
def simpletonCheckSqlInjection(place, parameter, value):
616610
"""
617-
This is a function for the quickest and simplest
611+
This is a function for the quickest and simplest
618612
sql injection check (e.g. AND 1=1) - only works
619613
with integer parameters
620614
"""
@@ -879,7 +873,7 @@ def checkWaf():
879873
conf.parameters[PLACE.GET] += "%s=%d %s" % (randomStr(), randomInt(), IDS_WAF_CHECK_PAYLOAD)
880874

881875
kb.matchRatio = None
882-
_ = Request.queryPage()
876+
Request.queryPage()
883877

884878
if kb.errorIsNone and kb.matchRatio is None:
885879
kb.matchRatio = LOWER_RATIO_BOUND

lib/controller/handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from lib.core.common import popValue
1212
from lib.core.common import pushValue
1313
from lib.core.data import conf
14-
from lib.core.data import kb
1514
from lib.core.data import logger
16-
from lib.core.enums import DBMS
1715
from lib.core.settings import MSSQL_ALIASES
1816
from lib.core.settings import MYSQL_ALIASES
1917
from lib.core.settings import ORACLE_ALIASES
@@ -64,7 +62,7 @@ def setHandler():
6462
( FIREBIRD_ALIASES, FirebirdMap, FirebirdConn ),
6563
( MAXDB_ALIASES, MaxDBMap, MaxDBConn ),
6664
( SYBASE_ALIASES, SybaseMap, SybaseConn ),
67-
( DB2_ALIASES, DB2Map, DB2Conn )
65+
( DB2_ALIASES, DB2Map, DB2Conn )
6866
]
6967

7068
if Backend.getIdentifiedDbms() is not None:

lib/core/agent.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
from lib.core.common import randomInt
1919
from lib.core.common import randomStr
2020
from lib.core.common import singleTimeWarnMessage
21-
from lib.core.convert import urlencode
2221
from lib.core.data import conf
2322
from lib.core.data import kb
2423
from lib.core.data import queries
25-
from lib.core.datatype import AttribDict
2624
from lib.core.enums import DBMS
2725
from lib.core.enums import PAYLOAD
2826
from lib.core.enums import PLACE

lib/core/common.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import inspect
1515
import logging
1616
import ntpath
17-
import optparse
1817
import os
1918
import pickle
2019
import posixpath
@@ -25,7 +24,6 @@
2524
import struct
2625
import sys
2726
import time
28-
import types
2927
import urllib
3028
import urlparse
3129
import unicodedata
@@ -49,14 +47,13 @@
4947
from extra.cloak.cloak import decloak
5048
from extra.magic import magic
5149
from extra.odict.odict import OrderedDict
50+
from extra.safe2bin.safe2bin import safecharencode
5251
from lib.core.bigarray import BigArray
5352
from lib.core.data import conf
5453
from lib.core.data import kb
5554
from lib.core.data import logger
5655
from lib.core.data import paths
57-
from lib.core.data import queries
5856
from lib.core.convert import htmlunescape
59-
from lib.core.convert import safecharencode
6057
from lib.core.convert import unicodeencode
6158
from lib.core.convert import urldecode
6259
from lib.core.convert import urlencode
@@ -120,7 +117,6 @@
120117
from lib.core.settings import DYNAMICITY_MARK_LENGTH
121118
from lib.core.settings import REFLECTIVE_MISS_THRESHOLD
122119
from lib.core.settings import SENSITIVE_DATA_REGEX
123-
from lib.core.settings import SUPPORTED_OS
124120
from lib.core.settings import UNION_UNIQUE_FIFO_LENGTH
125121
from lib.core.settings import URI_INJECTION_MARK_CHAR
126122
from lib.core.settings import URI_QUESTION_MARKER
@@ -403,7 +399,7 @@ def getErrorParsedDBMSes():
403399
1. Sort the tests, getSortedInjectionTests() - detection phase.
404400
2. Ask user whether or not skip specific DBMS tests in detection phase,
405401
lib/controller/checks.py - detection phase.
406-
3. Sort the fingerprint of the DBMS, lib/controller/handler.py -
402+
3. Sort the fingerprint of the DBMS, lib/controller/handler.py -
407403
fingerprint phase.
408404
"""
409405

@@ -869,7 +865,7 @@ def randomStr(length=4, lowercase=False, alphabet=None):
869865
"""
870866

871867
if alphabet:
872-
rndStr = "".join(random.choice(alphabet) for _ in xrange(0, length))
868+
rndStr = "".join(random.choice(alphabet) for _ in xrange(0, length))
873869
elif lowercase:
874870
rndStr = "".join(random.choice(string.lowercase) for _ in xrange(0, length))
875871
else:
@@ -1670,7 +1666,7 @@ def readXmlFile(xmlFile):
16701666
Reads XML file content and returns it's DOM representation
16711667
"""
16721668

1673-
checkFile(xmlFile)
1669+
checkFile(xmlFile)
16741670

16751671
with codecs.open(xmlFile, 'r', UNICODE_ENCODING) as f:
16761672
retVal = minidom.parse(f).documentElement
@@ -2179,7 +2175,7 @@ def enumValueToNameLookup(type_, value_):
21792175

21802176
def extractRegexResult(regex, content, flags=0):
21812177
"""
2182-
Returns 'result' group value from a possible match with regex on a given
2178+
Returns 'result' group value from a possible match with regex on a given
21832179
content
21842180
"""
21852181

lib/core/convert.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,14 @@
1313
import md5
1414
import sha
1515

16-
import binascii
1716
import pickle
1817
import re
1918
import sys
20-
import string
2119
import struct
2220
import urllib
2321

24-
from extra.safe2bin.safe2bin import safecharencode
25-
from extra.safe2bin.safe2bin import safechardecode
2622
from lib.core.data import conf
2723
from lib.core.data import kb
28-
from lib.core.data import logger
2924
from lib.core.enums import PLACE
3025
from lib.core.settings import UNICODE_ENCODING
3126
from lib.core.settings import URLENCODE_CHAR_LIMIT

lib/core/option.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import codecs
1111
import cookielib
12-
import difflib
1312
import inspect
1413
import logging
1514
import os
@@ -44,7 +43,6 @@
4443
from lib.core.common import paths
4544
from lib.core.common import randomRange
4645
from lib.core.common import randomStr
47-
from lib.core.common import readCachedFileContent
4846
from lib.core.common import readInput
4947
from lib.core.common import runningAsAdmin
5048
from lib.core.common import sanitizeStr
@@ -55,7 +53,6 @@
5553
from lib.core.data import conf
5654
from lib.core.data import kb
5755
from lib.core.data import logger
58-
from lib.core.data import paths
5956
from lib.core.data import queries
6057
from lib.core.datatype import AttribDict
6158
from lib.core.datatype import InjectionDict
@@ -87,7 +84,6 @@
8784
from lib.core.settings import DEFAULT_TOR_SOCKS_PORT
8885
from lib.core.settings import IS_WIN
8986
from lib.core.settings import NULL
90-
from lib.core.settings import PLATFORM
9187
from lib.core.settings import PYVERSION
9288
from lib.core.settings import SITE
9389
from lib.core.settings import DBMS_DICT

lib/core/replication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from extra.safe2bin.safe2bin import safechardecode
1011
from lib.core.common import unsafeSQLIdentificatorNaming
11-
from lib.core.convert import safechardecode
1212
from lib.core.exception import sqlmapMissingDependence
1313
from lib.core.exception import sqlmapValueException
1414

@@ -21,7 +21,7 @@ class Replication:
2121
def __init__(self, dbpath):
2222
try:
2323
import sqlite3
24-
except ImportError, _:
24+
except ImportError:
2525
errMsg = "missing module 'sqlite3' needed by switch '--replicate'"
2626
raise sqlmapMissingDependence, errMsg
2727

lib/core/revision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def getRevisionNumber():
2323
client = pysvn.Client()
2424
if client.info(curDir):
2525
retVal = client.info(curDir).revision.number
26-
except ImportError, _:
26+
except ImportError:
2727
process = execute("svn info %s" % curDir, shell=True, stdout=PIPE, stderr=PIPE)
2828
svnStdout, svnStderr = process.communicate()
2929

lib/core/session.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from lib.core.common import Backend
1313
from lib.core.common import Format
1414
from lib.core.common import dataToSessionFile
15-
from lib.core.common import getFilteredPageContent
1615
from lib.core.common import intersect
1716
from lib.core.common import readInput
1817
from lib.core.common import singleTimeWarnMessage
@@ -21,12 +20,7 @@
2120
from lib.core.data import conf
2221
from lib.core.data import kb
2322
from lib.core.data import logger
24-
from lib.core.datatype import InjectionDict
25-
from lib.core.enums import DBMS
2623
from lib.core.enums import OS
27-
from lib.core.enums import PAYLOAD
28-
from lib.core.enums import PLACE
29-
from lib.core.settings import METADB_SUFFIX
3024
from lib.core.settings import SUPPORTED_DBMS
3125
from lib.core.settings import UNKNOWN_DBMS_VERSION
3226

0 commit comments

Comments
 (0)