@@ -14,6 +14,7 @@ import (
1414 "github.com/chainreactors/utils/iutils"
1515 "github.com/chainreactors/words/mask"
1616 "github.com/chainreactors/words/rule"
17+ "github.com/charmbracelet/lipgloss"
1718 "github.com/expr-lang/expr"
1819 "github.com/vbauerster/mpb/v8"
1920 "io/ioutil"
@@ -304,10 +305,6 @@ func (opt *Option) NewRunner() (*Runner, error) {
304305 r .ClientType = ihttp .STANDARD
305306 }
306307
307- if opt .Threads == DefaultThreads && len (opt .Dictionaries ) == 0 {
308- r .Threads = 1000
309- }
310-
311308 err = opt .BuildPlugin (r )
312309 if err != nil {
313310 return nil , err
@@ -318,6 +315,10 @@ func (opt *Option) NewRunner() (*Runner, error) {
318315 return nil , err
319316 }
320317
318+ if opt .Threads == DefaultThreads && r .bruteMod {
319+ r .Threads = 1000
320+ }
321+
321322 pkg .DefaultStatistor = pkg.Statistor {
322323 Word : opt .Word ,
323324 WordCount : len (r .Wordlist ),
@@ -392,6 +393,8 @@ func (opt *Option) NewRunner() (*Runner, error) {
392393 r .Probes = strings .Split (opt .OutputProbe , "," )
393394 }
394395
396+ fmt .Println (opt .PrintConfig (r ))
397+
395398 // init output file
396399 if opt .OutputFile != "" {
397400 r .OutputFile , err = files .NewFile (opt .OutputFile , false , false , true )
@@ -435,30 +438,136 @@ func (opt *Option) NewRunner() (*Runner, error) {
435438 return r , nil
436439}
437440
438- func (opt * Option ) PrintPlugin () {
439- var s strings.Builder
440- if opt .CrawlPlugin {
441- s .WriteString ("crawl enable; " )
442- }
443- if opt .Finger {
444- s .WriteString ("active fingerprint enable; " )
445- }
446- if opt .BakPlugin {
447- s .WriteString ("bak file enable; " )
441+ func (opt * Option ) PrintConfig (r * Runner ) string {
442+ // 定义颜色样式
443+ keyStyle := lipgloss .NewStyle ().Bold (true ).Foreground (lipgloss .Color ("#FFFFFF" )).Width (20 ) // Key 加粗并设定宽度
444+ stringValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#FFA07A" )) // 字符串样式
445+ arrayValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#98FB98" )) // 数组样式
446+ numberValueStyle := lipgloss .NewStyle ().Foreground (lipgloss .Color ("#ADD8E6" )) // 数字样式
447+ panelWidth := 60 // 调整 panelWidth 使内容稍微靠左
448+ padding := 2 // 减少 padding 以调整布局靠左
449+
450+ // 分割线样式和终端宽度计算
451+ divider := strings .Repeat ("─" , panelWidth ) // 使用"─"符号生成更加连贯的分割线
452+
453+ // 处理不同类型的值
454+ formatValue := func (value interface {}) string {
455+ switch v := value .(type ) {
456+ case string :
457+ return stringValueStyle .Render (v )
458+ case []string :
459+ return arrayValueStyle .Render (fmt .Sprintf ("%v" , v ))
460+ case int , int64 , float64 :
461+ return numberValueStyle .Render (fmt .Sprintf ("%v" , v ))
462+ default :
463+ return stringValueStyle .Render (fmt .Sprintf ("%v" , v )) // 默认为字符串样式
464+ }
448465 }
449- if opt .CommonPlugin {
450- s .WriteString ("common file enable; " )
466+
467+ // 处理互斥参数,选择输出有值的那一个
468+ inputSource := ""
469+ if opt .ResumeFrom != "" {
470+ inputSource = lipgloss .JoinHorizontal (lipgloss .Left , "🌀 " , keyStyle .Render ("ResumeFrom: " ), formatValue (opt .ResumeFrom ))
471+ } else if len (opt .URL ) > 0 {
472+ inputSource = lipgloss .JoinHorizontal (lipgloss .Left , "🌐 " , keyStyle .Render ("URL: " ), formatValue (opt .URL ))
473+ } else if opt .URLFile != "" {
474+ inputSource = lipgloss .JoinHorizontal (lipgloss .Left , "📂 " , keyStyle .Render ("URLFile: " ), formatValue (opt .URLFile ))
475+ } else if len (opt .CIDRs ) > 0 {
476+ inputSource = lipgloss .JoinHorizontal (lipgloss .Left , "📡 " , keyStyle .Render ("CIDRs: " ), formatValue (opt .CIDRs ))
477+ } else if opt .RawFile != "" {
478+ inputSource = lipgloss .JoinHorizontal (lipgloss .Left , "📄 " , keyStyle .Render ("RawFile: " ), formatValue (opt .RawFile ))
479+ }
480+
481+ // Input Options
482+ inputOptions := lipgloss .JoinVertical (lipgloss .Left ,
483+ inputSource , // 互斥量处理
484+
485+ // PortRange 展示
486+ lipgloss .JoinHorizontal (lipgloss .Left , "🔢 " , keyStyle .Render ("PortRange: " ), formatValue (opt .PortRange )),
487+
488+ // Dictionaries 展示
489+ lipgloss .JoinHorizontal (lipgloss .Left , "📚 " , keyStyle .Render ("Dictionaries: " ), formatValue (opt .Dictionaries )),
490+
491+ // Word, Rules, FilterRule 展开为单独的行
492+ lipgloss .JoinVertical (lipgloss .Left ,
493+ lipgloss .JoinHorizontal (lipgloss .Left , "💡 " , keyStyle .Render ("Word: " ), formatValue (r .Word )),
494+ lipgloss .JoinHorizontal (lipgloss .Left , "📜 " , keyStyle .Render ("Rules: " ), formatValue (opt .Rules )),
495+ lipgloss .JoinHorizontal (lipgloss .Left , "🔍 " , keyStyle .Render ("FilterRule: " ), formatValue (opt .FilterRule )),
496+ ),
497+
498+ // AppendRule 和 AppendWords 展开为单独的行
499+ lipgloss .JoinVertical (lipgloss .Left ,
500+ lipgloss .JoinHorizontal (lipgloss .Left , "🔧 " , keyStyle .Render ("AppendRule: " ), formatValue (r .AppendRule )),
501+ lipgloss .JoinHorizontal (lipgloss .Left , "🧩 " , keyStyle .Render ("AppendWords: " ), formatValue (len (r .AppendWords ))),
502+ ),
503+ )
504+
505+ // Output Options
506+ outputOptions := lipgloss .JoinVertical (lipgloss .Left ,
507+ lipgloss .JoinHorizontal (lipgloss .Left , "📊 " , keyStyle .Render ("Match: " ), formatValue (opt .Match )),
508+ lipgloss .JoinHorizontal (lipgloss .Left , "⚙️ " , keyStyle .Render ("Filter: " ), formatValue (opt .Filter )),
509+ )
510+
511+ // Plugin Options
512+ pluginValues := []string {}
513+ if opt .ActivePlugin {
514+ pluginValues = append (pluginValues , "active" )
451515 }
452516 if opt .ReconPlugin {
453- s . WriteString ( "recon enable; " )
517+ pluginValues = append ( pluginValues , "recon" )
454518 }
455- if opt .RetryCount > 0 {
456- s . WriteString ( "Retry Count: " + strconv . Itoa ( opt . RetryCount ) )
519+ if opt .BakPlugin {
520+ pluginValues = append ( pluginValues , "bak" )
457521 }
458-
459- if s .Len () > 0 {
460- logs .Log .Important (s .String ())
522+ if opt .CommonPlugin {
523+ pluginValues = append (pluginValues , "common" )
461524 }
525+ if opt .CrawlPlugin {
526+ pluginValues = append (pluginValues , "crawl" )
527+ }
528+
529+ pluginOptions := lipgloss .JoinVertical (lipgloss .Left ,
530+ lipgloss .JoinHorizontal (lipgloss .Left , "🔎 " , keyStyle .Render ("Extracts: " ), formatValue (opt .Extracts )),
531+ lipgloss .JoinHorizontal (lipgloss .Left , "🔌 " , keyStyle .Render ("Plugins: " ), formatValue (strings .Join (pluginValues , ", " ))),
532+ )
533+
534+ // Mode Options
535+ modeOptions := lipgloss .JoinVertical (lipgloss .Left ,
536+ lipgloss .JoinHorizontal (lipgloss .Left , "🛑 " , keyStyle .Render ("BlackStatus: " ), formatValue (pkg .BlackStatus )),
537+ lipgloss .JoinHorizontal (lipgloss .Left , "✅ " , keyStyle .Render ("WhiteStatus: " ), formatValue (pkg .WhiteStatus )),
538+ lipgloss .JoinHorizontal (lipgloss .Left , "🔄 " , keyStyle .Render ("FuzzyStatus: " ), formatValue (pkg .FuzzyStatus )),
539+ lipgloss .JoinHorizontal (lipgloss .Left , "🔒 " , keyStyle .Render ("UniqueStatus: " ), formatValue (pkg .UniqueStatus )),
540+ lipgloss .JoinHorizontal (lipgloss .Left , "🔑 " , keyStyle .Render ("Unique: " ), formatValue (opt .Unique )),
541+ )
542+
543+ // Misc Options
544+ miscOptions := lipgloss .JoinVertical (lipgloss .Left ,
545+ lipgloss .JoinHorizontal (lipgloss .Left , "⏱ " , keyStyle .Render ("Timeout: " ), formatValue (opt .Timeout )),
546+ lipgloss .JoinHorizontal (lipgloss .Left , "📈 " , keyStyle .Render ("PoolSize: " ), formatValue (opt .PoolSize )),
547+ lipgloss .JoinHorizontal (lipgloss .Left , "🧵 " , keyStyle .Render ("Threads: " ), formatValue (opt .Threads )),
548+ lipgloss .JoinHorizontal (lipgloss .Left , "🌍 " , keyStyle .Render ("Proxy: " ), formatValue (opt .Proxy )),
549+ )
550+
551+ // 将所有内容拼接在一起
552+ content := lipgloss .JoinVertical (lipgloss .Left ,
553+ inputOptions ,
554+ outputOptions ,
555+ pluginOptions ,
556+ modeOptions ,
557+ miscOptions ,
558+ )
559+
560+ // 使用正确的方式添加 padding,并居中显示内容
561+ contentWithPadding := lipgloss .NewStyle ().PaddingLeft (padding ).Render (content )
562+
563+ // 使用 Place 方法来将整个内容居中显示
564+ return lipgloss .Place (panelWidth + padding * 2 , 0 , lipgloss .Center , lipgloss .Center ,
565+ lipgloss .JoinVertical (lipgloss .Center ,
566+ divider , // 顶部分割线
567+ contentWithPadding ,
568+ divider , // 底部分割线
569+ ),
570+ )
462571}
463572
464573func (opt * Option ) BuildPlugin (r * Runner ) error {
@@ -501,7 +610,6 @@ func (opt *Option) BuildPlugin(r *Runner) error {
501610 r .bruteMod = true
502611 }
503612
504- opt .PrintPlugin ()
505613 if r .bruteMod {
506614 logs .Log .Important ("enabling brute mod, because of enabled brute plugin" )
507615 }
@@ -670,7 +778,6 @@ func (opt *Option) BuildWords(r *Runner) error {
670778 })
671779 }
672780
673- logs .Log .Importantf ("%s mod, Loaded %d dictionaries, %d rules and %d decorators" , opt .Mod , len (opt .Dictionaries ), len (opt .Rules ), len (r .Fns ))
674781 return nil
675782}
676783
0 commit comments