Skip to main content

Utilities to work with bytecode.

Project description

Bytecomp v1.1.0

Utilities for working with bytecode.

Magic:

import bytecomp

bytecomp.MAGIC # Returns Magic

PYC Headers:

import bytecomp

bytecomp.HEADER # Returns .pyc Header
bytecomp.generate_header() # Also returns a .pyc header

Compiling Bytecode:

import bytecomp

code_object = compile("""print('Hello!')""",'file','exec')
pyc = open('compiled.pyc','wb')
pyc.write(bytecomp.compile_object(code_object))
pyc.close()

# Above code generates a working .pyc file from a code object.

Executing Bytecode:

import bytecomp

code_object = b'U\r\r\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00@\x00\x00\x00s\x0c\x00\x00\x00e\x00d\x00\x83\x01\x01\x00d\x01S\x00)\x02z\x03Hi!N)\x01\xda\x05print\xa9\x00r\x01\x00\x00\x00r\x01\x00\x00\x00\xda\x03idk\xda\x08<module>\x01\x00\x00\x00\xf3\x00\x00\x00\x00'
bytecomp.exec_bytecode(code_object)

# Above code executes the bytes-like object (Can have a header or not have a header)

Removing a header from Bytecode:

import bytecomp

bytecomp.remove_header(b'U\r\r\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00@\x00\x00\x00s\x0c\x00\x00\x00e\x00d\x00\x83\x01\x01\x00d\x01S\x00)\x02z\x03Hi!N)\x01\xda\x05print\xa9\x00r\x01\x00\x00\x00r\x01\x00\x00\x00\xda\x03idk\xda\x08<module>\x01\x00\x00\x00\xf3\x00\x00\x00\x00')

# Above code removes the header (First 16 bytes) so you can unmarshal it and execute it

Encrypting Bytecode:

import bytecomp

code_object = compile("print('This is a test.')",'file','exec')
crypted = bytecomp.crypt_bytecode(code_object)

# Above code returns a string, which can be executed with the code below.

Executing Encrypted Bytecode:

import bytecomp
bytecomp.exec_crypted('c%0*YdNS#d&&L@bBZH4CS3P4z1MEQT3dCicKq7%Pk+qG5g*A~Sj8%udo+~gnr%V-yQdA2Q$_ll;by)5*l$PgY7p`F~2WbQo_ZgFOG869eT4rP=7Gx$^vjD}ufs6(KfJq*%')

# Above code executes the encrypted code we made earlier.

Bytecomp is created by DeKrypt.
Support the project! Leave a star.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bytecomp-1.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

bytecomp-1.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file bytecomp-1.1.0.tar.gz.

File metadata

  • Download URL: bytecomp-1.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for bytecomp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f8c75a515297da12b9c89b93ec15406d7d00a98b711a0bf9ae599c75ded1cb03
MD5 8f4cafaf17f1eb830d04d1d49918afa0
BLAKE2b-256 7d7f56eff900f81457c7056b8eb6286b118df10436b106701272b4fb994bf2b4

See more details on using hashes here.

File details

Details for the file bytecomp-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bytecomp-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for bytecomp-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38506e26023e66276ab4e2c89bfa4fc9b7870c5caf28d961710f30c8dc917745
MD5 5ea2082316c8b7e8a82bb6454a6fa3a2
BLAKE2b-256 1a49336b0cd75367d1955128e5d305caa004873a1734e8bb891ab173dce54e72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page