Skip to content

Commit 684143c

Browse files
committed
header support random str
1 parent d7ee3ef commit 684143c

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ Usage of ./httpx:
9090
▶ ./httpx -output TEST.db -server # 启动服务并访问 http://127.0.0.1:9100/
9191
```
9292

93+
```bash
94+
▶ ./httpx -targets domains.txt -header "Host: {{RAND}}.dnslog.cn" # 对应header的fuzz,搭配代理工具获取请求包,查询RAND字段
95+
```
96+
9397
## 逻辑查询
9498

9599
📢: 正常查询字符串时,必须添加""
@@ -155,3 +159,4 @@ body
155159
- [ ] 常见信息提取 github.com/mingrammer/commonregex
156160
- [x] 二维码识别、APK链接提取(需-get-path)
157161
- [ ] http2 detect
162+
- [ ] 功能整合: JSFinder

cmd/httpx/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/chromedp/cdproto/fetch"
1717
"github.com/gin-gonic/gin"
1818
"io/fs"
19+
"math/rand"
1920
"net/http"
2021
"net/url"
2122
"os"
@@ -44,6 +45,7 @@ func init() {
4445
os.Exit(1)
4546
}
4647
_ = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
48+
rand.Seed(time.Now().UnixNano())
4749
}
4850

4951
//go:embed website
@@ -99,7 +101,7 @@ func main() {
99101
flag.BoolVar(&conf.Rebuild, "rebuild", false, "rebuild data table")
100102
flag.BoolVar(&conf.Server, "server", false, "read the database by starting the web service")
101103

102-
flag.Var(&conf.Header, "header", "specify request header, example:\n-header 'Content-Type: application/json' -header 'Bypass: 127.0.0.1'")
104+
flag.Var(&conf.Header, "header", "specify request header, example:\n-header 'Content-Type: application/json' -header 'Bypass: 127.0.0.1'\n-header 'Host: {{RAND}}.dnslog.cn'")
103105
flag.StringVar(&conf.Method, "method", "GET", "request method, example:\n-method GET")
104106
flag.StringVar(&conf.Data, "data", "", "request body data, example:\n-data 'test=test'")
105107
flag.Parse()

config/blacklists.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ var OutOfRange = []string{
1313
"example.com",
1414
"qq.com",
1515
"wechat.com",
16-
"zhihu.com",
17-
"aliyun.",
18-
"apple.",
19-
"apache.org",
20-
"googlevideo.com",
21-
"google.cn",
22-
".google",
23-
"npmjs.org",
16+
"zhihu.com",
17+
"aliyun.",
18+
"apple.",
19+
"apache.org",
20+
"googlevideo.com",
21+
"google.cn",
22+
".google",
23+
"npmjs.org",
2424
}

pkg/requests/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (r *request) Run() error {
7979
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
8080
req.Header.Set("Connection", "close")
8181
for i := 0; i < len(r.conf.Headers); i++ {
82+
r.conf.Headers[i].Value = strings.ReplaceAll(r.conf.Headers[i].Value, "{{RAND}}", utils.RandString(10))
8283
if strings.ToUpper(r.conf.Headers[i].Name) == "HOST" {
8384
req.Host = r.conf.Headers[i].Value
8485
continue

pkg/screenshot/screenshot.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (c *chrome) listen(ctx context.Context, lock *sync.Mutex, request map[strin
222222
case *fetch.EventRequestPaused:
223223
// Add Headers
224224
// Can Not Set Host Header
225-
if len(c.conf_.Headers) == 0 || !c.conf_.IsExist(e.Request.URL) {
225+
if len(c.conf_.Headers) == 0 || !c.conf_.IsExist(strings.Trim(e.Request.URL, "/")) {
226226
go func() {
227227
err := fetch.ContinueRequest(e.RequestID).Do(cdp.WithExecutor(ctx, chromedp.FromContext(ctx).Target))
228228
if err != nil {
@@ -231,11 +231,19 @@ func (c *chrome) listen(ctx context.Context, lock *sync.Mutex, request map[strin
231231
}()
232232
} else {
233233
go func() {
234+
headers := make([]*fetch.HeaderEntry, 0)
235+
for i := 0; i < len(c.conf_.Headers); i++ {
236+
if strings.ToUpper(c.conf_.Headers[i].Name) == "HOST" {
237+
continue
238+
}
239+
c.conf_.Headers[i].Value = strings.ReplaceAll(c.conf_.Headers[i].Value, "{{RAND}}", utils.RandString(10))
240+
headers = append(headers, c.conf_.Headers[i])
241+
}
234242
err := fetch.ContinueRequest(e.RequestID).
235243
WithURL(e.Request.URL).
236244
WithMethod(c.conf_.Method).
237245
WithPostData(base64.StdEncoding.EncodeToString([]byte(c.conf_.Data))). // If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON)
238-
WithHeaders(c.conf_.Headers).
246+
WithHeaders(headers).
239247
Do(cdp.WithExecutor(ctx, chromedp.FromContext(ctx).Target))
240248
if err != nil {
241249
c.l.Error(err)

0 commit comments

Comments
 (0)