summaryrefslogtreecommitdiff
path: root/decryptor
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2024-07-05 21:09:56 +0800
committerGitHub <[email protected]>2024-07-05 21:09:56 +0800
commitd75b66b20217c3df378db138566c028038c0b9b3 (patch)
tree5e279fd59db392450b450d51b95e7d526f499da1 /decryptor
parent9aec9bfbd4d6370423927fdd7b8bc0bb0f8aa811 (diff)
parent94cc9f8998228d2b4f372e228919a5bab9c6b9ec (diff)
downloadchina-unicom-iptv-gd-d75b66b20217c3df378db138566c028038c0b9b3.tar.gz
china-unicom-iptv-gd-d75b66b20217c3df378db138566c028038c0b9b3.zip
Merge pull request #2 from lizhineng/decrypt
Find a possible key for authinfo
Diffstat (limited to 'decryptor')
-rw-r--r--decryptor/Cargo.lock147
-rw-r--r--decryptor/Cargo.toml8
-rw-r--r--decryptor/src/main.rs65
3 files changed, 220 insertions, 0 deletions
diff --git a/decryptor/Cargo.lock b/decryptor/Cargo.lock
new file mode 100644
index 0000000..ee6196f
--- /dev/null
+++ b/decryptor/Cargo.lock
@@ -0,0 +1,147 @@
+# 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",
+]
+
+[[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 = "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 = "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 = "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"
diff --git a/decryptor/Cargo.toml b/decryptor/Cargo.toml
new file mode 100644
index 0000000..80d0338
--- /dev/null
+++ b/decryptor/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "decryptor"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+hex = "0.4.3"
+openssl = "0.10.64"
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);
+ }
+ }
+}