Jump to content
vatman32

[Python] ReadProcessMemory() OFFSET POINTER

Recommended Posts

  • Active Members
Posted (edited)

Neata.

 

address = 0x0018FB54
address = address + 0x14
address = address + 0x0
address = address + 0x7

ReadProcessMemory(processHandle, address, buffer, bufferSize, byref(bytesRead))

 

Se rupe filmul la acel "0x0" , prin urmare nu reusesc sa completez pointerul. Am luat la puricat documentatia python cat mi-a permis experienta pana in prezent, am rupt stackoverflow, am cautat si pe rst si nu gasesc un exemplu viabil sa accesez un amarat de pointer.

 

Am invartit variabila aia de am innebunit, de ieri ma chinui intruna. Am luat cateva snipetturi de cod C++ si le-am transcris in python insa nu faceau obiectul problemei prezentate mai sus, ci ma aducea intr-un punct in care am mai fost, sa inaintez cu 2-3 offset-uri asta daca vreun offset nu echivala cu decimal mai mare de 99 (de ex am avut offset +444 (1BCh) si iar s-a rupt filmul ca la 0x0, nu schimba cu nimic rezultatul final oricate offset-uri ii mai adaugam dupa acel +444.

 

Provocarea principala este ca vreau sa pot manevra un proces la fel de usor si rapid prin cod Python nu C++ (am fix pe creier) si inafara de impedimente de astea stupide nu am avut nici o dilema pana in prezent care sa ma retina mai mult de 6-7 ore pana sa gasesc o rezolvare.

 

Sistem de operare: Windows 7 x64

Aplicatiile pe care exersez: x32

 

Multumesc anticipat.

Edited by vatman32
uitat paranteza
  • Active Members
Posted (edited)
36 minutes ago, gear said:

Ai omis o paranteză

 

 

Multumesc de atentionare, am copiat linia dintr-un cod principal la care lucrez si probabil am omis, insa nu e motivul pentru care nu reusesec sa formez acel pointer.

Edited by vatman32
am scris ca un bou in graba, imi place sa editez posturi pe care la postez acum 5 secunde :-|
  • Active Members
Posted (edited)

Am inteles asa partial ce vrei. Uite un exemplu care functioneaza:

 

from ctypes import *

PROCESS_ALL_ACCESS = 0x1F0FFF
ADDRESS = 0x1000000  # Iau headerul de la .exe
PID = 3648           # In cazul meu e Process ID de la PyCharm

open_process = windll.kernel32.OpenProcess
read_process_memory = windll.kernel32.ReadProcessMemory
close_handle = windll.kernel32.CloseHandle


buff = c_char_p('aici ceva string pointer')
buff_size = len(buff.value)
bytes_read = c_ulong(0)

process_handle = open_process(PROCESS_ALL_ACCESS, False, PID)
if read_process_memory(process_handle, ADDRESS, buff, buff_size, byref(bytes_read)):
    print("Success: {}".format(buff))
else:
    print("Failed.")

close_handle(process_handle)

BTW, `address = address + 0x14` nu cred ca face ceea ce te astepti tu sa faca :) 

 

Uite, un exemplu de pointer catre un chunk de memorie:

 

>>> import ctypes
>>> x = (ctypes.c_ulong*5)()
>>> x
<__main__.c_ulong_Array_5 object at 0x00C2DB20>
>>> ctypes.cast(x, ctypes.POINTER(ctypes.c_ulong))
<__main__.LP_c_ulong object at 0x0119FD00>
>>> 

 

Ai un exemplu pe git cu mai multe functionalitati:

 

https://github.com/thezdi/scripts/blob/master/python_injector.py

 

Sper sa te ajute.

Edited by MrGrj
  • Upvote 5

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...