The technical principle of a piece of magical Python code

Magic code source: 

 code show as below:

unused=b'\x50K\3\4'+b'\0'*26+b'+(\xca\xcc+\xd1P\xcfHL\xceNMQ\xc8\xc9\xcfQ\xd7\4\0PK\1\2'+b'\0'*6+b'\1'+b'\0'*9+b'\x15'+b'\0'*7+b'\13'+b'\0'*17+b'__\x6da\x69n__.\x70y\x50K\5\6'+b'\0'*8+b'9\0\0\0003\0\0\0'
i=__import__
i("runpy").run_path(i("py_compile").compile(__file__))

In fact, the result of running this code:

 Incredible, so let's take a look at zipimport.py and zlib_decompress_impl :

 It is not difficult to find that after unused is compiled into pyc, there is zip in pyc (it happens to be an import format supported by py)

 

Guess you like

Origin blog.csdn.net/weixin_48144018/article/details/130103619