JavaRush /Java Blog /Random-KO /์ž๋ฐ” ๋ฉ”๋ชจ๋ฆฌ ์กฐ์ž‘
Cyber Cheat
๋ ˆ๋ฒจ 5

์ž๋ฐ” ๋ฉ”๋ชจ๋ฆฌ ์กฐ์ž‘

Random-KO ๊ทธ๋ฃน์— ๊ฒŒ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค
์•ˆ๋…•ํ•˜์„ธ์š” ์ž๋ฐ” ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค! ์ผ๋ฐ˜์ ์œผ๋กœ ๋‚˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์งˆ๋ฌธ์„ ์Šค์Šค๋กœ์—๊ฒŒ ๋˜์กŒ์Šต๋‹ˆ๋‹ค: Java Memory Manipulation ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋•๋ถ„์— ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ํ”„๋กœ์„ธ์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ฝ๊ณ  ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ ?์ด ์งˆ๋ฌธ์„ ํ•œ ๊ฒƒ์€ ์ด๋ฒˆ์ด ์ฒ˜์Œ์€ ์•„๋‹ˆ์ง€๋งŒ ์ด์— ๋Œ€ํ•œ ์ •๋ณด๊ฐ€ ๊ฑฐ์˜ ์—†์Šต๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ์ธํ„ฐ๋„ท์—์„œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ์‚ฌ๋žŒ์ด Java์—์„œ๋Š” ์ด๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๊ณ  ์“ฐ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋น„๋ก ์ด๊ฒƒ์ด ์‹ค์ œ๋ผ๋Š” ๊ฒŒ์‹œ๋ฌผ์„ ๋ณธ ์ ์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋„์›€์„ ์š”์ฒญํ•˜๊ณ  ์‹ถ์€๋ฐ, ์ด ์ œํ’ˆ์„ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•˜๋ฉด ๋˜๋‚˜์š”? :)
public static void main(String args[]) {
    	//Get ProcessID
    	long pid = findProcessId("nuclearthrone.exe");
    	if(pid == 0) {
    		System.err.println("ProcessId not found.");
    		System.exit(1);
    	}
    	System.out.println(pid);

    	Pointer readProcess = openProcess(readRight, pid);//opens process with read privileges
    	Pointer writeProcess = openProcess(writeRight, pid);

    	int size = 4;//we want to read 4 bytes
    	int adress = Integer.parseInt("036CB314", 16);

    	//ReadMemory
    	 read = readMemory(readProcess, adress, size);
    	System.out.println(read.getInt(0));//value of memory read

    	//Write Memory
    	Cheater.writeMemory(4, 1079246848, writeProcess, adress);
    }

    static long findProcessId(String processName) {
		//This Reference will contain the processInfo that will be parsed t recover the ProcessId
		Tlhelp32.PROCESSENTRY32.ByReference processInfo = new Tlhelp32.PROCESSENTRY32.ByReference();

		//this handle allows us to parse the process map
		WinNT.HANDLE processesSnapshot = kernel32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPPROCESS, new DWORD(0L));
		if(processesSnapshot == kernel32.INVALID_HANDLE_VALUE) {
			if(DEBUG) System.err.println("INVALID_HANDLE_VALUE");
			return 0L;
		}

		try {// This will parse all the processes to find the process id corresponding to the process name
			kernel32.Process32First(processesSnapshot, processInfo);
			if(processName.equals(Native.toString(processInfo.szExeFile))) {
				if(DEBUG) if(DEBUG) System.out.println("Process " + processName + " found : " + processInfo.th32ProcessID.longValue());
                return processInfo.th32ProcessID.longValue();
			}

			while(kernel32.Process32Next(processesSnapshot, processInfo)) {
				if(processName.equals(Native.toString(processInfo.szExeFile)))
                {
                    if(DEBUG) System.out.println("Process " + processName + " found : " + processInfo.th32ProcessID.longValue());
                    return processInfo.th32ProcessID.longValue();
                }
			}

			if(DEBUG) System.out.println("Did not find requested Process: " + processName);
			return 0L;
		} finally {
			kernel32.CloseHandle(processesSnapshot);
		}
	}//findProcessId

    static Pointer openProcess( permissions, long pid) {
    	Pointer process = myKernel32.OpenProcess(permissions, true, (int)pid);
    	 process;
    }
    static Memory readMemory( process, int adress, int readSize) {
    	 output = new Memory(readSize);
		if(!myKernel32.ReadProcessMemory(process, adress, output, readSize, new IntByReference(0))) {
			int error =myKernel32.getLastError();
			switch(error) {
			default:
				System.err.println("Failed to read the process: " + error);
				break;
			case 0x12B:
				System.err.println("Failed to read the specified adress");
				break;
			}
			System.exit(1);
		}
		return output;
    }
    static void writeMemory(int readSize, int newValue, Pointer process, long adress) {
    	IntByReference written = new IntByReference(0);
		 toWrite = new Memory(readSize);

		toWrite.setInt(0, newValue);

		if(!myKernel32.WriteProcessMemory(process, (int)adress toWrite, , written)) {
			int error = myKernel32.getLastError();
			switch(error)
            {
                default:
                    System.err.println("Failed to write in the process : " + error);
                    break;
            }
            System.exit(1);
		}
		System.out.println("Wrote " + written.getValue() + " times");
    }
์ฝ”๋ฉ˜ํŠธ
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION