pyinstxtractor icon indicating copy to clipboard operation
pyinstxtractor copied to clipboard

Use xdis.magics.versions to obtain opcode for proper version of Python

Open rakovskij-stanislav opened this issue 4 years ago • 2 comments

Suggest to use xdis.magics.versions for proper magic insertion in pyc files:

{b'\x02\x99\x99\x00': '1.0', b'\x03\x99\x99\x00': '1.1', b'\x89.\r\n': '1.3', b'\x04\x17\r\n': '1.4', b'\x99N\r\n': '1.5', b'\xfc\xc4\r\n': '1.6', b'\x87\xc6\r\n': '2.0', b'*\xeb\r\n': '2.1', b'-\xed\r\n': '2.2', b';\xf2\r\n': '2.3a0', b'E\xf2\r\n': '2.3a0', b'Y\xf2\r\n': '2.4a0', b'c\xf2\r\n': '2.4a3', b'm\xf2\r\n': '2.4b1', b'w\xf2\r\n': '2.5a0', b'\x81\xf2\r\n': '2.5a0', b'\x8b\xf2\r\n': '2.5a0', b'\x8c\xf2\r\n': '2.5a0', b'\x95\xf2\r\n': '2.5b3', b'\x9f\xf2\r\n': '2.5b3', b'\xa9\xf2\r\n': '2.5c1', b'\xb3\xf2\r\n': '2.5c2', b'\xb7\xf2\r\n': '2.5dropbox', b'\xc7\xf2\r\n': '2.6a0', b'\xd1\xf2\r\n': '2.6a1', b'\xdb\xf2\r\n': '2.7a0', b'\xe5\xf2\r\n': '2.7a0+1', b'\xef\xf2\r\n': '2.7a0+2', b'\xf9\xf2\r\n': '2.7a0+3', b'\x03\xf3\r\n': '2.7', b'a\n\r\n': '2.7pyston-0.6.1', b'\n\xf3\r\n': '2.7pypy', b'\xb8\x0b\r\n': '3.000', b'\xc2\x0b\r\n': '3.000+1', b'\xcc\x0b\r\n': '3.000+2', b'\xd6\x0b\r\n': '3.000+3', b'\xe0\x0b\r\n': '3.000+4', b'\xea\x0b\r\n': '3.000+5', b'\xf4\x0b\r\n': '3.000+6', b'\xf5\x0b\r\n': '3.000+7', b'\xff\x0b\r\n': '3.000+8', b'\t\x0c\r\n': '3.000+9', b'\x13\x0c\r\n': '3.000+10', b'\x1d\x0c\r\n': '3.000+11', b'\x1f\x0c\r\n': '3.000+12', b"'\x0c\r\n": '3.0a4', b';\x0c\r\n': '3.0a5', b'E\x0c\r\n': '3.1a0', b'O\x0c\r\n': '3.1a0+', b'X\x0c\r\n': '3.2a0', b'b\x0c\r\n': '3.2a1', b'l\x0c\r\n': '3.2a2', b's\x0c\r\n': '3.2pypy', b'v\x0c\r\n': '3.3a0', b'\x80\x0c\r\n': '3.3a0+', b'\x94\x0c\r\n': '3.3a1', b'\x8a\x0c\r\n': '3.3a2', b'\x9e\x0c\r\n': '3.3a4', b'\xb2\x0c\r\n': '3.4a1', b'\xbc\x0c\r\n': '3.4a1+1', b'\xc6\x0c\r\n': '3.4a1+2', b'\xd0\x0c\r\n': '3.4a1+3', b'\xda\x0c\r\n': '3.4a4', b'\xe4\x0c\r\n': '3.4a4+', b'\xee\x0c\r\n': '3.4rc2', b'\xf8\x0c\r\n': '3.5a0', b'\x02\r\r\n': '3.5b1', b'\x0c\r\r\n': '3.5b2', b'\x16\r\r\n': '3.5', b'\x17\r\r\n': '3.5.2', b' \r\r\n': '3.6a0', b'!\r\r\n': '3.6a0+1', b'*\r\r\n': '3.6a1', b'+\r\r\n': '3.6a1+1', b',\r\r\n': '3.6a1+2', b'-\r\r\n': '3.6b1', b'/\r\r\n': '3.6b1+1', b'0\r\r\n': '3.6b1+2', b'1\r\r\n': '3.6b1+3', b'2\r\r\n': '3.6b2', b'3\r\r\n': '3.6rc1', b'>\r\r\n': '3.7.0alpha0', b'?\r\r\n': '3.7.0alpha3', b'@\r\r\n': '3.7.0beta2', b'A\r\r\n': '3.7.0beta3', b'B\r\r\n': '3.7.0', b'H\r\r\n': '3.8.0a1', b'I\r\r\n': '3.8.0a3+', b'R\r\r\n': '3.8.0a1+', b'S\r\r\n': '3.8.0b2+', b'T\r\r\n': '3.8.0beta2', b'U\r\r\n': '3.8.0rc1+', b'\\\r\r\n': '3.9.0a0', b']\r\r\n': '3.9.0a0', b'^\r\r\n': '3.9.0alpha1', b'_\r\r\n': '3.9.0a0', b'`\r\r\n': '3.9.0a2', b'a\r\r\n': '3.9.0beta5', b'0\x00\r\n': '3.2a2', b'@\x00\r\n': '3.3pypy', b'p\x00\r\n': '3.5pypy', b'\xa0\x00\r\n': '3.6.1pypy', b'\xc0\x00\r\n': '3.6pypy', b'\xf3\x03\r\n': '2.7.1b3Jython', b'zV\r\n': '2.7.7Pyston'}

rakovskij-stanislav avatar Dec 23 '20 18:12 rakovskij-stanislav

xdis.magics.versions isn't used as this doesn't solves the problem of unmarshalling code object of a different Python version than the one used to build the executable. Using the same version of Python is a necessity because of this. While the pyc magic header will be written correctly the underlying problem will remain.

I'm also aware of the xdis library which supposedly allows to load bytecode from a different Python version. There are no plans to use xdis at the moment as this will introduce a dependency.

If this is used in the future it will be in the form of a separate file/project.

extremecoders-re avatar Dec 24 '20 06:12 extremecoders-re

How to get the pyc of the submodule, I didn't see that I only saw the main module

2963663242 avatar Aug 05 '21 17:08 2963663242

This feature has been introduced in the form of a separate tool pyinstxtractor-ng which uses xdis to unmarshal

https://github.com/pyinstxtractor/pyinstxtractor-ng

extremecoders-re avatar Sep 18 '22 12:09 extremecoders-re