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.
A test repository to build a python package and publish the package to Artifact Registry using GCB

A test repository to build a python package and publish the package to Artifact Registry using GCB. Then have the package be a dependency in a GCF function.

1 Feb 09, 2022
SymbLang are my programming language! Insired by the brainf**k.

SymbLang . - output as Unicode. , - input. ; - clear data. & - character that the main line start with. @value: 0 - 9 - character that the function

1 Apr 04, 2022
A Python package to request and process seismic waveform data from Hi-net.

HinetPy is a Python package to simplify tedious data request, download and format conversion tasks related to NIED Hi-net. NIED Hi-net | Source Code |

Dongdong Tian 65 Dec 09, 2022
In this project we will implement AirBnB clone using console

AirBnB Clone In this project we will implement AirBnB clone using console. Usage The shell should work like this

Nandweza Allan 1 Feb 07, 2022
Extend the maya channel box with searchability and colour

channel-box-plus will add search-ability over its attributes, and it will colour user defined attributes, making them easier to distinguish.

Robert Joosten 12 Jun 08, 2022
An extended version of the hotkeys demo code using action classes

An extended version of the hotkeys application using action classes. In adafruit's Hotkeys code, a macro is using a series of integers, assumed to be

Neradoc 5 May 01, 2022
Launcher program to select which version of the Q-Sys software to launch.

QSC-QSYS Launcher Launcher program to select which version of the Q-Sys software to launch. Instructions To use the application simply save the "Q-Sys

Zach Lisko 2 Sep 28, 2022
All solutions for the 2021 Advent of Code event.

Advent of Code 2021 Solutions All solutions for the 2021 Advent of Code event. Setup Create a file called .session. Go to adventofcode.com and copy th

Bruce Berrios 6 Dec 26, 2021
Interfaces between napari and pymeshlab library to allow import, export and construction of surfaces.

napari-pymeshlab Interfaces between napari and the pymeshlab library to allow import, export and construction of surfaces. This is a WIP and feature r

Zach Marin 4 Oct 12, 2022
Senator Stock Trading Tester

Senator Stock Trading Tester Program to compare stock performance of Senator's transactions vs when the sale is disclosed. Using to find if tracking S

Cole Cestaro 1 Dec 07, 2021
Simple Python Gemini browser with nice formatting

gg I wasn't satisfied with any of the other available Gemini clients, so I wrote my own. Requires Python 3.9 (maybe older, I haven't checked) and opti

Sarah Taube 2 Nov 21, 2021
Projeto de análise de dados com SQL

Project-Analizyng-International-Debt-Statistics- Projeto de análise de dados com SQL - Plataforma Data Camp Descrição do Projeto : Não é que nós human

Lorrayne Silva 1 Feb 01, 2022
Battle-Ship - Python-console battle ship

Battle-Ship this SHOULD work in lenux(if i spelled it wrong spam issues till I fix it) the thing that maby wont work is where it clears the screen the

pl608 2 Jan 06, 2022
Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Salma Saidane 64 Sep 28, 2022
MuMMI Core is the underlying infrastructure and generalizable component of the MuMMI framework

MuMMI Core is the underlying infrastructure and generalizable component of the MuMMI framework, which facilitates the coordination of massively parallel multiscale simulations.

4 Aug 17, 2022
A tool to improve Boolean satisfiability (SAT) solver user's life

SatHelper This is a tool to improve the Boolean satisfiability (SAT) and MaxSAT solver user's life. It helps you model various problems as SAT and Max

Tomas Balyo 1 Nov 16, 2021
This is a simple quizz which can ask user for login/register session, then consult to the Quiz interface.

SIMPLE-QUIZ- This is a simple quizz which can ask user for login/register session, then consult to the Quiz interface. By CHAKFI Ahmed MASTER SYSTEMES

CHAKFI Ahmed 1 Jan 10, 2022
Prototype application for GCM bias-correction and downscaling

dodola Prototype application for GCM bias-correction and downscaling This is an unstable prototype. This is under heavy development. Features Nothing!

Climate Impact Lab 9 Dec 27, 2022
Tool that adds githuh profile views to ur acc

Tool that adds githuh profile views to ur acc

Lamp 2 Nov 28, 2021
Open source style Deep Dream project

DeepDream ⚠️ If you don't have a gpu with cuda, the style transfer execution time will be much longer Prerequisites Python =3.8.10 How to Install sud

Patrick martins de lima 7 May 17, 2022