mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-13 21:02:44 +08:00
fix: 修复一些逻辑问题
This commit is contained in:
parent
235e2aee60
commit
86b6faec79
106
Common/Flag.go
106
Common/Flag.go
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Banner() {
|
func Banner() {
|
||||||
@ -31,109 +30,28 @@ func Banner() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清屏并隐藏光标
|
|
||||||
fmt.Print("\033[H\033[2J\033[?25l")
|
|
||||||
defer fmt.Print("\033[?25h")
|
|
||||||
|
|
||||||
// 创建边框
|
// 创建边框
|
||||||
topBorder := "┌" + strings.Repeat("─", maxLength+2) + "┐"
|
topBorder := "┌" + strings.Repeat("─", maxLength+2) + "┐"
|
||||||
bottomBorder := "└" + strings.Repeat("─", maxLength+2) + "┘"
|
bottomBorder := "└" + strings.Repeat("─", maxLength+2) + "┘"
|
||||||
|
|
||||||
// 呼吸灯效果循环
|
// 打印banner
|
||||||
for cycle := 0; cycle < 2; cycle++ { // 2个完整循环
|
fmt.Println(topBorder)
|
||||||
// 亮度由暗到亮
|
|
||||||
for i := 0; i <= 10; i++ {
|
|
||||||
fmt.Print("\033[H")
|
|
||||||
dim := float64(i) / 10.0
|
|
||||||
|
|
||||||
printDimmed(topBorder, colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
for lineNum, line := range lines {
|
|
||||||
printDimmed("│ ", colors[0], dim)
|
|
||||||
for _, char := range line {
|
|
||||||
printDimmed(string(char), colors[lineNum%2], dim)
|
|
||||||
}
|
|
||||||
padding := maxLength - len(line)
|
|
||||||
printDimmed(strings.Repeat(" ", padding)+" │", colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
|
|
||||||
printDimmed(bottomBorder, colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
vStr := fmt.Sprintf(" Fscan Version: %s", version)
|
|
||||||
printDimmed(vStr, colors[1], dim)
|
|
||||||
fmt.Print("\n\n")
|
|
||||||
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 亮度由亮到暗
|
|
||||||
for i := 10; i >= 0; i-- {
|
|
||||||
fmt.Print("\033[H")
|
|
||||||
dim := float64(i) / 10.0
|
|
||||||
|
|
||||||
printDimmed(topBorder, colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
for lineNum, line := range lines {
|
|
||||||
printDimmed("│ ", colors[0], dim)
|
|
||||||
for _, char := range line {
|
|
||||||
printDimmed(string(char), colors[lineNum%2], dim)
|
|
||||||
}
|
|
||||||
padding := maxLength - len(line)
|
|
||||||
printDimmed(strings.Repeat(" ", padding)+" │", colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
|
|
||||||
printDimmed(bottomBorder, colors[0], dim)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
vStr := fmt.Sprintf(" Fscan Version: %s", version)
|
|
||||||
printDimmed(vStr, colors[1], dim)
|
|
||||||
fmt.Print("\n\n")
|
|
||||||
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 最后显示完整亮度的版本
|
|
||||||
fmt.Print("\033[H")
|
|
||||||
printDimmed(topBorder, colors[0], 1.0)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
for lineNum, line := range lines {
|
for lineNum, line := range lines {
|
||||||
printDimmed("│ ", colors[0], 1.0)
|
fmt.Print("│ ")
|
||||||
for _, char := range line {
|
// 使用对应的颜色打印每个字符
|
||||||
printDimmed(string(char), colors[lineNum%2], 1.0)
|
c := color.New(colors[lineNum%2])
|
||||||
}
|
c.Print(line)
|
||||||
|
// 补齐空格
|
||||||
padding := maxLength - len(line)
|
padding := maxLength - len(line)
|
||||||
printDimmed(strings.Repeat(" ", padding)+" │", colors[0], 1.0)
|
fmt.Printf("%s │\n", strings.Repeat(" ", padding))
|
||||||
fmt.Println()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printDimmed(bottomBorder, colors[0], 1.0)
|
fmt.Println(bottomBorder)
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
vStr := fmt.Sprintf(" Fscan Version: %s", version)
|
// 打印版本信息
|
||||||
printDimmed(vStr, colors[1], 1.0)
|
c := color.New(colors[1])
|
||||||
fmt.Print("\n\n")
|
c.Printf(" Fscan Version: %s\n\n", version)
|
||||||
}
|
|
||||||
|
|
||||||
// 辅助函数:打印带透明度的文字
|
|
||||||
func printDimmed(text string, col color.Attribute, dim float64) {
|
|
||||||
if dim < 0.2 {
|
|
||||||
fmt.Print(strings.Repeat(" ", len(text)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
intensity := int(255 * dim)
|
|
||||||
fmt.Printf("\033[38;2;%d;%d;%dm%s\033[0m",
|
|
||||||
int(float64(0)*dim),
|
|
||||||
intensity,
|
|
||||||
int(float64(0)*dim),
|
|
||||||
text)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Flag(Info *HostInfo) {
|
func Flag(Info *HostInfo) {
|
||||||
|
@ -33,11 +33,56 @@ func Scan(info Common.HostInfo) {
|
|||||||
switch {
|
switch {
|
||||||
case Common.LocalMode:
|
case Common.LocalMode:
|
||||||
// 本地信息收集模式
|
// 本地信息收集模式
|
||||||
Common.LogInfo("执行本地信息收集")
|
LocalScan = true
|
||||||
|
|
||||||
|
// 定义本地模式允许的插件
|
||||||
|
validLocalPlugins := map[string]bool{
|
||||||
|
"localinfo": true,
|
||||||
|
// 添加其他 ModeLocal 中定义的插件
|
||||||
|
}
|
||||||
|
|
||||||
|
if Common.ScanMode != "" && Common.ScanMode != Common.ModeLocal {
|
||||||
|
// 如果指定了模式但不是 ModeLocal,检查是否是合法的单插件
|
||||||
|
if !validLocalPlugins[Common.ScanMode] {
|
||||||
|
Common.LogError(fmt.Sprintf("无效的本地模式插件: %s, 仅支持 localinfo", Common.ScanMode))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ScanMode 保持为单插件名
|
||||||
|
} else {
|
||||||
|
// 没有指定模式或指定了 ModeLocal,使用完整的本地模式
|
||||||
|
Common.ScanMode = Common.ModeLocal
|
||||||
|
}
|
||||||
|
|
||||||
|
if Common.ScanMode == Common.ModeLocal {
|
||||||
|
Common.LogInfo("执行本地信息收集 - 使用全部本地插件")
|
||||||
|
} else {
|
||||||
|
Common.LogInfo(fmt.Sprintf("执行本地信息收集 - 使用插件: %s", Common.ScanMode))
|
||||||
|
}
|
||||||
|
|
||||||
executeScans([]Common.HostInfo{info}, &ch, &wg)
|
executeScans([]Common.HostInfo{info}, &ch, &wg)
|
||||||
|
|
||||||
case len(Common.URLs) > 0:
|
case len(Common.URLs) > 0:
|
||||||
// Web模式
|
// Web模式
|
||||||
|
WebScan = true
|
||||||
|
|
||||||
|
// 定义Web模式允许的插件
|
||||||
|
validWebPlugins := map[string]bool{
|
||||||
|
"webtitle": true,
|
||||||
|
"webpoc": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
if Common.ScanMode != "" && Common.ScanMode != Common.ModeWeb {
|
||||||
|
// 如果指定了模式但不是 ModeWeb,检查是否是合法的单插件
|
||||||
|
if !validWebPlugins[Common.ScanMode] {
|
||||||
|
Common.LogError(fmt.Sprintf("无效的Web插件: %s, 仅支持 webtitle 和 webpoc", Common.ScanMode))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ScanMode 保持为单插件名
|
||||||
|
} else {
|
||||||
|
// 没有指定模式或指定了 ModeWeb,使用完整的Web模式
|
||||||
|
Common.ScanMode = Common.ModeWeb
|
||||||
|
}
|
||||||
|
|
||||||
var targetInfos []Common.HostInfo
|
var targetInfos []Common.HostInfo
|
||||||
for _, url := range Common.URLs {
|
for _, url := range Common.URLs {
|
||||||
urlInfo := info
|
urlInfo := info
|
||||||
@ -47,7 +92,12 @@ func Scan(info Common.HostInfo) {
|
|||||||
urlInfo.Url = url
|
urlInfo.Url = url
|
||||||
targetInfos = append(targetInfos, urlInfo)
|
targetInfos = append(targetInfos, urlInfo)
|
||||||
}
|
}
|
||||||
Common.LogInfo("开始Web扫描")
|
|
||||||
|
if Common.ScanMode == Common.ModeWeb {
|
||||||
|
Common.LogInfo("开始Web扫描 - 使用全部Web插件")
|
||||||
|
} else {
|
||||||
|
Common.LogInfo(fmt.Sprintf("开始Web扫描 - 使用插件: %s", Common.ScanMode))
|
||||||
|
}
|
||||||
executeScans(targetInfos, &ch, &wg)
|
executeScans(targetInfos, &ch, &wg)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user