psiphon icon indicating copy to clipboard operation
psiphon copied to clipboard

TypeError: Odd-length string

Open KokoseiJ opened this issue 6 years ago • 14 comments

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?

KokoseiJ avatar Sep 02 '19 11:09 KokoseiJ

Same Issue

dhruvsatyapanthi007 avatar Sep 02 '19 11:09 dhruvsatyapanthi007

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 avatar Oct 06 '19 05:10 Erixcode

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 avatar Oct 06 '19 12:10 Erixcode

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!!

Erixcode avatar Oct 06 '19 12:10 Erixcode

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 avatar Oct 07 '19 23:10 KokoseiJ

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 avatar Oct 08 '19 00:10 KokoseiJ

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 avatar Oct 09 '19 16:10 KokoseiJ

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.

tanmaytat11 avatar Oct 09 '19 22:10 tanmaytat11

@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.

KokoseiJ avatar Oct 13 '19 06:10 KokoseiJ

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

Erixcode avatar Oct 13 '19 06:10 Erixcode

@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.

KokoseiJ avatar Dec 25 '19 08:12 KokoseiJ

@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.

Erixcode avatar Dec 25 '19 09:12 Erixcode

@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 avatar Dec 25 '19 10:12 KokoseiJ

Oh god Oh fuck It won't work without handshaking

KokoseiJ avatar Dec 27 '19 00:12 KokoseiJ