Guest User

Untitled

a guest
Mar 1st, 2020
290
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import binascii,struct
  2.  
  3. class tools:
  4.     def __init__(self, processid): #Default class params
  5.         self.processid = processid
  6.    
  7.     def find_target_range(self):
  8.         target = int("5afe708",16)
  9.         maps_file = open("/proc/{}/maps".format(self.processid), 'r')
  10.        
  11.         for line in maps_file.readlines():  # for each mapped region                            
  12.                 splitter = line.split(" ") #Split the line into spaces
  13.                 region_low = int(splitter[0].split("-")[0],16) #region low of chunk
  14.                 region_high =  int(splitter[0].split("-")[1],16) #region high of chunk
  15.                
  16.                 if target > region_low:
  17.                       if target < region_high:
  18.                                 returndata = {"region_low" : region_low,
  19.                                                 "region_high" : region_high}
  20.                                 return(returndata)
  21.  
  22.     def find_mana_address(self,heapdata):
  23.         print("Scanning memory , this could take a few seconds....")
  24.         mem_file = open("/proc/{}/mem".format(self.processid), 'rb')
  25.  
  26.         region_low=heapdata["region_low"]
  27.         region_high=heapdata["region_high"]
  28.         mem_file.seek(region_low) #Goto the start address of our heap
  29.         memoryposition = region_low #Just a buffer so we know what address we are at currently
  30.  
  31.  
  32.         while memoryposition<region_high: #Stop searching when we exit end of heap
  33.             memoryposition = memoryposition +8
  34.             chunks=""
  35.             count = 0
  36.             while count<8: #Read every 8 bytes and stick them into a string
  37.                 count=count+1
  38.                 chunk = binascii.hexlify(mem_file.read(1))
  39.                 chunks = chunks + str(chunk)
  40.                 shifted_bytes = chunks.upper()
  41.             if shifted_bytes == "F0AA780100000000":
  42.                 print("Signature found at - " + str(memoryposition))
  43.                              
  44.                 int_memory_address = (memoryposition+120)
  45.                 print("Memory address is - " + str(int_memory_address))  
  46.                 return int_memory_address
  47.  
  48.  
  49.     def read_address(self,address,size):
  50.  
  51.         mem_file = open("/proc/{}/mem".format(self.processid), 'rb')
  52.         mem_file.seek(address)  # seek to region start
  53.         count = 0
  54.         chunks = ""
  55.         while count<size:
  56.             count=count+1
  57.             chunk = binascii.hexlify(mem_file.read(1))
  58.             chunks = chunks + str(chunk)
  59.         shifted_bytes = ("".join(map(str.__add__, chunks[-2::-2] ,chunks[-1::-2]))) #Split each byte and then reverse its order (but dont reverse the actual byte)
  60.         value = (int(shifted_bytes,16))
  61.  
  62.         return value
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.     def ManaLoop(self,mana_memory_address):
  70.         #This will just loop reading our mana amount and print whenever it changes. We could add sendhotkey here if mana is below X value ect to make
  71.         #A safe cheat tool this should be on a thread really but its just a e.g:
  72.         lastmana_value = 0 #Just a buffer
  73.  
  74.        
  75.         while 1==1: #Loop forever
  76.             mana_amount = self.read_address(mana_memory_address,4)
  77.             if not lastmana_value == mana_amount:
  78.                 print("Mana Changed To :" + str(mana_amount))
  79.                 lastmana_value= mana_amount
  80. if __name__ == "__main__":
  81.     #This is only true if this python file is ran directly
  82.     test_process_id = 14982 #We can just get this from system monitor
  83.     testhandler = tools(test_process_id)
  84.     heapdata = (testhandler.find_target_range())
  85.  
  86.     mana_memory_address = testhandler.find_mana_address(heapdata)
  87.     testhandler.ManaLoop(mana_memory_address)
RAW Paste Data