1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00
Files
nmap/scripts/anonFTP.nse
david aa87f1db15 Fix the creation of an exception handler in anonFTP.nse. I changed
nmap.new_try(err_catch())
to
	nmap.new_try(err_catch)
The first statement calles new_try with the result of calling the err_catch
function, which is nil, when what is wanted is to call new_try with the
function itself as an argument.
2008-10-16 21:58:59 +00:00

50 lines
1.0 KiB
Lua

id = "Anonymous FTP"
description = [[
Checks if a FTP server allows anonymous logins.
]]
---
-- @output
-- |_ Anonymous FTP: Anonymous login allowed
author = "Eddie Bell <ejlbell@gmail.com>"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"default", "auth", "intrusive"}
require "shortport"
portrule = shortport.port_or_service(21, "ftp")
--- Connects to the ftp server and checks if the server allows anonymous logins.
action = function(host, port)
local socket = nmap.new_socket()
local result
local status = true
local isAnon = false
local err_catch = function()
socket:close()
end
local try = nmap.new_try(err_catch)
socket:set_timeout(5000)
try(socket:connect(host.ip, port.number, port.protocol))
try(socket:send("USER anonymous\r\n"))
try(socket:send("PASS IEUser@\r\n"))
while status do
status, result = socket:receive_lines(1);
if string.match(result, "^230") then
isAnon = true
break
end
end
socket:close()
if(isAnon) then
return "FTP: Anonymous login allowed"
end
end