Advertisement
Anaryl

my_debugger.py

Sep 26th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. ###My Debugger my_debugger.py
  2. ###Anaryl
  3. from ctypes import *
  4. from my_debugger_defines import *
  5.  
  6. kernel32 = windll.kernel32
  7.  
  8. class debugger():
  9.     def __init__(self):
  10.         pass
  11.        
  12.     def load(self,path_to_exe):
  13.    
  14.         # dwCreation flag determines how to create the process
  15.         # set creation_flags = CREATE_NEW_CONSOLE if you want
  16.         # to see the calculator GUI
  17.         creation_flags = DEBUG_PROCESS
  18.         # instantiate the structs
  19.         startupinfo = STARTUPINFO()
  20.         process_information = PROCESS_INFORMATION()
  21.         # The following two options allow the started process
  22.         # to be shown as a separate window. This also illustrates
  23.         # how different settings in the STARTUPINFO struct can affect
  24.         # the debuggee.
  25.         startupinfo.dwFlags = 0x1
  26.         startupinfo.wShowWindow = 0x0
  27.         # We then initialize the cb variable in the STARTUPINFO struct
  28.         # which is just the size of the struct itself
  29.         startupinfo.cb = sizeof(startupinfo)
  30.        
  31.         if kernel32.CreateProcessA(path_to_exe,
  32.             None,
  33.             None,
  34.             None,
  35.             None,
  36.             creation_flags,
  37.             None,
  38.             None,
  39.             byref(startupinfo),
  40.             byref(process_information)):
  41.            
  42.                         print "[*] We have successfully launched the process!"
  43.                         print "[*] PID: %d" % process_information.dwProcessId
  44.         else:
  45.                 print "[*] Error: 0x%08x." % kernel32.GetLastError()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement