def test_match_dns_fingerprints_match_country(): fp.setup_fingerprints() msm = { "probe_cc": "TR", "test_keys": { "queries": [{ "engine": "system", "resolver_hostname": None, "query_type": "A", "hostname": "beeg.com", "answers": [ { "hostname": "beeg.com", "answer_type": "CNAME", "ttl": 0 }, { "ipv4": "195.175.254.2", "answer_type": "A", "ttl": 0 }, ], "failure": None, "resolver_port": None, }] }, } matches = fp.match_fingerprints(msm) assert matches == [{"dns_full": "195.175.254.2", "locality": "country"}]
def test_match_fingerprints_match_country(): fp.setup_fingerprints() msm = { "probe_cc": "MY", "test_keys": { "requests": [{ "response": { "body": "foo ... Makluman/Notification ... foo" } }] }, } matches = fp.match_fingerprints(msm) assert matches == [{ "body_match": "Makluman/Notification", "locality": "country" }]
def test_match_fingerprints_dict_body(): fp.setup_fingerprints() # from 20200108T054856Z-web_connectivity-20200109T102441Z_AS42610_613KNyjuQqiuloY1a391dhZccSDz9M1MD30P6EpUIWSByjcq4T-AS42610-RU-probe-0.2.0.json msm = { "probe_cc": "MY", "test_keys": { "requests": [{ "response": { "body": { "data": "q82BgAABAAEAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQABwAwAAQABAAA/+AAEXbjYIg==", "format": "base64", } } }] }, } assert fp.match_fingerprints(msm) == []
def test_match_fingerprints_match_zz(): fp.setup_fingerprints() msm = { "probe_cc": "IE", "test_keys": { "requests": [{ "response": { "body": "", "headers": { "Server": "Kerio Control Embedded Web Server" }, } }] }, } matches = fp.match_fingerprints(msm) assert matches == [{ "header_full": "Kerio Control Embedded Web Server", "header_name": "server", "locality": "local", }], matches
def test_match_fingerprints_no_match(): fp.setup_fingerprints() msm = {"probe_cc": "IE", "test_keys": {"requests": []}} assert fp.match_fingerprints(msm) == []