mirror of https://github.com/pozm/gdke.git
now just need to get data from the vector...
This commit is contained in:
parent
a2349d7491
commit
aaf92cd109
|
@ -69,6 +69,15 @@ version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.83"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cexpr"
|
name = "cexpr"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -247,7 +256,6 @@ dependencies = [
|
||||||
"crossbeam",
|
"crossbeam",
|
||||||
"dll-syringe",
|
"dll-syringe",
|
||||||
"poggers",
|
"poggers",
|
||||||
"semver",
|
|
||||||
"windows",
|
"windows",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -257,6 +265,17 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"poggers",
|
"poggers",
|
||||||
"poggers-derive",
|
"poggers-derive",
|
||||||
|
"retour",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -367,6 +386,16 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libudis86-sys"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "139bbf9ddb1bfc90c1ac64dd2923d9c957cd433cee7315c018125d72ab08a6b0"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.12"
|
version = "0.4.12"
|
||||||
|
@ -416,6 +445,16 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mmap-fixed-fixed"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0681853891801e4763dc252e843672faf32bcfee27a0aa3b19733902af450acc"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "7.1.1"
|
version = "7.1.1"
|
||||||
|
@ -457,9 +496,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.16.0"
|
version = "1.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
|
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "path-absolutize"
|
name = "path-absolutize"
|
||||||
|
@ -569,6 +608,34 @@ version = "0.6.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "region"
|
||||||
|
version = "3.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"libc",
|
||||||
|
"mach",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "retour"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9af44d40e2400b44d491bfaf8eae111b09f23ac4de6e92728e79d93e699c527"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"generic-array",
|
||||||
|
"libc",
|
||||||
|
"libudis86-sys",
|
||||||
|
"mmap-fixed-fixed",
|
||||||
|
"once_cell",
|
||||||
|
"region",
|
||||||
|
"slice-pool2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -623,12 +690,6 @@ dependencies = [
|
||||||
"syn 2.0.48",
|
"syn 2.0.48",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "1.0.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.196"
|
version = "1.0.196"
|
||||||
|
@ -668,6 +729,12 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slice-pool2"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a3d689654af89bdfeba29a914ab6ac0236d382eb3b764f7454dde052f2821f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stopwatch2"
|
name = "stopwatch2"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
|
@ -747,6 +814,12 @@ dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typenum"
|
||||||
|
version = "1.17.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typewit"
|
name = "typewit"
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
|
@ -768,6 +841,12 @@ version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "which"
|
name = "which"
|
||||||
version = "4.4.2"
|
version = "4.4.2"
|
||||||
|
|
|
@ -19,7 +19,6 @@ strip = false
|
||||||
# members = ["gdke-gui"]
|
# members = ["gdke-gui"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
semver = "*"
|
|
||||||
anyhow = "*"
|
anyhow = "*"
|
||||||
windows = { features = [
|
windows = { features = [
|
||||||
"Win32_Foundation",
|
"Win32_Foundation",
|
||||||
|
|
|
@ -10,3 +10,4 @@ crate-type = ["cdylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
poggers = { path = "../../poggers" }
|
poggers = { path = "../../poggers" }
|
||||||
poggers-derive = { path = "../../poggers/poggers-derive/" }
|
poggers-derive = { path = "../../poggers/poggers-derive/" }
|
||||||
|
retour = { version = "0.3.1", features = ["static-detour", "thiscall-abi"] }
|
||||||
|
|
|
@ -1,9 +1,26 @@
|
||||||
use std::{net::UdpSocket, time::Duration};
|
use std::{
|
||||||
|
collections::HashMap, ffi::c_void, mem::size_of, net::UdpSocket, ptr::null, time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use poggers::structures::process::{implement::utils::ProcessUtils, Process};
|
use poggers::{
|
||||||
|
structures::process::{implement::utils::ProcessUtils, Process},
|
||||||
|
traits::Mem,
|
||||||
|
};
|
||||||
|
use retour::static_detour;
|
||||||
|
|
||||||
#[poggers_derive::create_entry(no_console)]
|
// *const i32, *const i32, *const i32, bool
|
||||||
|
type open_and_parse_t = unsafe extern "fastcall" fn(*const i32, *const i32, *const i32, bool) -> ();
|
||||||
|
static_detour! {
|
||||||
|
pub static OpenAndParse: unsafe extern "fastcall" fn(*const i32, *const i32, *const i32, bool) -> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[poggers_derive::create_entry(no_free)]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
let mut sigs = HashMap::<u32, (&'static str, i32)>::new();
|
||||||
|
sigs.insert(
|
||||||
|
1,
|
||||||
|
("E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 49 8B 8C 24 ? ? ? ?", -0x3c),
|
||||||
|
);
|
||||||
let sock = UdpSocket::bind("127.0.0.1:29849").unwrap();
|
let sock = UdpSocket::bind("127.0.0.1:29849").unwrap();
|
||||||
let mut buf = [1; 1];
|
let mut buf = [1; 1];
|
||||||
sock.connect("127.0.0.1:28713").expect("uanble to connect");
|
sock.connect("127.0.0.1:28713").expect("uanble to connect");
|
||||||
|
@ -11,7 +28,38 @@ pub fn main() {
|
||||||
let proc = Process::this_process();
|
let proc = Process::this_process();
|
||||||
let modd = proc.get_base_module().unwrap();
|
let modd = proc.get_base_module().unwrap();
|
||||||
|
|
||||||
println!("sending data");
|
println!("sending data, waiting for sig ver");
|
||||||
std::thread::sleep(Duration::from_secs(2));
|
std::thread::sleep(Duration::from_secs(2));
|
||||||
sock.send(&buf);
|
sock.send(&buf);
|
||||||
|
|
||||||
|
let mut sig_type = [0; 4];
|
||||||
|
sock.recv(&mut sig_type);
|
||||||
|
let int_sig = u32::from_ne_bytes(sig_type);
|
||||||
|
let sig = sigs.get(&int_sig).expect("sig type match not compatible");
|
||||||
|
let mut addr = modd.scan(sig.0).unwrap().unwrap() as isize; //+ sig.1 as isize;
|
||||||
|
// addr += sig.1 as isize;
|
||||||
|
let ptr_to_fn = (addr as usize + size_of::<u8>()) as *const u8;
|
||||||
|
let mut addr_offset = [0; 4];
|
||||||
|
unsafe { std::ptr::copy(ptr_to_fn, addr_offset.as_mut_ptr(), 4) };
|
||||||
|
let by = i32::from_ne_bytes(addr_offset);
|
||||||
|
println!("addr offset = {:x?}", addr_offset);
|
||||||
|
let fn_ptr = (addr + by as isize + 5) as *const c_void;
|
||||||
|
println!("fnptr = {:x?}", fn_ptr);
|
||||||
|
|
||||||
|
println!("sig found: {:x} {:p}", addr, ptr_to_fn);
|
||||||
|
let sock2 = sock.try_clone().unwrap();
|
||||||
|
unsafe {
|
||||||
|
let open_and_parse = std::mem::transmute::<isize, open_and_parse_t>(fn_ptr as isize);
|
||||||
|
let opp = OpenAndParse
|
||||||
|
.initialize(open_and_parse, move |this, base, key, mode| {
|
||||||
|
println!("open and parse called {key:?}");
|
||||||
|
let mut key: *const u8 = std::ptr::null();
|
||||||
|
// std::arch::asm!("mov {}, r8", out(reg) key);
|
||||||
|
// println!("key = {:?}", key);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
opp.enable();
|
||||||
|
println!("detour enabled {}", opp.is_enabled());
|
||||||
|
}
|
||||||
|
sock.send(&[]);
|
||||||
}
|
}
|
||||||
|
|
59
src/lib.rs
59
src/lib.rs
|
@ -1,8 +1,9 @@
|
||||||
#![feature(offset_of)]
|
#![feature(offset_of_nested)]
|
||||||
pub mod versioning;
|
pub mod versioning;
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
ffi::{c_void, CStr, CString},
|
ffi::{c_void, CStr, CString},
|
||||||
|
io::Read,
|
||||||
mem::{size_of, transmute},
|
mem::{size_of, transmute},
|
||||||
net::UdpSocket,
|
net::UdpSocket,
|
||||||
ptr::{addr_of, null, null_mut},
|
ptr::{addr_of, null, null_mut},
|
||||||
|
@ -69,40 +70,54 @@ pub unsafe fn spawn_and_inject(proc: &str) {
|
||||||
&mut 0,
|
&mut 0,
|
||||||
);
|
);
|
||||||
let proc = Process::find_pid(proc_info.dwProcessId).unwrap();
|
let proc = Process::find_pid(proc_info.dwProcessId).unwrap();
|
||||||
let pebby: PEB = proc.read(ptr_to_pbi.PebBaseAddress as usize).expect("the");
|
let image_base_addr: *const c_void = proc
|
||||||
let pImage = pebby.Reserved3[1] as usize;
|
.read(ptr_to_pbi.PebBaseAddress as usize + 0x10)
|
||||||
let e_lf: u32 = proc
|
.expect("the");
|
||||||
.read(pImage + std::mem::offset_of!(IMAGE_DOS_HEADER, e_lfanew))
|
let mut headers = [0; 4096];
|
||||||
.expect("bruh");
|
proc.raw_read(image_base_addr as usize, headers.as_mut_ptr(), 4096);
|
||||||
let entry: u32 = proc
|
let dos_hdr = transmute::<*const u8, *const IMAGE_DOS_HEADER>(headers.as_ptr());
|
||||||
.read(
|
let nt_hdrs = transmute::<*const u8, *const IMAGE_NT_HEADERS64>(
|
||||||
pImage
|
headers
|
||||||
+ e_lf as usize
|
.as_ptr()
|
||||||
+ std::mem::offset_of!(IMAGE_NT_HEADERS64, OptionalHeader.AddressOfEntryPoint),
|
.wrapping_add((*dos_hdr).e_lfanew.try_into().unwrap()),
|
||||||
)
|
);
|
||||||
.expect("bruh");
|
let code_entry =
|
||||||
let entry = pImage + entry as usize;
|
image_base_addr.wrapping_add((*nt_hdrs).OptionalHeader.AddressOfEntryPoint as usize);
|
||||||
println!("entry = {:x}", entry);
|
println!(
|
||||||
let entry_insts: [u8; 2] = proc.read(entry).expect("failed to read entry");
|
"entry = {:p} B = {:X} C = {:p}",
|
||||||
|
code_entry,
|
||||||
|
(*nt_hdrs).OptionalHeader.AddressOfEntryPoint,
|
||||||
|
image_base_addr
|
||||||
|
);
|
||||||
|
let entry_insts: [u8; 2] = proc
|
||||||
|
.read(code_entry as usize)
|
||||||
|
.expect("failed to read entry");
|
||||||
let pay_load: [u8; 2] = [0xEB, 0xFE];
|
let pay_load: [u8; 2] = [0xEB, 0xFE];
|
||||||
proc.write(entry, &pay_load);
|
proc.write(code_entry as usize, &pay_load);
|
||||||
//
|
//
|
||||||
// resume the thread
|
// resume the thread
|
||||||
ResumeThread(proc_info.hThread);
|
ResumeThread(proc_info.hThread);
|
||||||
|
// ResumeThread(proc_info.hThread);
|
||||||
// wait until trapped... and inject
|
// wait until trapped... and inject
|
||||||
{
|
|
||||||
let sock = UdpSocket::bind("127.0.0.1:28713").expect("failed to bind socket");
|
let sock = UdpSocket::bind("127.0.0.1:28713").expect("failed to bind socket");
|
||||||
|
{
|
||||||
let target = OwnedProcess::from_pid(proc.get_pid()).unwrap();
|
let target = OwnedProcess::from_pid(proc.get_pid()).unwrap();
|
||||||
let syrnge = Syringe::for_process(target);
|
let syrnge = Syringe::for_process(target);
|
||||||
let injmod = syrnge.inject("./target/debug/gdkeinj.dll").unwrap();
|
let injmod = syrnge.inject("./target/debug/gdkeinj.dll").unwrap();
|
||||||
|
|
||||||
println!("waiting until udp is ok ");
|
println!("waiting until udp is ok ");
|
||||||
|
|
||||||
sock.recv(&mut [0]);
|
let (_, addr) = sock.recv_from(&mut [0]).unwrap();
|
||||||
|
sock.send_to(&1_u32.to_ne_bytes(), addr).unwrap();
|
||||||
|
let _ = sock.recv(&mut []);
|
||||||
}
|
}
|
||||||
// we're done. let's kill the process.
|
// we're done. let's kill the process.
|
||||||
println!("done, restoring..",);
|
println!("done, running code after enter..",);
|
||||||
proc.write(entry, &entry_insts);
|
let mut inp = String::new();
|
||||||
|
std::io::stdin().read_line(&mut inp);
|
||||||
|
proc.write(code_entry as usize, &entry_insts);
|
||||||
|
println!("waiting for call.");
|
||||||
|
let _ = sock.recv(&mut []);
|
||||||
|
println!("complete.");
|
||||||
TerminateProcess(proc_info.hProcess, 1);
|
TerminateProcess(proc_info.hProcess, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,4 @@ fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
spawn_and_inject("./z421.exe");
|
spawn_and_inject("./z421.exe");
|
||||||
}
|
}
|
||||||
println!("hi");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::{
|
use std::{
|
||||||
io::{Stdin, Stdout},
|
io::{BufRead, BufReader, Cursor, Stdin, Stdout},
|
||||||
path::Path,
|
path::Path,
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
};
|
};
|
||||||
fn check_gd_ver(exe: Path) -> anyhow::Result<semver::Version> {
|
fn check_gd_ver(exe: &Path) -> anyhow::Result<String> {
|
||||||
assert!(exe.exists());
|
assert!(exe.exists());
|
||||||
let stdo = Command::new(exe)
|
let stdo = Command::new(exe)
|
||||||
.arg("-V")
|
.arg("-V")
|
||||||
|
@ -11,5 +11,10 @@ fn check_gd_ver(exe: Path) -> anyhow::Result<semver::Version> {
|
||||||
.arg("random-no-way-a-game-has-this-btw")
|
.arg("random-no-way-a-game-has-this-btw")
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.output()?;
|
.output()?;
|
||||||
stdo.stdout
|
let bufr = Cursor::new(stdo.stdout);
|
||||||
|
|
||||||
|
Ok(bufr
|
||||||
|
.lines()
|
||||||
|
.next()
|
||||||
|
.ok_or(anyhow::anyhow!("unable to read version"))??)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue