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

AttributeError: 'NoneType' object has no attribute 'encode' #9

Open
eppesuig opened this issue Sep 26, 2017 · 17 comments
Open

AttributeError: 'NoneType' object has no attribute 'encode' #9

eppesuig opened this issue Sep 26, 2017 · 17 comments

Comments

@eppesuig
Copy link

Hello,
I am testing snxvpn with python3 on a debian stretch machine. I installed the program with pip3 and I installed python3-lxml as well. Now, when I run snxconnect with parameters --host, --snxpath, and --username, I get this error:

Traceback (most recent call last):
File "/usr/local/bin/snxconnect", line 5, in
main ()
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 511, in main
result = rq.login ()
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 193, in login
( password = enc.encrypt (self.args.password)
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 379, in encrypt
x = self.pad (password)
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 365, in pad
for x in iterbytes (reversed (txt.encode ('utf-8'))) :
AttributeError: 'NoneType' object has no attribute 'encode'

Any hint on what to check?

Thank you very much,
Giuseppe

@schlatterbeck
Copy link
Owner

Thanks for the bug-report. Fixed in the latest commit.
The problem was: I'm mainly using it with a .netrc file. That means I didn't notice that password prompting didn't work.
Let me know if it works for you.

@eppesuig
Copy link
Author

Hello,
it seems the problem is not fixed. I am prompted for the password, but then the program stop like this:

Traceback (most recent call last):
File "/usr/local/bin/snxconnect", line 5, in
main ()
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 522, in main
result = rq.login ()
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 196, in login
( password = enc.encrypt (self.args.password)
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 390, in encrypt
x = self.pad (password)
File "/usr/local/lib/python3.5/dist-packages/snxconnect.py", line 376, in pad
for x in iterbytes (reversed (txt.encode ('utf-8'))) :
AttributeError: 'NoneType' object has no attribute 'encode'

Bye,
Giuseppe

@schlatterbeck
Copy link
Owner

I've pushed another change, can you test directly from git or are you using pypi?

@schlatterbeck schlatterbeck reopened this Sep 28, 2017
@eppesuig
Copy link
Author

Yes, the new patch fix the password problem. Now I get a different error message:

Login failed (expected MultiChallenge)

Is this something I can work around?

Thank you,
Giuseppe

@schlatterbeck
Copy link
Owner

schlatterbeck commented Sep 28, 2017 via email

@eppesuig
Copy link
Author

I may connect from Windows and cisco client without any second password.
This is the complete (anonymised) output using --debug:

root@computer:~# snxconnect --debug --host vpn.XXXX.com --snxpath /usr/bin/snx --username user@domain
Password:
sslvpn/Login/Login
https://vpn.XXXX.com/sslvpn/Login/Login
sslvpn/Login/../Login/JS_RSA.js
{'modulus': 'c63c133...dff54c319', 'exponent': '010001'}
sslvpn/Login/Login
https://vpn.XXXX.com/sslvpn/Login/Login
Date: Thu, 28 Sep 2017 10:22:18 GMT
Server: CPWS
X-Frame-Options: SAMEORIGIN
Pragma: no-cache
Cache-Control: no-store
Vary: User-Agent
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

Login failed (expected MultiChallenge)
Login failed (no MultiChallenge): https://vpn.XXXX.com/sslvpn/Login/Login

@schlatterbeck
Copy link
Owner

schlatterbeck commented Oct 3, 2017 via email

@eppesuig
Copy link
Author

eppesuig commented Oct 4, 2017

Hello RAlf,
this is the output I get, with debug.

root@computer:~# snxconnect --debug --host vpn.XXXXX.com --snxpath /usr/bin/snx --username user@XXXXX
Password:
sslvpn/Login/Login
https://vpn.XXXXX.com/sslvpn/Login/Login
sslvpn/Login/../Login/JS_RSA.js
{'modulus': 'c63c13369305...87edff54c319', 'exponent': '010001'}
sslvpn/Login/Login
https://vpn.XXXXX.com/sslvpn/Login/Login
Date: Wed, 04 Oct 2017 07:12:34 GMT
Server: CPWS
X-Frame-Options: SAMEORIGIN
Pragma: no-cache
Cache-Control: no-store
Vary: User-Agent
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

Unexpected response, looking for MultiChallenge or Portal
purl: https://vpn.XXXXX.com/sslvpn/Login/Login

Bye,
Giuseppe

P.S. Don't bother about delays: I am busy too :-)

@schlatterbeck
Copy link
Owner

schlatterbeck commented Oct 4, 2017 via email

@eppesuig
Copy link
Author

eppesuig commented Oct 4, 2017

Hello Ralf,
I did install debian package mitmproxy and run it. It opened a regular proxy on localhost:8080. I setup the environment variable https_proxy=http://localhost:8080 before running your program, and I got the error message:

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)>

so, I opened a browser, connected via the proxy to "https://vpn.XXXXX.com/" and saved the SSL certificate. Then, from root, I moved that file in /usr/local/share/ca-certificates/mitmit.crt and ran update-ca-certificates. Now that CA should have been trusted by openssl applications like python.
I ran again your program and got the same error. Do you have any suggestion on how to proceed?

Thank you,
Giuseppe

@schlatterbeck
Copy link
Owner

schlatterbeck commented Oct 5, 2017 via email

@eppesuig
Copy link
Author

Hello Ralf,
I finally tried your suggestion, but I made some mistake since it did not start. This is what I've done:

  1. start mitmdump as you suggested, changing example.com with my VPN server site URL
  2. connected with this command: "env http_proxy=http://localhost:6060 snxconnect --debug --host localhost:80 --snxpath /usr/bin/snx --username [email protected]". This did not use the proxy mitm proxy and gave error «SSL: WRONG_VERSION_NUMBER»
  3. I made the same command with https_proxy instead of http_proxy. This used mitm proxy and gave error «urlopen error Tunnel connection failed: 400 Bad Request». I know it uses mitm since mitm wrote on its stdout «HTTP protocol error in client request: Invalid HTTP request form (expected: relative, got: authority)».

Do you have any idea about what I am doing wrong?

Thank you very much,
Giuseppe

@schlatterbeck
Copy link
Owner

schlatterbeck commented Oct 18, 2017 via email

@crschimidtsp
Copy link

crschimidtsp commented Oct 23, 2018

Hi Ralf, could you help me please? I'm trying to connect to Checkpoint VPN using linux, but I am stuck in this error:

[root@fedora ~]# snxconnect -D -H vpnti.xxxxxx.com.br -U x213716 --save-cookies
Password:
sslvpn/Login/Login
https://FQDN/sslvpn/Login/Login
sslvpn/Login/../Login/JS_RSA.js
{u'modulus': u'c904cd14bc6e4005609680523129a13304ba1d95c35ecdd2bc9cbc77571091958840a544f13d3e289c1f62014211d74b40000fe9c26edce34792f25341a396af572d6885fcd262d0b7f1e3b0a325e8be42e0d436d2e2f047ba06c56a43a75618d8b8cc5ca8a8559d7bb8d4812b7cf398feb19814e2d532ef4ae2805f60e3b4a75d85eb79ba5b132789cabe954ac2617e8fe3065bc3ad5c2cae24309e2395877e40261f019466e802966f5061bff58147f7dc12188aec6795b718fc70314e8c7312888018a8e4e077e169bfdfc9d0c50631249a4dd88c2f0b15478c57eb13acf6c8ae0dc643a4345e839499c08145626372c883d8b664939c093d8cc49544f35f', u'exponent': u'010001'}
sslvpn/Login/Login
Traceback (most recent call last):
File "/usr/bin/snxconnect", line 5, in
main ()
File "/usr/lib/python2.7/site-packages/snxconnect.py", line 522, in main
result = rq.login ()
File "/usr/lib/python2.7/site-packages/snxconnect.py", line 196, in login
( password = enc.encrypt (self.args.password)
File "/usr/lib/python2.7/site-packages/snxconnect.py", line 390, in encrypt
x = self.pad (password)
File "/usr/lib/python2.7/site-packages/snxconnect.py", line 376, in pad
for x in iterbytes (reversed (txt.encode ('utf-8'))) :
AttributeError: 'NoneType' object has no attribute 'encode'

I'd appreciate any help

@swaechter
Copy link

@crschimidtsp I have the same problem, were you able to figure it out?

@tuxflo
Copy link

tuxflo commented Aug 12, 2019

I'm not sure if this helps but I'm using a fork of this project (https://github.com/agnis-mateuss/snxvpn) and I don't have issues with connecting to a CheckPoint VPN.

@swaechter
Copy link

@tuxflo Thank you for the link, I tried it (Installing the software, importing the self signed certificate, playing around with the options etc), but I always ended up with a Login failed (expected MultiChallenge)

Although I respect and appreciate the time people spend in these projects + helping others, it's like fighting in an already lost battle (No upstream vendor support from Checkpoint) :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants