mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
Expand i18n coverage
This commit is contained in:
@@ -48,14 +48,14 @@ func (p *ForwardShellPlugin) Scan(ctx context.Context, info *common.HostInfo, se
|
||||
port = 4444
|
||||
}
|
||||
|
||||
output.WriteString("=== 正向Shell服务器 ===\n")
|
||||
fmt.Fprintf(&output, "监听端口: %d\n", port)
|
||||
fmt.Fprintf(&output, "平台: %s\n\n", runtime.GOOS)
|
||||
output.WriteString(i18n.GetText("forwardshell_header") + "\n")
|
||||
output.WriteString(i18n.Tr("local_listen_port", port) + "\n")
|
||||
output.WriteString(i18n.Tr("local_platform", runtime.GOOS) + "\n\n")
|
||||
|
||||
// 启动正向Shell服务器
|
||||
err := p.startForwardShellServer(ctx, port, state)
|
||||
if err != nil {
|
||||
fmt.Fprintf(&output, "正向Shell服务器错误: %v\n", err)
|
||||
output.WriteString(i18n.Tr("forwardshell_server_error", err) + "\n")
|
||||
return &plugins.Result{
|
||||
Success: false,
|
||||
Output: output.String(),
|
||||
@@ -63,7 +63,7 @@ func (p *ForwardShellPlugin) Scan(ctx context.Context, info *common.HostInfo, se
|
||||
}
|
||||
}
|
||||
|
||||
output.WriteString("✓ 正向Shell服务已完成\n")
|
||||
output.WriteString(i18n.GetText("forwardshell_done") + "\n")
|
||||
common.LogSuccess(i18n.Tr("forwardshell_complete", port))
|
||||
|
||||
return &plugins.Result{
|
||||
@@ -79,7 +79,7 @@ func (p *ForwardShellPlugin) startForwardShellServer(ctx context.Context, port i
|
||||
// 监听指定端口
|
||||
listener, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
|
||||
if err != nil {
|
||||
return fmt.Errorf("监听端口失败: %w", err)
|
||||
return fmt.Errorf("%s: %w", i18n.GetText("listen_port_failed"), err)
|
||||
}
|
||||
defer func() { _ = listener.Close() }()
|
||||
|
||||
@@ -169,7 +169,7 @@ func (p *ForwardShellPlugin) executeCommand(conn net.Conn, command string) {
|
||||
case "linux", "darwin":
|
||||
cmd = exec.Command("/bin/sh", "-c", command)
|
||||
default:
|
||||
_, _ = fmt.Fprintf(conn, "不支持的平台: %s\n", runtime.GOOS)
|
||||
_, _ = fmt.Fprintln(conn, i18n.Tr("unsupported_platform", runtime.GOOS))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -182,18 +182,18 @@ func (p *ForwardShellPlugin) executeCommand(conn net.Conn, command string) {
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
_, _ = conn.Write([]byte("命令执行超时\n"))
|
||||
_, _ = conn.Write([]byte(i18n.GetText("command_timeout") + "\n"))
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(conn, "命令执行失败: %v\n", err)
|
||||
_, _ = fmt.Fprintln(conn, i18n.Tr("command_exec_failed", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 发送命令输出
|
||||
if len(output) == 0 {
|
||||
_, _ = conn.Write([]byte("(命令执行成功,无输出)\n"))
|
||||
_, _ = conn.Write([]byte(i18n.GetText("command_success_no_output") + "\n"))
|
||||
} else {
|
||||
_, _ = conn.Write(output)
|
||||
if !strings.HasSuffix(string(output), "\n") {
|
||||
|
||||
Reference in New Issue
Block a user