Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit readme and change command #16

Merged
merged 2 commits into from
Nov 20, 2023
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
60 changes: 20 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,31 @@
# BlazeHTTP
<h1 align="center">最好用的 WAF 测试工具</h1>
<p align="center">
<img src="./images/blazehttp_cmd.gif">
</p>

一个可以帮您测试 WAF 关键指标的工具

主要为了解决下面问题:
## 测试指标
| 指标 | 描述 | 统计方法 |
| ---- | ---- | ---- |
| 检出率 | 用来反应 WAF 检测能力的全面性,没有检出即为 ”漏报“。 | 攻击样本拦截数量 |
| 误报率 | 用来反应对正常流量的干扰,不靠谱的结果即为 ”误报“。 | 正常样本拦截数量 |
| 准确率 | 准确率是检出率和误报率的综合指标,避免漏报和误报顾此失彼。 | |
| 检测耗时 | 用来反应 WAF 性能,耗时越大则性能越差。 | |

1. 标准库不支持解析`畸形的HTTP请求`
2. 没有免费的工具发送`大量`的`HTTP请求`
3. 没有免费的工具可以测试 WAF 的关键指标
## 🚛 下载代码

> 如果项目对您有用, 欢迎star、fork!
> 如果项目有任何问题,欢迎提PR!

## 使用帮助

### 编译 or 下载 release

```bash
go build -o ./build/blazehttp ./cmd/blazehttp
``` bash
git clone https://github.com/chaitin/blazehttp.git && cd blazehttp
```

### 开始测试

```bash
./build/blazehttp http://127.0.0.1:8008
sending 100% |██████████████████████████████████████████| (33669/33669, 943 it/s) [35s:0s]
TP[攻击拦截]: 412 TN[正常放行]: 33071 FP[误报]: 23 FN[漏报]: 163
总样本数量: 33669 成功: 33669 错误: 0
检出率: 71.65%
误报率: 5.29%
准确率: 99.45%
## 🚀 一键运行

90% 平均耗时: 0.67毫秒
99% 平均耗时: 0.87毫秒
平均耗时: 0.87毫秒
``` bash
bash build.sh && ./build/blazehttp -t http://127.0.0.1:8008
```

### 环境准备(推荐)

nginx.conf
## 🕹️ 靶机服务

``` conf
location / {
return 200 'hello WAF!';
default_type text/plain;
}
```
启动 web 服务,并接入 waf
``` bash
docker run -d -p 8088:80 -v /path/to/nginx.conf:/etc/nginx/nginx.conf -d nginx:latest
```
docker run -d -p 8080:80 --name hello_waf -d co0ontty/hello_waf:latest
```
8 changes: 1 addition & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@
rm -rf ./build/
mkdir ./build/

export CGO_ENABLED=0

GOOS=windows GOARCH=amd64 go build -o ./build/blazehttp_windows.exe ./cmd/blazehttp
GOOS=darwin GOARCH=arm64 go build -o ./build/blazehttp_mac_m1 ./cmd/blazehttp
GOOS=darwin GOARCH=amd64 go build -o ./build/blazehttp_mac_x64 ./cmd/blazehttp
GOOS=linux GOARCH=arm64 go build -o ./build/blazehttp_linux_arm64 ./cmd/blazehttp
GOOS=linux GOARCH=amd64 go build -o ./build/blazehttp_linux_x64 ./cmd/blazehttp
go build -o ./build/blazehttp ./cmd/blazehttp
20 changes: 5 additions & 15 deletions cmd/blazehttp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/tls"
"flag"
"fmt"
"math"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -263,25 +262,16 @@ func main() {
}
}

fmt.Printf("TP[攻击拦截]: %d TN[正常放行]: %d FP[误报]: %d FN[漏报]: %d\n", TP, TN, FP, FN)
fmt.Printf("总样本数量: %d 成功: %d 错误: %d\n", len(fileList), success, (len(fileList) - success))
fmt.Printf("检出率: %.2f%%\n", float64(TP)*100/float64(TP+FN))
fmt.Printf("误报率: %.2f%%\n", float64(FP)*100/float64(TP+FP))
fmt.Printf("准确率: %.2f%%\n\n", float64(TP+TN)*100/float64(TP+TN+FP+FN))
fmt.Printf("检出率: %.2f%% (恶意样本总数: %d , 正确拦截: %d , 漏报放行: %d)\n", float64(TP)*100/float64(TP+FN), TP+FN, TP, FN)
fmt.Printf("误报率: %.2f%% (正常样本总数: %d , 正确放行: %d , 误报拦截: %d)\n", float64(FP)*100/float64(TN+FP), TN+FP, TN, FP)
fmt.Printf("准确率: %.2f%% (正确拦截 + 正确放行)/样本总数 \n", float64(TP+TN)*100/float64(TP+TN+FP+FN))

all := len(elap)
p90 := int(math.Ceil(float64(all) * 0.9))
p99 := int(math.Ceil(float64(all) * 0.99))
sort.Slice(elap, func(i, j int) bool { return elap[i] < elap[j] })
var sum int64 = 0
for i, v := range elap {
for _, v := range elap {
sum += v
if i == p90 {
fmt.Printf("90%% 平均耗时: %.2f毫秒\n", float64(sum)/float64(p90)/1000000)
} else if i == p99 {
fmt.Printf("99%% 平均耗时: %.2f毫秒\n", float64(sum)/float64(p90)/1000000)
break
}
}
fmt.Printf("平均耗时: %.2f毫秒\n", float64(sum)/float64(p90)/1000000)
fmt.Printf("平均耗时: %.2f毫秒\n", float64(sum)/float64(all)/1000000)
}
Binary file added images/blazehttp_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.