mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-23 19:51:52 +08:00
fix: Web 全局状态同步、字典文件错误提示、长驻插件连接可取消
- scan.go: Web API 构建 config/state 后同步到全局实例 - config_builder.go: 用户名/密码/URL 文件读取失败时输出错误日志 - reverseshell.go: 读命令设 1s 超时,超时后检查 ctx 实现可取消 - forwardshell.go: handleClient 接受 ctx,取消时关闭连接解除阻塞 - socks5proxy.go: handleClient 接受 ctx,取消时关闭连接解除 IO 阻塞
This commit is contained in:
@@ -114,14 +114,20 @@ func (p *ForwardShellPlugin) startForwardShellServer(ctx context.Context, port i
|
||||
}
|
||||
|
||||
common.LogSuccess(i18n.Tr("forwardshell_client_connected", conn.RemoteAddr().String()))
|
||||
go p.handleClient(conn)
|
||||
go p.handleClient(ctx, conn)
|
||||
}
|
||||
}
|
||||
|
||||
// handleClient 处理客户端连接
|
||||
func (p *ForwardShellPlugin) handleClient(clientConn net.Conn) {
|
||||
func (p *ForwardShellPlugin) handleClient(ctx context.Context, clientConn net.Conn) {
|
||||
defer func() { _ = clientConn.Close() }()
|
||||
|
||||
// ctx 取消时关闭连接,解除阻塞的读操作
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
_ = clientConn.Close()
|
||||
}()
|
||||
|
||||
// 发送欢迎信息
|
||||
welcome := fmt.Sprintf("FScan Forward Shell - %s\nType 'exit' to disconnect\n\n", runtime.GOOS)
|
||||
_, _ = clientConn.Write([]byte(welcome))
|
||||
@@ -145,7 +151,7 @@ func (p *ForwardShellPlugin) handleClient(clientConn net.Conn) {
|
||||
p.executeCommand(clientConn, command)
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
if err := scanner.Err(); err != nil && ctx.Err() == nil {
|
||||
common.LogError(i18n.Tr("forwardshell_read_failed", err))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user