Skip to content

Commit

Permalink
Fix socks proxy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chen2aaron committed Mar 22, 2019
1 parent 85d2c0c commit 4d857ac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pocsuite3/lib/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ def get_host_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 80))
ip = s.getsockname()[0]
except Exception:
ip = '127.0.0.1'
finally:
s.close()

Expand Down
1 change: 1 addition & 0 deletions pocsuite3/lib/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class PROXY_TYPE:
HTTPS = "HTTPS"
SOCKS4 = "SOCKS4"
SOCKS5 = "SOCKS5"
SOCKS5H = "SOCKS5H"


class ERROR_TYPE_ID:
Expand Down
9 changes: 5 additions & 4 deletions pocsuite3/lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ def _set_network_proxy():
username = _.group(1)
password = _.group(2)

if scheme in (PROXY_TYPE.SOCKS4, PROXY_TYPE.SOCKS5):
if scheme in (PROXY_TYPE.SOCKS4, PROXY_TYPE.SOCKS5, PROXY_TYPE.SOCKS5H):
socks.set_default_proxy(
socks.PROXY_TYPE_SOCKS5 if scheme == PROXY_TYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4,
socks.PROXY_TYPE_SOCKS4 if scheme == PROXY_TYPE.SOCKS4 else socks.PROXY_TYPE_SOCKS5,
hostname,
port,
username=username,
password=password
password=password,
rdns=True if scheme == PROXY_TYPE.SOCKS5H else False,
)
socket.socket = socks.socksocket
else:
Expand Down Expand Up @@ -587,10 +588,10 @@ def init():
_set_http_user_agent()
_set_http_extra_headers()

_set_connect_back()
_set_network_proxy()
_set_network_timeout()
_set_threads()
_set_connect_back()
_set_listener()
remove_extra_log_message()
update()
2 changes: 1 addition & 1 deletion pocsuite3/lib/request/patch/hook_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def session_request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None, auth=None,
timeout=conf.timeout if 'timeout' in conf else 10,
timeout=conf.timeout if 'timeout' in conf else None,
allow_redirects=True, proxies=None, hooks=None, stream=None, verify=False, cert=None, json=None):
# Create the Request.
merged_cookies = merge_cookies(merge_cookies(RequestsCookieJar(), self.cookies),
Expand Down

0 comments on commit 4d857ac

Please sign in to comment.