py2dis - A disassembly engine & library for Python

Related tags

Miscellaneouspy2dis
Overview


py2dis - A disassembly engine & library for Python.

py2dis is a disassembly library for Python that does not use any modules/libraries other than colorama, comes with a miniature built-in disassembler engine, and features to assist in disassembling classes, functions, raw bytecode, source code strings, and more!

Version

Features

  • Opcode lookups
  • Dumping bytecode
  • Instruction lookups
  • Disassembling Classes
  • Disassembling Functions
  • Disassembling raw bytecode (passed to function)
  • Disassembling source code strings (passed to function)

Disassembling Classes

from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


class Target:
  def __init__(self: None, message: str) -> None:
    self.message = message

  def function(self: None) -> None:
    print(self.message)

class Example:
  def __init__(self: None, Class: None) -> None:
    self.Class = Class

  def execute(self: None) -> None:
    py2dis.disassemble_class(self.Class)

if __name__ == "__main__":
  Example(Target).execute()

Disassembling Functions

None: self.function = function def execute(self: None) -> None: py2dis.disassemble_function(self.function) if __name__ == "__main__": Example(LoginSystem).execute() ">
from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


def LoginSystem() -> bool:
  if input("Enter the secret code: ") == "1337":
    print("You have successfully authenticated!")
    return True
  return False

class Example:
  def __init__(self: None, function: None) -> None:
    self.function = function

  def execute(self: None) -> None:
    py2dis.disassemble_function(self.function)

if __name__ == "__main__":
  Example(LoginSystem).execute()	

Disassembling Raw Bytecode

from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


class Example:
  def __init__(self: None, bytecode: bytes) -> None:
    self.bytecode = bytecode

  def execute(self: None) -> None:
    py2dis.disassemble_bytecode(self.bytecode)

if __name__ == "__main__":
  Example(b"t\x00d\x01\x83\x01\x01\x00d\x00S\x00").execute()

Disassembling Source Code Strings

from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


class Example:
  def __init__(self: None, code: str) -> None:
    self.code = code

  def execute(self: None) -> None:
    py2dis.disassemble_source_code(self.code)

if __name__ == "__main__":
  Example("print('Hello, World!')").execute()

Looking up Opcodes

from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


class Example:
  def __init__(self: None, opcode: int) -> None:
    self.opcode = opcode

  def execute(self: None) -> None:
    return py2dis.opcode_lookup(self.opcode)

if __name__ == "__main__":
  print(Example(123).execute())

Looking up Instructions

from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


class Example:
  def __init__(self: None, instruction: str) -> None:
    self.instruction = instruction

  def execute(self: None) -> None:
    return py2dis.instruction_lookup(self.instruction)

if __name__ == "__main__":
  print(Example("SEND").execute())

Exporting Bytecode from a Function

None: self.function = function def execute(self: None) -> None: return py2dis.export_raw_bytecode(self.function) if __name__ == "__main__": print(Example(LoginSystem).execute())">
from lib.py2dis import *


# example.py
# Date: 01/09/22
# Author: 0x80000000


def LoginSystem() -> bool:
  if input("Enter the secret code: ") == "1337":
    print("You have successfully authenticated!")
    return True
  return False

class Example:
  def __init__(self: None, function: None) -> None:
    self.function = function

  def execute(self: None) -> None:
    return py2dis.export_raw_bytecode(self.function)

if __name__ == "__main__":
  print(Example(LoginSystem).execute())

Requirements

pip3 install colorama	

Screenshots

image image

Credits

https://github.com/0x80000000

Contributions 🎉

All contributions are accepted, simply open an Issue / Pull request.
High-level bindings to the Valhalla framework.

Valhalla for Python This spin-off project simply offers improved Python bindings to the fantastic Valhalla project. Installation pip install valhalla

GIS • OPS 20 Dec 13, 2022
A simple method to create strong password.

A simple method to create strong password.

1 Jan 23, 2022
Running a complete single-node all-in-one cluster instance of TIBCO ActiveMatrixâ„¢ BusinessWorks 6.8.0.

TIBCO ActiveMatrixâ„¢ BusinessWorks 6.8 Docker Image Image for running a complete single-node all-in-one cluster instance of TIBCO ActiveMatrixâ„¢ Busines

Federico Alpi 1 Dec 10, 2021
This app is to use algorithms to find the root of the equation

In this repository, I made an amazing app with tkinter python language and other libraries the idea of this app is to use algorithms to find the root of the equation I used three methods from numeric

Mohammad Al Jadallah 3 Sep 16, 2022
COVID-19 case tracker in Dash

covid_dashy_personal This is a personal project to build a simple COVID-19 tracker for Australia with Dash. Key functions of this dashy will be to Dis

Jansen Zhang 1 Nov 30, 2021
Dashboard to view a stock's basic information, RSI, Bollinger bands, EMA, SMA, sentiment analysis via Python

Your One And Only Trading Bot No seriously, we mean it! Contributors Jihad Al-Hussain John Gaffney Shanel Kuchera Kazuki Takehashi Patrick Thornquist

5 May 21, 2022
An end-to-end encrypted chat

An end-to-end encrypted chat, that allows users to anonymously talk without ip logs, personal info, or need for registration.

Privalise 1 Nov 27, 2021
Dockernized ZeroTierOne controller with zero-ui web interface.

docker-zerotier-controller Dockernized ZeroTierOne controller with zero-ui web interface. 中文讨论 Customize ZeroTierOne's controller planets Modify patch

sbilly 209 Jan 04, 2023
The official FOSSCOMM 2021 CTF by [email protected]

FOSSCOMM 2021 CTF Table of Contents General Info FAQ General Info Purpose: This CTF is a collaboration between the FOSSCOMM conference and the Machina 2 Nov 14, 2021

Lightweight and Modern kernel for VK Bots

This is the kernel for creating VK Bots written in Python 3.9

Yrvijo 4 Nov 21, 2021
XHacks 2021 Startup Track Winner: Be Heard. Educate, Enact, Empower. No voice left behind. (backend)

Be Heard: X Hacks 2021 Submission Educate, Enact, Empower. No voice left behind. Inspiration To say 2020 was an eventful year would be an understateme

3 Jul 14, 2022
Python wrapper around Apple App Store Api

App Store Connect Api This is a Python wrapper around the Apple App Store Api : https://developer.apple.com/documentation/appstoreconnectapi So far, i

123 Jan 06, 2023
A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.

deep-translator Translation for humans A flexible FREE and UNLIMITED tool to translate between different languages in a simple way using multiple tran

Nidhal Baccouri 806 Jan 04, 2023
ARA Records Ansible and makes it easier to understand and troubleshoot.

ARA Records Ansible ARA Records Ansible and makes it easier to understand and troubleshoot. It's another recursive acronym. What it does Simple to ins

Community managed Ansible repositories 1.6k Dec 25, 2022
Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication

Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication (among and within files, including virtual machine images). Current release is

bup 6.9k Dec 27, 2022
Python package for handling and analyzing PSRFITS files

PyPulse A pure-Python package for handling and analyzing PSRFITS files. Read the documentation here. This is an alternate code base from PSRCHIVE. Req

Michael Lam 15 Nov 30, 2022
Cardano SundaeSwap ISO SPO vote ranking script

Cardano SundaeSwap ISO SPOs vote ranking This Python 3 script uses the database populated by cardano-db-sync from the Cardano blockchain to generate a

SM₳UG 1 Nov 17, 2021
Desafio Final do Mod1 do Bootcamp EDC - v2 usando a RAIS

IGTI - Bootcamp Engenheiro de Dados Cloud Módulo 1 - Desafio Final - RAIS 2020 Código do Desafio Final V2 do Bootcamp Engenheiro de Dados Cloud do IGT

Neylson Crepalde 17 Nov 02, 2022
A python library with various gambling and gaming classes

gamble is a simple library that implements a collection of some common gambling-related classes Features die, dice, d-notation cards, decks, hands pok

Jacobi Petrucciani 16 May 24, 2022
Hartree-Fock Workshop for the Han-sur-Lesse Winterschool of 2021

Hartree-Fock course for the Han-sur-Lesse Winterschool of 2021 Requirements For going through these exercises, please install the Anaconda suite. Next

Ivo Filot 2 Nov 16, 2022