diff --git a/Cargo.lock b/Cargo.lock index 3d0cfdc..cb9d8c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1373,7 +1373,6 @@ dependencies = [ "dll-syringe", "poggers 1.2.1 (git+https://github.com/pozm/poggers.git)", "rust-embed", - "tauri-plugin-dialog", "thiserror", "windows 0.56.0", ] @@ -1382,6 +1381,7 @@ dependencies = [ name = "gdke-gui" version = "0.1.0" dependencies = [ + "anyhow", "serde", "serde_json", "tauri", diff --git a/Cargo.toml b/Cargo.toml index 4a208a8..95eeffc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,4 @@ -workspace = { members = ["gdkeinj","gdke-gui/src-tauri"] } +workspace = { members = ["gdkeinj", "gdke-gui/src-tauri"] } [package] name = "gdke" version = "0.2.2" @@ -42,4 +42,3 @@ windows = { features = [ ], version = "0.56" } dll-syringe = "*" poggers = { version = "*", git = "https://github.com/pozm/poggers.git" } -tauri-plugin-dialog = "2.0.0-rc.2" diff --git a/gdke-gui/bun.lockb b/gdke-gui/bun.lockb old mode 100644 new mode 100755 index ed14a5a..dcd9187 Binary files a/gdke-gui/bun.lockb and b/gdke-gui/bun.lockb differ diff --git a/gdke-gui/package.json b/gdke-gui/package.json index 750c86d..3efcee5 100644 --- a/gdke-gui/package.json +++ b/gdke-gui/package.json @@ -10,6 +10,8 @@ "tauri": "tauri" }, "dependencies": { + "@radix-ui/react-dialog": "^1.1.1", + "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-slot": "^1.1.0", "@tauri-apps/api": ">=2.0.0-rc.0", "@tauri-apps/plugin-dialog": "^2.0.0-rc.0", diff --git a/gdke-gui/src-tauri/Cargo.toml b/gdke-gui/src-tauri/Cargo.toml index 3944fe9..4721efa 100644 --- a/gdke-gui/src-tauri/Cargo.toml +++ b/gdke-gui/src-tauri/Cargo.toml @@ -20,4 +20,5 @@ tauri-plugin-shell = "2.0.0-rc" serde = { version = "1", features = ["derive"] } serde_json = "1" tauri-plugin-dialog = "2.0.0-rc" - +anyhow = "*" +# gdke = { path = "../.." } diff --git a/gdke-gui/src-tauri/capabilities/default.json b/gdke-gui/src-tauri/capabilities/default.json index 3bb4cc4..7c37008 100644 --- a/gdke-gui/src-tauri/capabilities/default.json +++ b/gdke-gui/src-tauri/capabilities/default.json @@ -2,9 +2,12 @@ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", - "windows": ["main"], + "windows": [ + "main" + ], "permissions": [ "core:default", - "shell:allow-open" + "shell:allow-open", + "dialog:allow-open" ] } diff --git a/gdke-gui/src-tauri/src/lib.rs b/gdke-gui/src-tauri/src/lib.rs index 56d8e27..bd343a1 100644 --- a/gdke-gui/src-tauri/src/lib.rs +++ b/gdke-gui/src-tauri/src/lib.rs @@ -1,7 +1,22 @@ +use std::{ffi::OsStr, path::Path}; + // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] -fn greet(name: &str) -> String { - format!("Hello, {}! You've been greeted from Rust!", name) +fn get_secret(program: &Path, sig: &str) -> Result { + spawn_and_inject_sig(program, sig) + .map_err(|e| e.to_string()) + .map(|val| { + let mut hex_str = "0x".to_string(); + for char in val { + hex_str.push_str(&format!("{char:02X}")) + } + hex_str + }) + // String::new() +} +fn spawn_and_inject_sig>(proc: T, sig: &str) -> anyhow::Result<[u8; 32]> { + Ok([62; 32]) + // Err(()) } #[cfg_attr(mobile, tauri::mobile_entry_point)] @@ -9,7 +24,7 @@ pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_dialog::init()) - .invoke_handler(tauri::generate_handler![greet]) + .invoke_handler(tauri::generate_handler![get_secret]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/gdke-gui/src-tauri/tauri.conf.json b/gdke-gui/src-tauri/tauri.conf.json index e9a0dcf..1546eed 100644 --- a/gdke-gui/src-tauri/tauri.conf.json +++ b/gdke-gui/src-tauri/tauri.conf.json @@ -1,4 +1,5 @@ { + "$schema": "https://github.com/tauri-apps/tauri/releases/download/tauri-build-v2.0.0-beta.13/schema.json", "productName": "gdke-gui", "version": "0.1.0", "identifier": "one.meli.gdke-gui", @@ -30,5 +31,6 @@ "icons/icon.icns", "icons/icon.ico" ] - } + }, + "plugins": {} } diff --git a/gdke-gui/src/App.css b/gdke-gui/src/App.css index c78c8f0..e57a729 100644 --- a/gdke-gui/src/App.css +++ b/gdke-gui/src/App.css @@ -3,5 +3,5 @@ @tailwind utilities; body { - @apply dark:bg-black dark:text-white + @apply dark:bg-black dark:text-white; } diff --git a/gdke-gui/src/App.tsx b/gdke-gui/src/App.tsx index 7d63968..2082585 100644 --- a/gdke-gui/src/App.tsx +++ b/gdke-gui/src/App.tsx @@ -1,23 +1,145 @@ -import { useState } from "react"; -import reactLogo from "./assets/react.svg"; -import { invoke } from "@tauri-apps/api/core"; +import { useEffect, useState } from "react"; import "./App.css"; -import { Input } from "./components/ui/input"; import { open } from "@tauri-apps/plugin-dialog"; +import { event } from "@tauri-apps/api"; +import { invoke } from "@tauri-apps/api/core"; +import { + Dialog, + DialogContent, + DialogTitle, + DialogDescription, + DialogHeader, +} from "./components/ui/dialog"; +import { Label } from "./components/ui/label"; +import { Input } from "./components/ui/input"; +import { Button } from "./components/ui/button"; function App() { - const [greetMsg, setGreetMsg] = useState(""); - const [name, setName] = useState(""); - function get_file() { - open({ + const [drag_over, set_drag_over] = useState(false); + const [show_pre_run, set_show_pre_run] = useState(false); + const [signature, set_signature] = useState(""); + const [program, set_program] = useState(""); + const [loading, set_loading] = useState(false); + const [outcome, set_outcome] = useState( + null, + ); + async function get_file() { + const outcome = await open({ title: "File picker", filters: [{ name: "Applications", extensions: ["exe"] }], directory: false, }); + if (!outcome) return; + ask_for_sig(outcome.path); } + const run_program = () => { + set_loading(true); + invoke("get_secret", { sig: signature, program }).then( + (out) => { + set_outcome([true, out as string]); + set_loading(false); + }, + (e) => { + set_loading(false); + set_outcome([false]); + }, + ); + }; + const ask_for_sig = async (path: string) => { + set_outcome(null); + set_signature(""); + set_show_pre_run(true); + set_program(path); + }; + useEffect(() => { + const listeners: Promise[] = []; + listeners.push( + event.listen<{ paths: string[] }>(event.TauriEvent.DRAG_DROP, (evt) => { + set_drag_over(false); + console.log(evt); + ask_for_sig(evt.payload.paths[0]); + }), + ); + listeners.push( + event.listen(event.TauriEvent.DRAG_LEAVE, (evt) => { + set_drag_over(false); + console.log(evt); + }), + ); + listeners.push( + event.listen(event.TauriEvent.DRAG_ENTER, (evt) => { + set_drag_over(true); + console.log(evt); + }), + ); + return () => { + (async () => { + for await (const off_fn of listeners) { + off_fn(); + } + })(); + }; + }, []); return ( -
+
+ set_show_pre_run(e)}> + + + Extract Secret Key + {outcome === null && !loading && ( + + After entering a sig we will try our hardest to search for the + key with that signature. + + )} + +
+ {outcome === null || loading ? ( +
+ + set_signature(e.currentTarget.value)} + placeholder="59 48 29 ?? 92 47 ?? .." + /> +
+ ) : loading ? ( +
Loading just give us a sec
+ ) : outcome?.[0] === true ? ( + <> +

+ Successfully got Key! +

{" "} + {" "} + + + ) : ( +
failure
+ )} +
+ {outcome?.[0] && ( + + )} + +
+
+
+

👋 Welcome to Gdke

To get started drop your program below: diff --git a/gdke-gui/src/components/ui/dialog.tsx b/gdke-gui/src/components/ui/dialog.tsx new file mode 100644 index 0000000..306cfc3 --- /dev/null +++ b/gdke-gui/src/components/ui/dialog.tsx @@ -0,0 +1,120 @@ +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { X } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Dialog = DialogPrimitive.Root + +const DialogTrigger = DialogPrimitive.Trigger + +const DialogPortal = DialogPrimitive.Portal + +const DialogClose = DialogPrimitive.Close + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +DialogContent.displayName = DialogPrimitive.Content.displayName + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +

+) +DialogHeader.displayName = "DialogHeader" + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogFooter.displayName = "DialogFooter" + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogTitle.displayName = DialogPrimitive.Title.displayName + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogDescription.displayName = DialogPrimitive.Description.displayName + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogClose, + DialogTrigger, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +} diff --git a/gdke-gui/src/components/ui/label.tsx b/gdke-gui/src/components/ui/label.tsx new file mode 100644 index 0000000..683faa7 --- /dev/null +++ b/gdke-gui/src/components/ui/label.tsx @@ -0,0 +1,24 @@ +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const labelVariants = cva( + "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" +) + +const Label = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & + VariantProps +>(({ className, ...props }, ref) => ( + +)) +Label.displayName = LabelPrimitive.Root.displayName + +export { Label } diff --git a/src/lib.rs b/src/lib.rs index 055ceeb..88b3e78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ pub mod versioning; use std::{ - ffi::{c_void, CStr, CString}, + ffi::{c_void, CStr, CString, OsStr}, io::{Read, Write}, mem::{size_of, transmute}, net::UdpSocket, @@ -61,8 +61,8 @@ impl Drop for ProcKiller { } } } -pub unsafe fn spawn_and_inject(proc: &str, sig: &str) -> anyhow::Result<[u8; 32]> { - let pth = Path::new(proc); +pub unsafe fn spawn_and_inject>(proc: T, sig: &str) -> anyhow::Result<[u8; 32]> { + let pth = Path::new(&proc); if !pth.is_file() { panic!("file does not exist"); }