#!/usr/bin/env python ''' Matthew Wollenweber mjw@cyberwart.com watchfunc just run somethign temporarily ''' DESC = "just a temporary script to do some task" USAGE = "!watchfunc 0xDEADBEEF" import immlib from immlib import LogBpHook #import time import struct import unicodedata import getopt def main(args): imm = immlib.Debugger() load_hook = MyLoadHook() addr = long(args[0], 16) load_hook.add("I'm watching you", addr, 0, 0, 0) imm.Log("watching hook set") return "Watching the function" def usage(): print USAGE if __name__=="__main__": print "This module is for use within Immunity Debugger only" class MyLoadHook(LogBpHook): def __init__(self): LogBpHook.__init__(self) self.imm = immlib.Debugger() def run(self,regs): imm = self.imm r = imm.getRegs() eax = r['EAX'] ecx = r['ECX'] esi = r['ESI'] edi = r['EDI'] esp = r['ESP'] calledfrom = imm.callStack()[0].calledfrom args =[] arg_s = "" try: for x in range(1, 16): tmp = imm.callStack()[x].procedure if tmp.find(" = ") >= 0: args.append(tmp.strip()) else: break raise Exception('secret', '42') except: for x in args: arg_s += x + " " imm.Log("[WATCHFUNC]: Called from: 0x%08x %s eax=0x%08x ecx=0x%08x esi=0x%08x edi=0x%08x esp=0x%08x" % (calledfrom, arg_s, eax, ecx, esi, edi, esp)) return