Lua/NSE套接字连接问题
我可以毫无问题地远程登录到某个主机和端口并发出命令。但是,当我尝试编写与同一主机和端口的套接字连接(使用 nmap NSE 和 Lua)脚本时,它失败并显示以下错误消息:
|_sockettest:尝试通过关闭的套接字接收
套接字我的代码的连接部分在这里:
local msg
local response
msg = "hello\n"
local socket = nmap.new_socket()
socket:set_timeout(150000)
socket:send(msg)
response,data = socket:receive()
return data
我认为数据发送正常。服务器应该只回显我发送的内容。有谁知道问题可能是什么?
I can telnet to a certain host and port no problem and issue commands. However when i try to script a socket connection (using nmap NSE and Lua) to the same host and port, it fails with the following error message:
|_sockettest: Trying to receive through a closed socket
the socket connect part of my code is here:
local msg
local response
msg = "hello\n"
local socket = nmap.new_socket()
socket:set_timeout(150000)
socket:send(msg)
response,data = socket:receive()
return data
I think the data is sending ok. The server should just echo back what i sent. Does anyone know what the problem could be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在接收之前(以及发送之前)调用
socket:connect
。说真的,请阅读您编写的代码。 您指定的发送对象是哪里?You need to call
socket:connect
before receiving (and before sending). Seriously, read that code you wrote. Where did you specify to whom you're sending ?