diff --git a/.gitignore b/.gitignore index b63ac3190..8540099ee 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ ca chat3.openai.com.har chat4.openai.com.har platform.openai.com.har -login.chat.openai.com.har \ No newline at end of file +login.chat.openai.com.har +auth0.openai.com.har +4.har \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 646b4718d..688a31333 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ninja" -version = "0.8.1" +version = "0.8.2" edition = "2021" description = "Reverse engineered ChatGPT proxy" license = "GPL-3.0" diff --git a/README.md b/README.md index 9afc60b37..9f82f2c2f 100644 --- a/README.md +++ b/README.md @@ -124,8 +124,8 @@ Sending `GPT-4/GPT-3.5/Creating API-Key` dialog requires sending `Arkose Token` Making [Releases](https://github.com/gngpp/ninja/releases/latest) has a precompiled deb package, binaries, in Ubuntu, for example: ```shell -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz -tar -xf ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/ninja-0.8.2-x86_64-unknown-linux-musl.tar.gz +tar -xf ninja-0.8.2-x86_64-unknown-linux-musl.tar.gz ./ninja run ``` @@ -134,11 +134,11 @@ tar -xf ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz There are pre-compiled ipk files in GitHub [Releases](https://github.com/gngpp/ninja/releases/latest), which currently provide versions of aarch64/x86_64 and other architectures. After downloading, use opkg to install, and use nanopi r4s as example: ```shell -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/ninja_0.8.1_aarch64_generic.ipk -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/luci-app-ninja_1.1.6-1_all.ipk -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/ninja_0.8.2_aarch64_generic.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/luci-app-ninja_1.1.6-1_all.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk -opkg install ninja_0.8.1_aarch64_generic.ipk +opkg install ninja_0.8.2_aarch64_generic.ipk opkg install luci-app-ninja_1.1.6-1_all.ipk opkg install luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk ``` diff --git a/README_zh.md b/README_zh.md index fb1738738..5b6bbc6cf 100644 --- a/README_zh.md +++ b/README_zh.md @@ -124,8 +124,8 @@ GitHub [Releases](https://github.com/gngpp/ninja/releases/latest) 中有预编译的 deb包,二进制文件,以Ubuntu为例: ```shell -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz -tar -xf ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/ninja-0.8.2-x86_64-unknown-linux-musl.tar.gz +tar -xf ninja-0.8.2-x86_64-unknown-linux-musl.tar.gz ./ninja run ``` @@ -134,11 +134,11 @@ tar -xf ninja-0.8.1-x86_64-unknown-linux-musl.tar.gz GitHub [Releases](https://github.com/gngpp/ninja/releases/latest) 中有预编译的 ipk 文件, 目前提供了 aarch64/x86_64 等架构的版本,下载后使用 opkg 安装,以 nanopi r4s 为例: ```shell -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/ninja_0.8.1_aarch64_generic.ipk -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/luci-app-ninja_1.1.6-1_all.ipk -wget https://github.com/gngpp/ninja/releases/download/v0.8.1/luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/ninja_0.8.2_aarch64_generic.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/luci-app-ninja_1.1.6-1_all.ipk +wget https://github.com/gngpp/ninja/releases/download/v0.8.2/luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk -opkg install ninja_0.8.1_aarch64_generic.ipk +opkg install ninja_0.8.2_aarch64_generic.ipk opkg install luci-app-ninja_1.1.6-1_all.ipk opkg install luci-i18n-ninja-zh-cn_1.1.6-1_all.ipk ``` diff --git a/openai/Cargo.toml b/openai/Cargo.toml index 8649fcf67..d62c4fed9 100644 --- a/openai/Cargo.toml +++ b/openai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openai" -version = "0.8.1" +version = "0.8.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/openai/src/arkose/crypto.rs b/openai/src/arkose/crypto.rs index 390ef95fb..67aaffc95 100644 --- a/openai/src/arkose/crypto.rs +++ b/openai/src/arkose/crypto.rs @@ -17,7 +17,8 @@ pub fn encrypt(data: &str, key: &str) -> anyhow::Result { pub fn decrypt(data: Vec, key: &str) -> anyhow::Result { let dec_data = ase_decrypt(data, key)?; - Ok(String::from_utf8(dec_data)?) + let data = String::from_utf8(dec_data)?; + Ok(data) } fn aes_encrypt(content: &str, password: &str) -> anyhow::Result { @@ -71,7 +72,8 @@ fn ase_decrypt(content: Vec, password: &str) -> anyhow::Result> { .map(|i| u8::from_str_radix(&encode_data.s[i..i + 2], 16)) .collect(); - let (key, iv) = default_evp_kdf(password.as_bytes(), &salt?).map_err(|s| anyhow::anyhow!(s))?; + let (key, _) = default_evp_kdf(password.as_bytes(), &salt?).map_err(|s| anyhow::anyhow!(s))?; + let iv = hex_string_to_bytes(&encode_data.iv).ok_or(anyhow!("hex decode error"))?; use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, KeyIvInit}; type Aes256CbcDec = cbc::Decryptor; @@ -81,8 +83,8 @@ fn ase_decrypt(content: Vec, password: &str) -> anyhow::Result> { let decode_bytes = Aes256CbcDec::new_from_slices(&key, &iv)? .decrypt_padded_b2b_mut::(&decode_ct, &mut buf) .map_err(|err| anyhow::anyhow!(err))?; - - Ok(decode_bytes.to_vec()) + let decode_data = decode_bytes.to_vec(); + Ok(decode_data) } fn evp_kdf( @@ -125,6 +127,33 @@ fn evp_kdf( Ok(derived_key_bytes[..key_size * 4].to_vec()) } +fn hex_string_to_bytes(hex_string: &str) -> Option> { + let mut bytes = Vec::new(); + let mut buffer = 0; + let mut buffer_length = 0; + + for hex_char in hex_string.chars() { + if let Some(digit) = hex_char.to_digit(16) { + buffer = (buffer << 4) | digit; + buffer_length += 1; + + if buffer_length == 2 { + bytes.push(buffer as u8); + buffer = 0; + buffer_length = 0; + } + } else { + return None; + } + } + + if buffer_length > 0 { + return None; + } + + Some(bytes) +} + fn default_evp_kdf(password: &[u8], salt: &[u8]) -> Result<(Vec, Vec), &'static str> { let key_size = 256 / 32; let iv_size = 128 / 32; diff --git a/openwrt/ninja/Makefile b/openwrt/ninja/Makefile index 5077ea547..7203ddddb 100644 --- a/openwrt/ninja/Makefile +++ b/openwrt/ninja/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ninja -PKG_VERSION:=0.8.1 +PKG_VERSION:=0.8.2 PKG_LICENSE:=MIT PKG_MAINTAINER:=gngpp