diff options
| author | Li Zhineng <[email protected]> | 2024-07-05 20:55:30 +0800 |
|---|---|---|
| committer | Li Zhineng <[email protected]> | 2024-07-05 20:55:30 +0800 |
| commit | f5d517897b58bb4e652750355cc3566e644fa1b3 (patch) | |
| tree | b79fb565d1cdbd2f7482cd50537d0749657b8463 /decryptor | |
| parent | e30c0ea7c7a128f4f0579f7e254a95105e2b48b9 (diff) | |
| download | china-unicom-iptv-gd-f5d517897b58bb4e652750355cc3566e644fa1b3.tar.gz china-unicom-iptv-gd-f5d517897b58bb4e652750355cc3566e644fa1b3.zip | |
decryptor Rust implementation
Diffstat (limited to 'decryptor')
| -rw-r--r-- | decryptor/Cargo.lock | 201 | ||||
| -rw-r--r-- | decryptor/Cargo.toml | 9 | ||||
| -rw-r--r-- | decryptor/src/main.rs | 65 |
3 files changed, 275 insertions, 0 deletions
diff --git a/decryptor/Cargo.lock b/decryptor/Cargo.lock new file mode 100644 index 0000000..3da45c6 --- /dev/null +++ b/decryptor/Cargo.lock @@ -0,0 +1,201 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "decryptor" +version = "0.1.0" +dependencies = [ + "hex", + "openssl", + "rand", +] + +[[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 = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" diff --git a/decryptor/Cargo.toml b/decryptor/Cargo.toml new file mode 100644 index 0000000..918bd84 --- /dev/null +++ b/decryptor/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "decryptor" +version = "0.1.0" +edition = "2021" + +[dependencies] +hex = "0.4.3" +openssl = "0.10.64" +rand = "0.8.5" diff --git a/decryptor/src/main.rs b/decryptor/src/main.rs new file mode 100644 index 0000000..d48e7bb --- /dev/null +++ b/decryptor/src/main.rs @@ -0,0 +1,65 @@ +use std::{env, process}; +use openssl::symm::{decrypt, Cipher}; +use hex; + +fn decrypt_authinfo(authinfo_raw: String) -> Result<(String, String), String> { + let authinfo = hex::decode(authinfo_raw).map_err(|_| "Invalid hex encoding for authinfo")?; + + let cipher = Cipher::des_ede3(); + let iv = [0u8; 8]; + + // Decrypting loop, iterating from 000000 to 999999 + for i in 0..1_000_000 { + let key = format!("{:06}", i); + let key_bytes = format!("{}000000000000000000", key).into_bytes(); + + match decrypt(cipher, &key_bytes, Some(&iv), &authinfo) { + Ok(bytes) => { + let result = String::from_utf8_lossy(&bytes); + + if result.contains("OTT") { + return Ok((key, result.to_string())); + } + } + Err(_) => { + // Decryption failed with this key, continue trying + } + } + } + + return Err("Could not find a possible key".to_string()); +} + +fn main() { + let args: Vec<String> = env::args().collect(); + + if args.len() != 2 { + eprintln!("Usage: {} <authinfo>", args[0]); + process::exit(1); + } + + let authinfo_raw = args[1].clone(); + + match decrypt_authinfo(authinfo_raw) { + Ok((key, result)) => { + let components: Vec<&str> = result.split('$').collect(); + + println!("========================================"); + println!("Found key: {}", key); + println!("========================================"); + println!("{}", result); + println!("========================================"); + println!(" random: {}", components[0]); + println!(" encry token: {}", components[1]); + println!(" user id: {}", components[2]); + println!(" device id: {}", components[3]); + println!(" ip address: {}", components[4]); + println!(" mac address: {}", components[5]); + println!(" reserved: {}", components[6]); + println!(" ott: {}", components[7]); + } + Err(err) => { + eprintln!("Error: {}", err); + } + } +} |
