thispc / psiphon

A multi-functional version of a popular network circumvention tool
GNU General Public License v3.0
229 stars 59 forks source link

TypeError: Odd-length string #27

Open KokoseiJ opened 5 years ago

KokoseiJ commented 5 years ago

I am running Fedora 30. I tried to update the list, but it just gives me "TypeError: Odd-length string". Full traceback is here: Traceback (most recent call last): File "psi_client.py", line 440, in update() File "psi_client.py", line 311, in update js = i[loc:].decode('hex') File "/usr/lib64/python2.7/encodings/hex_codec.py", line 42, in hex_decode output = binascii.a2b_hex(input) TypeError: Odd-length string

Any fix, or having a same issue?

dhruvsatyapanthi007 commented 5 years ago

Same Issue

Erixcode commented 4 years ago

same here, i'm fedora 30 and run the docker:latest. during update got same error: root@fefbd46bc6a8:~/psiphon# psiphon -u 100% [......................................................] 1409925 / 1409925Traceback (most recent call last): File "psi_client.py", line 440, in <module> update() File "psi_client.py", line 311, in update js = i[loc:].decode('hex') File "/usr/lib/python2.7/encodings/hex_codec.py", line 42, in hex_decode output = binascii.a2b_hex(input) TypeError: Odd-length string root@fefbd46bc6a8:~/psiphon#

it seems "servers.dat" file did not generate in the normal way so serverlist did not get updated and timeout issue occurs, i used windows based server_list.dat and had no luck (format is different) i'm going to use android version and check whether that file is ok with linux or not!

Edit: it seems this part of code has issue :

f = open('server_list','r')
    lol=f.read()
    lol = json.loads(lol)
    lol = lol["data"]
    serv = lol.split('\n')
    regions = dict()
    regions["propagation_channel_id"] = "FFFFFFFFFFFFFFFF"
    regions["sponsor_id"] = "FFFFFFFFFFFFFFFF"
    regions["servers"] = list()
    for i in serv:
        loc = i.find('{"webServerCertificate":'.encode('hex'))
        js = i[loc:].decode('hex')
        js = json.loads(js)

        regions["servers"].append(i)
    json.dump(regions, open('servers.dat', 'w'))

so i've edited this part with this code and the output file is structural the same with the original file but cannot be read (i'm so noob in python)

f = open('server_list','r')
lol=f.read()
lol = json.loads(lol)
lol = lol["data"]
serv = lol.split('\n')
regions = dict()
regions["propagation_channel_id"] = "FFFFFFFFFFFFFFFF"
regions["sponsor_id"] = "FFFFFFFFFFFFFFFF"
regions["servers"] = list()
for i in serv:
    loc = i.find('"webServerCertificate":'.encode('hex'))
    js = "{" + i[loc:].decode('hex')
    js = json.loads(js)
    regions["servers"].append(i)
json.dump(regions, open('servers.dat', 'w'))
Erixcode commented 4 years ago

OK issue fixed and output file is working, it seems the main file needs some maintenance since the project is written in 2017 and today's server_list file does not matches. so I've updated the file and output is OK now please test if this is working. thanks

psi_client.py.tar.gz

Erixcode commented 4 years ago

File is ok, the issue is main script should be written from scratch!! i get delimiter: <class 'pexpect.exceptions.EOF'> DEBUG: OSSH connection: Timeout exceeded. for all updated servers!! and i have no knowledge of fixing this issue!! this project is dead!!

KokoseiJ commented 4 years ago

I think it is splitting the file in the wrong point. Some of the string that are used to split the file actually didn't exist in the actual file, and that cause the error, I guess.

KokoseiJ commented 4 years ago

also, For the future users - This project won't work anymore due to different file format. Main core of Psiphon has been wrote in Go, Which is compilable in Linux. So If you need to use Psiphon in Linux, Complie it by yourself.

KokoseiJ commented 4 years ago

If someone is interested at writing the new Psiphon client from scratch, let me know. as I get some free time, I will open a new repository and start developing one. @Erixcode you might want to check this

tanmaytat11 commented 4 years ago

If someone is interested at writing the new Psiphon client from scratch, let me know. as I get some free time, I will open a new repository and start developing one. @Erixcode you might want to check this

@KokoseiJ I am interested to help out in writing a new psiphon client. I know we have stopped activity and development around the python client but this used to work atleast when @thispc and me modified it 2 years back. Lemme know where you are getting started.

KokoseiJ commented 4 years ago

@KokoseiJ I am interested to help out in writing a new psiphon client. I know we have stopped activity and development around the python client but this used to work atleast when @thispc and me modified it 2 years back. Lemme know where you are getting started.

Oh, My god.

OK. but since I am doing another project and I don't have much time to spend at programming(I can write codes in weekend only), It's quite hard to start a new project right now. I will contact you when I've got some free time. My project will probably be done at november.

and, sorry for my bad english If it's hard to read. English is not my main language.

Erixcode commented 4 years ago

I would be happy to help if my low knowledge helps xD

KokoseiJ commented 4 years ago

@tanmaytat11 @thispc @Erixcode I made a PR. check: https://github.com/thispc/psiphon/pull/30 It works on my side, but I can't build a ssh binary. dunno if it's because I am using Fedora. Anyway, I hope you guys to check my fix. and, Merry Christmas everyone!

Edit: plus, I am planning to completely remake the pyclient from scratch with Python3 as this code is running on Python 2 and containing some unnecessary parts because it's from 2012.

Erixcode commented 4 years ago

@KokoseiJ I think Binary Build issue is because mismatch in openssl version with current one already installed on the system. I tried docker to avoid this issue but still got error as i mentioned before! which i think the code needs to be rewritten from scratch.

KokoseiJ commented 4 years ago

@Erixcode Well That's above my ability. using it with SSH relay is the current solution I guess. plus, You can disable OSSH by removing preserved ssh executable, which will make that error disappear.

KokoseiJ commented 4 years ago

Oh god Oh fuck It won't work without handshaking