merge soc07 r4797 - Anonymous ftp login NSE script improvements

This commit is contained in:
fyodor 2007-08-11 03:29:27 +00:00
parent b2d25c8b4d
commit 237000cd29

View file

@ -2,15 +2,15 @@ id="Anonymous FTP"
description="Checks to see if a FTP server allows anonymous logins"
author = "ejlb <ejlbell@gmail.com>"
author = "Eddie Bell <ejlbell@gmail.com>"
license = "See nmaps COPYING for licence"
categories = {"intrusive"}
portrule = function(host, port)
if port.number == 21
and port.service == "ftp"
if (port.number == 21
or port.service == "ftp")
and port.protocol == "tcp"
and port.state == "open"
then
@ -22,23 +22,30 @@ end
action = function(host, port)
local socket = nmap.new_socket()
local result;
local result
local status = true
local isAnon = false
socket:connect(host.ip, port.number, port.protocol)
socket:send("USER anonymous\r\n")
socket:send("PASS IEUser@\r\n")
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\n\r"))
try(socket:send("PASS IEUser@\n\r"))
while status do
status, result = socket:receive_lines(1);
if string.match(result, "^230") then
isAnon = true;
break;
isAnon = true
break
end
end
socket:close();
socket:close()
if(isAnon) then
return "FTP: Anonymous login allowed"