From 21cc084b4da217d966933e7ae3e074803daae78e Mon Sep 17 00:00:00 2001 From: gorgiaxx Date: Wed, 8 Mar 2017 11:04:45 +0800 Subject: [PATCH] add cookies support --- README.md | 1 + lib/TunnaClient.py | 3 ++- lib/__init__.py | 0 proxy.py | 1 + settings.py | 5 ++++- 5 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 lib/__init__.py diff --git a/README.md b/README.md index 6b45f39..b7e6eef 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Advanced Options `--start-ping, -s` Start the pinging thread first - some services send data first (eg. SSH) +`--cookie, -C` Request cookies * See limitations diff --git a/lib/TunnaClient.py b/lib/TunnaClient.py index fd3d166..b4a07ad 100644 --- a/lib/TunnaClient.py +++ b/lib/TunnaClient.py @@ -182,6 +182,7 @@ def __init__(self, url , options): remote_ip = options['remote_ip'] remote_port = options['remote_port'] verbose = options['verbose'] + self.cookie = options['cookie'] self.url=url @@ -248,7 +249,7 @@ def HTTPreq(self,url,data=None,headers=None): kargs['url']=url if data: kargs['data']=data #Will do a GET if no data else POST if headers: kargs['headers']=headers - else: kargs['headers']={'Content-Type':'application/octet-stream'} + else: kargs['headers']={'Content-Type':'application/octet-stream','Cookie':self.cookie} #Make Request f=opener.open(urllib2.Request(**kargs)) diff --git a/lib/__init__.py b/lib/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/proxy.py b/proxy.py index b5dff0d..072e9e9 100644 --- a/proxy.py +++ b/proxy.py @@ -61,6 +61,7 @@ def main(): advancedGroup.add_option('-q','--ping-interval', help='webshprx pinging thread interval (default = 0.5)', dest='ping_delay', action='store', type='float', default=Defaults['ping_delay']) advancedGroup.add_option('-s','--start-ping', help='Start the pinging thread first - some services send data first (eg. SSH)', dest='start_p_thread', action='store_true', default=Defaults['start_p_thread']) advancedGroup.add_option('-c','--verify-server-cert', help='Verify Server Certificate', dest='start_p_thread', action='store_false', default=Defaults['ignoreServerCert']) + advancedGroup.add_option('-C','--cookie', help='Request cookies', dest='cookie', action='store', default=Defaults['Cookie']) parser.add_option_group(advancedGroup) diff --git a/settings.py b/settings.py index 2d9b72c..f625071 100644 --- a/settings.py +++ b/settings.py @@ -20,7 +20,10 @@ #! Not to be changed 'ProxyFileWin':'lib/socks4aServer.exe', - 'ProxyFilePy':'lib/socks4aServer.py' + 'ProxyFilePy':'lib/socks4aServer.py', + + #! HTTP headers + 'Cookie':'', } Webserver_Defaults ={