Skip to content

Commit 2e6b306

Browse files
committed
update 1.7.3
1 parent 657442a commit 2e6b306

File tree

113 files changed

+2863
-3058
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2863
-3058
lines changed

Diff for: core/exp/nacos/extract.go

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package nacos
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"os"
7+
"path/filepath"
8+
"slack-wails/lib/structs"
9+
"strings"
10+
)
11+
12+
// 定义关键词分类
13+
var categories = map[string][]string{
14+
"Auth": {"username", "password"},
15+
"OSS": {"accesskey", "secret"},
16+
"Database": {"jdbc", "redis", "elasticsearch", "database", "mongo", "mssql", "mysql", "oracle", "postgres", "sqlserver"},
17+
}
18+
19+
// 统计单个文件中每个类别关键词的出现次数
20+
func countKeywordsInFile(filePath string) (structs.NacosNode, error) {
21+
file, err := os.Open(filePath)
22+
if err != nil {
23+
return structs.NacosNode{}, err
24+
}
25+
defer file.Close()
26+
27+
// 初始化统计信息
28+
nodeInfo := structs.NacosNode{}
29+
30+
// 逐行读取文件
31+
scanner := bufio.NewScanner(file)
32+
for scanner.Scan() {
33+
line := strings.ToLower(scanner.Text()) // 转换为小写
34+
for category, keywords := range categories {
35+
for _, keyword := range keywords {
36+
if strings.Contains(line, keyword) {
37+
switch category {
38+
case "Auth":
39+
nodeInfo.Auth++
40+
case "OSS":
41+
nodeInfo.OSS++
42+
case "Database":
43+
nodeInfo.Database++
44+
}
45+
}
46+
}
47+
}
48+
}
49+
50+
if err := scanner.Err(); err != nil {
51+
return structs.NacosNode{}, err
52+
}
53+
return nodeInfo, nil
54+
}
55+
56+
// 遍历目录并统计每个文件的关键词出现次数,返回结果数组
57+
func ProcessDirectory(dir string) []structs.NacosConfig {
58+
var results []structs.NacosConfig
59+
60+
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
61+
if err != nil {
62+
return err
63+
}
64+
65+
// 只处理 .yaml 或 .yml 文件
66+
if !info.IsDir() {
67+
nodeInfo, err := countKeywordsInFile(path)
68+
if err != nil {
69+
fmt.Printf("Error processing file %s: %v\n", path, err)
70+
return nil
71+
}
72+
73+
// 检查是否有关键词匹配
74+
if nodeInfo.Auth > 0 || nodeInfo.OSS > 0 || nodeInfo.Database > 0 {
75+
// 添加结果到数组中
76+
results = append(results, structs.NacosConfig{
77+
Name: path,
78+
NodeInfo: nodeInfo,
79+
})
80+
}
81+
}
82+
return nil
83+
})
84+
85+
if err != nil {
86+
fmt.Printf("Error walking directory: %v\n", err)
87+
}
88+
89+
return results
90+
}

Diff for: core/exp/nacos/extract_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package nacos
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
func TestExtract(t *testing.T) {
9+
// 设置目标目录
10+
dir := "./configs" // 替换为实际的配置文件目录路径
11+
12+
// 获取所有文件的统计结果
13+
results := ProcessDirectory(dir)
14+
15+
// 输出总结果
16+
fmt.Println("Final Results:")
17+
for _, result := range results {
18+
fmt.Printf("File: %s\n", result.Name)
19+
fmt.Printf(" Auth (账号密码): %d\n", result.NodeInfo.Auth)
20+
fmt.Printf(" OSS: %d\n", result.NodeInfo.OSS)
21+
fmt.Printf(" Database: %d\n", result.NodeInfo.Database)
22+
}
23+
}

Diff for: core/portscan/adb.go

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package portscan
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"slack-wails/lib/gologger"
7+
"strings"
8+
"time"
9+
10+
"github.com/wailsapp/wails/v2/pkg/runtime"
11+
)
12+
13+
func AdbScan(ctx context.Context, address string) {
14+
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"
15+
conn, err := WrapperTcpWithTimeout("tcp", address, time.Duration(6)*time.Second)
16+
if err == nil {
17+
defer func() {
18+
if conn != nil {
19+
_ = conn.Close()
20+
}
21+
}()
22+
} else {
23+
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address))
24+
return
25+
}
26+
27+
_, err = conn.Write([]byte{0x43, 0x4e, 0x58, 0x4e, 0x01, 0x00, 0x00, 0x01,
28+
0x00, 0x00, 0x10, 0x00, 0xea, 0x00, 0x00, 0x00,
29+
0x44, 0x5b, 0x00, 0x00, 0xbc, 0xb1, 0xa7, 0xb1,
30+
0x68, 0x6f, 0x73, 0x74, 0x3a, 0x3a, 0x66, 0x65,
31+
0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x3d, 0x73,
32+
0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x76, 0x32, 0x2c,
33+
0x63, 0x6d, 0x64, 0x2c, 0x73, 0x74, 0x61, 0x74,
34+
0x5f, 0x76, 0x32, 0x2c, 0x6c, 0x73, 0x5f, 0x76,
35+
0x32, 0x2c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x5f,
36+
0x70, 0x75, 0x73, 0x68, 0x5f, 0x6d, 0x6b, 0x64,
37+
0x69, 0x72, 0x2c, 0x61, 0x70, 0x65, 0x78, 0x2c,
38+
0x61, 0x62, 0x62, 0x2c, 0x66, 0x69, 0x78, 0x65,
39+
0x64, 0x5f, 0x70, 0x75, 0x73, 0x68, 0x5f, 0x73,
40+
0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x74,
41+
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
42+
0x2c, 0x61, 0x62, 0x62, 0x5f, 0x65, 0x78, 0x65,
43+
0x63, 0x2c, 0x72, 0x65, 0x6d, 0x6f, 0x75, 0x6e,
44+
0x74, 0x5f, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x2c,
45+
0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x61, 0x70,
46+
0x70, 0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65,
47+
0x63, 0x76, 0x5f, 0x76, 0x32, 0x2c, 0x73, 0x65,
48+
0x6e, 0x64, 0x72, 0x65, 0x63, 0x76, 0x5f, 0x76,
49+
0x32, 0x5f, 0x62, 0x72, 0x6f, 0x74, 0x6c, 0x69,
50+
0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, 0x63,
51+
0x76, 0x5f, 0x76, 0x32, 0x5f, 0x6c, 0x7a, 0x34,
52+
0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65, 0x63,
53+
0x76, 0x5f, 0x76, 0x32, 0x5f, 0x7a, 0x73, 0x74,
54+
0x64, 0x2c, 0x73, 0x65, 0x6e, 0x64, 0x72, 0x65,
55+
0x63, 0x76, 0x5f, 0x76, 0x32, 0x5f, 0x64, 0x72,
56+
0x79, 0x5f, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x65,
57+
0x6e, 0x64, 0x2c, 0x6f, 0x70, 0x65, 0x6e, 0x73,
58+
0x63, 0x72, 0x65, 0x65, 0x6e, 0x5f, 0x6d, 0x64,
59+
0x6e, 0x73})
60+
if err != nil {
61+
gologger.Info(ctx, fmt.Sprintf("write %s failed", address))
62+
return
63+
}
64+
65+
err = conn.SetReadDeadline(time.Now().Add(time.Duration(6) * time.Second))
66+
if err != nil {
67+
gologger.Info(ctx, fmt.Sprintf("set read deadline for %s failed", address))
68+
return
69+
}
70+
71+
buf := make([]byte, 0x1000)
72+
n, err := conn.Read(buf)
73+
if err != nil {
74+
gologger.Info(ctx, fmt.Sprintf("read from %s failed", address))
75+
return
76+
}
77+
78+
if n > 4 && string(buf[:4]) != "CNXN" {
79+
gologger.Info(ctx, "ADB需要授权/非ADB服务")
80+
return
81+
}
82+
83+
if strings.Contains(string(buf[:n]), "ro.product.name") {
84+
result += string(buf[24:n]) + "\n"
85+
} else {
86+
buf = make([]byte, 0x1000)
87+
n, err = conn.Read(buf)
88+
if err != nil {
89+
gologger.Info(ctx, fmt.Sprintf("read from %s failed", address))
90+
return
91+
}
92+
93+
result += string(buf[:n]) + "\n"
94+
}
95+
96+
if result != "" {
97+
runtime.EventsEmit(ctx, "bruteResult", Burte{
98+
Status: true,
99+
Host: address,
100+
Protocol: "adb",
101+
Username: "unauthorized",
102+
Password: "",
103+
})
104+
return
105+
}
106+
}

Diff for: core/portscan/jdwp.go

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package portscan
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"slack-wails/lib/gologger"
7+
"strings"
8+
"time"
9+
10+
"github.com/wailsapp/wails/v2/pkg/runtime"
11+
)
12+
13+
func JdwpScan(ctx context.Context, address string) {
14+
client, err := WrapperTcpWithTimeout("tcp", address, time.Duration(6)*time.Second)
15+
defer func() {
16+
if client != nil {
17+
client.Close()
18+
}
19+
}()
20+
if err != nil {
21+
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address))
22+
return
23+
}
24+
err = client.SetDeadline(time.Now().Add(time.Duration(6) * time.Second))
25+
if err != nil {
26+
gologger.Info(ctx, fmt.Sprintf("connect %s failed", address))
27+
return
28+
}
29+
_, err = client.Write([]byte("JDWP-Handshake"))
30+
if err != nil {
31+
gologger.Info(ctx, fmt.Sprintf("write jdwp-handshake to %s failed", address))
32+
return
33+
}
34+
35+
rev := make([]byte, 1024)
36+
n, errRead := client.Read(rev)
37+
if errRead != nil {
38+
gologger.Info(ctx, fmt.Sprintf("read %s err: %s", address, errRead))
39+
return
40+
}
41+
if !strings.Contains(string(rev[:n]), "JDWP-Handshake") {
42+
// 不是JDWP
43+
gologger.Info(ctx, fmt.Sprintf("%s is not jdwp", address))
44+
return
45+
}
46+
runtime.EventsEmit(ctx, "bruteResult", Burte{
47+
Status: true,
48+
Host: address,
49+
Protocol: "jdwp",
50+
Username: "unauthorized",
51+
Password: "",
52+
})
53+
}

Diff for: core/portscan/portbrute.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,34 @@ type Burte struct {
1616

1717
var ExitBruteFunc = false
1818

19-
var DefaultPorts = map[string]string{
19+
var defaultPorts = map[string]string{
2020
"ftp": "21",
2121
"ssh": "22",
2222
"telnet": "23",
2323
"ldap": "389",
2424
"smb": "445", // SMB 通常使用445端口
2525
"socks5": "1080",
26+
"rmi": "1099",
2627
"oracle": "1521",
2728
"mssql": "1433",
2829
"mqtt": "1883",
2930
"mysql": "3306",
3031
"rdp": "3389",
3132
"postgresql": "5432",
33+
"adb": "5555",
3234
"vnc": "5900",
3335
"redis": "6379",
36+
"jdwp": "8000",
3437
"memcached": "11211",
3538
"mongodb": "27017",
3639
}
3740

38-
// AddDefaultPort 检查并为给定的主机添加默认端口号
39-
func AddDefaultPort(scheme, host string) string {
41+
// 检查并为给定的主机添加默认端口号
42+
func addDefaultPort(scheme, host string) string {
4043
if strings.Contains(host, ":") {
4144
return host
4245
}
43-
defaultPort := DefaultPorts[scheme]
46+
defaultPort := defaultPorts[scheme]
4447
return host + ":" + defaultPort
4548
}
4649

@@ -49,7 +52,7 @@ func PortBrute(ctx context.Context, host string, usernames, passwords []string)
4952
if err != nil {
5053
return
5154
}
52-
u.Host = AddDefaultPort(u.Scheme, u.Host)
55+
u.Host = addDefaultPort(u.Scheme, u.Host)
5356
switch u.Scheme {
5457
case "ftp":
5558
FtpScan(ctx, u.Host, usernames, passwords)
@@ -83,5 +86,11 @@ func PortBrute(ctx context.Context, host string, usernames, passwords []string)
8386
MqttScan(ctx, u.Host, usernames, passwords)
8487
case "socks5":
8588
Socks5Scan(ctx, u.Host, usernames, passwords)
89+
case "jdwp":
90+
JdwpScan(ctx, u.Host)
91+
case "adb":
92+
AdbScan(ctx, u.Host)
93+
case "rmi":
94+
RmiScan(ctx, u.Host)
8695
}
8796
}

Diff for: core/portscan/portscan.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type PortResult struct {
2626
HttpTitle string
2727
}
2828

29-
func TcpScan(ctx context.Context, addresses <-chan Address, workers, timeout int) {
29+
func TcpScan(ctx context.Context, addresses <-chan Address, workers, timeout int, proxy *clients.Proxy) {
3030
var id int32
3131
single := make(chan struct{})
3232
retChan := make(chan PortResult)
@@ -43,7 +43,7 @@ func TcpScan(ctx context.Context, addresses <-chan Address, workers, timeout int
4343
if ExitFunc {
4444
return
4545
}
46-
pr := Connect(add.IP, add.Port, timeout)
46+
pr := Connect(add.IP, add.Port, timeout, proxy)
4747
atomic.AddInt32(&id, 1)
4848
runtime.EventsEmit(ctx, "progressID", id)
4949
if pr.Status {
@@ -76,10 +76,10 @@ type Address struct {
7676
Port int
7777
}
7878

79-
func Connect(ip string, port, timeout int) PortResult {
79+
func Connect(ip string, port, timeout int, proxy *clients.Proxy) PortResult {
8080
var pr PortResult
8181
scanner := gonmap.New()
82-
status, response := scanner.Scan(ip, port, time.Second*time.Duration(timeout))
82+
status, response := scanner.Scan(ip, port, time.Second*time.Duration(timeout), proxy)
8383
switch status {
8484
case gonmap.Closed:
8585
pr.Status = false

0 commit comments

Comments
 (0)