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.
An advanced pencil sketch generator

Pencilate An advanced pencil sketch generator About : An advanced pencil sketch maker made in just 12 lines of code. Yes you read it right, JUST 12 LI

MAINAK CHAUDHURI 23 Dec 17, 2022
A Python script to parse Fortinet products serial numbers, and detect the associated model and version.

ParseFortinetSerialNumber A Python script to parse Fortinet products serial numbers, and detect the associated model and version. Example $ ./ParseFor

Podalirius 10 Oct 28, 2022
List Less Than Ten with python

List Less Than Ten with python

PyLaboratory 0 Feb 07, 2022
Repository, with small useful and functional applications

Repositorio,com pequenos aplicativos uteis e funcionais A ideia e ir deselvolvendo pequenos aplicativos funcionais e adicionar a este repositorio List

GabrielDuke 6 Dec 06, 2021
Framework To Ease Operating with Quantum Computers

QType Framework To Ease Operating with Quantum Computers Concept # define an array of 15 cubits:

Antonio Párraga Navarro 2 Jun 06, 2022
OB_Template is a vault template reference for using Obsidian.

Obsidian Template OB_Template is a vault template reference for using Obsidian. If you've tested out Obsidian. and worked through the "Obsidian Help"

323 Dec 27, 2022
Bots in moderation and a game (for now)

Tutorial: come far funzionare il bot e durarlo per 24/7 (o quasi...) Ci sono 17 passi per seguire: Andare sul sito Replit https://replit.com/ Vedrete

ZacyKing 1 Dec 27, 2021
Kunai Shitty Raider Leaked LMFAO

Kunai-Raider-Leaked Kunai Shitty Raider Leaked LMFA

5 Nov 24, 2021
Blender addon that simplifies access to useful operators and adds missing functionality

Quick Menu is a Blender addon that simplifies common tasks Compatible with Blender 3.x.x Install through Edit - Preferences - Addons - Install... -

passivestar 94 Dec 27, 2022
HairCLIP: Design Your Hair by Text and Reference Image

Overview This repository hosts the official PyTorch implementation of the paper: "HairCLIP: Design Your Hair by Text and Reference Image". Our single

322 Dec 30, 2022
A system for assigning and grading notebooks

nbgrader Linux: Windows: Forum: Coverage: Cite: A system for assigning and grading Jupyter notebooks. Documentation can be found on Read the Docs. Hig

Project Jupyter 1.2k Dec 26, 2022
Domoticz-hyundai-kia - Domoticz Hyundai-Kia plugin for Domoticz home automation system

Domoticz Hyundai-Kia plugin Author: Creasol https://www.creasol.it/domotics For

Creasol 7 Aug 03, 2022
python's memory-saving dictionary data structure

ConstDict python代替的Dict数据结构 若字典不会增加字段,只读/原字段修改 使用ConstDict可节省内存 Dict()内存主要消耗的地方: 1、Dict扩容机制,预留内存空间 2、Dict也是一个对象,内部会动态维护__dict__,增加slot类属性可以节省内容 节省内存大小

Grenter 1 Nov 03, 2021
A web application (with multiple API project options) that uses MariaDB HTAP!

Bookings Bookings is a web application that, backed by the power of the MariaDB Connectors and the MariaDB X4 Platform, unleashes the power of smart t

MariaDB Corporation 4 Dec 28, 2022
Program Input Nilai Mahasiswa Menggunakan Fungsi

PROGRAM INPUT NILAI MAHASISWA MENGGUNAKAN FUNGSI Nama : Maulana Reza Badrudin Nim : 312110510 Matkul : Bahas Pemograman DESKRIPSI Deklarasi dicti

Maulana Reza Badrudin 1 Jan 05, 2022
A Python 3 client for the beanstalkd work queue

Greenstalk Greenstalk is a small and unopinionated Python client library for communicating with the beanstalkd work queue. The API provided mostly map

Justin Mayhew 67 Dec 08, 2022
Tools to convert SQLAlchemy models to Pydantic models

Pydantic-SQLAlchemy Tools to generate Pydantic models from SQLAlchemy models. Still experimental. How to use Quick example: from typing import List f

Sebastián Ramírez 893 Dec 29, 2022
The learning agent learns firstly approaching to the football and then kicking the football to the target position

Football Court This project utilized Pytorch and Tensorflow so that the learning agent learns firstly approaching to the football and then kicking the

1 Nov 19, 2021
This is where I learn machine learning

This is where I learn machine learning🤷‍ This means that this repo covers no specific topic of machine learning or a project - I work in here when I want to learn/try something

Wilhelm Berghammer 47 Nov 16, 2022
tidevice can be used to communicate with iPhone device

h 该工具能够用于与iOS设备进行通信, 提供以下功能 截图 获取手机信息 ipa包的安装和卸载 根据bundleID 启动和停止应用 列出安装应用信息 模拟Xcode运行XCTest,常用的如启动WebDriverAgent测试

Alibaba 1.8k Dec 30, 2022