Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

魔改增加功能,便于盲注 #25

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Next Next commit
为http() 增加了 params 参数,支持以 dict 形式传入query string
1nhann committed Mar 4, 2022
commit 98d2860fe5caca2835605b468a828cd62c84ca12
22 changes: 14 additions & 8 deletions HackRequests/HackRequests.py
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ def __init__(self, conpool=None):
else:
self.httpcon = conpool

def _get_urlinfo(self, url, realhost: str):
def _get_urlinfo(self, url, params: dict,realhost: str):
p = parse.urlparse(url)
scheme = p.scheme.lower()
if scheme != "http" and scheme != "https":
@@ -125,11 +125,17 @@ def _get_urlinfo(self, url, realhost: str):
port = 80 if scheme == "http" else 443
if ":" in hostname:
hostname, port = hostname.split(":")
path = ""
if p.path:
query = parse.urlencode(params)
if p.path == "":
path = "/"
else:
path = p.path
if p.query:
path = path + "?" + p.query
if p.query:
path = path + "?" + p.query
if query:
path = path + "&" + query
elif query:
path = path + "?" + query
if realhost:
if ":" not in realhost:
realhost = realhost + ":80"
@@ -242,7 +248,7 @@ def httpraw(self, raw: str, **kwargs):
log["response"] = "HTTP/%.1f %d %s" % (
rep.version * 0.1, rep.status,
rep.reason) + '\r\n' + str(rep.msg)
if port == 80 or port == 443:
if port == 80 or port ==
_url = "{scheme}://{host}{path}".format(scheme=scheme, host=host, path=path)
else:
_url = "{scheme}://{host}{path}".format(scheme=scheme, host=host + ":" + port, path=path)
@@ -263,7 +269,7 @@ def http(self, url, **kwargs):

proxy = kwargs.get('proxy', None)
headers = kwargs.get('headers', {})

params = kwargs.get("params", {})
# real host:ip
real_host = kwargs.get("real_host", None)

@@ -286,7 +292,7 @@ def http(self, url, **kwargs):
if "Content-Length" in headers:
del headers["Content-Length"]

urlinfo = scheme, host, port, path = self._get_urlinfo(url, real_host)
urlinfo = scheme, host, port, path = self._get_urlinfo(url, params,real_host)
log = {}
try:
conn = self.httpcon.get_con(urlinfo, proxy=proxy)