Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Install

**Latest Release**

go install -v github.com/aztecrabbit/bugscanner-go@latest
go install -v github.com/LamonLind/bugscanner-go@latest

**Latest Commit**

go install -v github.com/aztecrabbit/bugscanner-go@HEAD
go install -v github.com/LamonLind/bugscanner-go@HEAD


#### Add go bin to PATH
Expand Down
66 changes: 23 additions & 43 deletions cmd/scan_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"time"

"github.com/aztecrabbit/bugscanner-go/pkg/queuescanner"
"github.com/Lamonlind/bugscanner-go/pkg/queuescanner"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -105,11 +105,17 @@ func scanDirect(c *queuescanner.Ctx, p *queuescanner.QueueScannerScanParams) {
hCfRay := httpRes.Header.Get("CF-RAY")
hLocation := httpRes.Header.Get("Location")

// Skip hosts redirecting to "https://jio.com/BalanceExhaust"
if hLocation == "https://jio.com/BalanceExhaust" {
return
}

resColor := color.New()

isHiddenCloudflare := slices.Contains(req.ServerList, "cloudflare") && hCfRay != "" && hServerLower != "cloudflare"

if slices.Contains(req.ServerList, hServerLower) || isHiddenCloudflare {
// Save results for all servers, not just Cloudflare
if slices.Contains(req.ServerList, hServerLower) || isHiddenCloudflare || len(req.ServerList) == 1 {
if isHiddenCloudflare {
resColor = colorG1
hServer = fmt.Sprintf("%s (cf)", hServer)
Expand Down Expand Up @@ -155,6 +161,21 @@ func scanDirect(c *queuescanner.Ctx, p *queuescanner.QueueScannerScanParams) {
s = resColor.Sprint(s)

c.Log(s)

// Write the log entry to the file in real-time
if scanDirectFlagOutput != "" {
file, err := os.OpenFile(scanDirectFlagOutput, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println(err.Error())
return
}
defer file.Close()

_, err = file.WriteString(s + "\n")
if err != nil {
fmt.Println(err.Error())
}
}
}

func scanDirectRun(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -218,61 +239,20 @@ func scanDirectRun(cmd *cobra.Command, args []string) {
mapServerList[res.Server] = append(mapServerList[res.Server], res)
}

domainList := make([]string, 0)
ipList := make([]string, 0)

for server, resList := range mapServerList {
if len(resList) == 0 {
continue
}

var resColor *color.Color

mapIPList := make(map[string]bool)
mapDomainList := make(map[string]bool)

for _, res := range resList {
if resColor == nil {
resColor = res.Color
}

for _, netIP := range res.NetIPList {
ip := netIP.String()
mapIPList[ip] = true
}

mapDomainList[res.Request.Domain] = true
}

c.Log(resColor.Sprintf("\n%s\n", server))

domainList = append(domainList, fmt.Sprintf("# %s", server))
for doamin := range mapDomainList {
domainList = append(domainList, doamin)
c.Log(resColor.Sprint(doamin))
}
domainList = append(domainList, "")
c.Log("")

ipList = append(ipList, fmt.Sprintf("# %s", server))
for ip := range mapIPList {
ipList = append(ipList, ip)
c.Log(resColor.Sprint(ip))
}
ipList = append(ipList, "")
c.Log("")
}

outputList := make([]string, 0)
outputList = append(outputList, domainList...)
outputList = append(outputList, ipList...)

if scanDirectFlagOutput != "" {
err := os.WriteFile(scanDirectFlagOutput, []byte(strings.Join(outputList, "\n")), 0644)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/aztecrabbit/bugscanner-go
module github.com/LamonLind/bugscanner-go

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/aztecrabbit/bugscanner-go/cmd"
import "github.com/LamonLind/bugscanner-go/cmd"

func main() {
cmd.Execute()
Expand Down