@@ -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 判断指纹是否应该包含在指定类型中
959967func 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 {
0 commit comments