当前位置:网站首页>PyC file decompile
PyC file decompile
2022-07-02 16:09:00 【1ens】
pyc File structure
File format :
03f3 0d0a magic Express python Version information for , here 03f30d0a yes python2.7 The logo of ;
6206 b160 Time stamp , Compiled time information
63 Blockde The beginning of
after 4 byte 0000 0000 :argcount Number of parameters
after 4 byte 0000 0000: nlocals Number of local variables
after 4 byte 1b00 0000: stacksize Stack space size
after 4 byte 4000 0000:flags
73: type string
3501 0000 bytes ( The small end model )
After that is opcode
Reference resources :PYC File format analysis
At present, we pay more attention to byte length , Because if you modify its source code , Then the length must change , Therefore, this value should also be modified , And note that it is a small end sequence storage .
Source code mixed dishes :
It can be decompiled , But decompiled is difficult for people to understand . Well known are AST Grammar tree .
pyc Mixed dishes
For executable pyc, We can use pycdump Tool to dump , Check its bytecode form .
Corresponding pyc The file is kept in pycdump Under the folder , function python dump.py test.py
This is a direct jump mixed dish :
The first three jump There is no problem in operation logic , But it will cause decompilation failure Its bytecode is 0x71 0x**
We can insert many such instructions , Arbitrary illegal instructions ( In fact, random data can ), Then use some JUMP Instructions to skip such illegal instructions , The purpose of making mixed dishes , And does not affect the normal operation of the program .
Treatment method : We delete these three instructions , And will code_string Reduce the length of 6 Bytes . That's the top
3501 0000 bytes ( The small end model ), Then save . Final use uncompyle6 Decompile , Analyze .
Overlapping instructions :
# example 1 Python Single overlap instruction
0 JUMP_ABSOLUTE [71 05 00] 5
3 PRINT_ITEM [47 -- --]
4 LOAD_CONST [64 64 01] 356
7 STOP_CODE [00 -- --]
# example 1 Actually implement
0 JUMP_ABSOLUTE [71 05 00] 5
5 LOAD_CONST [64 01 00] 1
Here we jump to the third line , But not all the code in the third line is executed , Instead, his operands are regarded as code execution .
uncompyle6 -o total.py .\test.pyc
Reference resources :
边栏推荐
- Wavedec2 in MATLAB, talk about the wavedec2 function [easy to understand]
- Invalid bound statement (not found)解决方法总结
- 结构体的内存对齐
- JS learning notes - process control
- Boot connection to impala database
- Strings and arrays
- Conditions and solutions of deadlock
- The sea of stars hidden behind the nebula graph
- Memory alignment of structure
- Flink real-time data warehouse (IX): incremental synchronization of data in MySQL
猜你喜欢
原神2.6服务端下载以及搭建安装教程
Mobile web development learning notes - Layout
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
idea jar包冲突排查
Practice of constructing ten billion relationship knowledge map based on Nebula graph
注册成为harmonyos开发者并安装DevEco Studio 3.0 Beta2 for HarmonyOS
Idea jar package conflict troubleshooting
How to use percona tool to add fields to MySQL table after interruption
2020.4.12 byte written test questions B DP D monotone stack
随机推荐
Boot transaction usage
【题解】Educational Codeforces Round 82
Wise target detection 23 - pytoch builds SSD target detection platform
Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
Data Lake (11): Iceberg table data organization and query
Add an empty column to spark dataframe - add an empty column to spark dataframe
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
dried food! Understand the structural vulnerability of graph convolution networks
Leetcode -- number of palindromes
Lseek error
又是一年毕业季
The difference and usage of calloc, malloc and realloc functions
华为云服务器安装mysqlb for mysqld.service failed because the control process exited with error code.See “sys
2022最新最详细必成功的在Vscode中设置背景图、同时解决不受支持的问题
QVariant与Json的各种纠葛——Qt
仙人掌之歌——投石问路(2)
AWS virtual machine expansion
构建多架构镜像的最佳实践
可视化技术在 Nebula Graph 中的应用
Pyobject to char* (string)