Skip to content

Commit

Permalink
bump version to v0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 committed Nov 16, 2023
1 parent 2d175e2 commit f55d67a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ ca
chat3.openai.com.har
chat4.openai.com.har
platform.openai.com.har
login.chat.openai.com.har
login.chat.openai.com.har
auth0.openai.com.har
4.har
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```
Expand Down
12 changes: 6 additions & 6 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion openai/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
37 changes: 33 additions & 4 deletions openai/src/arkose/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub fn encrypt(data: &str, key: &str) -> anyhow::Result<String> {

pub fn decrypt(data: Vec<u8>, key: &str) -> anyhow::Result<String> {
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<EncryptionData> {
Expand Down Expand Up @@ -71,7 +72,8 @@ fn ase_decrypt(content: Vec<u8>, password: &str) -> anyhow::Result<Vec<u8>> {
.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<aes::Aes256>;
Expand All @@ -81,8 +83,8 @@ fn ase_decrypt(content: Vec<u8>, password: &str) -> anyhow::Result<Vec<u8>> {
let decode_bytes = Aes256CbcDec::new_from_slices(&key, &iv)?
.decrypt_padded_b2b_mut::<Pkcs7>(&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(
Expand Down Expand Up @@ -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<Vec<u8>> {
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<u8>, Vec<u8>), &'static str> {
let key_size = 256 / 32;
let iv_size = 128 / 32;
Expand Down
2 changes: 1 addition & 1 deletion openwrt/ninja/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gngppz@gmail.com>
Expand Down

0 comments on commit f55d67a

Please sign in to comment.