mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-13 21:02:44 +08:00
Translate 5 file from Plugins
Translate Chinese text to English in various plugin files. * **Plugins/FTP.go** - Translate log messages and comments from Chinese to English. - Update function comments to English. * **Plugins/IMAP.go** - Translate log messages and comments from Chinese to English. - Update function comments to English. * **Plugins/Kafka.go** - Translate log messages and comments from Chinese to English. - Update function comments to English. * **Plugins/LDAP.go** - Translate log messages and comments from Chinese to English. - Update function comments to English. * **Plugins/Memcached.go** - Translate log messages and comments from Chinese to English. - Update function comments to English. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/redhawkeye/fscan?shareId=XXXX-XXXX-XXXX-XXXX).
This commit is contained in:
parent
5d20cc05c3
commit
5cf3b46909
@ -16,16 +16,16 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
maxRetries := Common.MaxRetries
|
||||
target := fmt.Sprintf("%v:%v", info.Host, info.Ports)
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("开始扫描 %s", target))
|
||||
Common.LogDebug("尝试匿名登录...")
|
||||
Common.LogDebug(fmt.Sprintf("Starting scan %s", target))
|
||||
Common.LogDebug("Attempting anonymous login...")
|
||||
|
||||
// 尝试匿名登录
|
||||
// Attempt anonymous login
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
success, dirs, err := FtpConn(info, "anonymous", "")
|
||||
if success && err == nil {
|
||||
Common.LogSuccess("匿名登录成功!")
|
||||
Common.LogSuccess("Anonymous login successful!")
|
||||
|
||||
// 保存匿名登录结果
|
||||
// Save anonymous login result
|
||||
result := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -50,24 +50,24 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
|
||||
totalUsers := len(Common.Userdict["ftp"])
|
||||
totalPass := len(Common.Passwords)
|
||||
Common.LogDebug(fmt.Sprintf("开始尝试用户名密码组合 (总用户数: %d, 总密码数: %d)", totalUsers, totalPass))
|
||||
Common.LogDebug(fmt.Sprintf("Starting username and password combinations (Total users: %d, Total passwords: %d)", totalUsers, totalPass))
|
||||
|
||||
tried := 0
|
||||
total := totalUsers * totalPass
|
||||
|
||||
// 遍历用户名密码组合
|
||||
// Iterate through username and password combinations
|
||||
for _, user := range Common.Userdict["ftp"] {
|
||||
for _, pass := range Common.Passwords {
|
||||
tried++
|
||||
pass = strings.Replace(pass, "{user}", user, -1)
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] 尝试: %s:%s", tried, total, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] Trying: %s:%s", tried, total, user, pass))
|
||||
|
||||
var lastErr error
|
||||
|
||||
// 重试循环
|
||||
// Retry loop
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
if retryCount > 0 {
|
||||
Common.LogDebug(fmt.Sprintf("第%d次重试: %s:%s", retryCount+1, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("Retry %d: %s:%s", retryCount+1, user, pass))
|
||||
}
|
||||
|
||||
done := make(chan struct {
|
||||
@ -91,10 +91,10 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
select {
|
||||
case result := <-done:
|
||||
if result.success && result.err == nil {
|
||||
successLog := fmt.Sprintf("FTP服务 %s 成功爆破 用户名: %v 密码: %v", target, user, pass)
|
||||
successLog := fmt.Sprintf("FTP service %s successfully brute-forced Username: %v Password: %v", target, user, pass)
|
||||
Common.LogSuccess(successLog)
|
||||
|
||||
// 保存爆破成功结果
|
||||
// Save brute-force success result
|
||||
vulnResult := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -114,12 +114,12 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
lastErr = result.err
|
||||
case <-time.After(time.Duration(Common.Timeout) * time.Second):
|
||||
lastErr = fmt.Errorf("连接超时")
|
||||
lastErr = fmt.Errorf("Connection timeout")
|
||||
}
|
||||
|
||||
// 错误处理
|
||||
// Error handling
|
||||
if lastErr != nil {
|
||||
errlog := fmt.Sprintf("FTP服务 %s 尝试失败 用户名: %v 密码: %v 错误: %v",
|
||||
errlog := fmt.Sprintf("FTP service %s attempt failed Username: %v Password: %v Error: %v",
|
||||
target, user, pass, lastErr)
|
||||
Common.LogError(errlog)
|
||||
|
||||
@ -128,7 +128,7 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
|
||||
if strings.Contains(lastErr.Error(), "too many connections") {
|
||||
Common.LogDebug("连接数过多,等待5秒...")
|
||||
Common.LogDebug("Too many connections, waiting 5 seconds...")
|
||||
time.Sleep(5 * time.Second)
|
||||
if retryCount < maxRetries-1 {
|
||||
continue
|
||||
@ -139,15 +139,15 @@ func FtpScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
}
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("扫描完成,共尝试 %d 个组合", tried))
|
||||
Common.LogDebug(fmt.Sprintf("Scan complete, tried %d combinations", tried))
|
||||
return tmperr
|
||||
}
|
||||
|
||||
// FtpConn 建立FTP连接并尝试登录
|
||||
// FtpConn establishes an FTP connection and attempts login
|
||||
func FtpConn(info *Common.HostInfo, user string, pass string) (success bool, directories []string, err error) {
|
||||
Host, Port := info.Host, info.Ports
|
||||
|
||||
// 建立FTP连接
|
||||
// Establish FTP connection
|
||||
conn, err := ftp.DialTimeout(fmt.Sprintf("%v:%v", Host, Port), time.Duration(Common.Timeout)*time.Second)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
@ -158,12 +158,12 @@ func FtpConn(info *Common.HostInfo, user string, pass string) (success bool, dir
|
||||
}
|
||||
}()
|
||||
|
||||
// 尝试登录
|
||||
// Attempt login
|
||||
if err = conn.Login(user, pass); err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
// 获取目录信息
|
||||
// Get directory information
|
||||
dirs, err := conn.List("")
|
||||
if err == nil && len(dirs) > 0 {
|
||||
directories = make([]string, 0, min(6, len(dirs)))
|
||||
@ -179,7 +179,7 @@ func FtpConn(info *Common.HostInfo, user string, pass string) (success bool, dir
|
||||
return true, directories, nil
|
||||
}
|
||||
|
||||
// min 返回两个整数中的较小值
|
||||
// min returns the smaller of two integers
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// IMAPScan 主扫描函数
|
||||
// IMAPScan main scan function
|
||||
func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
if Common.DisableBrute {
|
||||
return
|
||||
@ -20,10 +20,10 @@ func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
maxRetries := Common.MaxRetries
|
||||
target := fmt.Sprintf("%v:%v", info.Host, info.Ports)
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("开始扫描 %s", target))
|
||||
Common.LogDebug(fmt.Sprintf("Starting scan %s", target))
|
||||
totalUsers := len(Common.Userdict["imap"])
|
||||
totalPass := len(Common.Passwords)
|
||||
Common.LogDebug(fmt.Sprintf("开始尝试用户名密码组合 (总用户数: %d, 总密码数: %d)", totalUsers, totalPass))
|
||||
Common.LogDebug(fmt.Sprintf("Starting username and password combinations (Total users: %d, Total passwords: %d)", totalUsers, totalPass))
|
||||
|
||||
tried := 0
|
||||
total := totalUsers * totalPass
|
||||
@ -32,11 +32,11 @@ func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
for _, pass := range Common.Passwords {
|
||||
tried++
|
||||
pass = strings.Replace(pass, "{user}", user, -1)
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] 尝试: %s:%s", tried, total, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] Trying: %s:%s", tried, total, user, pass))
|
||||
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
if retryCount > 0 {
|
||||
Common.LogDebug(fmt.Sprintf("第%d次重试: %s:%s", retryCount+1, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("Retry %d: %s:%s", retryCount+1, user, pass))
|
||||
}
|
||||
|
||||
done := make(chan struct {
|
||||
@ -60,10 +60,10 @@ func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
case result := <-done:
|
||||
err = result.err
|
||||
if result.success {
|
||||
successMsg := fmt.Sprintf("IMAP服务 %s 爆破成功 用户名: %v 密码: %v", target, user, pass)
|
||||
successMsg := fmt.Sprintf("IMAP service %s brute-forced successfully Username: %v Password: %v", target, user, pass)
|
||||
Common.LogSuccess(successMsg)
|
||||
|
||||
// 保存结果
|
||||
// Save result
|
||||
vulnResult := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -81,11 +81,11 @@ func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
return nil
|
||||
}
|
||||
case <-time.After(time.Duration(Common.Timeout) * time.Second):
|
||||
err = fmt.Errorf("连接超时")
|
||||
err = fmt.Errorf("Connection timeout")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("IMAP服务 %s 尝试失败 用户名: %v 密码: %v 错误: %v", target, user, pass, err)
|
||||
errMsg := fmt.Sprintf("IMAP service %s attempt failed Username: %v Password: %v Error: %v", target, user, pass, err)
|
||||
Common.LogError(errMsg)
|
||||
|
||||
if retryErr := Common.CheckErrs(err); retryErr != nil {
|
||||
@ -100,17 +100,17 @@ func IMAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
}
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("扫描完成,共尝试 %d 个组合", tried))
|
||||
Common.LogDebug(fmt.Sprintf("Scan complete, tried %d combinations", tried))
|
||||
return tmperr
|
||||
}
|
||||
|
||||
// IMAPConn 连接测试函数
|
||||
// IMAPConn connection test function
|
||||
func IMAPConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
host, port := info.Host, info.Ports
|
||||
timeout := time.Duration(Common.Timeout) * time.Second
|
||||
addr := fmt.Sprintf("%s:%s", host, port)
|
||||
|
||||
// 尝试普通连接
|
||||
// Attempt plain connection
|
||||
conn, err := net.DialTimeout("tcp", addr, timeout)
|
||||
if err == nil {
|
||||
if flag, err := tryIMAPAuth(conn, user, pass, timeout); err == nil {
|
||||
@ -119,33 +119,33 @@ func IMAPConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
// 尝试TLS连接
|
||||
// Attempt TLS connection
|
||||
tlsConfig := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
conn, err = tls.DialWithDialer(&net.Dialer{Timeout: timeout}, "tcp", addr, tlsConfig)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("连接失败: %v", err)
|
||||
return false, fmt.Errorf("Connection failed: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
return tryIMAPAuth(conn, user, pass, timeout)
|
||||
}
|
||||
|
||||
// tryIMAPAuth 尝试IMAP认证
|
||||
// tryIMAPAuth attempts IMAP authentication
|
||||
func tryIMAPAuth(conn net.Conn, user string, pass string, timeout time.Duration) (bool, error) {
|
||||
conn.SetDeadline(time.Now().Add(timeout))
|
||||
|
||||
reader := bufio.NewReader(conn)
|
||||
_, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("读取欢迎消息失败: %v", err)
|
||||
return false, fmt.Errorf("Failed to read welcome message: %v", err)
|
||||
}
|
||||
|
||||
loginCmd := fmt.Sprintf("a001 LOGIN \"%s\" \"%s\"\r\n", user, pass)
|
||||
_, err = conn.Write([]byte(loginCmd))
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("发送登录命令失败: %v", err)
|
||||
return false, fmt.Errorf("Failed to send login command: %v", err)
|
||||
}
|
||||
|
||||
for {
|
||||
@ -153,9 +153,9 @@ func tryIMAPAuth(conn net.Conn, user string, pass string, timeout time.Duration)
|
||||
response, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return false, fmt.Errorf("认证失败")
|
||||
return false, fmt.Errorf("Authentication failed")
|
||||
}
|
||||
return false, fmt.Errorf("读取响应失败: %v", err)
|
||||
return false, fmt.Errorf("Failed to read response: %v", err)
|
||||
}
|
||||
|
||||
if strings.Contains(response, "a001 OK") {
|
||||
@ -163,7 +163,7 @@ func tryIMAPAuth(conn net.Conn, user string, pass string, timeout time.Duration)
|
||||
}
|
||||
|
||||
if strings.Contains(response, "a001 NO") || strings.Contains(response, "a001 BAD") {
|
||||
return false, fmt.Errorf("认证失败")
|
||||
return false, fmt.Errorf("Authentication failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,17 +15,17 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
|
||||
maxRetries := Common.MaxRetries
|
||||
target := fmt.Sprintf("%v:%v", info.Host, info.Ports)
|
||||
Common.LogDebug(fmt.Sprintf("开始扫描 %s", target))
|
||||
Common.LogDebug(fmt.Sprintf("Starting scan %s", target))
|
||||
|
||||
// 尝试无认证访问
|
||||
Common.LogDebug("尝试无认证访问...")
|
||||
// Attempt unauthenticated access
|
||||
Common.LogDebug("Attempting unauthenticated access...")
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
if retryCount > 0 {
|
||||
Common.LogDebug(fmt.Sprintf("第%d次重试无认证访问", retryCount+1))
|
||||
Common.LogDebug(fmt.Sprintf("Retry %d for unauthenticated access", retryCount+1))
|
||||
}
|
||||
flag, err := KafkaConn(info, "", "")
|
||||
if flag && err == nil {
|
||||
// 保存无认证访问结果
|
||||
// Save unauthenticated access result
|
||||
result := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -38,13 +38,13 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
},
|
||||
}
|
||||
Common.SaveResult(result)
|
||||
Common.LogSuccess(fmt.Sprintf("Kafka服务 %s 无需认证即可访问", target))
|
||||
Common.LogSuccess(fmt.Sprintf("Kafka service %s can be accessed without authentication", target))
|
||||
return nil
|
||||
}
|
||||
if err != nil && Common.CheckErrs(err) != nil {
|
||||
if retryCount < maxRetries-1 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
break
|
||||
@ -52,21 +52,21 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
|
||||
totalUsers := len(Common.Userdict["kafka"])
|
||||
totalPass := len(Common.Passwords)
|
||||
Common.LogDebug(fmt.Sprintf("开始尝试用户名密码组合 (总用户数: %d, 总密码数: %d)", totalUsers, totalPass))
|
||||
Common.LogDebug(fmt.Sprintf("Starting username and password combinations (Total users: %d, Total passwords: %d)", totalUsers, totalPass))
|
||||
|
||||
tried := 0
|
||||
total := totalUsers * totalPass
|
||||
|
||||
// 遍历所有用户名密码组合
|
||||
// Iterate through all username and password combinations
|
||||
for _, user := range Common.Userdict["kafka"] {
|
||||
for _, pass := range Common.Passwords {
|
||||
tried++
|
||||
pass = strings.Replace(pass, "{user}", user, -1)
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] 尝试: %s:%s", tried, total, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] Trying: %s:%s", tried, total, user, pass))
|
||||
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
if retryCount > 0 {
|
||||
Common.LogDebug(fmt.Sprintf("第%d次重试: %s:%s", retryCount+1, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("Retry %d: %s:%s", retryCount+1, user, pass))
|
||||
}
|
||||
|
||||
done := make(chan struct {
|
||||
@ -90,7 +90,7 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
case result := <-done:
|
||||
err = result.err
|
||||
if result.success && err == nil {
|
||||
// 保存爆破成功结果
|
||||
// Save brute-force success result
|
||||
vulnResult := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -105,15 +105,15 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
},
|
||||
}
|
||||
Common.SaveResult(vulnResult)
|
||||
Common.LogSuccess(fmt.Sprintf("Kafka服务 %s 爆破成功 用户名: %s 密码: %s", target, user, pass))
|
||||
Common.LogSuccess(fmt.Sprintf("Kafka service %s brute-forced successfully Username: %s Password: %s", target, user, pass))
|
||||
return nil
|
||||
}
|
||||
case <-time.After(time.Duration(Common.Timeout) * time.Second):
|
||||
err = fmt.Errorf("连接超时")
|
||||
err = fmt.Errorf("Connection timeout")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
Common.LogError(fmt.Sprintf("Kafka服务 %s 尝试失败 用户名: %s 密码: %s 错误: %v",
|
||||
Common.LogError(fmt.Sprintf("Kafka service %s attempt failed Username: %s Password: %s Error: %v",
|
||||
target, user, pass, err))
|
||||
if retryErr := Common.CheckErrs(err); retryErr != nil {
|
||||
if retryCount == maxRetries-1 {
|
||||
@ -127,11 +127,11 @@ func KafkaScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
}
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("扫描完成,共尝试 %d 个组合", tried))
|
||||
Common.LogDebug(fmt.Sprintf("Scan complete, tried %d combinations", tried))
|
||||
return tmperr
|
||||
}
|
||||
|
||||
// KafkaConn 尝试 Kafka 连接
|
||||
// KafkaConn attempts Kafka connection
|
||||
func KafkaConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
host, port := info.Host, info.Ports
|
||||
timeout := time.Duration(Common.Timeout) * time.Second
|
||||
@ -141,7 +141,7 @@ func KafkaConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
config.Net.TLS.Enable = false
|
||||
config.Version = sarama.V2_0_0_0
|
||||
|
||||
// 设置 SASL 配置
|
||||
// Set SASL configuration
|
||||
if user != "" || pass != "" {
|
||||
config.Net.SASL.Enable = true
|
||||
config.Net.SASL.Mechanism = sarama.SASLTypePlaintext
|
||||
@ -152,25 +152,25 @@ func KafkaConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
|
||||
brokers := []string{fmt.Sprintf("%s:%s", host, port)}
|
||||
|
||||
// 尝试作为消费者连接测试
|
||||
// Attempt to connect as a consumer
|
||||
consumer, err := sarama.NewConsumer(brokers, config)
|
||||
if err == nil {
|
||||
defer consumer.Close()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 如果消费者连接失败,尝试作为客户端连接
|
||||
// If consumer connection fails, attempt to connect as a client
|
||||
client, err := sarama.NewClient(brokers, config)
|
||||
if err == nil {
|
||||
defer client.Close()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 检查错误类型
|
||||
// Check error type
|
||||
if strings.Contains(err.Error(), "SASL") ||
|
||||
strings.Contains(err.Error(), "authentication") ||
|
||||
strings.Contains(err.Error(), "credentials") {
|
||||
return false, fmt.Errorf("认证失败")
|
||||
return false, fmt.Errorf("Authentication failed")
|
||||
}
|
||||
|
||||
return false, err
|
||||
|
@ -16,13 +16,13 @@ func LDAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
maxRetries := Common.MaxRetries
|
||||
target := fmt.Sprintf("%v:%v", info.Host, info.Ports)
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("开始扫描 %s", target))
|
||||
Common.LogDebug("尝试匿名访问...")
|
||||
Common.LogDebug(fmt.Sprintf("Starting scan %s", target))
|
||||
Common.LogDebug("Attempting anonymous access...")
|
||||
|
||||
// 首先尝试匿名访问
|
||||
// First try anonymous access
|
||||
flag, err := LDAPConn(info, "", "")
|
||||
if flag && err == nil {
|
||||
// 记录匿名访问成功
|
||||
// Record successful anonymous access
|
||||
result := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -35,28 +35,28 @@ func LDAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
},
|
||||
}
|
||||
Common.SaveResult(result)
|
||||
Common.LogSuccess(fmt.Sprintf("LDAP服务 %s 匿名访问成功", target))
|
||||
Common.LogSuccess(fmt.Sprintf("LDAP service %s anonymous access successful", target))
|
||||
return err
|
||||
}
|
||||
|
||||
totalUsers := len(Common.Userdict["ldap"])
|
||||
totalPass := len(Common.Passwords)
|
||||
Common.LogDebug(fmt.Sprintf("开始尝试用户名密码组合 (总用户数: %d, 总密码数: %d)", totalUsers, totalPass))
|
||||
Common.LogDebug(fmt.Sprintf("Starting username and password combinations (Total users: %d, Total passwords: %d)", totalUsers, totalPass))
|
||||
|
||||
tried := 0
|
||||
total := totalUsers * totalPass
|
||||
|
||||
// 遍历所有用户名密码组合
|
||||
// Iterate over all username and password combinations
|
||||
for _, user := range Common.Userdict["ldap"] {
|
||||
for _, pass := range Common.Passwords {
|
||||
tried++
|
||||
pass = strings.Replace(pass, "{user}", user, -1)
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] 尝试: %s:%s", tried, total, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("[%d/%d] Trying: %s:%s", tried, total, user, pass))
|
||||
|
||||
// 重试循环
|
||||
// Retry loop
|
||||
for retryCount := 0; retryCount < maxRetries; retryCount++ {
|
||||
if retryCount > 0 {
|
||||
Common.LogDebug(fmt.Sprintf("第%d次重试: %s:%s", retryCount+1, user, pass))
|
||||
Common.LogDebug(fmt.Sprintf("Retry %d: %s:%s", retryCount+1, user, pass))
|
||||
}
|
||||
|
||||
done := make(chan struct {
|
||||
@ -80,7 +80,7 @@ func LDAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
case result := <-done:
|
||||
err = result.err
|
||||
if result.success && err == nil {
|
||||
// 记录成功爆破的凭据
|
||||
// Record successful brute force credentials
|
||||
vulnResult := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -95,15 +95,15 @@ func LDAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
},
|
||||
}
|
||||
Common.SaveResult(vulnResult)
|
||||
Common.LogSuccess(fmt.Sprintf("LDAP服务 %s 爆破成功 用户名: %v 密码: %v", target, user, pass))
|
||||
Common.LogSuccess(fmt.Sprintf("LDAP service %s brute force successful Username: %v Password: %v", target, user, pass))
|
||||
return nil
|
||||
}
|
||||
case <-time.After(time.Duration(Common.Timeout) * time.Second):
|
||||
err = fmt.Errorf("连接超时")
|
||||
err = fmt.Errorf("connection timeout")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errlog := fmt.Sprintf("LDAP服务 %s 尝试失败 用户名: %v 密码: %v 错误: %v", target, user, pass, err)
|
||||
errlog := fmt.Sprintf("LDAP service %s attempt failed Username: %v Password: %v Error: %v", target, user, pass, err)
|
||||
Common.LogError(errlog)
|
||||
|
||||
if retryErr := Common.CheckErrs(err); retryErr != nil {
|
||||
@ -118,7 +118,7 @@ func LDAPScan(info *Common.HostInfo) (tmperr error) {
|
||||
}
|
||||
}
|
||||
|
||||
Common.LogDebug(fmt.Sprintf("扫描完成,共尝试 %d 个组合", tried))
|
||||
Common.LogDebug(fmt.Sprintf("Scan complete, tried %d combinations", tried))
|
||||
return tmperr
|
||||
}
|
||||
|
||||
@ -126,17 +126,17 @@ func LDAPConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
address := fmt.Sprintf("%s:%s", info.Host, info.Ports)
|
||||
timeout := time.Duration(Common.Timeout) * time.Second
|
||||
|
||||
// 配置LDAP连接
|
||||
// Configure LDAP connection
|
||||
l, err := ldap.Dial("tcp", address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
// 设置超时
|
||||
// Set timeout
|
||||
l.SetTimeout(timeout)
|
||||
|
||||
// 尝试绑定
|
||||
// Attempt to bind
|
||||
if user != "" {
|
||||
bindDN := fmt.Sprintf("cn=%s,dc=example,dc=com", user)
|
||||
err = l.Bind(bindDN, pass)
|
||||
@ -148,7 +148,7 @@ func LDAPConn(info *Common.HostInfo, user string, pass string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 尝试简单搜索以验证权限
|
||||
// Attempt a simple search to verify permissions
|
||||
searchRequest := ldap.NewSearchRequest(
|
||||
"dc=example,dc=com",
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
|
@ -7,29 +7,29 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// MemcachedScan 检测Memcached未授权访问
|
||||
// MemcachedScan checks for unauthorized access to Memcached
|
||||
func MemcachedScan(info *Common.HostInfo) error {
|
||||
realhost := fmt.Sprintf("%s:%v", info.Host, info.Ports)
|
||||
timeout := time.Duration(Common.Timeout) * time.Second
|
||||
|
||||
// 建立TCP连接
|
||||
// Establish TCP connection
|
||||
client, err := Common.WrapperTcpWithTimeout("tcp", realhost, timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// 设置超时时间
|
||||
// Set timeout
|
||||
if err := client.SetDeadline(time.Now().Add(timeout)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 发送stats命令
|
||||
// Send stats command
|
||||
if _, err := client.Write([]byte("stats\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 读取响应
|
||||
// Read response
|
||||
rev := make([]byte, 1024)
|
||||
n, err := client.Read(rev)
|
||||
if err != nil {
|
||||
@ -37,9 +37,9 @@ func MemcachedScan(info *Common.HostInfo) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 检查响应内容
|
||||
// Check response content
|
||||
if strings.Contains(string(rev[:n]), "STAT") {
|
||||
// 保存结果
|
||||
// Save result
|
||||
result := &Common.ScanResult{
|
||||
Time: time.Now(),
|
||||
Type: Common.VULN,
|
||||
@ -53,7 +53,7 @@ func MemcachedScan(info *Common.HostInfo) error {
|
||||
},
|
||||
}
|
||||
Common.SaveResult(result)
|
||||
Common.LogSuccess(fmt.Sprintf("Memcached %s 未授权访问", realhost))
|
||||
Common.LogSuccess(fmt.Sprintf("Memcached %s unauthorized access", realhost))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user