예제 #1
0
def test_disabled_config():
    module = FTPBanner()

    if module.name not in config.config:
        config.config.add_section(module.name)
    config.config.set(module.name, "enabled", "no")

    result = module.should_execute("ftp", 21)

    config.config.set(module.name, "enabled", "yes")

    assert result is False
예제 #2
0
def test_get_banner_timeout():
    banner = FTPBanner()
    Loot.reset()

    hostname = "1.1.1.1"
    port = 21

    banner.execute(hostname, port)

    port = str(port)

    assert Loot.loot[hostname] is not None
    assert Loot.loot[hostname][port] is not None
    assert Loot.loot[hostname][port][banner.loot_name] is not None
예제 #3
0
def test_get_banner_invalid():
    banner = FTPBanner()
    Loot.reset()

    hostname = "256.128.63.32"
    port = 21

    banner.execute(hostname, port)

    port = str(port)

    assert Loot.loot[hostname] is not None
    assert Loot.loot[hostname][port] is not None
    assert Loot.loot[hostname][port][banner.loot_name] is not None
예제 #4
0
def test_get_banner_unreachable():
    banner = FTPBanner()
    Loot.reset()

    hostname = "127.0.0.1"
    port = 2121

    banner.execute(hostname, port)

    port = str(port)

    assert Loot.loot[hostname] is not None
    assert Loot.loot[hostname][port] is not None
    assert Loot.loot[hostname][port][banner.loot_name] is not None
    assert "Banner" not in Loot.loot[hostname][port][banner.loot_name]
예제 #5
0
def test_get_banner():
    banner = FTPBanner()

    hostname = "speedtest.tele2.net"
    port = 21

    try:
        banner.execute(hostname, port)

        port = str(port)

        assert Loot.loot[hostname] is not None
        assert Loot.loot[hostname][port] is not None
        assert Loot.loot[hostname][port][banner.loot_name] is not None

        if not Loot.loot[hostname][port][banner.loot_name]:
            warnings.warn("Banner not present")
            raise AssertionError()
        assert Loot.loot[hostname][port][banner.loot_name] is not None
    except AssertionError:
        warnings.warn("Unable to connect to speedtest.tele2.net")
예제 #6
0
def test_should_not_run():
    banner = FTPBanner()

    result = banner.should_execute("ssh", 22)

    assert result is False
예제 #7
0
def test_should_run_port():
    banner = FTPBanner()

    result = banner.should_execute("ftpd", 21)

    assert result is True
예제 #8
0
def test_should_run_service():
    banner = FTPBanner()

    result = banner.should_execute("ftp", 2121)

    assert result is True
예제 #9
0
def test_module_creation():
    banner = FTPBanner()
    assert banner is not None