Skip to content

Commit 6f2168d

Browse files
committed
chore: update resources
1 parent 4f90dd6 commit 6f2168d

File tree

8 files changed

+33
-14
lines changed

8 files changed

+33
-14
lines changed

cmd/transform/transform.go

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,27 @@ func transformFingersYAML(repoDir, fingerprintType, outputFile string) error {
884884
return fmt.Errorf("找不到目录: %s,请先下载", repoDir)
885885
}
886886

887+
// 根据类型确定扫描目录
888+
var scanDir string
889+
if fingerprintType == "http" {
890+
scanDir = filepath.Join(repoDir, "fingers", "http")
891+
} else if fingerprintType == "socket" {
892+
scanDir = filepath.Join(repoDir, "fingers", "socket")
893+
} else {
894+
return fmt.Errorf("不支持的指纹类型: %s", fingerprintType)
895+
}
896+
897+
if !fileExists(scanDir) {
898+
return fmt.Errorf("找不到目录: %s", scanDir)
899+
}
900+
887901
fmt.Printf("正在收集 %s 类型的指纹...\n", fingerprintType)
902+
fmt.Printf("扫描目录: %s\n", scanDir)
888903

889904
var fingerprints []map[string]interface{}
890905

891906
// 递归遍历目录
892-
err := filepath.Walk(repoDir, func(path string, info os.FileInfo, err error) error {
907+
err := filepath.Walk(scanDir, func(path string, info os.FileInfo, err error) error {
893908
if err != nil {
894909
return err
895910
}
@@ -915,22 +930,15 @@ func transformFingersYAML(repoDir, fingerprintType, outputFile string) error {
915930
// 尝试解析为对象
916931
var dataMap map[string]interface{}
917932
if err := yaml.Unmarshal(content, &dataMap); err == nil {
918-
// 根据类型过滤
919-
if shouldIncludeFingerprint(dataMap, fingerprintType) {
920-
fingerprints = append(fingerprints, dataMap)
921-
}
933+
fingerprints = append(fingerprints, dataMap)
922934
return nil
923935
}
924936

925937
// 尝试解析为数组
926938
var dataArray []map[string]interface{}
927939
if err := yaml.Unmarshal(content, &dataArray); err == nil {
928-
// 遍历数组中的每个元素
929-
for _, item := range dataArray {
930-
if shouldIncludeFingerprint(item, fingerprintType) {
931-
fingerprints = append(fingerprints, item)
932-
}
933-
}
940+
// 将数组中的每个元素添加到指纹列表
941+
fingerprints = append(fingerprints, dataArray...)
934942
return nil
935943
}
936944

@@ -957,6 +965,16 @@ func transformFingersYAML(repoDir, fingerprintType, outputFile string) error {
957965

958966
// shouldIncludeFingerprint 判断指纹是否应该包含在指定类型中
959967
func shouldIncludeFingerprint(data map[string]interface{}, fingerprintType string) bool {
968+
// 检查 protocol 字段(fingers 格式)
969+
if protocol, ok := data["protocol"].(string); ok {
970+
if fingerprintType == "http" {
971+
return protocol == "http" || protocol == "https"
972+
} else if fingerprintType == "socket" {
973+
return protocol == "tcp" || protocol == "udp"
974+
}
975+
}
976+
977+
// 兼容 neutron/nuclei 格式
960978
if fingerprintType == "http" {
961979
// HTTP 指纹包含 http 或 requests 字段
962980
if _, hasHTTP := data["http"]; hasHTTP {

fingerprinthub/fingerprinthub.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8+
"io/ioutil"
89
"net/http"
910
"strings"
1011
"sync"
@@ -65,7 +66,7 @@ func (c *CachedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
6566
}
6667

6768
// 读取响应体
68-
bodyBytes, err := io.ReadAll(resp.Body)
69+
bodyBytes, err := ioutil.ReadAll(resp.Body)
6970
resp.Body.Close()
7071
if err != nil {
7172
return nil, err
-102 KB
Binary file not shown.
-7.26 KB
Binary file not shown.

resources/fingers_http.json.gz

108 KB
Binary file not shown.

resources/fingers_socket.json.gz

424 Bytes
Binary file not shown.

resources/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"compress/gzip"
66
"encoding/json"
7-
"io"
7+
"io/ioutil"
88

99
"strings"
1010

@@ -72,5 +72,5 @@ func DecompressGzip(data []byte) ([]byte, error) {
7272
}
7373
defer reader.Close()
7474

75-
return io.ReadAll(reader)
75+
return ioutil.ReadAll(reader)
7676
}

resources/wappalyzer.json.gz

321 KB
Binary file not shown.

0 commit comments

Comments
 (0)