开发者

Lua/NSE socket connection problem

开发者 https://www.devze.com 2023-03-16 18:13 出处:网络
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

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 mes开发者_开发技巧sage:

|_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?


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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号