Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
import os import struct import re import mmap import gdb NULL = 0 pass # True on Linux and Mac OS X RTLD_LAZY = 1 RTLD_NOW = 2 _DLOPEN_FORMAT = '((void *(*)())dlopen)((char *)%s, (int)%d)' _DLSYM_FORMAT = '((void *(*)())dlsym)((void *)0x%x, (char *)%s)' _DLCLOSE_FORMAT = '((int (*)())dlclose)((void *)0x%x)' self.handle = None if flags is None: flags = self.RTLD_LAZY if path != NULL: if : path = path = '"%s"' % (path,) expr = self._DLOPEN_FORMAT % (, ) handle = if not handle: raise self.handle = handle symbol = '"%s"' % (symbol,) expr = self._DLSYM_FORMAT % (, symbol) result = if not result: raise return result msg = if not msg: return None return """Redirect all invocations of one function to another.""" _ADDR_RE = _MMAP_FORMAT = '((void *(*)())mmap)((void *)0x%x, (size_t)0x%x, ' \ '(int)%d, (int)%d, (int)%d, ' \ '(off_t)0x%x)' _JMP_INSN = _REL_INSNS = _ADDR_MAX = . format = "@Q" if self._width == 8 else "@I" daddr = return % (daddr,) expr = self._MMAP_FORMAT % (addr, length, prot, flags, fd, offset) result = if not result: raise return result saddr, taddr = saddr + aoff, taddr + aoff reloff, = daddr = (saddr + reloff) & reloff = (daddr - taddr) & 0xffffffff reloff = = reloff for offset in offsets: for insn in : aoff = offset + if == insn: saddr = endjmp = saddr + nbytes expr = 'x/%di 0x%x' % (nbytes, ) disass = nexti = None offsets = for line in : match = if match is None: continue addr = if addr >= endjmp: nexti = addr break else: raise nbytes = nexti - saddr bytes = prot = mmap.PROT_EXEC | mmap.PROT_READ | mmap.PROT_WRITE flags = mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS taddr = bytes += return taddr inferior = bytes = if taddrp: tramp = expr = "set *(void **)0x%x = (void *)0x%x" % (taddrp, tramp) if ':' in arg: path, symbol = else: path, symbol = NULL, arg return . args = if == 2: src, dst = args tramp = None elif == 3: src, dst, tramp = args else: raise self._width = saddr = daddr = taddrp = if tramp else None try: return except (Error,), e: print "error: %s" % (,) |