From d560878af95f87b2a4f7df243796ad156a057346 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Thu, 9 Feb 2023 14:18:16 +0100 Subject: [PATCH] Feat: keyinput and no ssl --- receiver/Cargo.lock | 130 ++++++++++++++++++++++++++++++++++++------- receiver/Cargo.toml | 5 +- receiver/src/main.rs | 6 ++ 3 files changed, 119 insertions(+), 22 deletions(-) diff --git a/receiver/Cargo.lock b/receiver/Cargo.lock index 9f3db45..6bd6822 100644 --- a/receiver/Cargo.lock +++ b/receiver/Cargo.lock @@ -66,6 +66,12 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "block-buffer" version = "0.9.0" @@ -140,6 +146,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" + +[[package]] +name = "core-graphics" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f15b3cb55687886a6b66953123621e5a1529a91a01666d646fb64baa13f900f0" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + [[package]] name = "cpufeatures" version = "0.2.5" @@ -221,12 +255,41 @@ dependencies = [ "subtle", ] +[[package]] +name = "enigo" +version = "0.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce8d7672e87b3155fd5e8a9226276da5c833e15bc879c7b98a78f743b67814" +dependencies = [ + "core-graphics", + "libc", + "objc", + "pkg-config", + "unicode-segmentation", + "winapi", +] + [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "futures" version = "0.3.26" @@ -398,12 +461,30 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + [[package]] name = "once_cell" version = "1.17.0" @@ -416,19 +497,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl-sys" -version = "0.9.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "paho-mqtt" version = "0.12.0" @@ -452,7 +520,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f92767091deda553bdb716820e5c168e2fbeb48c2f7f27a3d459b84cd53d680c" dependencies = [ "cmake", - "openssl-sys", ] [[package]] @@ -538,6 +605,7 @@ version = "0.1.0" dependencies = [ "base64", "crypto_helper", + "enigo", "hex", "paho-mqtt", "pbkdf2", @@ -675,6 +743,12 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "universal-hash" version = "0.5.0" @@ -695,12 +769,6 @@ dependencies = [ "serde", ] -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" @@ -766,3 +834,25 @@ name = "wasm-bindgen-shared" version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/receiver/Cargo.toml b/receiver/Cargo.toml index 170ac75..f4a34bc 100644 --- a/receiver/Cargo.toml +++ b/receiver/Cargo.toml @@ -8,9 +8,10 @@ edition = "2021" [dependencies] base64 = "0.21.0" hex = "0.4.3" -paho-mqtt = "0.12.0" +paho-mqtt = { version = "0.12.0", default-features = false, features = ["bundled"] } pbkdf2 = "0.11.0" crypto_helper = {path = "../crypto_helper"} uuid = { version = "1.3.0", features = ["serde", "v4"] } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" \ No newline at end of file +serde_json = "1.0" +enigo = "0.0.14" diff --git a/receiver/src/main.rs b/receiver/src/main.rs index d4ee8cd..5c1ed69 100644 --- a/receiver/src/main.rs +++ b/receiver/src/main.rs @@ -1,4 +1,5 @@ use std::{env, process, time::Duration, fmt::format}; +use enigo::KeyboardControllable; use serde::{Deserialize, Serialize}; use serde_json::Result; @@ -47,6 +48,7 @@ fn main() { let password = "test"; let broker_domain = "broker.emqx.io"; let broker_url = format!("tcp://{}:1883", broker_domain); + let mut en = enigo::Enigo::new(); let c = crypto_helper::crypto::Crypto::new("test", "broker.emqx.io"); @@ -68,6 +70,10 @@ fn main() { } println!("Got time: {} with id {}", msg.time, msg.id); + let time_with_comma = format!("{},{}", msg.time / 1000, (msg.time/10) % 100); + en.key_sequence(&time_with_comma); + en.key_click(enigo::Key::Tab); + en.key_click(enigo::Key::Tab); let reply = MqttMessage { id: msg.id,