Skip to content
Snippets Groups Projects
Commit 40e68c69 authored by Chris Hines's avatar Chris Hines
Browse files

was trying to get the tunnel based on the csrf-token header which is wrong. So...

was trying to get the tunnel based on the csrf-token header which is wrong. So try all possible token formats
parent 12573302
No related branches found
No related tags found
2 merge requests!83was trying to get the tunnel based on the csrf-token header which is wrong. So...,!82was trying to get the tunnel based on the csrf-token header which is wrong. So...
Pipeline #55172 passed
......@@ -106,62 +106,31 @@ class TWSProxy(threading.Thread):
import re
import requests
logger = logging.getLogger()
token = b'Authorization: token (?P<authtok>\w+)[\W|$]'
m = re.search(token,header)
if m:
try:
authtok = m.groupdict()['authtok'].rstrip()
s = requests.Session()
url = TES+'tunnelstat/'+authtok.decode()
try:
r = s.get(url)
port = r.json()
except:
raise Exception('unable to get a port number for the authtok {}'.format(r.text))
return port
except Exception as e:
import traceback
logger.error('Exception')
logger.error(e)
logger.error(traceback.format_exc())
raise e
token = b'token=(?P<authtok>\w+)[&|\W|$]'
m = re.search(token,header)
if m:
try:
authtok = m.groupdict()['authtok'].rstrip()
s = requests.Session()
url = TES+'tunnelstat/'+authtok.decode()
token_format: = [ b'Authorization: token (?P<authtok>\w+)[\W|$]',
b'token=(?P<authtok>\w+)[&|\W|$]',
b'twsproxyauth=(?P<authtok>\w+)[\W|$]']
for token in token_formats:
m = re.search(token,header)
if m:
try:
r = s.get(url)
port = r.json()
except:
raise Exception('unable to get a port number for the authtok {}'.format(r.text))
return port
except Exception as e:
import traceback
logger.error('Exception')
logger.error(e)
logger.error(traceback.format_exc())
raise e
token = b'twsproxyauth=(?P<authtok>\w+)[\W|$]'
m = re.search(token,header)
if m:
authtok = m.groupdict()['authtok']
s = requests.Session()
url = TES+'tunnelstat/'+authtok.decode()
try:
r = s.get(url)
port = r.json()
except:
raise Exception('unable to get a port number for the authtok {}'.format(r.text))
return port
authtok = m.groupdict()['authtok'].rstrip()
s = requests.Session()
url = TES+'tunnelstat/'+authtok.decode()
try:
r = s.get(url)
port = r.json()
except:
raise Exception('unable to get a port number for the authtok {}'.format(r.text))
if port is not None:
return port
except Exception as e:
import traceback
logger.error('Exception')
logger.error(e)
logger.error(traceback.format_exc())
raise e
return None
# if m:
# print('match verify!',m.group(0))
# return 8888
# else:
# return None
@staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment