Open aszhiak opened 8 years ago
Can you do an import json and then do a json.dumps(msg_decoded, indent=4)?
On Tue, Mar 22, 2016 at 1:19 PM, aszhiak notifications@github.com wrote:
Hello I'm trying to execute the script to connect to my work vpn and shows the following error: ------------>8------------------ Traceback (most recent call last): File "./juniper-vpn.py", line 284, in jvpn.run() File "./juniper-vpn.py", line 123, in run self.action_tncc() File "./juniper-vpn.py", line 143, in action_tncc self.cj.set_cookie(t.get_cookie(dspreauth_cookie, dssignin_cookie)) File "/home/aobigdata/Downloads/juniper-vpn-py-master/tncc.py", line 242, in get_cookie data = self.get_msg_contents(response['msg']) File "/home/aobigdata/Downloads/juniper-vpn-py-master/tncc.py", line 187, in get_msg_contents compressed = msg_decoded[0x0ce4][0][0x0ce7][0] IndexError: list index out of range Terminated --------------8<------------------------ I'm using Ubuntu 15 with python 2.7.10 any help with this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13
Thank you for your reply, I'm sysadmin and I dont know so much about python programming, when i'm trying to do what you say, I'm not able to because the python shell closes after the execution of the script, I tried with subprocess.Popen and os.system from python shell and also doing a script, but the error just closes python without executing the json.dumps.. what can I do?
Put the import line with the other imports, and put the dumps line on the line before the error.
On Wed, Mar 23, 2016 at 3:28 AM, aszhiak notifications@github.com wrote:
Thank you for your reply, I'm sysadmin and I dont know so much about python programming, when i'm trying to do what you say, I'm not able to because the python shell closes after the execution of the script, I tried with subprocess.Popen and os.system from python shell and also doing a script, but the error just closes python without executing the json.dumps.. what can I do?
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-200286602
Sorry, forget about the popen thing. Try this script:
https://gist.github.com/russdill/2052a68801bb09925c77
But rather than running it directly, let openconnect run it with --csd-wrapper tncc.py --user-agent "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1" --juniper
This will make it easy to see the output of the script.
On Wed, Mar 23, 2016 at 3:28 AM, aszhiak notifications@github.com wrote:
Thank you for your reply, I'm sysadmin and I dont know so much about python programming, when i'm trying to do what you say, I'm not able to because the python shell closes after the execution of the script, I tried with subprocess.Popen and os.system from python shell and also doing a script, but the error just closes python without executing the json.dumps.. what can I do?
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-200286602
I have tried both script with the import and the json.dump but the output its the same with and without the both lines.. the import is placed at the start of the script with the rest of imports, and json.dump is placed in the line 202 I paste you the error with the openconnect:
Traceback (most recent call last):
File "tncc.py", line 337, in
The error is exactly the same with both scripts the old and the new one you gave me.. the only change is the line numbers..
My bad, the line should be print json.dumps(msg.decoded, indent=4)
On Sat, Mar 26, 2016 at 3:08 PM, aszhiak notifications@github.com wrote:
I have tried both script with the import and the json.dump but the output its the same with and without the both lines.. the import is placed at the start of the script with the rest of imports, and json.dump is placed in the line 202 I paste you the error with the openconnect:
Traceback (most recent call last): File "tncc.py", line 337, in server.process_cmd() File "tncc.py", line 317, in process_cmd cookie = self.tncc.get_cookie(args['Cookie'], args['DSSIGNIN']) File "tncc.py", line 264, in get_cookie data = self.get_msg_contents(response['msg']) File "tncc.py", line 203, in get_msg_contents compressed = msg_decoded[0x0ce4][0][0x0ce7][0] IndexError: list index out of range Received invalid response from TNCC Failed to obtain WebVPN cookie
The error is exactly the same with both scripts the old and the new one you gave me.. the only change is the line numbers..
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-201939939
No problem ;P, this is the output:
Connected to HTTPS on vpn.company.com
{
"3312": [
{
"30": [
"Company_Checker"
]
}
],
"18": [
[
2
]
],
"3315": [
[
1
]
],
"3300": [
{}
]
}
Traceback (most recent call last):
File "tncc.py", line 337, in
hmmm...after the response = self.parse_response(), can you put a:
print json.dumps(response, indent=4)
On Sat, Mar 26, 2016 at 3:19 PM, aszhiak notifications@github.com wrote:
No problem.. If I knew python i would notice, this is the output:
Connected to HTTPS on vpn.company.com { "3312": [ { "30": [ "Company_Checker" ] } ], "18": [ [ 2 ] ], "3315": [ [ 1 ] ], "3300": [ {} ] } Traceback (most recent call last): File "tncc.py", line 337, in server.process_cmd() File "tncc.py", line 317, in process_cmd cookie = self.tncc.get_cookie(args['Cookie'], args['DSSIGNIN']) File "tncc.py", line 264, in get_cookie data = self.get_msg_contents(response['msg']) File "tncc.py", line 203, in get_msg_contents compressed = msg_decoded[0x0ce4][0][0x0ce7][0] IndexError: list index out of range Received invalid response from TNCC Failed to obtain WebVPN cookie
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-201941143
sure, here's the output:
Connected to HTTPS on vpn.company.com
{
"timestamp": "1459078085",
"interval": "10",
"SESSION_POLICIES": "",
"SESSION": "",
"connId": "0",
"msg": "AAAAE8AAAKAAAAWDAAAM5MAAAAwAAAWDAAAM8MAAAGgAAAWDAAAM8cAAAB4AAAWDVGVsZWZvbmljYV9DaGVja2VyAAAAAAzmwAAAOwAABYNObyBydWxlcyBhcmUgY29uZmlndXJlZCBmb3IgdGhlIExpbnV4IHBsYXRmb3JtLgAAAAASwAAAEAAABYMAAAACAAAM84AAABAAAAWDAAAAAQ=="
}
{
"3312": [
{
"30": [
"Company_Checker"
]
}
],
"18": [
[
2
]
],
"3315": [
[
1
]
],
"3300": [
{}
]
}
Traceback (most recent call last):
File "tncc.py", line 337, in
Ok, so it's saying policies don't exist for Linux, maybe there is a way to handle that. But can you try a windows user agent string first?
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1
On Sun, Mar 27, 2016 at 4:29 AM, aszhiak notifications@github.com wrote:
sure, here's the output:
Connected to HTTPS on vpn.company.com { "timestamp": "1459078085", "interval": "10", "SESSION_POLICIES": "", "SESSION": "", "connId": "0", "msg": "AAAAE8AAAKAAAAWDAAAM5MAAAAwAAAWDAAAM8MAAAGgAAAWDAAAM8cAAAB4AAAWDVGVsZWZvbmljYV9DaGVja2VyAAAAAAzmwAAAOwAABYNObyBydWxlcyBhcmUgY29uZmlndXJlZCBmb3IgdGhlIExpbnV4IHBsYXRmb3JtLgAAAAASwAAAEAAABYMAAAACAAAM84AAABAAAAWDAAAAAQ==" } { "3312": [ { "30": [ "Company_Checker" ] } ], "18": [ [ 2 ] ], "3315": [ [ 1 ] ], "3300": [ {} ] } Traceback (most recent call last): File "tncc.py", line 337, in server.process_cmd() File "tncc.py", line 317, in process_cmd cookie = self.tncc.get_cookie(args['Cookie'], args['DSSIGNIN']) File "tncc.py", line 264, in get_cookie data = self.get_msg_contents(response['msg']) File "tncc.py", line 203, in get_msg_contents compressed = msg_decoded[0x0ce4][0][0x0ce7][0] IndexError: list index out of range Received invalid response from TNCC Failed to obtain WebVPN cookie
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-202042772
I have changed useragent inside tnnc.py because I was having the same issue just changing it in openconnect and now the output is this one:
Connected to HTTPS on vpn.company.com
{
"timestamp": "1459109752",
"interval": "10",
"SESSION_POLICIES": "",
"SESSION": "",
"connId": "3",
"msg": "AAAAE8AAAbAAAAWDAAAM5MAAAZQAAAWDAAAM58AAAYUAAAWDAAWDFkNPTVBSRVNTRUQ6NjExOnicjVBda8JAEOyzv+LIL8j5kVTiCcEGlBorxgpCIVzuNnJtchcuF9uAP74XrcWHFnzb3ZmdndnJOtyEMVqFcUScNdW0BAPaddAuXL7aUcBAm7TkI+JnGVDP9+Exy3CO8Rh7LB8OeH80AN/t86AGfQSdGlECwcPRGLtjz/WdaW9SdbpIWm3iVNcb2EFHWjR2pLJ3YCaVTZmBJjhAlVZHwW2t4SBqo9sA6aYAwTFxL2WnhcnmB07tzpWafkCLyfw52qfLl1m4TONwNl+sohtG3WRnUrJPtlH8tk2ANVqY9oZy0d9CAbmSgtEkvAFNW1kwMVrIw3m8E/DpDc/mSiHtE359aiiBkwBJAF7HVsqobquDbUxVCNaSI3NP7unSpN4Jn/6Mdf4VJmutDBwAFRQtZK50SZlQ8t8n9+948uUyp4beacnmYqqRplOBr0pDXVsPi6faBmVKcmFsSwsb0kHT3sM3ngvVIQAAAAAAAAzzgAAAEAAABYMAAAAB"
}
Traceback (most recent call last):
File "tncc.py", line 337, in
ok, now try removing the print json.dumps and see if it works.
On Sun, Mar 27, 2016 at 1:20 PM, aszhiak notifications@github.com wrote:
I have changed useragent inside tnnc.py because I was having the same issue just changing it in openconnect and now the output is this one:
Connected to HTTPS on vpn.company.com { "timestamp": "1459109752", "interval": "10", "SESSION_POLICIES": "", "SESSION": "", "connId": "3", "msg": "AAAAE8AAAbAAAAWDAAAM5MAAAZQAAAWDAAAM58AAAYUAAAWDAAWDFkNPTVBSRVNTRUQ6NjExOnicjVBda8JAEOyzv+LIL8j5kVTiCcEGlBorxgpCIVzuNnJtchcuF9uAP74XrcWHFnzb3ZmdndnJOtyEMVqFcUScNdW0BAPaddAuXL7aUcBAm7TkI+JnGVDP9+Exy3CO8Rh7LB8OeH80AN/t86AGfQSdGlECwcPRGLtjz/WdaW9SdbpIWm3iVNcb2EFHWjR2pLJ3YCaVTZmBJjhAlVZHwW2t4SBqo9sA6aYAwTFxL2WnhcnmB07tzpWafkCLyfw52qfLl1m4TONwNl+sohtG3WRnUrJPtlH8tk2ANVqY9oZy0d9CAbmSgtEkvAFNW1kwMVrIw3m8E/DpDc/mSiHtE359aiiBkwBJAF7HVsqobquDbUxVCNaSI3NP7unSpN4Jn/6Mdf4VJmutDBwAFRQtZK50SZlQ8t8n9+948uUyp4beacnmYqqRplOBr0pDXVsPi6faBmVKcmFsSwsb0kHT3sM3ngvVIQAAAAAAAAzzgAAAEAAABYMAAAAB" } Traceback (most recent call last): File "tncc.py", line 337, in server.process_cmd() File "tncc.py", line 317, in process_cmd cookie = self.tncc.get_cookie(args['Cookie'], args['DSSIGNIN']) File "tncc.py", line 264, in get_cookie data = self.get_msg_contents(response['msg']) File "tncc.py", line 202, in get_msg_contents print json.dumps(msg_decoded, indent=4) File "/usr/lib/python2.7/json/init.py", line 250, in dumps sort_keys=sort_keys, **kw).encode(obj) File "/usr/lib/python2.7/json/encoder.py", line 209, in encode chunks = list(chunks) File "/usr/lib/python2.7/json/encoder.py", line 434, in _iterencode for chunk in _iterencode_dict(o, _current_indent_level): File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict for chunk in chunks: File "/usr/lib/python2.7/json/encoder.py", line 332, in _iterencode_list for chunk in chunks: File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict for chunk in chunks: File "/usr/lib/python2.7/json/encoder.py", line 313, in _iterencode_list yield buf + _encoder(value) UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 16: invalid start byte Received invalid response from TNCC Failed to obtain WebVPN cookie
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-202140648
Well now I have the following issue.. after request me the login and password I got the following message and ask me again for the password.
Got HTTP response: HTTP/1.1 302 Moved
OK, it's not liking the answer you are giving for the policies. Where it responds to the policies and says 'OK', change the OK to Fail. If this doesn't work, the script may need to start getting smart about which policies to say yes to, and which to say no to.
On Sun, Mar 27, 2016 at 2:49 PM, aszhiak notifications@github.com wrote:
Well now I have the following issue.. after request me the login and password I got the following message and ask me again for the password.
Got HTTP response: HTTP/1.1 302 Moved
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-202152283
Well I changed that and now openconnect just crashed:
Connected to HTTPS on vpn.company.com Unknown form ID 'frm' Dumping unknown HTML form:
Failed to obtain WebVPN cookie I don't know if this is relevant but the vpn doesn't have policies for linux, to connect from linux I have a tweaked firefox with some .so of windows media player, activex etc.. and with this I bypass the hostchecker and then just copy the DSID and paste it as parameter to a script which contains a openconnect sentence.I'm guessing the juniper-vpn.py script gives you a "Unknown form type: frm". It looks like it could be a confirmation form though. The forms that openconnect and juniper-vpn.py know about are frmLogin, frmDefender, frmNextToken, and frmConfirmation, so having a form just named 'frm' seems odd. It might be helpful to print out the entire page so it can be seen what it's asking, but the easiest thing is to just try and assume it's a confirmation form. In juniper-vpn.py, in the next_action function where it's testing for what kind of form it is, just change the line:
elif form.name == 'frmConfirmation':
to:
elif form.name == 'frmConfirmation' or form.name == 'frm':
On Sun, Mar 27, 2016 at 3:04 PM, aszhiak notifications@github.com wrote:
Well I changed that and now openconnect just crashed:
Connected to HTTPS on vpn.company.com Unknown form ID 'frm' Dumping unknown HTML form:
Failed to obtain WebVPN cookie
I don't know if this is relevant but the vpn doesn't have policies for linux, to connect from linux I have a tweaked firefox with some .so of windows media player, activex etc.. and with this I bypass the hostchecker and then just copy the DSID and paste it as parameter to a script.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/russdill/juniper-vpn-py/issues/13#issuecomment-202156180
After that change, the script just stuck or freeze at this point: python ./juniper-vpn.py --host vpn.company.com --username username --stdin DSID=%DSID% openconnect --juniper -b --no-cert-check --useragent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' %HOST% --cookie-on-stdin policy vc0|0|policy_6|1|Registry_1 ruleremed needsMonitoring 0 minver1 0 registry_name1 CompanyLtd rulename1 Registry_1 registry_value1 Protege la Informacion regView641 0 object_number 1 registry_type1 String registry_subkey1 SYSTEM\TSecurity ruleid1 0 provider registry registry_key1 HKEY_LOCAL_MACHINE policy vc0|0|policy_6|1|Registry_1 conditional 0 object_number 1 expressionIDs rulecount 1 provider policydata
And after some time do:
Traceback (most recent call last):
File "./juniper-vpn.py", line 284, in
If I execute openconnect instead of juniper-vpn.py I have the frm error.
In juniper-vpn.py, uncomment the lines before # Want debugging messages? Also, in the function run (def run(self):), add the lines:
print self.r.info() print self.r.read()
before self.last_action = action
Note in python that indentation is part of the syntax, so be sure they are intended the same number of spaces as the next line. This will likely print a great deal of information and much of it may be personal, so you may need to interpret it and compare what you see with the manual login process on windows.
On Sun, Mar 27, 2016 at 4:14 PM, aszhiak notifications@github.com wrote:
After that change, the script just stuck or freeze at this point: python ./juniper-vpn.py --host vpn.company.com --username username --stdin DSID=%DSID% openconnect --juniper -b --no-cert-check --useragent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' %HOST% --cookie-on-stdin policy vc0|0|policy_6|1|Registry_1 ruleremed needsMonitoring 0 minver1 0 registry_name1 CompanyLtd rulename1 Registry_1 registry_value1 Protege la Informacion regView641 0 object_number 1 registry_type1 String registry_subkey1 SYSTEM\TSecurity ruleid1 0 provider registry registry_key1 HKEY_LOCAL_MACHINE policy vc0|0|policy_6|1|Registry_1 conditional 0 object_number 1 expressionIDs rulecount 1 provider policydata
And after some time do:
Traceback (most recent call last): File "./juniper-vpn.py", line 284, in jvpn.run() File "./juniper-vpn.py", line 129, in run self.action_continue() File "./juniper-vpn.py", line 205, in action_continue self.r = self.br.submit() File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 541, in submit return self.open(self.click(args, _kwds)) File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 230, in _mech_open response = UserAgentBase.open(self, request, data) File "/usr/local/lib/python2.7/dist-packages/mechanize/_opener.py", line 193, in open response = urlopen(self, req, data) File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 344, in _open '_open', req) File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain result = func(_args) File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 1170, in https_open return self.do_open(conn_factory, req) File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 1118, in do_open raise URLError(err) urllib2.URLError:
If I execute openconnect instead of juniper-vpn.py I have the frm error.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub
I am getting this error when I just run
$ python2 tncc.py
Traceback (most recent call last):
File "tncc.py", line 596, in <module>
vpn_host = sys.argv[1]
IndexError: list index out of range
Perhaps it should check that it's invoked with arguments?
Hello I'm trying to execute the script to connect to my vpn and shows the following error: ------------>8------------------ Traceback (most recent call last): File "./juniper-vpn.py", line 284, in
jvpn.run()
File "./juniper-vpn.py", line 123, in run
self.action_tncc()
File "./juniper-vpn.py", line 143, in action_tncc
self.cj.set_cookie(t.get_cookie(dspreauth_cookie, dssignin_cookie))
File "/home/usertest/Downloads/juniper-vpn-py-master/tncc.py", line 242, in get_cookie
data = self.get_msg_contents(response['msg'])
File "/home/usertest/Downloads/juniper-vpn-py-master/tncc.py", line 187, in get_msg_contents
compressed = msg_decoded[0x0ce4][0][0x0ce7][0]
IndexError: list index out of range
Terminated
--------------8<------------------------
I'm using Ubuntu 15 with python 2.7.10 any help with this?