def test_hostname_proto_port(): target = 'http://example.com:80' targets = Target.parse_target(target) assert len(targets) == 1 t = targets.pop() assert t == Target(host='example.com', port='80', protocol='http')
def test_ip_port(): target = '192.168.1.1:8080' targets = Target.parse_target(target) assert len(targets) == 1 t = targets.pop() assert t == Target(host='192.168.1.1', port='8080') assert str(t) == target
def test_hostname(): target = 'example.com' targets = Target.parse_target(target) assert len(targets) == 1 t = targets.pop() assert t == Target(host='example.com')
def test_ip(): target = '127.0.0.1' targets = Target.parse_target(target) assert len(targets) == 1 t = targets.pop() assert t == Target(host=target) assert str(t) == target
def test_cidr(): target = '192.168.1.0/24' targets = Target.parse_target(target) assert len(targets) == 254 # TODO explicitly validate the range """
def test_proto_ip_port(): target = 'snmp://192.168.1.1:8080' targets = Target.parse_target(target) assert len(targets) == 1 t = targets.pop() assert t == Target(host='192.168.1.1', port=8080, protocol='snmp') assert str(t) == target
def test_nmap(): path = os.path.dirname(os.path.abspath(__file__)) nmap = os.path.join(path, "tomcat_nmap.xml") targets = Target.parse_target(nmap) assert len(targets) == 1 t = targets.pop() path = os.path.dirname(os.path.abspath(__file__)) print("target: %s" % t) assert t == Target(host='127.0.0.1', port='8080')
def test_targets_file(): target = '/tmp/targets.txt' with open(target, 'w') as fout: fout.write('127.0.0.1\n') fout.write('127.0.0.2:8080\n') targets = Target.parse_target(target) assert len(targets) == 2 for t in targets: if t.host == '127.0.0.1': t1(t) else: t2(t) os.remove(target)
def test_targets_file(): target = '/tmp/targets.txt' with open(target, 'w') as fout: fout.write('127.0.0.1\n') fout.write('127.0.0.2:8080\n') targets = Target.parse_target(target) assert len(targets) == 2 for t in targets: if t.host == '127.0.0.1': t1(t) else: t2(t) remove(target)
def test_nmap(): nmap = "tests/tomcat_nmap.xml" targets = Target.parse_target(nmap) assert len(targets) == 1 t = targets.pop() assert t == Target(host='127.0.0.1', port='8080')