polish scanner SDK API and docs

This commit is contained in:
ZacharyZcR
2026-05-18 15:49:57 +08:00
parent 6605c93dd9
commit d4ed0867c9
9 changed files with 836 additions and 71 deletions
+49
View File
@@ -0,0 +1,49 @@
package main
import (
"context"
"fmt"
"time"
fscan "github.com/shadow1ng/fscan/pkg/fscan"
)
func main() {
for _, plugin := range fscan.ListPlugins() {
if plugin.Default {
fmt.Printf("default plugin: %s ports=%v safe=%v\n", plugin.Name, plugin.Ports, plugin.Safe)
}
}
config := fscan.Config{
Timeout: 3 * time.Second,
Threads: 64,
DisablePing: true,
DisableBrute: true,
Plugins: []string{"ssh", "mysql", "redis"},
}
target := fscan.Target{
Host: "127.0.0.1",
Ports: []int{22, 3306, 6379},
}
var summary fscan.ResultSummary
scanner := fscan.NewScanner(config)
err := scanner.ScanEach(context.Background(), func(result fscan.Result) error {
summary.Add(result)
if service, ok := result.Service(); ok {
fmt.Printf("service=%s target=%s\n", service, result.Target)
}
if result.IsCredential() {
username, _ := result.Username()
password, _ := result.Password()
fmt.Printf("credential target=%s username=%s password=%s\n", result.Target, username, password)
}
return nil
}, target)
if err != nil {
panic(err)
}
fmt.Printf("stream summary: %+v\n", summary)
}