(target, ports)
return rep
portscan a target and output a LaTeX table
report_ports(target, ports) -> string
portscan a target and output a LaTeX table
report_ports(target, ports) -> string
portscan a target and output a LaTeX table report_ports ( target ports ) - > string
def report_ports(target, ports):
    """portscan a target and output a LaTeX table
report_ports(target, ports) -> string"""
    ans,unans = sr(IP(dst=target)/TCP(dport=ports),timeout=5)
    rep = "\\begin{tabular}{|r|l|l|}\n\\hline\n"
    for s,r in ans:
        if not r.haslayer(ICMP):
            if r.payload.flags == 0x12:
                rep += r.sprintf("%TCP.sport% & open & SA \\\\\n")
    rep += "\\hline\n"
    for s,r in ans:
        if r.haslayer(ICMP):
            rep += r.sprintf("%TCPerror.dport% & closed & ICMP type %ICMP.type%/%ICMP.code% from %IP.src% \\\\\n")
        elif r.payload.flags != 0x12:
            rep += r.sprintf("%TCP.sport% & closed & TCP %TCP.flags% \\\\\n")
    rep += "\\hline\n"
    for i in unans:
        rep += i.sprintf("%TCP.dport% & ? & unanswered \\\\\n")
    rep += "\\hline\n\\end{tabular}\n"
    return rep
def report_ports ( target , ports ) : ans , unans = sr ( IP ( dst = target ) / TCP ( dport = ports ) , timeout = 5 ) rep = "\\begin{tabular}{|r|l|l|}\n\\hline\n" for s , r in ans : if not r . haslayer ( ICMP ) : if r . payload . flags == 0x12 : rep += r . sprintf ( "%TCP.sport% & open & SA \\\\\n" ) rep += "\\hline\n" for s , r in ans : if r . haslayer ( ICMP ) : rep += r . sprintf ( "%TCPerror.dport% & closed & ICMP type %ICMP.type%/%ICMP.code% from %IP.src% \\\\\n" ) elif r . payload . flags != 0x12 : rep += r . sprintf ( "%TCP.sport% & closed & TCP %TCP.flags% \\\\\n" ) rep += "\\hline\n" for i in unans : rep += i . sprintf ( "%TCP.dport% & ? & unanswered \\\\\n" ) rep += "\\hline\n\\end{tabular}\n" return rep