Skip to content

Commit 207ac77

Browse files
authored
Merge pull request #419 from CIRCL/domain_object
fix: [Decoded] add Decoded file
2 parents b4a85c0 + d765a83 commit 207ac77

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

bin/lib/Decoded.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
# -*-coding:UTF-8 -*
3+
4+
import os
5+
import sys
6+
import redis
7+
8+
9+
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages'))
10+
import Item
11+
12+
13+
import ConfigLoader
14+
15+
config_loader = ConfigLoader.ConfigLoader()
16+
r_serv_metadata = config_loader.get_redis_conn("ARDB_Metadata")
17+
config_loader = None
18+
19+
def _get_decoded_items_list(sha1_string):
20+
return r_serv_metadata.zrange('nb_seen_hash:{}'.format(sha1_string), 0, -1)
21+
22+
def get_item_decoded(item_id):
23+
'''
24+
Retun all decoded item of a given item id.
25+
26+
:param item_id: item id
27+
'''
28+
res = r_serv_metadata.smembers('hash_paste:{}'.format(item_id))
29+
if res:
30+
return list(res)
31+
else:
32+
return []
33+
34+
def get_domain_decoded_item(domain):
35+
'''
36+
Retun all decoded item of a given domain.
37+
38+
:param domain: crawled domain
39+
'''
40+
res = r_serv_metadata.smembers('hash_domain:{}'.format(domain))
41+
if res:
42+
return list(res)
43+
else:
44+
return []
45+
46+
def save_domain_decoded(domain, sha1_string):
47+
r_serv_metadata.sadd('hash_domain:{}'.format(domain), sha1_string) # domain - hash map
48+
r_serv_metadata.sadd('domain_hash:{}'.format(sha1_string), domain) # hash - domain ma
49+
50+
if __name__ == "__main__":
51+
#sha1_str = '1e4db5adc1334ad2c9762db9ff6b845ee6ddc223'
52+
#res = _get_decoded_items_list(sha1_str)
53+
#print(res)
54+
#print(len(res))
55+
56+
res = get_domain_decoded_item('2222222dpg65ioqu.onion')
57+
print(res)

0 commit comments

Comments
 (0)