remove serde / serialization & failure msg

This commit is contained in:
anna 2023-02-16 20:17:43 +00:00
parent c798de768c
commit 7c7066e58e
No known key found for this signature in database
GPG Key ID: C72F3433D1A673B4
6 changed files with 804 additions and 430 deletions

1100
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,11 @@ name = "gdke"
version = "0.1.0"
edition = "2021"
[profile.release]
lto = true
strip = true
opt-level = "z"
codegen-units = 1
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -1,12 +1,16 @@
[package]
name = "gdke-gui"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
[profile.release]
lto = true
strip = true
opt-level = "z"
codegen-units = 1
# 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
egui = "0.21.0"
eframe = { version = "0.21.3" }
poggers = {version = "0.2.*", path = "../../poggers"}

View File

@ -6,22 +6,15 @@ use poggers::external::process::{ExPartialProcess, ExProcess};
use crate::Data;
#[derive(serde::Deserialize, serde::Serialize,Debug)]
#[derive(Debug)]
pub struct gdkeApp {
#[serde(skip)]
procs : Rc<RefCell<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 {
@ -45,27 +38,10 @@ impl Default for gdkeApp {
}
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()
}
Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
}
}
@ -75,8 +51,9 @@ impl eframe::App for gdkeApp {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("GDKE");
ui.separator();
egui::Window::new("Key").open(awaiting).show(ctx, |ui| {
egui::Window::new("Key").collapsible(false).resizable(true).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);
@ -87,10 +64,18 @@ impl eframe::App for gdkeApp {
Data::Key(key) => {
println!("Got key: {}", key);
*last_key = key;
},
Data::Failure(e) => {
println!("Failed to get key");
*last_key = format!("Failed to get key: {}", e);
}
_ =>{ }
Data::Pid(_) => {unreachable!()}
}
};
} else{
ui.centered_and_justified(|ui| {
ui.spinner();
});
}
});
if !*awaiting {
@ -113,7 +98,7 @@ impl eframe::App for gdkeApp {
};
let selval = selected.clone();
ui.separator();
egui::ScrollArea::vertical().max_height(260f32).auto_shrink([false;2])
egui::ScrollArea::vertical().max_height(if selval.is_none() {f32::INFINITY} else {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) {
@ -122,8 +107,8 @@ impl eframe::App for gdkeApp {
}
}
});
ui.separator();
if let Some(selected) = selval {
ui.separator();
if ui.button(format!("get key for {}",selected.name)).clicked() {
tx.as_ref().unwrap().send(Data::Pid(selected.pid)).unwrap();
*awaiting = true;
@ -133,7 +118,4 @@ impl eframe::App for gdkeApp {
}
});
}
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, "d", &self)
}
}

View File

@ -1,8 +1,10 @@
use std::error::Error;
pub mod app;
pub enum Data {
Pid(u32),
Key(String),
Failure(String)
}

View File

@ -2,6 +2,8 @@
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use std::error::Error;
use gdke_gui::{app::gdkeApp, Data};
use poggers::{external::process::ExProcess, traits::Mem};
@ -19,32 +21,45 @@ fn main() {
match x {
Data::Pid(pid) => {
println!("Got pid: {}", pid);
match (|| -> Result<(),Box<dyn Error>> {
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));
let proc = ExProcess::new_from_pid(pid)?;
let bm = proc.get_base_module()?;
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();
return Ok(());
}
println!("sending data {}", data_string);
stx.send(Data::Key(data_string)).unwrap();
break;
} else {
return Err("Unable to resolve lea relative ptr".into());
}
// println!("Found sig: {:X}", x);
} else {
println!("Unable to resolve lea relative ptr");
println!("Failed to find with sig: {}", sig);
// return Err("Failed to find with sig".into());
}
// println!("Found sig: {:X}", x);
} else {
println!("Failed to find with sig: {}", sig);
}
// Ok(())
Err("Failed to find key".into())
})() {
Ok(_) => {},
Err(er) => {
println!("Error: {}", er);
stx.send(Data::Failure(er.to_string())).unwrap();
continue;
}
}
},