Nmap Development mailing list archives

Re: Fwd: shortport function


From: Ferdy Riphagen <f.riphagen () nsec nl>
Date: Tue, 31 Jul 2007 13:19:30 +0200

Diman Todorov wrote:
  
From: Diman Todorov <diman.todorov () univie ac at>
Date: 12. Juli 2007 12:52:03 GMT+02:00
To: Nmap Dev <nmap-dev () insecure org>
Subject: Re: shortport function


    
yes, this is true. The shortport.portnumber doesn't take a table  
for the port state, only a string. I commited a fix for that to the  
soc07 svn (svn://diman () svn insecure org/nmap-exp/soc07/). The only  
parameter which doesn't take a table now is the protocol. I will  
leave it that way until someone comes up with a scenario in which  
you don't care if the open port is a tcp or udp port ;)

    
  

Thanks Eddie and Diman,

I've seen that line form the MSSQL.nse script 'portrule =
shortport.portnumber({1433, 1434}, "udp", {"open", "open|filtered"})' 
and started a little testing.
So, in the end I tried to port the function a bit, maybe not that good
and not needed, I'll update to just committed changes..

My experiment, just like you did with the port:
local state_table;
    if(type(_state) == "string") then
        state_table = {_state, "open"}
    elseif(type(_state) == "table") then
        state_table = _state"
    elseif(type(_state) == "nil") then
        state_table = {"open"}
    end

return function(host, port)
        if(port.protocol == proto) then
            for _, _s in ipairs(state_table) do
                if(port.state == _s) then
                    for _, _port in ipairs(port_table) do
                        if(port.number == _port) then
                            return true
                        end
                    end
                end
            end
        end
        return false
    end
end




_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: