-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
657442a
commit 2e6b306
Showing
113 changed files
with
2,863 additions
and
3,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package nacos | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"slack-wails/lib/structs" | ||
"strings" | ||
) | ||
|
||
// 定义关键词分类 | ||
var categories = map[string][]string{ | ||
"Auth": {"username", "password"}, | ||
"OSS": {"accesskey", "secret"}, | ||
"Database": {"jdbc", "redis", "elasticsearch", "database", "mongo", "mssql", "mysql", "oracle", "postgres", "sqlserver"}, | ||
} | ||
|
||
// 统计单个文件中每个类别关键词的出现次数 | ||
func countKeywordsInFile(filePath string) (structs.NacosNode, error) { | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
return structs.NacosNode{}, err | ||
} | ||
defer file.Close() | ||
|
||
// 初始化统计信息 | ||
nodeInfo := structs.NacosNode{} | ||
|
||
// 逐行读取文件 | ||
scanner := bufio.NewScanner(file) | ||
for scanner.Scan() { | ||
line := strings.ToLower(scanner.Text()) // 转换为小写 | ||
for category, keywords := range categories { | ||
for _, keyword := range keywords { | ||
if strings.Contains(line, keyword) { | ||
switch category { | ||
case "Auth": | ||
nodeInfo.Auth++ | ||
case "OSS": | ||
nodeInfo.OSS++ | ||
case "Database": | ||
nodeInfo.Database++ | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if err := scanner.Err(); err != nil { | ||
return structs.NacosNode{}, err | ||
} | ||
return nodeInfo, nil | ||
} | ||
|
||
// 遍历目录并统计每个文件的关键词出现次数,返回结果数组 | ||
func ProcessDirectory(dir string) []structs.NacosConfig { | ||
var results []structs.NacosConfig | ||
|
||
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// 只处理 .yaml 或 .yml 文件 | ||
if !info.IsDir() { | ||
nodeInfo, err := countKeywordsInFile(path) | ||
if err != nil { | ||
fmt.Printf("Error processing file %s: %v\n", path, err) | ||
return nil | ||
} | ||
|
||
// 检查是否有关键词匹配 | ||
if nodeInfo.Auth > 0 || nodeInfo.OSS > 0 || nodeInfo.Database > 0 { | ||
// 添加结果到数组中 | ||
results = append(results, structs.NacosConfig{ | ||
Name: path, | ||
NodeInfo: nodeInfo, | ||
}) | ||
} | ||
} | ||
return nil | ||
}) | ||
|
||
if err != nil { | ||
fmt.Printf("Error walking directory: %v\n", err) | ||
} | ||
|
||
return results | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package nacos | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestExtract(t *testing.T) { | ||
// 设置目标目录 | ||
dir := "./configs" // 替换为实际的配置文件目录路径 | ||
|
||
// 获取所有文件的统计结果 | ||
results := ProcessDirectory(dir) | ||
|
||
// 输出总结果 | ||
fmt.Println("Final Results:") | ||
for _, result := range results { | ||
fmt.Printf("File: %s\n", result.Name) | ||
fmt.Printf(" Auth (账号密码): %d\n", result.NodeInfo.Auth) | ||
fmt.Printf(" OSS: %d\n", result.NodeInfo.OSS) | ||
fmt.Printf(" Database: %d\n", result.NodeInfo.Database) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package portscan | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"slack-wails/lib/gologger" | ||
"strings" | ||
"time" | ||
|
||
"github.com/wailsapp/wails/v2/pkg/runtime" | ||
) | ||
|
||
func AdbScan(ctx context.Context, address string) { | ||
result := "ADB> host::features=shell_v2,cmd,stat_v2,ls_v2,fixed_push_mkdir,apex,abb,fixed_push_symlink_timestamp,abb_exec,remount_shell,track_app,sendrecv_v2,sendrecv_v2_brotli,sendrecv_v2_lz4,sendrecv_v2_zstd,sendrecv_v2_dry_run_send,openscreen_mdns\n" | ||
conn, err := WrapperTcpWithTimeout("tcp", address, time.Duration(6)*time.Second) | ||
if err == nil { | ||
defer func() { | ||
if conn != nil { | ||
_ = conn.Close() | ||
} | ||
}() | ||
} else { | ||
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address)) | ||
return | ||
} | ||
|
||
_, err = conn.Write([]byte{0x43, 0x4e, 0x58, 0x4e, 0x01, 0x00, 0x00, 0x01, | ||
0x00, 0x00, 0x10, 0x00, 0xea, 0x00, 0x00, 0x00, | ||
0x44, 0x5b, 0x00, 0x00, 0xbc, 0xb1, 0xa7, 0xb1, | ||
0x68, 0x6f, 0x73, 0x74, 0x3a, 0x3a, 0x66, 0x65, | ||
0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x3d, 0x73, | ||
0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x76, 0x32, 0x2c, | ||
0x63, 0x6d, 0x64, 0x2c, 0x73, 0x74, 0x61, 0x74, | ||
0x5f, 0x76, 0x32, 0x2c, 0x6c, 0x73, 0x5f, 0x76, | ||
0x32, 0x2c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x5f, | ||
0x70, 0x75, 0x73, 0x68, 0x5f, 0x6d, 0x6b, 0x64, | ||
0x69, 0x72, 0x2c, 0x61, 0x70, 0x65, 0x78, 0x2c, | ||
0x61, 0x62, 0x62, 0x2c, 0x66, 0x69, 0x78, 0x65, | ||
0x64, 0x5f, 0x70, 0x75, 0x73, 0x68, 0x5f, 0x73, | ||
0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x74, | ||
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, | ||
0x2c, 0x61, 0x62, 0x62, 0x5f, 0x65, 0x78, 0x65, | ||
0x63, 0x2c, 0x72, 0x65, 0x6d, 0x6f, 0x75, 0x6e, | ||
0x74, 0x5f, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x2c, | ||
0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x61, 0x70, | ||
0x70, 0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, | ||
0x63, 0x76, 0x5f, 0x76, 0x32, 0x2c, 0x73, 0x65, | ||
0x6e, 0x64, 0x72, 0x65, 0x63, 0x76, 0x5f, 0x76, | ||
0x32, 0x5f, 0x62, 0x72, 0x6f, 0x74, 0x6c, 0x69, | ||
0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, 0x63, | ||
0x76, 0x5f, 0x76, 0x32, 0x5f, 0x6c, 0x7a, 0x34, | ||
0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, 0x63, | ||
0x76, 0x5f, 0x76, 0x32, 0x5f, 0x7a, 0x73, 0x74, | ||
0x64, 0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, | ||
0x63, 0x76, 0x5f, 0x76, 0x32, 0x5f, 0x64, 0x72, | ||
0x79, 0x5f, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x65, | ||
0x6e, 0x64, 0x2c, 0x6f, 0x70, 0x65, 0x6e, 0x73, | ||
0x63, 0x72, 0x65, 0x65, 0x6e, 0x5f, 0x6d, 0x64, | ||
0x6e, 0x73}) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("write %s failed", address)) | ||
return | ||
} | ||
|
||
err = conn.SetReadDeadline(time.Now().Add(time.Duration(6) * time.Second)) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("set read deadline for %s failed", address)) | ||
return | ||
} | ||
|
||
buf := make([]byte, 0x1000) | ||
n, err := conn.Read(buf) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("read from %s failed", address)) | ||
return | ||
} | ||
|
||
if n > 4 && string(buf[:4]) != "CNXN" { | ||
gologger.Info(ctx, "ADB需要授权/非ADB服务") | ||
return | ||
} | ||
|
||
if strings.Contains(string(buf[:n]), "ro.product.name") { | ||
result += string(buf[24:n]) + "\n" | ||
} else { | ||
buf = make([]byte, 0x1000) | ||
n, err = conn.Read(buf) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("read from %s failed", address)) | ||
return | ||
} | ||
|
||
result += string(buf[:n]) + "\n" | ||
} | ||
|
||
if result != "" { | ||
runtime.EventsEmit(ctx, "bruteResult", Burte{ | ||
Status: true, | ||
Host: address, | ||
Protocol: "adb", | ||
Username: "unauthorized", | ||
Password: "", | ||
}) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package portscan | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"slack-wails/lib/gologger" | ||
"strings" | ||
"time" | ||
|
||
"github.com/wailsapp/wails/v2/pkg/runtime" | ||
) | ||
|
||
func JdwpScan(ctx context.Context, address string) { | ||
client, err := WrapperTcpWithTimeout("tcp", address, time.Duration(6)*time.Second) | ||
defer func() { | ||
if client != nil { | ||
client.Close() | ||
} | ||
}() | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address)) | ||
return | ||
} | ||
err = client.SetDeadline(time.Now().Add(time.Duration(6) * time.Second)) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address)) | ||
return | ||
} | ||
_, err = client.Write([]byte("JDWP-Handshake")) | ||
if err != nil { | ||
gologger.Info(ctx, fmt.Sprintf("write jdwp-handshake to %s failed", address)) | ||
return | ||
} | ||
|
||
rev := make([]byte, 1024) | ||
n, errRead := client.Read(rev) | ||
if errRead != nil { | ||
gologger.Info(ctx, fmt.Sprintf("read %s err: %s", address, errRead)) | ||
return | ||
} | ||
if !strings.Contains(string(rev[:n]), "JDWP-Handshake") { | ||
// 不是JDWP | ||
gologger.Info(ctx, fmt.Sprintf("%s is not jdwp", address)) | ||
return | ||
} | ||
runtime.EventsEmit(ctx, "bruteResult", Burte{ | ||
Status: true, | ||
Host: address, | ||
Protocol: "jdwp", | ||
Username: "unauthorized", | ||
Password: "", | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.