Understanding Python disassembly with ChatGPT
2024-2-8 18:8:3 Author: infosecwriteups.com(查看原文) 阅读量:8 收藏

morimolymoly

InfoSec Write-ups

Hello, I am morimolymoly!

Today, I am going to introduce how to treat disassembly code of Python with ChatGPT!

You can create single application from Python sources with PyInstaller.

Simple code
executed result

This simple code is going to be a EXE file.

PyInstaller

EXE out from Pyinstaller behaves same as script one!

Executed result

You can extract pyc(Python compiled file) with pyinstxtractor

Executed result
Extracted one

Extracted files are here.

Most interesting one is main.pyc.

HEX

Hex editor reveals this is not human readable file.

We need decompiler or disassembler.

pycdc has decompiler and disassembler both!

However, decompiler sometimes emits garbage code.

Decompilation failure

Some CTFs has challenge of PyInstaller and sometimes it was made by new version of Python and pycdc does not work.

We have to look at disassembly code!

disassembly code

Here is a disassembly code!

This is simple script so easy to understand but sometimes you encounter complex script, you need another power./

Prompt is “Tell me about this python decompilation”

Result is here!

Finally, ChatGPT decompiled this disaseembly code!

Decompiled code

Another prompt “What is decompiled code for this main.pyc?


文章来源: https://infosecwriteups.com/understanding-python-disassembly-with-chatgpt-216e04c2e1ff?source=rss----7b722bfd1b8d---4
如有侵权请联系:admin#unsafe.sh