Skip to content

Commit fbd4222

Browse files
committed
Foo and fo
1 parent b278ee8 commit fbd4222

File tree

13 files changed

+74
-610
lines changed

13 files changed

+74
-610
lines changed

doc/THIRD-PARTY.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ This file lists bundled packages and their associated licensing terms.
1515
Copyright (C) 2013, Jonathan Hartley.
1616
* The Fcrypt library located under thirdparty/fcrypt/.
1717
Copyright (C) 2000, 2001, 2004 Carey Evans.
18-
* The Oset library located under thirdparty/oset/.
19-
Copyright (C) 2010, BlueDynamics Alliance, Austria.
20-
Copyright (C) 2009, Raymond Hettinger, and others.
2118
* The PrettyPrint library located under thirdparty/prettyprint/.
2219
Copyright (C) 2010, Chris Hall.
2320
* The SocksiPy library located under thirdparty/socks/.

lib/core/datatype.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8+
import collections
89
import copy
910
import types
1011

@@ -140,3 +141,61 @@ def set(self, key, value):
140141

141142
def keys(self):
142143
return self.cache.keys()
144+
145+
# Reference: https://code.activestate.com/recipes/576694/
146+
class OrderedSet(collections.MutableSet):
147+
def __init__(self, iterable=None):
148+
self.end = end = []
149+
end += [None, end, end] # sentinel node for doubly linked list
150+
self.map = {} # key --> [key, prev, next]
151+
if iterable is not None:
152+
self |= iterable
153+
154+
def __len__(self):
155+
return len(self.map)
156+
157+
def __contains__(self, key):
158+
return key in self.map
159+
160+
def add(self, key):
161+
if key not in self.map:
162+
end = self.end
163+
curr = end[1]
164+
curr[2] = end[1] = self.map[key] = [key, curr, end]
165+
166+
def discard(self, key):
167+
if key in self.map:
168+
key, prev, next = self.map.pop(key)
169+
prev[2] = next
170+
next[1] = prev
171+
172+
def __iter__(self):
173+
end = self.end
174+
curr = end[2]
175+
while curr is not end:
176+
yield curr[0]
177+
curr = curr[2]
178+
179+
def __reversed__(self):
180+
end = self.end
181+
curr = end[1]
182+
while curr is not end:
183+
yield curr[0]
184+
curr = curr[1]
185+
186+
def pop(self, last=True):
187+
if not self:
188+
raise KeyError('set is empty')
189+
key = self.end[1][0] if last else self.end[2][0]
190+
self.discard(key)
191+
return key
192+
193+
def __repr__(self):
194+
if not self:
195+
return '%s()' % (self.__class__.__name__,)
196+
return '%s(%r)' % (self.__class__.__name__, list(self))
197+
198+
def __eq__(self, other):
199+
if isinstance(other, OrderedSet):
200+
return len(self) == len(other) and list(self) == list(other)
201+
return set(self) == set(other)

lib/core/option.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import tempfile
1717
import threading
1818
import time
19-
import urllib2
2019

2120
import lib.controller.checks
2221
import lib.core.common
@@ -66,6 +65,7 @@
6665
from lib.core.data import queries
6766
from lib.core.datatype import AttribDict
6867
from lib.core.datatype import InjectionDict
68+
from lib.core.datatype import OrderedSet
6969
from lib.core.defaults import defaults
7070
from lib.core.dicts import DBMS_DICT
7171
from lib.core.dicts import DUMP_REPLACEMENTS
@@ -149,7 +149,6 @@
149149
from lib.utils.purge import purge
150150
from thirdparty.keepalive import keepalive
151151
from thirdparty.multipart import multipartpost
152-
from thirdparty.oset.pyoset import oset
153152
from thirdparty.six.moves import http_client as _http_client
154153
from thirdparty.six.moves import http_cookiejar as _http_cookiejar
155154
from thirdparty.six.moves import urllib as _urllib
@@ -2023,7 +2022,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
20232022
kb.preprocessFunctions = []
20242023
kb.skipVulnHost = None
20252024
kb.tamperFunctions = []
2026-
kb.targets = oset()
2025+
kb.targets = OrderedSet()
20272026
kb.testedParams = set()
20282027
kb.userAgents = None
20292028
kb.vainRun = True

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

1919
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
20-
VERSION = "1.3.3.60"
20+
VERSION = "1.3.3.61"
2121
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2222
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2323
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/subprocessng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _close(self, which):
8585
getattr(self, which).close()
8686
setattr(self, which, None)
8787

88-
if subprocess.mswindows:
88+
if IS_WIN:
8989
def send(self, input):
9090
if not self.stdin:
9191
return None

lib/parse/sitemap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from lib.core.common import readInput
1111
from lib.core.data import kb
1212
from lib.core.data import logger
13+
from lib.core.datatype import OrderedSet
1314
from lib.core.exception import SqlmapSyntaxException
1415
from lib.request.connect import Connect as Request
15-
from thirdparty.oset.pyoset import oset
1616
from thirdparty.six.moves import http_client as _http_client
1717

1818
abortedFlag = None
@@ -26,7 +26,7 @@ def parseSitemap(url, retVal=None):
2626
try:
2727
if retVal is None:
2828
abortedFlag = False
29-
retVal = oset()
29+
retVal = OrderedSet()
3030

3131
try:
3232
content = Request.getPage(url=url, raise404=True)[0] if not abortedFlag else ""

lib/takeover/web.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from lib.core.data import kb
3838
from lib.core.data import logger
3939
from lib.core.data import paths
40+
from lib.core.datatype import OrderedSet
4041
from lib.core.enums import DBMS
4142
from lib.core.enums import HTTP_HEADER
4243
from lib.core.enums import OS
@@ -50,7 +51,6 @@
5051
from lib.core.settings import SHELL_WRITABLE_DIR_TAG
5152
from lib.core.settings import VIEWSTATE_REGEX
5253
from lib.request.connect import Connect as Request
53-
from thirdparty.oset.pyoset import oset
5454
from thirdparty.six.moves import urllib as _urllib
5555

5656
class Web:
@@ -254,7 +254,7 @@ def webInit(self):
254254

255255
directories = list(arrayizeValue(getManualDirectories()))
256256
directories.extend(getAutoDirectories())
257-
directories = list(oset(directories))
257+
directories = list(OrderedSet(directories))
258258

259259
path = _urllib.parse.urlparse(conf.url).path or '/'
260260
path = re.sub(r"/[^/]*\.\w+\Z", '/', path)

lib/utils/crawler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from lib.core.data import conf
2323
from lib.core.data import kb
2424
from lib.core.data import logger
25+
from lib.core.datatype import OrderedSet
2526
from lib.core.enums import MKSTEMP_PREFIX
2627
from lib.core.exception import SqlmapConnectionException
2728
from lib.core.exception import SqlmapSyntaxException
@@ -31,15 +32,14 @@
3132
from lib.parse.sitemap import parseSitemap
3233
from lib.request.connect import Connect as Request
3334
from thirdparty.beautifulsoup.beautifulsoup import BeautifulSoup
34-
from thirdparty.oset.pyoset import oset
3535
from thirdparty.six.moves import http_client as _http_client
3636
from thirdparty.six.moves import urllib as _urllib
3737

3838
def crawl(target):
3939
try:
4040
visited = set()
4141
threadData = getCurrentThreadData()
42-
threadData.shared.value = oset()
42+
threadData.shared.value = OrderedSet()
4343

4444
def crawlThread():
4545
threadData = getCurrentThreadData()

lib/utils/hash.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from hashlib import sha256
4646
from hashlib import sha384
4747
from hashlib import sha512
48-
from Queue import Queue
4948

5049
from lib.core.common import Backend
5150
from lib.core.common import checkFile
@@ -68,6 +67,7 @@
6867
from lib.core.data import conf
6968
from lib.core.data import kb
7069
from lib.core.data import logger
70+
from lib.core.datatype import OrderedSet
7171
from lib.core.enums import DBMS
7272
from lib.core.enums import HASH
7373
from lib.core.enums import MKSTEMP_PREFIX
@@ -87,9 +87,9 @@
8787
from lib.core.settings import ROTATING_CHARS
8888
from lib.core.wordlist import Wordlist
8989
from thirdparty.colorama.initialise import init as coloramainit
90-
from thirdparty.oset.pyoset import oset
9190
from thirdparty.pydes.pyDes import des
9291
from thirdparty.pydes.pyDes import CBC
92+
from thirdparty.six.moves import queue as _queue
9393

9494
def mysql_passwd(password, uppercase=True):
9595
"""
@@ -561,7 +561,7 @@ def storeHashesToFile(attack_dict):
561561
if not attack_dict:
562562
return
563563

564-
items = oset()
564+
items = OrderedSet()
565565

566566
for user, hashes in attack_dict.items():
567567
for hash_ in hashes:
@@ -1059,7 +1059,7 @@ def dictionaryAttack(attack_dict):
10591059
warnMsg += "not supported on this platform"
10601060
singleTimeWarnMessage(warnMsg)
10611061

1062-
retVal = Queue()
1062+
retVal = _queue.Queue()
10631063
_bruteProcessVariantA(attack_info, hash_regex, suffix, retVal, 0, 1, kb.wordlists, custom_wordlist, conf.api)
10641064

10651065
except KeyboardInterrupt:
@@ -1150,7 +1150,7 @@ def dictionaryAttack(attack_dict):
11501150
class Value():
11511151
pass
11521152

1153-
retVal = Queue()
1153+
retVal = _queue.Queue()
11541154
found_ = Value()
11551155
found_.value = False
11561156

thirdparty/oset/LICENSE.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)