@@ -28,6 +28,7 @@ import (
2828 "github.com/chainreactors/words/mask"
2929 "github.com/chainreactors/words/rule"
3030 "github.com/charmbracelet/lipgloss"
31+ "github.com/charmbracelet/lipgloss/table"
3132 "github.com/expr-lang/expr"
3233 "github.com/vbauerster/mpb/v8"
3334)
@@ -293,9 +294,6 @@ func (opt *Option) Prepare() error {
293294 pkg .UniqueStatus = pkg .ParseStatus (pkg .DefaultUniqueStatus , opt .UniqueStatus )
294295 }
295296
296- logs .Log .Logf (pkg .LogVerbose , "Black Status: %v, WhiteStatus: %v, WAFStatus: %v" , pkg .BlackStatus , pkg .WhiteStatus , pkg .WAFStatus )
297- logs .Log .Logf (pkg .LogVerbose , "Fuzzy Status: %v, Unique Status: %v" , pkg .FuzzyStatus , pkg .UniqueStatus )
298-
299297 return nil
300298}
301299
@@ -488,73 +486,93 @@ func (opt *Option) NewRunner() (*Runner, error) {
488486
489487func (opt * Option ) PrintConfig (r * Runner ) string {
490488 // 定义颜色样式
491- keyStyle := lipgloss .NewStyle ().Bold (true ).Foreground (lipgloss .Color ("#FFFFFF" )).Width (20 ) // Key 加粗并设定宽度
492- stringValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#FFA07A" )) // 字符串样式
493- arrayValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#98FB98" )) // 数组样式
494- numberValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#ADD8E6" )) // 数字样式
495- panelWidth := 60 // 调整 panelWidth 使内容稍微靠左
496- padding := 2 // 减少 padding 以调整布局靠左
497-
498- // 分割线样式和终端宽度计算
499- divider := strings .Repeat ("─" , panelWidth ) // 使用"─"符号生成更加连贯的分割线
489+ keyStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#87CEEB" )).Bold (true )
490+ stringValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#FFA07A" ))
491+ arrayValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#98FB98" ))
492+ numberValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#FFD700" ))
500493
501- // 处理不同类型的值
494+ // 格式化值的辅助函数
502495 formatValue := func (value interface {}) string {
503496 switch v := value .(type ) {
504497 case string :
498+ if v == "" {
499+ return stringValueStyle .Render ("-" )
500+ }
505501 return stringValueStyle .Render (v )
506502 case []string :
503+ if len (v ) == 0 {
504+ return arrayValueStyle .Render ("-" )
505+ }
507506 return arrayValueStyle .Render (fmt .Sprintf ("%v" , v ))
508- case int , int64 , float64 :
507+ case int , int64 :
508+ return numberValueStyle .Render (fmt .Sprintf ("%v" , v ))
509+ case float64 :
510+ return numberValueStyle .Render (fmt .Sprintf ("%v" , v ))
511+ case bool :
509512 return numberValueStyle .Render (fmt .Sprintf ("%v" , v ))
510513 default :
511- return stringValueStyle .Render (fmt .Sprintf ("%v" , v )) // 默认为字符串样式
514+ return stringValueStyle .Render (fmt .Sprintf ("%v" , v ))
512515 }
513516 }
514517
515- // 处理互斥参数,选择输出有值的那一个
516- inputSource := ""
518+ // 收集所有配置行
519+ var rows [][]string
520+
521+ // Input Source (互斥参数)
517522 if opt .ResumeFrom != "" {
518- inputSource = lipgloss . JoinHorizontal ( lipgloss . Left , "🌀 " , keyStyle .Render ("ResumeFrom: " ), formatValue (opt .ResumeFrom ))
523+ rows = append ( rows , [] string { keyStyle .Render ("🌀 ResumeFrom " ), formatValue (opt .ResumeFrom )} )
519524 } else if len (opt .URL ) > 0 {
520- inputSource = lipgloss . JoinHorizontal ( lipgloss . Left , "🌐 " , keyStyle .Render ("URL: " ), formatValue (opt .URL ))
525+ rows = append ( rows , [] string { keyStyle .Render ("🌐 URL " ), formatValue (opt .URL )} )
521526 } else if opt .URLFile != "" {
522- inputSource = lipgloss . JoinHorizontal ( lipgloss . Left , "📂 " , keyStyle .Render ("URLFile: " ), formatValue (opt .URLFile ))
527+ rows = append ( rows , [] string { keyStyle .Render ("📂 URLFile " ), formatValue (opt .URLFile )} )
523528 } else if len (opt .CIDRs ) > 0 {
524- inputSource = lipgloss . JoinHorizontal ( lipgloss . Left , "📡 " , keyStyle .Render ("CIDRs: " ), formatValue (opt .CIDRs ))
529+ rows = append ( rows , [] string { keyStyle .Render ("📡 CIDRs " ), formatValue (opt .CIDRs )} )
525530 } else if opt .RawFile != "" {
526- inputSource = lipgloss . JoinHorizontal ( lipgloss . Left , "📄 " , keyStyle .Render ("RawFile: " ), formatValue (opt .RawFile ))
531+ rows = append ( rows , [] string { keyStyle .Render ("📄 RawFile " ), formatValue (opt .RawFile )} )
527532 }
528533
529534 // Input Options
530- inputOptions := lipgloss .JoinVertical (lipgloss .Left ,
531- inputSource , // 互斥量处理
532-
533- // PortRange 展示
534- lipgloss .JoinHorizontal (lipgloss .Left , "🔢 " , keyStyle .Render ("PortRange: " ), formatValue (opt .PortRange )),
535-
536- // Dictionaries 展示
537- lipgloss .JoinHorizontal (lipgloss .Left , "📚 " , keyStyle .Render ("Dictionaries: " ), formatValue (opt .Dictionaries )),
538-
539- // Word, Rules, FilterRule 展开为单独的行
540- lipgloss .JoinVertical (lipgloss .Left ,
541- lipgloss .JoinHorizontal (lipgloss .Left , "💡 " , keyStyle .Render ("Word: " ), formatValue (r .Word )),
542- lipgloss .JoinHorizontal (lipgloss .Left , "📜 " , keyStyle .Render ("Rules: " ), formatValue (opt .Rules )),
543- lipgloss .JoinHorizontal (lipgloss .Left , "🔍 " , keyStyle .Render ("FilterRule: " ), formatValue (opt .FilterRule )),
544- ),
545-
546- // AppendRule 和 AppendWords 展开为单独的行
547- lipgloss .JoinVertical (lipgloss .Left ,
548- lipgloss .JoinHorizontal (lipgloss .Left , "🔧 " , keyStyle .Render ("AppendRule: " ), formatValue (r .AppendRule )),
549- lipgloss .JoinHorizontal (lipgloss .Left , "🧩 " , keyStyle .Render ("AppendWords: " ), formatValue (len (r .AppendWords ))),
550- ),
551- )
535+ if opt .PortRange != "" {
536+ rows = append (rows , []string {keyStyle .Render ("🔢 PortRange" ), formatValue (opt .PortRange )})
537+ }
538+ if len (opt .Dictionaries ) > 0 {
539+ rows = append (rows , []string {keyStyle .Render ("📚 Dictionaries" ), formatValue (opt .Dictionaries )})
540+ }
541+ if r .Word != "" {
542+ rows = append (rows , []string {keyStyle .Render ("💡 Word" ), formatValue (r .Word )})
543+ }
544+ if len (opt .Rules ) > 0 {
545+ rows = append (rows , []string {keyStyle .Render ("📜 Rules" ), formatValue (opt .Rules )})
546+ }
547+ if opt .FilterRule != "" {
548+ rows = append (rows , []string {keyStyle .Render ("🔍 FilterRule" ), formatValue (opt .FilterRule )})
549+ }
550+ if r .AppendRules != nil && len (r .AppendRules .Expressions ) > 0 {
551+ rows = append (rows , []string {keyStyle .Render ("🔧 AppendRule" ), formatValue (len (r .AppendRules .Expressions ))})
552+ }
553+ if len (r .AppendWords ) > 0 {
554+ rows = append (rows , []string {keyStyle .Render ("🧩 AppendWords" ), formatValue (len (r .AppendWords ))})
555+ }
552556
553557 // Output Options
554- outputOptions := lipgloss .JoinVertical (lipgloss .Left ,
555- lipgloss .JoinHorizontal (lipgloss .Left , "📊 " , keyStyle .Render ("Match: " ), formatValue (opt .Match )),
556- lipgloss .JoinHorizontal (lipgloss .Left , "⚙️ " , keyStyle .Render ("Filter: " ), formatValue (opt .Filter )),
557- )
558+ if opt .Match != "" {
559+ rows = append (rows , []string {keyStyle .Render ("📊 Match" ), formatValue (opt .Match )})
560+ }
561+ if opt .Filter != "" {
562+ rows = append (rows , []string {keyStyle .Render ("⚙️ Filter" ), formatValue (opt .Filter )})
563+ }
564+ if opt .OutputFile != "" {
565+ rows = append (rows , []string {keyStyle .Render ("📝 OutputFile" ), formatValue (opt .OutputFile )})
566+ }
567+ if opt .DumpFile != "" {
568+ rows = append (rows , []string {keyStyle .Render ("💾 DumpFile" ), formatValue (opt .DumpFile )})
569+ }
570+ if ! opt .NoStat && r .StatFile != nil {
571+ rows = append (rows , []string {keyStyle .Render ("📈 StatFile" ), formatValue (r .StatFile .Filename )})
572+ }
573+ if opt .Fuzzy {
574+ rows = append (rows , []string {keyStyle .Render ("🔀 Fuzzy" ), formatValue (opt .Fuzzy )})
575+ }
558576
559577 // Plugin Options
560578 pluginValues := []string {}
@@ -576,49 +594,50 @@ func (opt *Option) PrintConfig(r *Runner) string {
576594 if opt .CrawlPlugin {
577595 pluginValues = append (pluginValues , "crawl" )
578596 }
597+ if opt .Finger {
598+ pluginValues = append (pluginValues , "finger" )
599+ }
579600
580- pluginOptions := lipgloss .JoinVertical (lipgloss .Left ,
581- lipgloss .JoinHorizontal (lipgloss .Left , "🔎 " , keyStyle .Render ("Extracts: " ), formatValue (opt .Extracts )),
582- lipgloss .JoinHorizontal (lipgloss .Left , "🔌 " , keyStyle .Render ("Plugins: " ), formatValue (strings .Join (pluginValues , ", " ))),
583- )
601+ if len (opt .Extracts ) > 0 {
602+ rows = append (rows , []string {keyStyle .Render ("🔎 Extracts" ), formatValue (opt .Extracts )})
603+ }
604+ if len (pluginValues ) > 0 {
605+ rows = append (rows , []string {keyStyle .Render ("🔌 Plugins" ), formatValue (strings .Join (pluginValues , ", " ))})
606+ }
584607
585608 // Mode Options
586- modeOptions := lipgloss .JoinVertical (lipgloss .Left ,
587- lipgloss .JoinHorizontal (lipgloss .Left , "🛑 " , keyStyle .Render ("BlackStatus: " ), formatValue (pkg .BlackStatus )),
588- lipgloss .JoinHorizontal (lipgloss .Left , "✅ " , keyStyle .Render ("WhiteStatus: " ), formatValue (pkg .WhiteStatus )),
589- lipgloss .JoinHorizontal (lipgloss .Left , "🔄 " , keyStyle .Render ("FuzzyStatus: " ), formatValue (pkg .FuzzyStatus )),
590- lipgloss .JoinHorizontal (lipgloss .Left , "🔒 " , keyStyle .Render ("UniqueStatus: " ), formatValue (pkg .UniqueStatus )),
591- lipgloss .JoinHorizontal (lipgloss .Left , "🔑 " , keyStyle .Render ("Unique: " ), formatValue (opt .Unique )),
592- )
609+ rows = append (rows , []string {keyStyle .Render ("🛑 BlackStatus" ), formatValue (pkg .BlackStatus )})
610+ rows = append (rows , []string {keyStyle .Render ("✅ WhiteStatus" ), formatValue (pkg .WhiteStatus )})
611+ rows = append (rows , []string {keyStyle .Render ("🔄 FuzzyStatus" ), formatValue (pkg .FuzzyStatus )})
612+ rows = append (rows , []string {keyStyle .Render ("🔒 UniqueStatus" ), formatValue (pkg .UniqueStatus )})
613+ if opt .Unique {
614+ rows = append (rows , []string {keyStyle .Render ("🔑 Unique" ), formatValue (opt .Unique )})
615+ }
616+ if opt .Depth > 0 {
617+ rows = append (rows , []string {keyStyle .Render ("🌳 Depth" ), formatValue (opt .Depth )})
618+ }
593619
594620 // Misc Options
595- miscOptions := lipgloss .JoinVertical (lipgloss .Left ,
596- lipgloss .JoinHorizontal (lipgloss .Left , "⏱ " , keyStyle .Render ("Timeout: " ), formatValue (opt .Timeout )),
597- lipgloss .JoinHorizontal (lipgloss .Left , "📈 " , keyStyle .Render ("PoolSize: " ), formatValue (opt .PoolSize )),
598- lipgloss .JoinHorizontal (lipgloss .Left , "🧵 " , keyStyle .Render ("Threads: " ), formatValue (opt .Threads )),
599- lipgloss .JoinHorizontal (lipgloss .Left , "🌍 " , keyStyle .Render ("Proxies: " ), formatValue (opt .Proxies )),
600- )
601-
602- // 将所有内容拼接在一起
603- content := lipgloss .JoinVertical (lipgloss .Left ,
604- inputOptions ,
605- outputOptions ,
606- pluginOptions ,
607- modeOptions ,
608- miscOptions ,
609- )
610-
611- // 使用正确的方式添加 padding,并居中显示内容
612- contentWithPadding := lipgloss .NewStyle ().PaddingLeft (padding ).Render (content )
613-
614- // 使用 Place 方法来将整个内容居中显示
615- return lipgloss .Place (panelWidth + padding * 2 , 0 , lipgloss .Center , lipgloss .Center ,
616- lipgloss .JoinVertical (lipgloss .Center ,
617- divider , // 顶部分割线
618- contentWithPadding ,
619- divider , // 底部分割线
620- ),
621- )
621+ rows = append (rows , []string {keyStyle .Render ("⏱ Timeout" ), formatValue (fmt .Sprintf ("%ds" , opt .Timeout ))})
622+ rows = append (rows , []string {keyStyle .Render ("🏊 PoolSize" ), formatValue (opt .PoolSize )})
623+ rows = append (rows , []string {keyStyle .Render ("🧵 Threads" ), formatValue (opt .Threads )})
624+ if len (opt .Proxies ) > 0 {
625+ rows = append (rows , []string {keyStyle .Render ("🌍 Proxies" ), formatValue (opt .Proxies )})
626+ }
627+ if opt .RateLimit > 0 {
628+ rows = append (rows , []string {keyStyle .Render ("⚡ RateLimit" ), formatValue (fmt .Sprintf ("%d/s" , opt .RateLimit ))})
629+ }
630+
631+ // 创建表格
632+ t := table .New ().
633+ Border (lipgloss .RoundedBorder ()).
634+ BorderStyle (lipgloss .NewStyle ().Foreground (lipgloss .Color ("99" ))).
635+ StyleFunc (func (row , col int ) lipgloss.Style {
636+ return lipgloss .NewStyle ().Padding (0 , 1 )
637+ }).
638+ Rows (rows ... )
639+
640+ return t .String ()
622641}
623642
624643func (opt * Option ) BuildPlugin (r * Runner ) error {
0 commit comments