mgostih

PyHack [WIP]

Mar 27th, 2016
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. from ctypes import *
  2. from time import sleep
  3. def GetHandle(windowname):
  4.     hwnd = windll.user32.FindWindowA(0,windowname.encode())
  5.     while (not hwnd):
  6.         hwnd = windll.user32.FindWindowA(0,windowname.encode())
  7.         sleep(0.25)
  8.     pId = c_uint32()
  9.     windll.user32.GetWindowThreadProcessId(hwnd,byref(pId))
  10.     return windll.kernel32.OpenProcess(0x0010 | 0x0020 | 0x0008 | 0x0400, 0, pId.value)
  11. def WriteMem(handle,address,ptr,size):
  12.     old = c_uint32()
  13.     old2 = c_uint32()
  14.     windll.kernel32.VirtualProtectEx(handle,address,size,0x40,byref(old))
  15.     windll.kernel32.WriteProcessMemory(handle,address,ptr,size,0)
  16.     windll.kernel32.VirtualProtectEx(handle,address,size,old,byref(old2))
  17.     #Usage: WriteMem(handle,0x00400000,byref(cvartype),size)
  18. def ReadDW(handle,address):
  19.     value = c_uint32()
  20.     old = c_uint32()
  21.     old2 = c_uint32()
  22.     windll.kernel32.VirtualProtectEx(handle,address,4,0x40,byref(old))
  23.     windll.kernel32.ReadProcessMemory(handle,address,byref(value),4,0)
  24.     windll.kernel32.VirtualProtectEx(handle,address,4,old,byref(old2))
  25.     return value.value
  26. def LoadLibrary(library):
  27.     return windll.kernel32.LoadLibraryA(library.encode())
  28. def GetProcAddress(module,function):
  29.     handle = windll.kernel32.GetModuleHandleA(module.encode())
  30.     return windll.kernel32.GetProcAddress(handle,function.encode())
  31. def Alloc(handle,size):
  32.     return windll.kernel32.VirtualAllocEx(handle,0,size,0x1000|0x2000,0x40)
  33. def GetDword():
  34.     try:
  35.         value = int(input("Please enter a valid number: "))
  36.     except:
  37.         print("The input is not a number")
  38.         return GetDword()
  39.     if value>(2**32 - 1):
  40.         print("Value too big, max is 4294967295")
  41.         return GetDword()
  42.     if value < 0:
  43.         print("Value too low, min is 0")
  44.         return GetDword()
  45.     value = c_uint32(value)
  46.     return value
Add Comment
Please, Sign In to add comment