• This repository has been archived on 14/Jul/2024
  • Stars
    star
    1,755
  • Rank 26,530 (Top 0.6 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 1 year ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reverse engineered ChatGPT proxy


English | 简体中文

CI CI Docker Image

ninja

Reverse engineered ChatGPT proxy (bypass Cloudflare 403 Access Denied)

Features

  • API key acquisition
  • Email/password account authentication (Google/Microsoft third-party login not supported)
  • ChatGPT-API/OpenAI-API/ChatGPT-to-API Http API proxy (for third-party client access)
  • Support IP proxy pool (support using Ipv6 subnet as proxy pool)
  • ChatGPT WebUI
  • Very small memory footprint

Limitations: This cannot bypass OpenAI's outright IP ban

ArkoseLabs

Sending GPT4/GPT-3.5 (already grayscale)/Creating API-Key dialog requires sending Arkose Token as a parameter. There are only two supported solutions for the time being.

  1. Use HAR

    The ChatGPT official website sends a GPT4 session message, and the browser F12 downloads the https://tcr9i.chat.openai.com/fc/gt2/public_key/35536E1E-65B4-4D96-9D97-6ADB7EFF8147 interface. HAR log file, use the startup parameter --arkose-chat4-har-file to specify the HAR file path to use (if you do not specify a path, use the default path ~/.chat4.openai.com.har, you can directly upload and update HAR ), supports uploading and updating HAR, request path: /har/upload, optional upload authentication parameter: --arkose-har-upload-key

  2. Use YesCaptcha / CapSolver

    The platform performs verification code parsing, start the parameter --arkose-solver to select the platform (use YesCaptcha by default), --arkose-solver-key fill in Client Key

  • Both solutions are used, the priority is: HAR > YesCaptcha / CapSolver
  • YesCaptcha / CapSolver is recommended to be used with HAR. When the verification code is generated, the parser is called for processing. After verification, HAR is more durable.

Currently OpenAI has updated Login which requires verification of Arkose Token. The solution is the same as GPT4. Fill in the startup parameters and specify the HAR file --arkose-auth-har-file. If you don't want to upload, you can log in through the browser code, which is not required. To create an API-Key, you need to upload the HAR feature file related to the Platform. The acquisition method is the same as above.

Http Server

Public interface, * represents any URL suffix

API documentation

  • Platfrom API doc
  • Backend API doc

Basic services

  • ChatGPT WebUI
  • Expose ChatGPT-API/OpenAI-API proxies
  • API prefix is consistent with the official one
  • ChatGPT to API
  • Can access third-party clients
  • Can access IP proxy pool to improve concurrency

Parameter Description

  • --level, environment variable LOG, log level: default info
  • --bind, environment variable BIND, service listening address: default 0.0.0.0:7999,
  • --tls-cert, environment variable TLS_CERT', TLS certificate public key. Supported format: EC/PKCS8/RSA
  • --tls-key, environment variable TLS_KEY, TLS certificate private key
  • --proxies, Proxy, supports proxy pool, multiple proxies are separated by ,, format: protocol://user:pass@ip:port, if the local IP is banned, you need to turn off the use of direct IP when using the proxy pool, --disable-direct turns off direct connection, otherwise your banned local IP will be used according to load balancing
  • --workers, worker threads: default 1
  • --disable-webui, if you don’t want to use the default built-in WebUI, use this parameter to turn it off

...

Install

Making Releases has a precompiled deb package, binaries, in Ubuntu, for example:

wget https://github.com/gngpp/ninja/releases/download/v0.7.3/ninja-0.7.3-x86_64-unknown-linux-musl.deb
dpkg -i ninja-0.7.3-x86_64-unknown-linux-musl.deb
ninja run

There are pre-compiled ipk files in GitHub Releases, which currently provide versions of aarch64/x86_64 and other architectures. After downloading, use opkg to install, and use nanopi r4s as example:

wget https://github.com/gngpp/ninja/releases/download/v0.7.3/ninja_0.7.3_aarch64_generic.ipk
wget https://github.com/gngpp/ninja/releases/download/v0.7.3/luci-app-ninja_1.1.4-1_all.ipk
wget https://github.com/gngpp/ninja/releases/download/v0.7.3/luci-i18n-ninja-zh-cn_1.1.4-1_all.ipk

opkg install ninja_0.7.3_aarch64_generic.ipk
opkg install luci-app-ninja_1.1.4-1_all.ipk
opkg install luci-i18n-ninja-zh-cn_1.1.4-1_all.ipk
docker run --rm -it -p 7999:7999 --name=ninja \
  -e WORKERS=1 \
  -e LOG=info \
  gngpp/ninja:latest run
  • Docker Compose

CloudFlare Warp is not supported in your region (China), please delete it, or if your VPS IP can be directly connected to OpenAI, you can also delete it

version: '3'

services:
  ninja:
    image: ghcr.io/gngpp/ninja:latest
    container_name: ninja
    restart: unless-stopped
    environment:
      - TZ=Asia/Shanghai
      - PROXIES=socks5://warp:10000
    command: run
    ports:
      - "8080:7999"
    depends_on:
      - warp

  warp:
    container_name: warp
    image: ghcr.io/gngpp/warp:latest
    restart: unless-stopped

  watchtower:
    container_name: watchtower
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: --interval 3600 --cleanup
    restart: unless-stopped

Command Manual

$ ninja --help
Reverse engineered ChatGPT proxy

Usage: ninja [COMMAND]

Commands:
  run      Run the HTTP server
  stop     Stop the HTTP server daemon
  start    Start the HTTP server daemon
  restart  Restart the HTTP server daemon
  status   Status of the Http server daemon process
  log      Show the Http server daemon log
  gt       Generate config template file (toml format file)
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

$ ninja run --help
Run the HTTP server

Usage: ninja run [OPTIONS]

Options:
  -L, --level <LEVEL>
          Log level (info/debug/warn/trace/error) [env: LOG=] [default: info]
  -C, --config <CONFIG>
          Configuration file path (toml format file) [env: CONFIG=]
  -b, --bind <BIND>
          Server bind address [env: BIND=] [default: 0.0.0.0:7999]
  -W, --workers <WORKERS>
          Server worker-pool size (Recommended number of CPU cores) [default: 1]
      --concurrent-limit <CONCURRENT_LIMIT>
          Enforces a limit on the concurrent number of requests the underlying [default: 65535]
  -x, --proxies <PROXIES>
          Server proxies pool, Example: protocol://user:pass@ip:port [env: PROXIES=]
  -i, --interface <INTERFACE>
          Bind address for outgoing connections (or IPv6 subnet fallback to Ipv4) [env: INTERFACE=]
  -I, --ipv6-subnet <IPV6_SUBNET>
          IPv6 subnet, Example: 2001:19f0:6001:48e4::/64 [env: IPV4_SUBNET=]
      --disable-direct
          Disable direct connection [env: DISABLE_DIRECT=]
      --cookie-store
          Enabled Cookie Store [env: COOKIE_STORE=]
      --timeout <TIMEOUT>
          Client timeout (seconds) [default: 600]
      --connect-timeout <CONNECT_TIMEOUT>
          Client connect timeout (seconds) [default: 60]
      --tcp-keepalive <TCP_KEEPALIVE>
          TCP keepalive (seconds) [default: 60]
      --pool-idle-timeout <POOL_IDLE_TIMEOUT>
          Set an optional timeout for idle sockets being kept-alive [default: 90]
      --tls-cert <TLS_CERT>
          TLS certificate file path [env: TLS_CERT=]
      --tls-key <TLS_KEY>
          TLS private key file path (EC/PKCS8/RSA) [env: TLS_KEY=]
  -A, --auth-key <AUTH_KEY>
          Login Authentication Key [env: AUTH_KEY=]
      --api-prefix <API_PREFIX>
          WebUI api prefix [env: API_PREFIX=]
      --preauth-api <PREAUTH_API>
          PreAuth Cookie API URL [env: PREAUTH_API=] [default: https://ai.fakeopen.com/auth/preauth]
  -D, --disable-webui
          Disable WebUI [env: DISABLE_WEBUI=]
      --cf-site-key <CF_SITE_KEY>
          Cloudflare turnstile captcha site key [env: CF_SECRET_KEY=]
      --cf-secret-key <CF_SECRET_KEY>
          Cloudflare turnstile captcha secret key [env: CF_SITE_KEY=]
      --arkose-endpoint <ARKOSE_ENDPOINT>
          Arkose endpoint, Example: https://client-api.arkoselabs.com
      --arkose-chat3-har-file <ARKOSE_CHAT3_HAR_FILE>
          About the browser HAR file path requested by ChatGPT GPT-3.5 ArkoseLabs
      --arkose-chat4-har-file <ARKOSE_CHAT4_HAR_FILE>
          About the browser HAR file path requested by ChatGPT GPT-4 ArkoseLabs
      --arkose-auth-har-file <ARKOSE_AUTH_HAR_FILE>
          About the browser HAR file path requested by Auth ArkoseLabs
      --arkose-platform-har-file <ARKOSE_PLATFORM_HAR_FILE>
          About the browser HAR file path requested by Platform ArkoseLabs
  -K, --arkose-har-upload-key <ARKOSE_HAR_UPLOAD_KEY>
          HAR file upload authenticate key
  -s, --arkose-solver <ARKOSE_SOLVER>
          About ArkoseLabs solver platform [default: yescaptcha]
  -k, --arkose-solver-key <ARKOSE_SOLVER_KEY>
          About the solver client key by ArkoseLabs
  -T, --tb-enable
          Enable token bucket flow limitation
      --tb-store-strategy <TB_STORE_STRATEGY>
          Token bucket store strategy (mem/redis) [default: mem]
      --tb-redis-url <TB_REDIS_URL>
          Token bucket redis connection url [default: redis://127.0.0.1:6379]
      --tb-capacity <TB_CAPACITY>
          Token bucket capacity [default: 60]
      --tb-fill-rate <TB_FILL_RATE>
          Token bucket fill rate [default: 1]
      --tb-expired <TB_EXPIRED>
          Token bucket expired (seconds) [default: 86400]
  -B, --preauth-bind <PREAUTH_BIND>
          Preauth MITM server bind address [env: PREAUTH_BIND=] [default: 0.0.0.0:8000]
  -X, --preauth-upstream <PREAUTH_UPSTREAM>
          Preauth MITM server upstream proxy [env: PREAUTH_UPSTREAM=]
      --preauth-cert <PREAUTH_CERT>
          Preauth MITM server CA certificate file path [default: ca/cert.crt]
      --preauth-key <PREAUTH_KEY>
          Preauth MITM server CA private key file path [default: ca/key.pem]
  -h, --help
          Print help

Platform Support

  • Linux
    • x86_64-unknown-linux-musl
    • aarch64-unknown-linux-musl
    • armv7-unknown-linux-musleabi
    • armv7-unknown-linux-musleabihf
    • arm-unknown-linux-musleabi
    • arm-unknown-linux-musleabihf
    • armv5te-unknown-linux-musleabi
  • Windows
    • x86_64-pc-windows-msvc
  • MacOS
    • x86_64-apple-darwin
    • aarch64-apple-darwin

Compile

  • Linux compile, Ubuntu machine for example:
git clone https://github.com/gngpp/ninja.git && cd ninja
cargo build --release
  • OpenWrt Compile
cd package
svn co https://github.com/gngpp/ninja/trunk/openwrt
cd -
make menuconfig # choose LUCI->Applications->luci-app-ninja  
make V=s

Instructions

  • Open source projects can be modified, but please keep the original author information to avoid losing technical support.
  • Project is standing on the shoulders of other giants, thanks!
  • Submit an issue if there are errors, bugs, etc., and I will fix them.

Preview

img0 img1

More Repositories

1

thunder

Synology NAS thunder run on Linux
Rust
700
star
2

luci-theme-design

LuCI design theme (Suitable for lede)
CSS
312
star
3

js-fuck

无视ip、账号强开gpt-4o
240
star
4

vertx-ddns

基于 Vert.x 的 DDNS 解决方案。自动更新域名解析到本机IP, 支持的DNS服务商: Alidns(阿里云) 、 Dnspod(腾讯云) 、Cloudflare、华为云
Java
133
star
5

vproxy

An easy and powerful Rust HTTP/Socks5 Proxy
Rust
121
star
6

fs

Funcaptcha challenge solver server
Rust
108
star
7

rquest

An easy and powerful Rust HTTP/WebSocket Client featuring TLS/JA3/JA4/HTTP2 fingerprint impersonate
Rust
93
star
8

MSI-MEG-Z490I-Unify-Hackintosh-EFI

🖥 MSI MEG Z490I UNIFY + i9-10850k + Radeon RX5500 XT Hackintosh EFI(OpenCore)
70
star
9

Actions-OpenWrt

Lean♂DHDAXCW Actions OpenWrt for Nanopi R5C/R4SE/X86
Makefile
44
star
10

Asus-ROG-Strix-B460I_OC_Hackintosh-EFI

🖥ASUS ROG STRIX B460-I GAMING RX560 Hackintosh EFI(OpenCore)
C++
32
star
11

cbypass

Bypass C**f** in HTTP proxy
Python
29
star
12

deeplx

DeepL Pro to free API
Rust
25
star
13

pikvm-orangepizero2

PiKVM for orangepizero2
Shell
19
star
14

claude2

Claude2 to OpenAI API
Go
17
star
15

mayi

基于RBAC、OAuth2.1认证模式的微服务动态权限脚手架
Java
15
star
16

luci-app-design-config

LuCI design theme config plugin
Lua
15
star
17

vdns

vdns支持多云平台DNS解析,支持Terminal CLI 方式修改DNS记录,同时以服务形式提供DDNS支持。
Go
14
star
18

gemini

Google Gemini API proxy
Rust
12
star
19

luci-app-watchcat-plus

OpenWrt LuCI watchcat plugins
Lua
10
star
20

qrcode-token

终端QRCode扫码获取阿里云盘Refresh Token
Go
10
star
21

openwrt-scripts

Openwrt packages for Nanopi R4S、360v6
Shell
9
star
22

aliyundrive-cli

阿里云盘 Terminal CLI
Rust
6
star
23

CapSolver-CloudflareBypass

A Python/Node implementation to bypass Cloudflare 5s via capsolver.
Python
6
star
24

wgsdc

WireGuard peer to peer endpoint Service discovery and Configuration plugin
Rust
5
star
25

luci-app-wireguard-ui

WireGuard UI for OpenWrt
Makefile
4
star
26

NanoPi-R4SE

基于 Lean ♂ DHDAXCW 源码的 NanoPi R4SE的 OpenWrt 固件
Shell
3
star
27

vertx-nacos

Vertx服务注册到Nacos的Simple Example
Java
3
star
28

vlog

Golang log library Encapsulation
Go
3
star
29

go-toolkit

golang tool
Go
3
star
30

wg-quick

WireGuard wg-quick for OpenWrt
Makefile
3
star
31

authc

OpenAI Apple PreAuth Cookie Server
3
star
32

rsproxy

A lightweight reverse proxy server written in Rust, supporting HTTP/HTTPS/WebSocket protocols.
Rust
3
star
33

CapSolver-HCAPTCHA-Solver

A Python selenium implementation to bypass hcaptcha via capsolver.
Python
2
star
34

profiles

Script profiles
Rust
1
star
35

wallpaper

基于Jsoup的壁纸爬虫
Java
1
star
36

rurl

Easy CLI HTTP client for Impersonating Chrome/OkHttp request
Rust
1
star
37

ROG-B460I-OC-0.6.5

1
star
38

zeros

Zerotier API Terminal CLI manages lans and provides virtual LAN DNS services
Rust
1
star
39

lede-rockchip-mt7921

1
star
40

mayi-web

Vue
1
star
41

boring

BoringSSL bindings for the Rust programming language.
Rust
1
star