Skip to content

Commit 045e826

Browse files
committed
fix Katana UniqueId
1 parent 59bc561 commit 045e826

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

pkg/mode/active.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/yhy0/Jie/crawler/crawlergo/model"
1414
"github.com/yhy0/Jie/fingprints"
1515
"github.com/yhy0/Jie/pkg/input"
16+
"github.com/yhy0/Jie/pkg/mitmproxy/go-mitmproxy/proxy"
1617
"github.com/yhy0/Jie/pkg/protocols/httpx"
1718
"github.com/yhy0/Jie/pkg/task"
1819
"github.com/yhy0/Jie/pkg/util"
@@ -186,7 +187,16 @@ func Katana(target string, waf []string, t *task.Task, fingerprint []string) []s
186187
Fingerprints: fingerprint,
187188
Waf: waf,
188189
Resp: resp,
189-
UniqueId: util.UUID(), // 这里爬虫中已经判断过了,所以生成一个 uuid 就行
190+
// UniqueId: util.UUID(), // 这里爬虫中已经判断过了,所以生成一个 uuid 就行
191+
// 需要先自己实现,Katana 去重逻辑不太行
192+
UniqueId: util.UniqueId(&proxy.Request{
193+
Method: result.Request.Method,
194+
URL: parseUrl,
195+
Header: headers,
196+
Body: []byte(result.Request.Body),
197+
}),
198+
RawRequest: result.Request.Raw,
199+
RawResponse: result.Response.Raw,
190200
}
191201

192202
// 分发扫描任务

pkg/util/uniqueness.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func UniqueId(req *proxy.Request) string {
3333
logging.Logger.Errorln(err)
3434
return ""
3535
}
36-
36+
3737
return key
3838
}
3939

@@ -49,17 +49,17 @@ func getRequestKey(req *proxy.Request) (string, error) {
4949
} else {
5050
host = req.URL.Host
5151
}
52-
52+
5353
// 将请求方法和 URL(不包括查询参数)连接在一起
5454
data := req.Method + req.URL.Scheme + "://" + host + req.URL.Path
55-
55+
5656
// 提取查询参数的名称 有的即使是 POST 请求,url请求路径中也会存在参数,所以这里全部都要提取
5757
var paramNames []string
5858
queryParams := req.URL.Query()
5959
for paramName := range queryParams {
6060
paramNames = append(paramNames, paramName)
6161
}
62-
62+
6363
if req.Method == "POST" {
6464
contentType := req.Header.Get("Content-Type")
6565
if strings.Contains(contentType, "application/x-www-form-urlencoded") {
@@ -91,13 +91,13 @@ func getRequestKey(req *proxy.Request) (string, error) {
9191
}
9292
}
9393
}
94-
94+
9595
// 对查询参数名称进行排序,以确保相同的参数集合具有相同的哈希值
9696
sort.Strings(paramNames)
97-
97+
9898
// 将排序后的参数名称连接在一起并添加到数据字符串中
9999
data += strings.Join(paramNames, "")
100-
100+
101101
// 计算 MD5 哈希值
102102
hash := md5.Sum([]byte(data))
103103
return hex.EncodeToString(hash[:]), nil
@@ -109,29 +109,29 @@ func SimpleUniqueId(u string) string {
109109
if err != nil {
110110
return ""
111111
}
112-
112+
113113
if parseUrl.Scheme == "http" && strings.HasSuffix(parseUrl.Host, ":80") {
114114
parseUrl.Host = strings.TrimRight(parseUrl.Host, ":80")
115115
} else if parseUrl.Scheme == "https" && strings.HasSuffix(parseUrl.Host, ":443") {
116116
parseUrl.Host = strings.TrimRight(parseUrl.Host, ":443")
117117
}
118-
118+
119119
// 将请求方法和 URL(不包括查询参数)连接在一起
120120
data := parseUrl.Scheme + "://" + parseUrl.Host + parseUrl.Path
121-
121+
122122
// 提取查询参数的名称 有的即使是 POST 请求,url请求路径中也会存在参数,所以这里全部都要提取
123123
var paramNames []string
124124
queryParams := parseUrl.Query()
125125
for paramName := range queryParams {
126126
paramNames = append(paramNames, paramName)
127127
}
128-
128+
129129
// 对查询参数名称进行排序,以确保相同的参数集合具有相同的哈希值
130130
sort.Strings(paramNames)
131-
131+
132132
// 将排序后的参数名称连接在一起并添加到数据字符串中
133133
data += strings.Join(paramNames, "")
134-
134+
135135
// 计算 MD5 哈希值
136136
hash := md5.Sum([]byte(data))
137137
return hex.EncodeToString(hash[:])

scan/gadget/sensitive/key.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func KeyDetection(url, body string) {
117117
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
118118
Target: url,
119119
Payload: strings.Join(matchedRegexes, ","),
120-
Response: body,
120+
// Response: body, // todo js 这种文本过大,不显示了
121121
},
122122
Level: output.Medium,
123123
}

test/xss_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestDomXss(t *testing.T) {
5353
// Fingerprints: technologies,
5454
}
5555

56-
mode.Crawler("https://public-firing-range.appspot.com/dom/", nil, task, nil)
56+
mode.Crawlergo("https://public-firing-range.appspot.com/dom/", nil, task, nil)
5757
fmt.Println(count)
5858
}
5959

0 commit comments

Comments
 (0)