This commit is contained in:
anna 2023-02-15 08:57:41 +00:00
parent 967352460b
commit f30700d15a
No known key found for this signature in database
GPG Key ID: C72F3433D1A673B4
8 changed files with 2369 additions and 36 deletions

101
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,101 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'gdke-gui'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=gdke-gui"
],
"filter": {
"name": "gdke-gui",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'gdke-gui'",
"cargo": {
"args": [
"build",
"--bin=gdke-gui",
"--package=gdke-gui"
],
"filter": {
"name": "gdke-gui",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'gdke-gui'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=gdke-gui",
"--package=gdke-gui"
],
"filter": {
"name": "gdke-gui",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'gdke'",
"cargo": {
"args": [
"build",
"--bin=gdke",
"--package=gdke"
],
"filter": {
"name": "gdke",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'gdke'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=gdke",
"--package=gdke"
],
"filter": {
"name": "gdke",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

2075
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,4 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
poggers = {version = "0.1.1-dev3", path = "../poggers"} poggers = {version = "0.2.*", path = "../poggers"}
[workspace]
members = [
"gdke-gui",
]

12
gdke-gui/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "gdke-gui"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
egui = "0.20.1"
eframe = { version = "0.20.1", features = ["persistence"] }
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
poggers = {version = "0.2.*", path = "../../poggers"}

130
gdke-gui/src/app.rs Normal file
View File

@ -0,0 +1,130 @@
use std::{borrow::BorrowMut, ops::Deref, sync::mpsc::{Receiver, Sender}};
use eframe::CreationContext;
use egui::{TextStyle, TextEdit};
use poggers::external::process::{ExPartialProcess, ExProcess};
use crate::Data;
#[derive(serde::Deserialize, serde::Serialize,Debug)]
pub struct gdkeApp {
#[serde(skip)]
procs : Vec<ExPartialProcess>,
#[serde(skip)]
selected: Option<ExPartialProcess>,
#[serde(skip)]
awaiting: bool,
#[serde(skip)]
last_key: String,
#[serde(skip)]
process: Option<ExProcess>,
search_query: String,
#[serde(skip)]
rx: Option<std::sync::mpsc::Receiver<Data>>,
#[serde(skip)]
tx: Option<std::sync::mpsc::Sender<Data>>
}
impl Default for gdkeApp {
fn default() -> Self {
let procs = if let Ok(procs) = ExProcess::get_processes() {
procs
} else {
Vec::new()
};
Self {
procs,
selected: None,
process: None,
search_query: String::new(),
rx: None,
awaiting: false,
last_key: String::new(),
tx: None
}
}
}
impl gdkeApp {
pub fn new(cc: &CreationContext<'_>, rx: Receiver<Data>,tx: Sender<Data>) -> gdkeApp {
if let Some(stor) = cc.storage {
if let Some(data) = eframe::get_value::<Self>(stor, "d") {
println!("Loaded data: {:?}", data);
return Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
} else {
Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
}
} else {
Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
}
}
}
impl eframe::App for gdkeApp {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
let Self {last_key, awaiting, rx,tx, procs, selected, process, search_query } = self;
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("GDKE");
ui.separator();
egui::Window::new("Key")..open(awaiting).show(ctx, |ui| {
ui.label("Getting key, please wait...");
if !last_key.is_empty() {
let mut keyda = last_key.clone();
TextEdit::singleline(&mut keyda).show(ui);
ui.label("Close this window when done.");
}
else if let Ok(data) = rx.as_ref().unwrap().try_recv() {
match data {
Data::Key(key) => {
println!("Got key: {}", key);
*last_key = key;
}
_ =>{ }
}
};
});
if !*awaiting {
ui.label("Select a Godot process to find the encryption key for.");
egui::TextEdit::singleline(&mut self.search_query).hint_text("Search...").show(ui);
let text_style = TextStyle::Body;
let row_height = ui.text_style_height(&text_style);
let filtered_procs = if self.search_query.is_empty() {self.procs.iter().collect::<Vec::<&ExPartialProcess>>()} else {self.procs.iter()
.filter(|p| p.name.contains(&self.search_query) || p.pid.to_string().contains(&self.search_query)).collect()
};
let selval = selected.clone();
ui.separator();
egui::ScrollArea::vertical().max_height(260f32).auto_shrink([false;2])
.show_rows(ui, row_height, filtered_procs.len(), move |ui,row_range| {
for row in row_range {
if let Some(proc) = (&filtered_procs).get(row) {
let owner_proc = proc.deref();
ui.selectable_value(selected, Some(owner_proc.clone()) , proc.name.clone());
}
}
});
ui.separator();
if let Some(selected) = selval {
if ui.button(format!("get key for {}",selected.name)).clicked() {
tx.as_ref().unwrap().send(Data::Pid(selected.pid)).unwrap();
*awaiting = true;
last_key.clear();
}
}
}
});
}
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, "d", &self)
}
}

8
gdke-gui/src/lib.rs Normal file
View File

@ -0,0 +1,8 @@
pub mod app;
pub enum Data {
Pid(u32),
Key(String),
}

61
gdke-gui/src/main.rs Normal file
View File

@ -0,0 +1,61 @@
use gdke_gui::{app::gdkeApp, Data};
use poggers::{external::process::ExProcess, traits::Mem};
const SIGS: [&str; 3] = ["48 8D 05 ? ? ? ? 41 8A 04 04","48 8D 05 ? ? ? ? 0F B6 ? 03","4C 8D 05 ? ? ? ? 0F 1F 40 00"];
fn main() {
let (stx, srx) = std::sync::mpsc::channel::<Data>();
let (ctx, crx) = std::sync::mpsc::channel::<Data>();
let jh = std::thread::spawn(move|| {
loop {
if let Ok(x) = crx.try_recv() {
match x {
Data::Pid(pid) => {
println!("Got pid: {}", pid);
let proc = ExProcess::new_from_pid(pid).unwrap();
let bm = proc.get_base_module().unwrap();
for sig in SIGS.iter() {
let res = unsafe {bm.scan_virtual(sig)};
if let Some(x) = res {
let data = unsafe {bm.resolve_relative_ptr(x+3, 4)};
if let Ok(x) = data {
println!("found key @ {:X}", x);
let key_data = unsafe {bm.read_sized(x, 32)};
if let Ok(x) = key_data {
// print!("Key: ");
let mut data_string = String::new();
for i in x {
data_string.push_str(&format!("{:02X}", i));
}
println!("sending data {}", data_string);
stx.send(Data::Key(data_string)).unwrap();
break;
}
} else {
println!("Unable to resolve lea relative ptr");
}
// println!("Found sig: {:X}", x);
} else {
println!("Failed to find with sig: {}", sig);
}
}
},
_ => {}
}
}
}
});
let native_options = eframe::NativeOptions::default();
eframe::run_native(
"gdke",
native_options,
Box::new(move |cc| Box::new(gdkeApp::new(cc, srx, ctx))),
);
jh.join();
}

11
gdke.code-workspace Normal file
View File

@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../poggers"
}
],
"settings": {}
}