MCPcopy Create free account
hub / github.com/C3ting/ARL / csv

Method csv

app/utils/nmap.py:604–665  ·  view source on GitHub ↗

returns CSV output as text Example : host;hostname;hostname_type;protocol;port;name;state;product;extrainfo;reason;version;conf;cpe 127.0.0.1;localhost;PTR;tcp;22;ssh;open;OpenSSH;protocol 2.0;syn-ack;5.9p1 Debian 5ubuntu1;10;cpe 127.0.0.1;localhost;PTR;tcp;

(self)

Source from the content-addressed store, hash-verified

602 return False
603
604 def csv(self):
605 """
606 returns CSV output as text
607
608 Example :
609 host;hostname;hostname_type;protocol;port;name;state;product;extrainfo;reason;version;conf;cpe
610 127.0.0.1;localhost;PTR;tcp;22;ssh;open;OpenSSH;protocol 2.0;syn-ack;5.9p1 Debian 5ubuntu1;10;cpe
611 127.0.0.1;localhost;PTR;tcp;23;telnet;closed;;;conn-refused;;3;
612 127.0.0.1;localhost;PTR;tcp;24;priv-mail;closed;;;conn-refused;;3;
613 """
614 assert 'scan' in self._scan_result, 'Do a scan before trying to get result !'
615
616 if sys.version_info < (3, 0):
617 fd = io.BytesIO()
618 else:
619 fd = io.StringIO()
620
621 csv_ouput = csv.writer(fd, delimiter=';')
622 csv_header = [
623 'host',
624 'hostname',
625 'hostname_type',
626 'protocol',
627 'port',
628 'name',
629 'state',
630 'product',
631 'extrainfo',
632 'reason',
633 'version',
634 'conf',
635 'cpe'
636 ]
637
638 csv_ouput.writerow(csv_header)
639
640 for host in self.all_hosts():
641 for proto in self[host].all_protocols():
642 if proto not in ['tcp', 'udp']:
643 continue
644 lport = list(self[host][proto].keys())
645 lport.sort()
646 for port in lport:
647 hostname = ''
648 for h in self[host]['hostnames']:
649 hostname = h['name']
650 hostname_type = h['type']
651 csv_row = [
652 host, hostname, hostname_type,
653 proto, port,
654 self[host][proto][port]['name'],
655 self[host][proto][port]['state'],
656 self[host][proto][port]['product'],
657 self[host][proto][port]['extrainfo'],
658 self[host][proto][port]['reason'],
659 self[host][proto][port]['version'],
660 self[host][proto][port]['conf'],
661 self[host][proto][port]['cpe']

Callers

nothing calls this directly

Calls 2

all_hostsMethod · 0.95
all_protocolsMethod · 0.80

Tested by

no test coverage detected