Giter Site home page Giter Site logo

hacky's Introduction

HACKY

Python hacking suite.

INSTALLATION

Tested on CPython 3.4

python setup.py install (preferred)

or

pip install hacky

EXAMPLES

  • Class transplantation:
>>> import hacky
>>> hacky.set_class(100, type('MyInt', (int,), {'__repr__': lambda self: "hello from hacky"}))
hello from hacky
>>> 100
hello from hacky
>>> 
  • Messing around with tp_flags:
>>> from types import FunctionType
>>> import hacky
>>> hacky.set_flags(
        FunctionType,
        hacky.get_flags(FunctionType) | (1 << 10)
    )
<class 'function'>
# you can now subclass function type
>>> class T(FunctionType): pass
>>>
  • Make your class final:
>>> hacky.set_flags(int, hacky.get_flags(int) ^ (1 << 10))
<class 'int'>
>>> class T(int): pass
TypeError: type 'int' is not an acceptable base type
  • Read process's memory. Lets examine memory around int object 100.
>>> [hacky.read_memory_in(id(100)+shift) for shift in range(20)]
[7, 0, 0, 0, 0, 0, 0, 0, 192, 228, 158, 0, 0, 0, 0, 0, 1, 0, 0, 0]
>>> import struct
>>> [int(item) for item in struct.pack('<I', id(int))]
[192, 228, 158, 0]

There are 7 links on this instance and also we get correct address of type int located in memory.

  • Modify process's memory:
>>> hacky.write_memory_in(id(100)+24, 200)
>>> 100
200
  • Inject attr at type`s dictionary
>>> object_dict = hacky.fetch_dict(object)
>>> object_dict["foo"] = "hello world"
>>> (100).foo
'hello world'
>>> "hello world".foo
'hello world'
>>> (lambda x: x).foo
'hello world'
  • More stuff soon.

hacky's People

Contributors

magniff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hacky's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.