Merge pull request #473 from cdxiaodong/dev

添加了端口排除,用来绕过端口蜜罐, 我看代码里面已经有写了 但是不能直接命令行参数调过去
This commit is contained in:
ZacharyZcR 2025-04-20 19:19:00 +08:00 committed by GitHub
commit e4833fd5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -3,9 +3,10 @@ package Common
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/fatih/color"
"os" "os"
"strings" "strings"
"github.com/fatih/color"
) )
func Banner() { func Banner() {
@ -65,6 +66,7 @@ func Flag(Info *HostInfo) {
flag.StringVar(&Info.Host, "h", "", GetText("flag_host")) flag.StringVar(&Info.Host, "h", "", GetText("flag_host"))
flag.StringVar(&ExcludeHosts, "eh", "", GetText("flag_exclude_hosts")) flag.StringVar(&ExcludeHosts, "eh", "", GetText("flag_exclude_hosts"))
flag.StringVar(&Ports, "p", MainPorts, GetText("flag_ports")) flag.StringVar(&Ports, "p", MainPorts, GetText("flag_ports"))
flag.StringVar(&ExcludePorts, "ep", "", GetText("flag_exclude_ports"))
flag.StringVar(&HostsFile, "hf", "", GetText("flag_hosts_file")) flag.StringVar(&HostsFile, "hf", "", GetText("flag_hosts_file"))
flag.StringVar(&PortsFile, "pf", "", GetText("flag_ports_file")) flag.StringVar(&PortsFile, "pf", "", GetText("flag_ports_file"))

View File

@ -275,6 +275,16 @@ func parsePorts() error {
return nil return nil
} }
// parseExcludePorts 解析排除端口配置
// 更新全局排除端口配置
func parseExcludePorts() {
if ExcludePorts != "" {
LogInfo(GetText("exclude_ports", ExcludePorts))
// 确保排除端口被正确设置到全局配置中
// 这将由PortScan函数在处理端口时使用
}
}
// ReadFileLines 读取文件内容并返回非空行的切片 // ReadFileLines 读取文件内容并返回非空行的切片
// 通用的文件读取函数,处理文件打开、读取和错误报告 // 通用的文件读取函数,处理文件打开、读取和错误报告
func ReadFileLines(filename string) ([]string, error) { func ReadFileLines(filename string) ([]string, error) {
@ -321,6 +331,9 @@ func ParseInput(Info *HostInfo) error {
// 处理端口配置组合 // 处理端口配置组合
processPortsConfig() processPortsConfig()
// 处理排除端口配置
parseExcludePorts()
// 处理额外用户名和密码 // 处理额外用户名和密码
processExtraCredentials() processExtraCredentials()
@ -381,6 +394,11 @@ func processPortsConfig() {
} }
LogInfo(GetText("extra_ports", AddPorts)) LogInfo(GetText("extra_ports", AddPorts))
} }
// 确保排除端口配置被记录
if ExcludePorts != "" {
LogInfo(GetText("exclude_ports_applied", ExcludePorts))
}
} }
// processExtraCredentials 处理额外的用户名和密码 // processExtraCredentials 处理额外的用户名和密码