From 2ca80ed9dc1cf64797e07c308de440df65fc0e42 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 7 Apr 2025 01:21:19 -0400 Subject: [PATCH] we can inspect 3rd party website cookies (yikes, but also wow) --- crates/desktop/tauri-4o/Cargo.toml | 2 +- .../src/commands/image_generation_command.rs | 21 +++++++++- crates/desktop/tauri-4o/src/lib.rs | 6 ++- .../tauri-4o/src/threads/login_thread.rs | 38 +++++++++++++++++++ crates/desktop/tauri-4o/src/threads/mod.rs | 1 + frontend/editor2d/src/KonvaApp/Engine.ts | 1 + 6 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 crates/desktop/tauri-4o/src/threads/login_thread.rs create mode 100644 crates/desktop/tauri-4o/src/threads/mod.rs diff --git a/crates/desktop/tauri-4o/Cargo.toml b/crates/desktop/tauri-4o/Cargo.toml index 15ac7e23dd..a64f777f20 100644 --- a/crates/desktop/tauri-4o/Cargo.toml +++ b/crates/desktop/tauri-4o/Cargo.toml @@ -51,7 +51,7 @@ serde = { workspace = true } serde_derive = { workspace = true } serde_json = { workspace = true } serde_yaml = { workspace = true } -tauri = { version = "2.4.1", features = [] } +tauri = { version = "2.4.1", features = ["unstable"] } tauri-plugin-log = "2.3.1" tempdir = "0.3.7" tempfile = "3.18.0" diff --git a/crates/desktop/tauri-4o/src/commands/image_generation_command.rs b/crates/desktop/tauri-4o/src/commands/image_generation_command.rs index 3ff191bb04..25ebe453cb 100644 --- a/crates/desktop/tauri-4o/src/commands/image_generation_command.rs +++ b/crates/desktop/tauri-4o/src/commands/image_generation_command.rs @@ -6,6 +6,7 @@ use image::codecs::png::{CompressionType, FilterType, PngEncoder}; use image::{DynamicImage, ImageReader}; use std::io::Cursor; use log::{error, info}; +use tauri::{AppHandle, Manager}; use openai_sora_client::credentials::SoraCredentials; use openai_sora_client::image_gen::common::{ImageSize, NumImages}; use openai_sora_client::image_gen::sora_image_gen_remix::{sora_image_gen_remix, SoraImageGenRemixRequest}; @@ -13,9 +14,27 @@ use openai_sora_client::upload::upload_media_from_bytes::sora_media_upload_from_ use openai_sora_client::upload::upload_media_from_file::SoraMediaUploadRequest; #[tauri::command] -pub async fn image_generation_command(image: &str, prompt: &str) -> Result { +pub async fn image_generation_command( + image: &str, + prompt: &str, + app: AppHandle, +) -> Result { info!("image_generation_command called; processing image..."); + for (w, webview) in app.webviews() { + info!("sending webview: {}", w); + //let result = webview.eval("window.location.replace('https://google.com');"); // works + //let result = webview.eval("document.body.innerHTML = 'hello'"); // works + let result = webview.eval("document.body.innerHTML = document.cookie"); + if let Err(err) = result { + error!("Error with webview: {:?}", err) + } + } + + if true { + return Ok("true".to_string()); + } + let bytes = BASE64_STANDARD.decode(image) .map_err(|err| format!("Base64 decode error: {}", err))?; diff --git a/crates/desktop/tauri-4o/src/lib.rs b/crates/desktop/tauri-4o/src/lib.rs index 8c9db1c7cf..e7733cad6b 100644 --- a/crates/desktop/tauri-4o/src/lib.rs +++ b/crates/desktop/tauri-4o/src/lib.rs @@ -1,12 +1,14 @@ +pub mod commands; pub mod events; pub mod state; +pub mod threads; pub mod transfer; pub mod utils; -pub mod commands; use crate::commands::flip_image::flip_image; use crate::commands::image_generation_command::image_generation_command; use crate::state::app_config::AppConfig; +use crate::threads::login_thread::login_thread; use tauri_plugin_log::Target; use tauri_plugin_log::TargetKind; @@ -47,7 +49,7 @@ pub fn run() { //} let app = app.handle().clone(); - //tauri::async_runtime::spawn(downloader_thread(app_data_root2, app)); + tauri::async_runtime::spawn(login_thread(app)); Ok(()) }) diff --git a/crates/desktop/tauri-4o/src/threads/login_thread.rs b/crates/desktop/tauri-4o/src/threads/login_thread.rs new file mode 100644 index 0000000000..8c723eb632 --- /dev/null +++ b/crates/desktop/tauri-4o/src/threads/login_thread.rs @@ -0,0 +1,38 @@ +use log::{error, info}; +use tauri::{AppHandle, Manager, Webview}; +use errors::AnyhowResult; + +pub async fn login_thread(app: AppHandle) -> ! { + loop { + for (w, webview) in app.webviews() { + info!("Sending webview {}", w); + if let Err(err) = random_behavior(&webview) { + error!("Error in webview : {:?}", err); + } + } + tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; + } +} + +pub fn random_behavior(webview: &Webview) -> AnyhowResult<()> { + let rand = rand::random_range(0..5u8); + match rand { + 0..3 => { + redirect_google(&webview)?; + } + _ => { + write_cookies_to_body(&webview)?; + } + } + Ok(()) +} + +pub fn redirect_google(webview: &Webview) -> AnyhowResult<()> { + webview.eval("window.location.replace('https://google.com');")?; + Ok(()) +} + +pub fn write_cookies_to_body(webview: &Webview) -> AnyhowResult<()> { + webview.eval("document.body.innerHTML = document.cookie")?; + Ok(()) +} diff --git a/crates/desktop/tauri-4o/src/threads/mod.rs b/crates/desktop/tauri-4o/src/threads/mod.rs new file mode 100644 index 0000000000..4f68c93e04 --- /dev/null +++ b/crates/desktop/tauri-4o/src/threads/mod.rs @@ -0,0 +1 @@ +pub mod login_thread; \ No newline at end of file diff --git a/frontend/editor2d/src/KonvaApp/Engine.ts b/frontend/editor2d/src/KonvaApp/Engine.ts index 87966e706f..80041e1c4a 100644 --- a/frontend/editor2d/src/KonvaApp/Engine.ts +++ b/frontend/editor2d/src/KonvaApp/Engine.ts @@ -339,6 +339,7 @@ export class Engine { }); uiEvents.toolbarMain.SAVE.onClick(async (/*event*/) => { + document.location.href = "https://auth.openai.com/log-in"; console.log('save clicked'); await this.realTimeDrawEngine.saveOutput(); });