Skip to content

Commit e82b1b5

Browse files
committed
Minor update
1 parent 9d653d2 commit e82b1b5

4 files changed

Lines changed: 42 additions & 12 deletions

File tree

‎data/txt/sha256sums.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ ccc4a717e887652b1fcce073d9409d9c59a3b28548c703a9e453d15845f90cd7 lib/core/patch
189189
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
190190
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
191191
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
192-
f47aed1aa1a986dc2d3789358a34f79aa1111e7ab8747c4fba4dfe3443f778a0 lib/core/settings.py
192+
65603f9bbf42cd67a1cf9b3f6277b3af3fdf6b3678fcaa2fe21fe09961f9316c lib/core/settings.py
193193
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
194194
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
195195
70ea3768f1b3062b22d20644df41c86238157ec80dd43da40545c620714273c6 lib/core/target.py
@@ -214,7 +214,7 @@ bc61bc944b81a7670884f82231033a6ac703324b34b071c9834886a92e249d0e lib/request/ch
214214
390cc4882ba9c76e16a5376ba6d856079e7cb47a3e4ee11925139e637ce05050 lib/request/comparison.py
215215
b9e2db44d265909792f6cc821ff910727b14aa2d5063c74b0f2ea6d40c4f3d9d lib/request/connect.py
216216
8e06682280fce062eef6174351bfebcb6040e19976acff9dc7b3699779783498 lib/request/direct.py
217-
cf019248253a5d7edb7bc474aa020b9e8625d73008a463c56ba2b539d7f2d8ec lib/request/dns.py
217+
05198477dbdeb6c405059eb21cbbcf9cb6804cc54a0f2a1d11741bfc6cbb7ca2 lib/request/dns.py
218218
92c81cc31ff4a396723242058fb2152c9e9745f8412d01ea74480b048a53af6c lib/request/httpshandler.py
219219
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/request/__init__.py
220220
7a0ac2522213e756348fd871a7af74cc963bdc82f9d7ade57be5de42b5bf7cab lib/request/inject.py
@@ -236,7 +236,7 @@ f522436fbd14bdab090a1d305fcac0361800cb8e36c8cbcb47933298376a71e0 lib/takeover/r
236236
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/techniques/blind/__init__.py
237237
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/techniques/dns/__init__.py
238238
3df9839fb92a81d46b6194d7adacb43f391efb78b071783c132e8d596ecbfaf1 lib/techniques/dns/test.py
239-
2934514a60cbcd48675053a73f785b4c7bfe606b51c34ae81a86818362ec4672 lib/techniques/dns/use.py
239+
74ca78082dcd20b3faf07cc944cd65ea552996df40e6fb58d0a011b262528456 lib/techniques/dns/use.py
240240
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/techniques/error/__init__.py
241241
5bbef46c16e34fd80e3f9f0e9aa255ce2e39be0d0e57479e25890b041c7efc7d lib/techniques/error/use.py
242242
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/techniques/__init__.py

‎lib/core/settings.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty import six
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.10.6.134"
23+
VERSION = "1.10.6.135"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -809,6 +809,11 @@
809809
# Reference: http://www.tcpipguide.com/free/t_DNSLabelsNamesandSyntaxRules.htm
810810
MAX_DNS_LABEL = 63
811811

812+
# Maximum number of (most recent) DNS resolution requests retained by the DNS server (bounded so
813+
# that unrelated/stray traffic to the listening :53 socket cannot grow memory without limit; the
814+
# value is popped right after it is triggered, so only recent entries ever matter)
815+
MAX_DNS_REQUESTS = 1000
816+
812817
# Alphabet used for prefix and suffix strings of name resolution requests in DNS technique (excluding hexadecimal chars for not mixing with inner content)
813818
DNS_BOUNDARIES_ALPHABET = re.sub(r"[a-fA-F]", "", string.ascii_letters)
814819

‎lib/request/dns.py‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
from __future__ import print_function
99

1010
import binascii
11+
import collections
1112
import os
1213
import re
1314
import socket
1415
import struct
1516
import threading
1617
import time
1718

19+
try:
20+
from lib.core.settings import MAX_DNS_REQUESTS
21+
except ImportError:
22+
MAX_DNS_REQUESTS = 1000 # fallback so this module stays runnable standalone
23+
1824
class DNSQuery(object):
1925
"""
2026
>>> DNSQuery(b'|K\\x01 \\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x01\\x03www\\x06google\\x03com\\x00\\x00\\x01\\x00\\x01\\x00\\x00)\\x10\\x00\\x00\\x00\\x00\\x00\\x00\\x0c\\x00\\n\\x00\\x08O4|Np!\\x1d\\xb3')._query == b"www.google.com."
@@ -74,7 +80,7 @@ class DNSServer(object):
7480

7581
def __init__(self):
7682
self._check_localhost()
77-
self._requests = []
83+
self._requests = collections.deque(maxlen=MAX_DNS_REQUESTS)
7884
self._lock = threading.Lock()
7985

8086
try:
@@ -140,12 +146,28 @@ def _():
140146
self._initialized = True
141147

142148
while True:
143-
data, addr = self._socket.recvfrom(1024)
144-
_ = DNSQuery(data)
145-
self._socket.sendto(_.response("127.0.0.1"), addr)
146-
147-
with self._lock:
148-
self._requests.append(_._query)
149+
try:
150+
data, addr = self._socket.recvfrom(1024)
151+
except KeyboardInterrupt:
152+
raise
153+
except Exception:
154+
break # socket closed/broken - stop serving (e.g. program exit)
155+
156+
# Note: a single malformed packet or a transient send error must NOT kill the
157+
# server thread (otherwise all subsequent DNS exfiltration is silently lost).
158+
# The query is recorded BEFORE responding, so the exfiltrated data is captured
159+
# even if crafting/sending the (fake) resolution response fails.
160+
try:
161+
_ = DNSQuery(data)
162+
163+
with self._lock:
164+
self._requests.append(_._query)
165+
166+
self._socket.sendto(_.response("127.0.0.1"), addr)
167+
except KeyboardInterrupt:
168+
raise
169+
except Exception:
170+
pass
149171

150172
except KeyboardInterrupt:
151173
raise

‎lib/techniques/dns/use.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def dnsUse(payload, expression):
8484
_ = conf.dnsServer.pop(prefix, suffix)
8585

8686
if _:
87-
_ = extractRegexResult(r"%s\.(?P<result>.+)\.%s" % (prefix, suffix), _, re.I)
87+
# Note: non-greedy so a '--dns-domain' label that happens to match the random
88+
# suffix can't make the match run past the real boundary (the boundary alphabet
89+
# excludes hex characters, so it can never under-match into the hex payload)
90+
_ = extractRegexResult(r"%s\.(?P<result>.+?)\.%s" % (prefix, suffix), _, re.I)
8891
_ = decodeDbmsHexValue(_)
8992
output = (output or "") + _
9093
offset += len(_)

0 commit comments

Comments
 (0)