본문 바로가기
1

치트엔진 말고 트레이너 만들어서 깔끔하게 게임 즐기는 방법과 소스코드

by 진사이트 2024. 6. 19.
반응형
Python Game Trainer Tutorial

Python Game Trainer Tutorial

1. 준비물

파이썬 설치: 파이썬이 설치되어 있어야 합니다. Python 공식 웹사이트에서 다운로드할 수 있습니다.

필요한 라이브러리: pymem과 같은 라이브러리를 사용하면 메모리 조작이 가능합니다. 이를 설치하려면 명령줄에 다음 명령을 입력하세요:

pip install pymem

2. 게임 프로세스 찾기

먼저, 조작하려는 게임의 프로세스를 찾아야 합니다. 이를 위해 pymem 라이브러리를 사용할 수 있습니다.

import pymem
import pymem.process

# 프로세스 이름 설정 (예: 'game.exe')
process_name = 'game.exe'

# 프로세스를 찾고 attach
try:
    pm = pymem.Pymem(process_name)
    print(f"Found process: {process_name}")
except pymem.exception.ProcessNotFound:
    print(f"Process {process_name} not found.")

3. 메모리 주소 찾기

조작하려는 값을 저장하는 메모리 주소를 찾아야 합니다. 이를 위해 Cheat Engine과 같은 툴을 사용할 수 있습니다.

4. 메모리 값 읽고 쓰기

메모리 주소를 찾았다면, pymem을 사용하여 해당 주소의 값을 읽고 쓸 수 있습니다.

# 예시 주소 (Cheat Engine으로 찾은 주소로 대체해야 합니다)
address = 0x00FF00FF

# 값 읽기
value = pm.read_int(address)
print(f"Current value at address {hex(address)}: {value}")

# 값 쓰기 (예: 값을 100으로 변경)
pm.write_int(address, 100)
print(f"Value at address {hex(address)} changed to 100")

5. EXE 파일로 변환

완성된 파이썬 스크립트를 exe 파일로 변환하려면 pyinstaller를 사용할 수 있습니다. pyinstaller를 설치하고, 명령줄에서 다음 명령을 실행하세요:

pip install pyinstaller

그런 다음, 스크립트를 exe로 변환합니다:

pyinstaller --onefile your_script.py

dist 폴더에 생성된 exe 파일을 확인할 수 있습니다.

6. 돈 올리기 버튼을 누르면 게임 메모리의 돈이 올라가도록 하기

아래는 tkinter를 사용하여 간단한 GUI를 추가하고, 돈을 올리기 위한 기능을 구현한 예제입니다:

import pymem
import pymem.process
import tkinter as tk
from tkinter import messagebox

# 게임 프로세스 이름
process_name = 'game.exe'

def increase_money():
    try:
        address = int(entry_address.get(), 16)  # 입력된 주소를 16진수로 변환
        current_value = pm.read_int(address)
        increase_value = int(entry_increase.get())
        new_value = current_value + increase_value
        pm.write_int(address, new_value)
        messagebox.showinfo("Success", f"Money increased by {increase_value}. New value: {new_value}")
    except Exception as e:
        messagebox.showerror("Error", f"An error occurred: {e}")

# 게임 프로세스 찾기
try:
    pm = pymem.Pymem(process_name)
    print(f"Found process: {process_name}")
except pymem.exception.ProcessNotFound:
    messagebox.showerror("Error", f"Process {process_name} not found.")
    exit()

# Tkinter 윈도우 생성
root = tk.Tk()
root.title("Game Trainer")

# 메모리 주소 입력 라벨 및 엔트리
tk.Label(root, text="Money Address (hex):").grid(row=0, column=0, padx=10, pady=10)
entry_address = tk.Entry(root)
entry_address.grid(row=0, column=1, padx=10, pady=10)

# 증가할 값 입력 라벨 및 엔트리
tk.Label(root, text="Increase Amount:").grid(row=1, column=0, padx=10, pady=10)
entry_increase = tk.Entry(root)
entry_increase.grid(row=1, column=1, padx=10, pady=10)

# 돈 올리기 버튼
increase_button = tk.Button(root, text="Increase Money", command=increase_money)
increase_button.grid(row=2, column=0, columnspan=2, padx=10, pady=10)

# Tkinter 메인 루프 시작
root.mainloop()
반응형