Explorar el Código

Merge branch 'master' of https://git.swrzm.de/msc/pentest-helpers into master

Marius Schwarz hace 4 años
padre
commit
1885893973
Se han modificado 6 ficheros con 100 adiciones y 39 borrados
  1. 9 4
      example.gnmap
  2. 1 0
      example.json
  3. 0 4
      example2.gnmap
  4. 0 0
      example3.gnmap
  5. 90 0
      nmap-get.py
  6. 0 31
      nmap-pp.py

+ 9 - 4
example.gnmap

@@ -1,4 +1,9 @@
-# Nmap 7.80 scan initiated Wed Nov  4 20:36:10 2020 as: nmap -oG example.gnmap 127.0.0.1
-Host: 127.0.0.1 (localhost)	Status: Up
-Host: 127.0.0.1 (localhost)	Ports: 9080/open/tcp//glrpc///, 9090/open/tcp//zeus-admin///	Ignored State: closed (998)
-# Nmap done at Wed Nov  4 20:36:10 2020 -- 1 IP address (1 host up) scanned in 0.17 seconds
+# Nmap 7.80 scan initiated Wed Nov  4 21:42:17 2020 as: nmap -sC -sV -T5 -oG example2.gnmap scanme.nmap.org
+Host: 45.33.32.156 (scanme.nmap.org)	Status: Up
+Host: 45.33.32.156 (scanme.nmap.org)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+Host: 127.0.0.1 (bullshit.host)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+Host: 127.0.0.2 (bullshit.host)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+Host: 127.0.0.4 (bullshit.host)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+Host: 127.0.0.3 (bullshit.host)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+Host: 127.0.0.4 (bullshit.host)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
+# Nmap done at Wed Nov  4 21:42:41 2020 -- 1 IP address (1 host up) scanned in 24.35 seconds

+ 1 - 0
example.json

@@ -0,0 +1 @@
+[{"ip":"45.33.32.156","status":"Up","hostname":"scanme.nmap.org","ports":[{"port_number":22,"state":"open","protocol":"tcp","owner":"","service":"ssh","sun_rpc_info":"","version":"OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)"},{"port_number":80,"state":"open","protocol":"tcp","owner":"","service":"http","sun_rpc_info":"","version":"Apache httpd 2.4.7 ((Ubuntu))"},{"port_number":9929,"state":"open","protocol":"tcp","owner":"","service":"nping-echo","sun_rpc_info":"","version":"Nping echo"},{"port_number":31337,"state":"open","protocol":"tcp","owner":"","service":"tcpwrapped","sun_rpc_info":"","version":""}]}]

+ 0 - 4
example2.gnmap

@@ -1,4 +0,0 @@
-# Nmap 7.80 scan initiated Wed Nov  4 21:42:17 2020 as: nmap -sC -sV -T5 -oG example2.gnmap scanme.nmap.org
-Host: 45.33.32.156 (scanme.nmap.org)	Status: Up
-Host: 45.33.32.156 (scanme.nmap.org)	Ports: 22/open/tcp//ssh//OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)/, 80/open/tcp//http//Apache httpd 2.4.7 ((Ubuntu))/, 9929/open/tcp//nping-echo//Nping echo/, 31337/open/tcp//tcpwrapped///
-# Nmap done at Wed Nov  4 21:42:41 2020 -- 1 IP address (1 host up) scanned in 24.35 seconds

+ 0 - 0
example3.gnmap


+ 90 - 0
nmap-get.py

@@ -0,0 +1,90 @@
+#!/usr/bin/python
+import sys
+import json
+from rich.console import Console
+from rich.table import Table
+import argparse
+
+# Setup Table
+console = Console()
+
+table = Table(show_header=True, header_style="bold blue")
+table.add_column("Host", style="dim")
+table.add_column("IP", style="dim")
+table.add_column("Port")
+table.add_column("Service")
+table.add_column("Version", justify="left")
+
+def pprint_table(hostlist, iponly):
+
+    global table
+    for host in hostlist:
+        if iponly:
+            print(host["ip"])
+        else:
+            for port in host["ports"]:
+                table.add_row(
+                    host["hostname"],
+                    host["ip"],
+                    str(port["port_number"]),
+                    port["service"],
+                    port["version"]
+                )
+
+    if not iponly:
+        console.print(table)
+
+def filter_by_port(port):
+    global hosts
+    out = []
+    ports = []
+    for host in hosts:
+        for p in host["ports"]:
+            if port == str(p["port_number"]) and p["state"] == "open":
+                ports.append(p)
+        host["ports"] = ports
+        ports = []
+        out.append(host)
+    return out
+
+
+def filter_by_version(version):
+    global hosts
+    out = []
+    ports = []
+    for host in hosts:
+        for p in host["ports"]:
+            if version.lower() in p["version"].lower():
+                ports.append(p)
+        host["ports"] = ports
+        ports = []
+        out.append(host)
+    return out
+
+# Setup Argument Parser
+parser = argparse.ArgumentParser(description='Filtering nmap')
+parser.add_argument('file', action='store', nargs='?',
+                    help='Input File')
+parser.add_argument('--port', dest='port', action='store',
+                    help='Filter by port number')
+parser.add_argument('--version', dest='version', action='store',
+                    help='Filter by version string')
+parser.add_argument('--ip', dest='ip', action='store_true',
+                    help='Only print the ips')
+
+
+args = parser.parse_args()
+
+if args.file:
+    with open(args.file, "r") as inp_file:
+        hosts = json.loads(inp_file.read())
+else:
+    hosts = json.loads(sys.stdin.read())
+
+
+if args.port:
+    pprint_table(filter_by_port(args.port), args.ip)
+elif args.version:
+    pprint_table(filter_by_version(args.version), args.ip)
+else:
+    pprint_table(hosts, args.ip)

+ 0 - 31
nmap-pp.py

@@ -1,31 +0,0 @@
-#!/usr/bin/python
-import sys
-import json
-from rich.console import Console
-from rich.table import Table
-import fileinput
-
-console = Console()
-
-table = Table(show_header=True, header_style="bold blue")
-table.add_column("Host", style="dim")
-table.add_column("Port")
-table.add_column("Service")
-table.add_column("Version", justify="left")
-
-if len(sys.argv) == 2:
-    with open(sys.argv[1], "r") as inp_file:
-        hosts = json.loads(inp_file.read())
-else:
-    hosts = json.loads(sys.stdin.read())
-
-for host in hosts:
-    for port in host["ports"]:
-        table.add_row(
-            host["hostname"],
-            str(port["port_number"]),
-            port["service"],
-            port["version"]
-        )
-
-console.print(table)