Ejemplo n.º 1
0
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')
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
def test_hostname():
    target = 'example.com'
    targets = Target.parse_target(target)
    assert len(targets) == 1

    t = targets.pop()
    assert t == Target(host='example.com')
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def test_cidr():
    target = '192.168.1.0/24'
    targets = Target.parse_target(target)
    assert len(targets) == 254

    # TODO explicitly validate the range
    """
Ejemplo n.º 6
0
def test_cidr():
    target = '192.168.1.0/24'
    targets = Target.parse_target(target)
    assert len(targets) == 254

    # TODO explicitly validate the range
    """
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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')
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
def test_hostname():
    target = 'example.com'
    targets = Target.parse_target(target)
    assert len(targets) == 1

    t = targets.pop()
    assert t == Target(host='example.com')
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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')
Ejemplo n.º 14
0
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')
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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')