Skip to content

Commit

Permalink
hotfix: workaround for unknown opcodes stopping decompilation
Browse files Browse the repository at this point in the history
this is far from the ideal solution, as the code comes incomplete, but is better than not decompiling the file at all

this workaround was proposed by https://github.com/zrax/pycdc/issues/307\#issuecomment-1382103504
  • Loading branch information
kamuridesu committed Apr 27, 2023
1 parent c815673 commit d425d88
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ASTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,9 +2563,10 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.push(nullptr);
break;
default:
fprintf(stderr, "Unsupported opcode: %s\n", Pyc::OpcodeName(opcode & 0xFF));
cleanBuild = false;
return new ASTNodeList(defblock->nodes());
stack.pop();
// fprintf(stderr, "Unsupported opcode: %s\n", Pyc::OpcodeName(opcode & 0xFF));
// cleanBuild = false;
// return new ASTNodeList(defblock->nodes());
}

else_pop = ( (curblock->blktype() == ASTBlock::BLK_ELSE)
Expand Down

2 comments on commit d425d88

@lol2232
Copy link

@lol2232 lol2232 commented on d425d88 May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting a segmentation fault once it gets to a certain part when using this to analyze some 3.10 malware that wouldn’t work without this because of unsupported opcodes

@kamuridesu
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting a segmentation fault once it gets to a certain part when using this to analyze some 3.10 malware that wouldn’t work without this because of unsupported opcodes

As stated in the commit message, this is not an ideal solution, just a workaround. For the things I had to do it worked fine.

I could analyze the project and try to map newer opcodes but I don't have time for it now.

Please sign in to comment.