Another process's memory access and modulation on Windows (like Cheat Engine)
###์ฌ์ฉ ๋ชจ๋
-
sys :
-
sys - platform : ํ๋ซํผ ์๋ณ ๊ฐ์ ๋ฐํ
-
sys - maxsize : Integer ์ต๋ ๊ฐ ๋ฐํ
-
sys - exit : ํ๋ก์ธ์ค ์ข ๋ฃ
-
ctype :
-
ctypes - windll : ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ก๋ (stdcall)
-
ctypes - wintypes : ์๋์ฐ ์ ์ฉ ๋ฐ์ดํฐ ํ์ ์ฌ์ฉ (ex. HWND, WPARAM, or DWORD)
-
ctypes - POINTER : ํฌ์ธํฐ
-
ctypes - Structure : ๊ตฌ์กฐ์ฒด
-
ctypes - Union : ๊ณต์ฉ์ฒด
-
ctypes - addressof : integer ๊ฐ์ผ๋ก ์ฃผ์ ๊ฐ์ ๋ฐํ
-
ctypes - byref :
-
ctypes - cast :
-
ctypes - create_unicode_buffer :
-
ctypes - create_string_buffer :
-
ctypes - c_bool : _Bool / bool(1) (C Type / Python Type)
-
ctypes - c_char : char /
-
ctypes - c_ubyte : unsigned char /
-
ctypes - c_byte : char /
-
ctypes - c_short : short / int
-
ctypes - c_int : int / int
-
ctypes - c_uint16 : unsigned short / int
-
ctypes - c_uint32 : unsigned long /
-
ctypes - c_uint64 :
-
ctypes - c_long : long /
-
ctypes - c_longlong : __int64 or long long /
-
ctypes - c_ulong : unsigned long /
-
ctypes - c_ulonglong : unsigned long long / int
-
ctypes - c_ushort : unsigned short / int
-
ctypes - c_void_p : void * /
-
ctypes - c_char_p : char * /
-
ctypes - c_wchar_p : wchar_t * /
-
ctypes - c_size_t : size_t
-
ctypes - sizeof : ๋ฉ๋ชจ๋ฆฌ ๋ฒํผ์ ํฌ๊ธฐ๋ฅผ ๋ฐ์ดํธ ํฌ๊ธฐ๋ก ๋ฐํ0
-
ctypes - c_ARRAY(ARRAY as c_ARRAY) : ๋ฐฐ์ด
-
ctypes - WinError : ์๋์ฐ ์๋ฌ ์ฒ๋ฆฌ
-
struct : ํ์ด์ฌ ๋ฌธ์์ด์ C ๊ตฌ์กฐ์ฒด๋ก์ ๋ณํ์ ์ ๊ณต
-
time : ์๊ฐ ๋ชจ๋
-
inspect : ๋ฐํ์ Objectdml ์ ๋ณด๋ฅผ ์ป์ ์ ์๊ฒ ๋์์ฃผ๋ ๋ชจ๋(Modules, classes, methods, functions..)
-
logging : ๋ก๊ทธ ์ฒ๋ฆฌ๋ฅผ ์ํ ๋ชจ๋
-
os : ์ด์์ฒด์ ์์ ์ ๊ณตํ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ๋ชจ๋
-
threading : ์ค๋ ๋ ํ๋ก๊ทธ๋๋ฐ ๋ชจ๋
-
binascii : ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ์ ASCII ๋ฐ์ดํฐ์ ์ํธ๋ณํ์ ์ ๊ณตํ๋ ๋ชจ๋
-
re : ์ ๊ทํํ์ ๋ชจ๋
###์ธ๋ถ ๊ตฌ์กฐ
-
engine.common.process
- def - type_unpack : ์๋ฃํ ํ์ธ ํ, ์๋ฃํ ํค์๋์ ๋นํธ ์๋ฅผ ๋ฐํ
- class - process :
- def - PELoad :
- def - write_byte : VirtualProtectEx์ PAGE_EXECUTE_READWRITE ์์ฑ์ ์ด์ฉํ์ฌ ์ฝ๊ณ ์ธ ์ ์๊ฒ ๋ฉ๋ชจ๋ฆฌ ๋ณดํธ ์ํ๋ฅผ ๋ณ๊ฒฝํ ํ ๋ฉ๋ชจ๋ฆฌ์ ๋ฌธ์์ด ๊ฐ์ ๊ธฐ๋ก. OldProtect ์์ฑ์ ์ด์ฉํ์ฌ ์๋ ์ํ๋ก ๋ณ๊ฒฝ. ์ฝ์ด์จ ๋ฉ๋ชจ๋ฆฌ ๊ฐ ๋ฐํ
- def - write_binary : c_type์ create_string_buffer ํจ์๋ฅผ ์ด์ฉํ์ฌ ๊ธฐ๋กํ ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ ๋ด์ ํ VirtualProtectEx๋ก ๋ฉ๋ชจ๋ฆฌ ์ฃผ์ ์ง์ ํ์ฌ WriteProcessMemory ํจ์๋ก ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ ๊ธฐ๋ก.
- def - read_byte : create_string_buffer ํจ์๋ฅผ ์ด์ฉํ์ฌ ์ฝ์ ๊ธธ์ด(๊ธฐ๋ณธ ๊ฐ 4) ์ง์ ํ while๋ฌธ์ ์ด์ฉํ์ฌ ReadProcessMemory ํจ์๋ก ๋ฐ์ดํฐ ์ฝ์.
- def - read_binary : create_string_buffer ํจ์๋ฅผ ์ด์ฉํ์ฌ ์ฝ์ ๊ธธ์ด(๊ธฐ๋ณธ ๊ฐ 4) ์ง์ ํ ReadProcessMemory ํจ์๋ก ๋ฐ์ดํฐ ์ฝ์.
- def - read : ์ฝ์ ๋ฐ์ดํฐ๊ฐ 'string'('s') ์ผ ๊ฒฝ์ฐ ์ฃผ์๋ฅผ read_byte ํจ์๋ก ์ ๋ฌํ๊ณ read_byte ํจ์๋ก ๋ถํฐ ์ ๋ฌ๋ฐ์ ๋ฐ์ดํฐ๋ฅผ for๋ฌธ์ผ๋ก '\x00'๊น์ง ์ฝ์ด ๋ฐํ. ์ฝ์ ๋ฐ์ดํฐ๊ฐ 'binary' ์ธ ๊ฒฝ์ฐ read_binary ํจ์๋ก ์ฃผ์๋ฅผ ์ ๋ฌํ๊ณ ๋ฐํ๋ ๊ฐ์ ์ฒ๋ฆฌ ์์ด ๋ฐํ. ์ฝ์ ๋ฐ์ดํฐ๊ฐ 'byte'('b')์ธ ๊ฒฝ์ฐ read_byte ํจ์๋ก ์ฃผ์ ์ ๋ฌ ํ ๋ฐํ๋ ๊ฐ์ ์ฒ๋ฆฌ ์์ด ๋ฐํ. ๊ทธ ๋ฐ์ ๊ฒฝ์ฐ type_unpack ํจ์๋ก ์๋ฃํ ํค์๋์ ๋นํธ ์๋ฅผ ๋ฐํ ๋ฐ์ ํ read_byteํจ์๋ก ๋ฐ์ดํฐ๋ฅผ ์ฝ์ด ๋ฐ์ดํฐ ์ธํฉ(struct.unpack) ์ํ.
- def - write : ๊ธฐ๋กํ ๋ฐ์ดํฐ๊ฐ 'binary' ์ธ ๊ฒฝ์ฐ write_binary ํจ์๋ก ์ฃผ์ ๋ฐ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ ํ ๋ฐํ๋ ๊ฐ์ ์ฒ๋ฆฌ์์ด ๋ฐํ. ๊ธฐ๋กํ ๋ฐ์ดํฐ๊ฐ ('binary' ๋ฐ)'bytes' ๊ฐ ์๋ ๊ฒฝ์ฐ type_unpack ํจ์๋ก ์๋ฃํ ํค์๋์ ๋นํธ ์๋ฅผ ๋ฐํ ๋ฐ์ ํ ํจํน(struct.pack)ํ์ฌ write_bytes ํจ์ ์ํ ํ ๋ฐํ๋ ๋ฐ์ดํฐ ์ฒ๋ฆฌ ์์ด ๋ฐํ. ๊ธฐ๋กํ ๋ฐ์ดํฐ๊ฐ 'bytes' ์ธ ๊ฒฝ์ฐ write_bytes ํจ์์ ์ฃผ์์ ๋ฐ์ดํฐ ์ ๋ฌ ํ ๋ฐํ๋ ๋ฐ์ดํฐ ์ฒ๋ฆฌ ์์ด ๋ฐํ.
- def - get_symbolic_name :
- def - getInstruction : read_byte ํจ์์ ์ฃผ์๋ฅผ ์ ๋ฌํ์ฌ ๊ธธ์ด 32 ๋งํผ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ ๋ฐ์ ํ Distorm3Decoder(Maybee -https://github.com/gdabah/distorm) ํจ์๋ก ๋์ค์ด์ ๋ธํ์ฌ ๋ฐํ
-
engine.common.util
- def - thread : threading.Thread ํจ์๋ฅผ ์ด์ฉํ์ฌ ์ค๋ ๋ ์์ฑ ๋ฐ ์์ ์์(Thread.start)ํ Thread ๋ฐํ
-
engine.common.address
- def - hex_dump :
- class - Address :