Lua/NSE socket connection problem
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 ?
精彩评论