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

Skip to content

Commit c517e97

Browse files
committed
few fixes and minor cosmetics
1 parent aedcf8c commit c517e97

13 files changed

Lines changed: 59 additions & 54 deletions

File tree

lib/controller/checks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
from lib.core.data import kb
4242
from lib.core.data import logger
4343
from lib.core.data import paths
44-
from lib.core.datatype import advancedDict
45-
from lib.core.datatype import injectionDict
44+
from lib.core.datatype import AttribDict
45+
from lib.core.datatype import InjectionDict
4646
from lib.core.enums import HTTPHEADER
4747
from lib.core.enums import HTTPMETHOD
4848
from lib.core.enums import NULLCONNECTION
@@ -68,7 +68,7 @@
6868
def checkSqlInjection(place, parameter, value):
6969
# Store here the details about boundaries and payload used to
7070
# successfully inject
71-
injection = injectionDict()
71+
injection = InjectionDict()
7272

7373
# Localized thread data needed for some methods
7474
threadData = getCurrentThreadData()
@@ -452,7 +452,7 @@ def genCmpPayload():
452452
if vector is None and "vector" in test and test.vector is not None:
453453
vector = "%s%s" % (test.vector, comment)
454454

455-
injection.data[stype] = advancedDict()
455+
injection.data[stype] = AttribDict()
456456
injection.data[stype].title = title
457457
injection.data[stype].payload = agent.removePayloadDelimiters(reqPayload)
458458
injection.data[stype].where = where

lib/core/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from lib.core.data import conf
2222
from lib.core.data import kb
2323
from lib.core.data import queries
24-
from lib.core.datatype import advancedDict
24+
from lib.core.datatype import AttribDict
2525
from lib.core.enums import DBMS
2626
from lib.core.enums import PAYLOAD
2727
from lib.core.enums import PLACE

lib/core/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,9 +1925,7 @@ def pushValue(value):
19251925
Push value to the stack (thread dependent)
19261926
"""
19271927

1928-
# TODO: quick fix
1929-
#getCurrentThreadData().valueStack.append(copy.deepcopy(value))
1930-
getCurrentThreadData().valueStack.append(value)
1928+
getCurrentThreadData().valueStack.append(copy.deepcopy(value))
19311929

19321930
def popValue():
19331931
"""

lib/core/data.py

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

10-
from lib.core.datatype import advancedDict
10+
from lib.core.datatype import AttribDict
1111
from lib.core.settings import LOGGER
1212

1313
# sqlmap paths
14-
paths = advancedDict()
14+
paths = AttribDict()
1515

1616
# object to store original command line options
17-
cmdLineOptions = advancedDict()
17+
cmdLineOptions = AttribDict()
1818

1919
# object to share within function and classes command
2020
# line options and settings
21-
conf = advancedDict()
21+
conf = AttribDict()
2222

2323
# object to share within function and classes results
24-
kb = advancedDict()
24+
kb = AttribDict()
2525

2626
# object with each database management system specific queries
2727
queries = {}

lib/core/datatype.py

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

10+
import copy
11+
import types
12+
1013
from lib.core.exception import sqlmapDataException
1114

12-
class advancedDict(dict):
15+
class AttribDict(dict):
1316
"""
1417
This class defines the sqlmap object, inheriting from Python data
1518
type dictionary.
@@ -46,7 +49,7 @@ def __setattr__(self, item, value):
4649
"""
4750

4851
# This test allows attributes to be set in the __init__ method
49-
if not self.__dict__.has_key('_advancedDict__initialised'):
52+
if not self.__dict__.has_key('_AttribDict__initialised'):
5053
return dict.__setattr__(self, item, value)
5154

5255
# Any normal attributes are handled normally
@@ -62,9 +65,20 @@ def __getstate__(self):
6265
def __setstate__(self, dict):
6366
self.__dict__ = dict
6467

65-
class injectionDict(advancedDict):
68+
def __deepcopy__(self, memo):
69+
retVal = self.__class__()
70+
memo[id(self)] = retVal
71+
for attr in dir(self):
72+
if not attr.startswith('_'):
73+
value = getattr(self, attr)
74+
if not isinstance(value, (types.BuiltinFunctionType, types.BuiltinFunctionType, types.FunctionType, types.MethodType)):
75+
setattr(retVal, attr, copy.deepcopy(value, memo))
76+
77+
return retVal
78+
79+
class InjectionDict(AttribDict):
6680
def __init__(self):
67-
advancedDict.__init__(self)
81+
AttribDict.__init__(self)
6882

6983
self.place = None
7084
self.parameter = None
@@ -75,11 +89,11 @@ def __init__(self):
7589

7690
# data is a dict with various stype, each which is a dict with
7791
# all the information specific for that stype
78-
self.data = advancedDict()
92+
self.data = AttribDict()
7993

8094
# conf is a dict which stores current snapshot of important
8195
# options used during detection
82-
self.conf = advancedDict()
96+
self.conf = AttribDict()
8397

8498
self.dbms = None
8599
self.dbms_version = None

lib/core/defaults.py

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

10-
from lib.core.datatype import advancedDict
10+
from lib.core.datatype import AttribDict
1111

1212
_defaults = {
1313
"timeSec": 5,
@@ -25,4 +25,4 @@
2525
"tech": "BEUST"
2626
}
2727

28-
defaults = advancedDict(_defaults)
28+
defaults = AttribDict(_defaults)

lib/core/option.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
from lib.core.data import logger
5656
from lib.core.data import paths
5757
from lib.core.data import queries
58-
from lib.core.datatype import advancedDict
59-
from lib.core.datatype import injectionDict
58+
from lib.core.datatype import AttribDict
59+
from lib.core.datatype import InjectionDict
6060
from lib.core.defaults import defaults
6161
from lib.core.enums import DBMS
6262
from lib.core.enums import HTTPHEADER
@@ -963,7 +963,7 @@ def __setPrefixSuffix():
963963
if conf.prefix is not None and conf.suffix is not None:
964964
# Create a custom boundary object for user's supplied prefix
965965
# and suffix
966-
boundary = advancedDict()
966+
boundary = AttribDict()
967967

968968
boundary.level = 1
969969
boundary.clause = [ 0 ]
@@ -1381,18 +1381,18 @@ def __setKnowledgeBaseAttributes(flushAll=True):
13811381
kb.alwaysRefresh = None
13821382
kb.arch = None
13831383
kb.authHeader = None
1384-
kb.bannerFp = advancedDict()
1384+
kb.bannerFp = AttribDict()
13851385

1386-
kb.brute = advancedDict({'tables':[], 'columns':[]})
1386+
kb.brute = AttribDict({'tables':[], 'columns':[]})
13871387
kb.bruteMode = False
13881388

1389-
kb.cache = advancedDict()
1389+
kb.cache = AttribDict()
13901390
kb.cache.content = {}
13911391
kb.cache.regex = {}
13921392
kb.cache.stdev = {}
13931393

13941394
kb.commonOutputs = None
1395-
kb.data = advancedDict()
1395+
kb.data = AttribDict()
13961396
kb.dataOutputFlag = False
13971397

13981398
# Active back-end DBMS fingerprint
@@ -1415,10 +1415,10 @@ def __setKnowledgeBaseAttributes(flushAll=True):
14151415
kb.hintValue = None
14161416
kb.htmlFp = []
14171417
kb.ignoreTimeout = False
1418-
kb.injection = injectionDict()
1418+
kb.injection = InjectionDict()
14191419
kb.injections = []
14201420

1421-
kb.locks = advancedDict()
1421+
kb.locks = AttribDict()
14221422
kb.locks.cacheLock = threading.Lock()
14231423
kb.locks.logLock = threading.Lock()
14241424
kb.locks.ioLock = threading.Lock()
@@ -1459,7 +1459,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
14591459
kb.uChar = "NULL"
14601460
kb.xpCmdshellAvailable = False
14611461

1462-
kb.misc = advancedDict()
1462+
kb.misc = AttribDict()
14631463
kb.misc.delimiter = randomStr(length=6, lowercase=True)
14641464
kb.misc.start = ":%s:" % randomStr(length=3, lowercase=True)
14651465
kb.misc.stop = ":%s:" % randomStr(length=3, lowercase=True)
@@ -1795,7 +1795,7 @@ def __resolveCrossReferences():
17951795
lib.core.threads.readInput = readInput
17961796
lib.core.common.getPageTemplate = getPageTemplate
17971797

1798-
def init(inputOptions=advancedDict(), overrideOptions=False):
1798+
def init(inputOptions=AttribDict(), overrideOptions=False):
17991799
"""
18001800
Set attributes into both configuration and knowledge base singletons
18011801
based upon command line and configuration file options.

lib/core/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from lib.core.data import conf
2121
from lib.core.data import kb
2222
from lib.core.data import logger
23-
from lib.core.datatype import injectionDict
23+
from lib.core.datatype import InjectionDict
2424
from lib.core.enums import DBMS
2525
from lib.core.enums import OS
2626
from lib.core.enums import PAYLOAD

lib/core/threads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
from lib.core.data import kb
1717
from lib.core.data import logger
18-
from lib.core.datatype import advancedDict
18+
from lib.core.datatype import AttribDict
1919
from lib.core.enums import PAYLOAD
2020
from lib.core.exception import sqlmapConnectionException
2121
from lib.core.exception import sqlmapThreadException
2222
from lib.core.exception import sqlmapValueException
2323
from lib.core.settings import MAX_NUMBER_OF_THREADS
2424
from lib.core.settings import PYVERSION
2525

26-
shared = advancedDict()
26+
shared = AttribDict()
2727

2828
class _ThreadData(threading.local):
2929
"""

lib/core/unescaper.py

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

1010
from lib.core.common import Backend
11-
from lib.core.datatype import advancedDict
11+
from lib.core.datatype import AttribDict
1212
from lib.core.settings import EXCLUDE_UNESCAPE
1313

14-
class Unescaper(advancedDict):
14+
class Unescaper(AttribDict):
1515
def unescape(self, expression, quote=True, dbms=None):
1616
if expression is None:
1717
return expression

0 commit comments

Comments
 (0)