Skip to content

Commit 39ba1bc

Browse files
committed
Adding custom/own support for HTTP2
1 parent 8a75c0b commit 39ba1bc

5 files changed

Lines changed: 560 additions & 47 deletions

File tree

data/txt/sha256sums.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ f8de57606325456928e46ae2896f5f8bbec9ad18b1c644b492a566fa992216f6 lib/core/decor
189189
9bf174058f15d14e24e94f9aaf42df045119d3617c6c54bd2f3af79b462f331d lib/core/replication.py
190190
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
191191
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
192-
2f4c7044d36e183fcb0a019d82ccbc7222abab1878454c479df9e89d23430733 lib/core/settings.py
192+
35c24cf138fdd68add3c8f6274d6ff735b5209c84eec635ba316f986b67325ef lib/core/settings.py
193193
c7804223319e18eb0b8e2cbf0a8b6896d1cefb7b0b1a2e9f1cf826a8a3b56750 lib/core/shell.py
194194
a2e98a94b231432736d6b304fc75525c8b5fdb4768c418387c5b4c1a610dad64 lib/core/subprocessng.py
195195
19f1e3c5e3ba703d28d510cd7a9ab8284d5fbe9df5ce7e77c86e5931571364b7 lib/core/target.py
@@ -212,9 +212,10 @@ c2f34e27578742e729c2fa9c1d4f0a0d8f8f7f4cf0fc14c62ec817a260c71dec lib/parse/site
212212
369484a2999d29f49bf839a329d1686ed94f6ea27c695e027fe08c8da51f30a3 lib/request/basic.py
213213
bc61bc944b81a7670884f82231033a6ac703324b34b071c9834886a92e249d0e lib/request/chunkedhandler.py
214214
9c0dccc1cee66d38478aaf75a7c513d0d136d50a90b15fed146faa1653899fe1 lib/request/comparison.py
215-
729e07a2ca6b1d83563e9c6dc5a884d1b664c1764be06776ea93bde305164f0c lib/request/connect.py
215+
c96deaa69743d2cf4ae48f2ae0036f7e11b838f97a0e8c7f1205c61e9dd36bc1 lib/request/connect.py
216216
8e06682280fce062eef6174351bfebcb6040e19976acff9dc7b3699779783498 lib/request/direct.py
217217
a6b37b436838caeb197fea858d0a39fadbff4736256e741b5fcec1f28fcf1ce0 lib/request/dns.py
218+
21e8e2d44788b124f741b76a483ce9528ca53ff6da6691808ee679fe91128050 lib/request/http2.py
218219
92c81cc31ff4a396723242058fb2152c9e9745f8412d01ea74480b048a53af6c lib/request/httpshandler.py
219220
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/request/__init__.py
220221
7a0ac2522213e756348fd871a7af74cc963bdc82f9d7ade57be5de42b5bf7cab lib/request/inject.py
@@ -256,7 +257,7 @@ c61816c9dba9f6cc2223aed1a923f95130979e5f0a88ec254ee667d955ed2734 lib/techniques
256257
aeefb42ea0c68f72744bc1bfd7194ec1bc06480d8a7e23f4b8d3d23fbba2b014 lib/utils/api.py
257258
442555ab85277aff7c9e0cf465ea5b0d28395c326f68363449b2d3941f4b6de2 lib/utils/brute.py
258259
da5bcbcda3f667582adf5db8c1b5d511b469ac61b55d387cec66de35720ed718 lib/utils/crawler.py
259-
a94958be0ec3e9d28d8171813a6a90655a9ad7e6aa33c661e8d8ebbfcf208dbb lib/utils/deps.py
260+
51deedec3d3e869b067824caa51406d2ef396c188f82013ca60777006a821e27 lib/utils/deps.py
260261
bd9267d94390ba87d6c5a35c90f2406d6a4135a7c8ea01db76dd9e6519eee2ed lib/utils/dialect.py
261262
51cfab194cd5b6b24d62706fb79db86c852b9e593f4c55c15b35f175e70c9d75 lib/utils/getch.py
262263
3c4ad819589fe4fca303706dc87969273a07a04dee85e23f064b39caf1fb80e9 lib/utils/gui.py

lib/core/settings.py

Lines changed: 1 addition & 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.7.2"
23+
VERSION = "1.10.7.3"
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)

lib/request/connect.py

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class WebSocketException(Exception):
6363
from lib.core.common import urldecode
6464
from lib.core.common import urlencode
6565
from lib.core.common import wasLastResponseDelayed
66-
from lib.core.compat import LooseVersion
6766
from lib.core.compat import patchHeaders
6867
from lib.core.compat import xrange
6968
from lib.core.convert import encodeBase64
@@ -111,7 +110,6 @@ class WebSocketException(Exception):
111110
from lib.core.settings import JAVASCRIPT_HREF_REGEX
112111
from lib.core.settings import LARGE_READ_TRIM_MARKER
113112
from lib.core.settings import LIVE_COOKIES_TIMEOUT
114-
from lib.core.settings import MIN_HTTPX_VERSION
115113
from lib.core.settings import MAX_CONNECTION_READ_SIZE
116114
from lib.core.settings import MAX_CONNECTIONS_REGEX
117115
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
@@ -632,49 +630,29 @@ class _(dict):
632630
cookie.value = re.sub(r"(%s)([^ \t])" % char, r"\g<1>\t\g<2>", cookie.value)
633631

634632
if conf.http2:
635-
try:
636-
import httpx
637-
except ImportError:
638-
raise SqlmapMissingDependence("httpx[http2] not available (e.g. 'pip%s install httpx[http2]')" % ('3' if six.PY3 else ""))
633+
from lib.request.http2 import open_url as http2OpenUrl
639634

640-
if LooseVersion(httpx.__version__) < LooseVersion(MIN_HTTPX_VERSION):
641-
raise SqlmapMissingDependence("outdated version of httpx detected (%s<%s)" % (httpx.__version__, MIN_HTTPX_VERSION))
635+
h2proxy = None
636+
if conf.proxy:
637+
_proxyParts = _urllib.parse.urlsplit(conf.proxy if "://" in conf.proxy else "http://%s" % conf.proxy)
638+
if (_proxyParts.scheme or "").lower().startswith("socks"):
639+
raise SqlmapMissingDependence("native HTTP/2 client does not support SOCKS proxies (omit '--http2' or use an HTTP proxy)")
640+
h2proxy = (_proxyParts.hostname, _proxyParts.port or 8080, conf.proxyCred or None)
642641

643642
try:
644-
proxy_mounts = dict(("%s://" % key, httpx.HTTPTransport(proxy="%s%s" % ("http://" if "://" not in kb.proxies[key] else "", kb.proxies[key]))) for key in kb.proxies) if kb.proxies else None
645-
with httpx.Client(verify=False, http2=True, timeout=timeout, follow_redirects=True, cookies=conf.cj, mounts=proxy_mounts) as client:
646-
conn = client.request(method or (HTTPMETHOD.POST if post is not None else HTTPMETHOD.GET), url, headers=headers, data=post)
647-
except (httpx.HTTPError, httpx.InvalidURL, httpx.CookieConflict, httpx.StreamError) as ex:
643+
conn = http2OpenUrl(url, method or (HTTPMETHOD.POST if post is not None else HTTPMETHOD.GET), headers, post, timeout, follow_redirects=kb.choices.redirect != REDIRECTION.NO, proxy=h2proxy)
644+
except IOError as ex:
648645
raise _http_client.HTTPException(getSafeExString(ex))
649646
else:
650-
if conn.status_code >= 400:
651-
raise _urllib.error.HTTPError(url, conn.status_code, conn.reason_phrase, conn.headers, io.BytesIO(conn.read()))
652-
653-
conn.code = conn.status_code
654-
conn.msg = conn.reason_phrase
655-
conn.info = lambda c=conn: c.headers
656-
657-
conn._read_buffer = conn.read()
658-
conn._read_offset = 0
647+
if conn.code >= 400:
648+
raise _urllib.error.HTTPError(url, conn.code, conn.msg, conn.info(), io.BytesIO(conn.read()))
659649

660650
requestMsg = re.sub(r" HTTP/[0-9.]+\r\n", " %s\r\n" % conn.http_version, requestMsg, count=1)
661651

662652
if not multipart:
663653
threadData.lastRequestMsg = requestMsg
664654

665655
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
666-
667-
def _read(count=None):
668-
offset = conn._read_offset
669-
if count is None:
670-
result = conn._read_buffer[offset:]
671-
conn._read_offset = len(conn._read_buffer)
672-
else:
673-
result = conn._read_buffer[offset: offset + count]
674-
conn._read_offset += len(result)
675-
return result
676-
677-
conn.read = _read
678656
else:
679657
if not multipart:
680658
threadData.lastRequestMsg = requestMsg

0 commit comments

Comments
 (0)