Skip to content

Instantly share code, notes, and snippets.

@diorcety
diorcety / thiscall.py
Created August 19, 2024 12:38 — forked from ess7/thiscall.py
Calling a thiscall DLL function in Python ctypes (x86)
import ctypes
def _thiscallcode(address):
buf = ctypes.windll.kernel32.VirtualAlloc(0, 4096, 0x3000, 0x40)
# Stack: ret addr, this, arg1, arg2, ...
# [esp] [esp+4] ...
code = b""
# code += b"\xcc"
code += b"\x8b\x4c\x24\x04" # mov ecx, dword ptr [esp+4]
code += b"\x8F\x04\x24" # pop dword ptr [esp+0]
@diorcety
diorcety / gist:c0655671889013035d4f1f14707603f3
Created July 21, 2023 10:56 — forked from antonpiatek/gist:c74991f7ec54126fc91dd66a290d7520
A jenkins script to clean up workspaces on slaves
// find old workspace folders on any node (master/slave)
// currently only look for deleted branches of multibranch (pipeline?) jobs, and remove them
// also finds builds older than 90 days. Set flags below to true to actually do deletes
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;