Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Python Hooking - Write Less Do More

Featured Replies

Posted

Sometimes, you need to manipulate low-level functionality (C APIs, etc) from high-level languages (Python).
Eg. Force the low-level side calls directly to your own Python override functions. This repo will help you do that.

[x] Windows
[x] Linux
[x] MacOS
[x] iOS
[x] Android

To hook & unhook a function, you only need to write codes as the following

import ctypes
from PyHooking import PyHooking, load_external_shared_library, arch, bits

# define the hook function

mylib = load_external_shared_library(f"Examples/mylib_{arch}_{bits}")

@PyHooking.CPrototype(ctypes.CFUNCTYPE(None, ctypes.c_char_p))
def hk_print_message(message):
    message = f"Invoked `hk_print_message('{message.decode('utf-8')}')`"
    PyHooking().invoke(mylib.print_message, message.encode())

# perform hooking

PyHooking().hook(mylib.print_message, hk_print_message)

mylib.print_message(b"This is a string from Python code")
mylib.c_invoke_print_message()

# perform unhooking

PyHooking().unhook(mylib.print_message)

mylib.print_message(b"This is a string from Python code")
mylib.c_invoke_print_message()

# result

'''
Invoked `hk_print_message('This is a string from Python code')`
Invoked `hk_print_message('This is a string from C code')`
This is a string from Python code
This is a string from C code
'''

The repository @ https://github.com/vic4key/py-hooking.git

Follow me on GitHub @ https://github.com/vic4key

Regards,
Vic P.

Edited by Vic
minor changes

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.