-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gaurd against pop from empty block stack #415
base: master
Are you sure you want to change the base?
Conversation
I guess one need to understand the root reason... |
Sorry for late response. In most cases I would agree with you 100%. I don't like half-fixes that hide If you want pycdc to decompile legitimately created pyc files, stick with what If you want this tool to also be useful for malware analysis, I would make a The following pyc will run fine despite being invalid.
|
@dennis-doyensec at least two consecutive jumps looks very suspicious, isn't it?
I tried this
|
Sorry it's been a bit. I don't have that file anymore. Those jumps are where I made a binary patch. There should be a PUSH there. Without the push, the stack was empty when a pop occurred. Python's interpreter was fine because it never took that |
I got a segfault when a block stack pop, when the block stack was already empty. This pull prevents emptying the block stack unless you are on the last instruction of the file. Or this is what I intended at least, I am new to this code base and pyc files in general.
This will prevent segfault seen found in issue #387, the provided pyc file there will decompile all the way with this pull. However, it can't be recompiled correctly unless it's a illegitimate pyc file. So I don't know if you would consider this a "fix". I guess it just changes the problem to something new.
I had a different crash that this pull prevents. It is a legitimate pyc file but a different python version.