Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ on:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
- cron: '3 3 3 * *'
jobs:
security_audit:
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
Expand All @@ -23,6 +21,7 @@ on:
jobs:
analyze:
name: Analyze
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
actions: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/committed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on: [pull_request]
jobs:
committed:
name: Lint Commits
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rustdoc
on:
push:
pull_request:
branches:
- main

Expand All @@ -11,7 +11,7 @@ env:

jobs:
rustdoc:
if: github.repository == 'emo-cat/rust-template'
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@ on:
- '!/*.md'
- '!/docs/**'
- "!/LICENSE-*"
push:
branches:
- main
paths:
- '**'
- '!/*.md'
- '!/docs/**'
- "!/LICENSE-*"
jobs:
ci:
name: CI
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
needs: [ test,rustfmt,clippy ]
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Done
run: exit 0
test:
name: Test
if: github.actor != 'dependabot[bot]'
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
strategy:
matrix:
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
Expand All @@ -48,7 +40,7 @@ jobs:
run: cargo test --workspace
rustfmt:
name: rustfmt
if: github.actor != 'dependabot[bot]'
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -67,7 +59,7 @@ jobs:
run: cargo fmt --all -- --check
clippy:
name: clippy
if: github.actor != 'dependabot[bot]'
if: startsWith(github.repository, 'emo-crab/') && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

.idea/
.idea/

# MITM proxy CA certificate storage
.slinger-mitm*/
*.pem
75 changes: 24 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
[package]
name = "slinger" #改这个
version = "0.2.9"
[workspace]
resolver = "2"
members = [
"slinger",
"slinger-mitm",
]

[workspace.package]
edition = "2021"
description = "An HTTP Client for Rust designed for hackers."
homepage = "https://github.com/emo-crab/slinger"
repository = "https://github.com/emo-crab/slinger"
authors = ["Kali-Team <root@kali-team.cn>"]
readme = "README.md"
license = "GPL-3.0-only"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
repository = "https://github.com/emo-crab/slinger"
homepage = "https://github.com/emo-crab/slinger"

[workspace.dependencies]
# Shared dependencies
thiserror = "2"
http = "1.3.1"
socket2 = "0.6.1"
bytes = "1.6.1"
tracing = "0.1"
tokio = { version = "1", default-features = false }
tokio-rustls = { version = "0.26.4", features = ["ring", "tls12"], default-features = false }
rustls-pemfile = "2"
rustls-pki-types = { version = "1.1.0", features = ["alloc"] }
rustls-native-certs = "0.8"

#https://github.com/johnthagen/min-sized-rust
[profile.release]
opt-level = "z" # Optimize for size.
lto = true # Enable Link Time Optimization
Expand All @@ -20,6 +34,7 @@ strip = true # Automatically strip symbols from the binary.

[profile.dev.package."*"]
opt-level = 3

[profile.test]
opt-level = 3
lto = "thin"
Expand All @@ -28,45 +43,3 @@ lto = "thin"
lto = true
codegen-units = 1
opt-level = 3


[dependencies]
thiserror = "2"
http = { version = "1.3.1" }
percent-encoding = "2.1"
socket2 = "0.6.1"
bytes = "1.6.1"
base64 = "0.22"
flate2 = { version = "1.0", default-features = false, features = ["default"], optional = true }
serde = { version = "1", features = ["derive"], optional = true }
http-serde = { version = "2.1.0", optional = true }
encoding_rs = { version = "0.8", optional = true }
mime = { version = "0.3.17", optional = true }
cookie = { version = "0.18.1", optional = true }
tokio-rustls = { version = "0.26.2", optional = true, features = ["ring", "tls12"], default-features = false }
tokio = { version = "1", default-features = false, features = ["net", "io-util", "time"] }
rustls-pemfile = { version = "2", optional = true }
rustls-pki-types = { version = "1.1.0", features = ["alloc"], optional = true }
rustls-native-certs = { version = "0.8", optional = true }
h2 = { version = "0.4", optional = true }
schemars = { version = "1.0.4", optional = true, features = ["bytes1"] }
[dev-dependencies]
tokio = { version = "1.0", default-features = false, features = ["macros", "rt-multi-thread"] }
futures = { version = "0.3.31" }
serde_json = "1"
tokio-native-tls = "0.3"
openssl = { version = "0.10.71", features = ["vendored"] }
[features]
default = []
# TLS feature hierarchy:
# - `tls`: Base TLS feature flag (enables TLS types and interfaces, but no backend)
# - `rustls`: Rustls TLS backend (requires `tls`)
# Note: If `tls` is enabled without a backend, you must provide a custom TLS connector callback.
tls = []
rustls = ["tls", "tokio-rustls", "rustls-pemfile", "rustls-pki-types", "rustls-native-certs"]
http2 = ["dep:h2"]
cookie = ["dep:cookie"]
charset = ["dep:encoding_rs", "dep:mime"]
serde = ["dep:serde", "http-serde"]
gzip = ["flate2"]
schema = ["dep:schemars", "serde"]
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*** that would make this better, please fork the repo and create a pull request
*** or simply open an issue with the tag "enhancement".
*** Don't forget to give the project a star!
*** Thanks again! Now go create something AMAZING! :D
*** Thanks again! Now go create something AMAZING!
-->


Expand Down Expand Up @@ -57,12 +57,28 @@

![Product Name Screen Shot][product-screenshot]

**Slinger** is a workspace containing:

### slinger
The core HTTP client library for Rust designed for hackers.

- customizable redirect policy
- http/https and socks5/socks5h proxies
- cookie store
- raw socket request
- HTTPS via tls

### slinger-mitm
A Man-in-the-Middle (MITM) proxy with transparent HTTPS traffic interception, similar to Burp Suite.

- Automatic CA certificate generation with improved certificate management (inspired by [hudsucker](https://github.com/omjadas/hudsucker))
- Certificate caching for high performance
- Transparent HTTPS interception using rustls backend
- Traffic interception and modification interfaces
- Random serial numbers and clock skew handling
- Reuses slinger's Socket implementation
- Minimal external dependencies

<p align="right">(<a href="#readme-top">back to top</a>)</p>


Expand All @@ -71,11 +87,13 @@

## Getting Started

### Using slinger (HTTP Client)

This example enables some optional features, so your `Cargo.toml` could look like this:

```toml
[dependencies]
slinger = { version = "0.2.2", features = ["serde", "cookie", "charset", "tls", "rustls", "gzip"] }
slinger = { version = "0.2.9", features = ["serde", "cookie", "charset", "tls", "rustls", "gzip"] }
```

And then the code:
Expand All @@ -89,6 +107,40 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```

### Using slinger-mitm (MITM Proxy)

Add to your `Cargo.toml`:

```toml
[dependencies]
slinger-mitm = { version = "0.2.9" }
tokio = { version = "1", features = ["full"] }
```

Example code:

```rust,no_run
use slinger_mitm::{MitmConfig, MitmProxy, Interceptor};
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = MitmConfig::default();
let proxy = MitmProxy::new(config).await?;

// Add logging interceptor
let handler = proxy.interceptor_handler();
let mut h = handler.write().await;
h.add_request_interceptor(Arc::new(Interceptor::logging()));
drop(h);

proxy.start("127.0.0.1:8080").await?;
Ok(())
}
```

See [slinger-mitm/README.md](slinger-mitm/README.md) for more details on MITM proxy usage.

<!-- FEATURES -->

## Features
Expand Down
34 changes: 34 additions & 0 deletions slinger-mitm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "slinger-mitm"
version = "0.0.1"
edition.workspace = true
description = "MITM proxy with transparent traffic interception using rustls backend for slinger"
homepage.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true

[dependencies]
# Core slinger library
slinger = { path = "../slinger", features = ["tls", "rustls", "http2"] }
# Workspace dependencies
thiserror.workspace = true
http.workspace = true
bytes.workspace = true
tracing.workspace = true
tokio = { workspace = true, features = ["net", "io-util", "rt", "sync", "fs", "macros"] }
tokio-rustls = { workspace = true }
rustls-pemfile.workspace = true

# MITM-specific dependencies
rcgen = { version = "0.14", features = ["x509-parser"] }
time = "0.3"
async-trait = "0.1"
moka = { version = "0.12", features = ["future"] }
rand = "0.8"

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "test-util"] }

[features]
default = []
Loading
Loading