Lua 脚本结束 TCP 连接?

问题描述 投票:0回答:1

我在 Lua 中编写了以下脚本以与 nmap 一起使用:

action = function()
    local target = "46.121.76.117"

    -- Create a new TCP socket
    local sock = nmap.new_socket("tcp")
    sock:set_timeout(10)

    -- Connect to the target IP and port
    local status, err = sock:connect(target, 6668)

    if not status then
        -- Failed to connect
        stdnse.debug1("Couldn't connect to %s on port %d; %s",target, 6668, err)
        sock:close()
        return
    end

问题是脚本没有等待1秒就立即打印:

无法连接到端口 6668 上的 46.121.76.117;超时

这是为什么呢? 我运行了

nmap 46.121.76.117
,它显示端口
6668
已打开。

另外,正如您在wireshark中看到的那样,前3个数据包在进行扫描时使用nmap发送,最后3个数据包使用我的Lua脚本发送。

出于某种奇怪的原因,我的 Lua 脚本发送了 [RST] 数据包

Wireshark

lua wireshark nmap
1个回答
0
投票

正如评论中提到的,

set_timeout
设置超时值以毫秒为单位,因此如果你想将其设置为10秒,则需要调用
set_timeout(10*1000)
。这很可能解释了您在 10 毫秒后客户端重置连接时看到的结果。

© www.soinside.com 2019 - 2024. All rights reserved.