-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiparser.py
More file actions
executable file
·56 lines (42 loc) · 2.04 KB
/
Copy pathiparser.py
File metadata and controls
executable file
·56 lines (42 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/python3
import sys
import os
import xml.etree.ElementTree as ET
from argparse import ArgumentParser
def main():
parser = ArgumentParser()
parser.add_argument("-i",dest="input_file", required=True, help="Input file: This is the file you want to parses for information.")
parser.add_argument("--linux", dest="linux_hosts", action="store_true", required=False, help="This flag will find linux hosts and will parses the IP addresses in to another file")
parser.add_argument("--windows", dest="windows_hosts", action="store_true", required=False, help="This will find Windows hosts from the input file.")
parser.add_argument("--mail", dest="mail_servers", action="store_true", required=False, help="This will find mail servers from the input file.")
parser.add_argument("--ips", dest="ip_finder", action="store_true", required=False, help="Grab ips from the input file.")
parser.add_argument("--ports", dest="ports", action="store_true", required=False, help="Lists all the ports which were found.")
arguments = parser.parse_args()
input_file = arguments.input_file
linux = arguments.linux_hosts
windows = arguments.windows_hosts
mail = arguments.mail_servers
ip_find = arguments.ip_finder
if len(sys.argv) == 0:
print("Were them arguments man?!")
if input_file is False:
print("Please specify a file you would like to parse")
else:
_t = ET.parse(input_file)
_r = _t.getroot()
if ip_find is True:
print("[#] Printing IPS from input file. ")
for address in _r.iter('address'):
print(" [+] ", address.attrib['addr'])
if arguments.ports is True:
print("[#] Finding ports from input file. ")
ports = []
for port in _r.iter('port'):
ports.append(port.attrib['portid'])
p = list(set(ports))
print ("[#] Below are the unique port numbers found: ")
print (" [+] ",p)
if linux is True:
print ("[#] Discovering linux hosts")
if __name__ == "__main__":
main()