2016-02-04 15:22:51 +01:00
|
|
|
#!/usr/bin/env python
|
2014-09-05 10:41:00 +02:00
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
The DomClassifier Module
|
|
|
|
============================
|
|
|
|
|
|
|
|
The DomClassifier modules is fetching the list of files to be
|
|
|
|
processed and index each file with a full-text indexer (Whoosh until now).
|
|
|
|
|
|
|
|
"""
|
|
|
|
import time
|
|
|
|
from packages import Paste
|
|
|
|
from pubsublogger import publisher
|
|
|
|
|
|
|
|
import DomainClassifier.domainclassifier
|
|
|
|
from Helper import Process
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
publisher.port = 6380
|
|
|
|
publisher.channel = "Script"
|
|
|
|
|
|
|
|
config_section = 'DomClassifier'
|
|
|
|
|
|
|
|
p = Process(config_section)
|
|
|
|
|
|
|
|
publisher.info("""ZMQ DomainClassifier is Running""")
|
|
|
|
|
2014-09-08 16:51:43 +02:00
|
|
|
c = DomainClassifier.domainclassifier.Extract(rawtext="")
|
2014-09-17 17:19:03 +02:00
|
|
|
|
|
|
|
cc = p.config.get("DomClassifier", "cc")
|
|
|
|
cc_tld = p.config.get("DomClassifier", "cc_tld")
|
|
|
|
|
2014-09-05 10:41:00 +02:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
message = p.get_from_set()
|
|
|
|
|
|
|
|
if message is not None:
|
|
|
|
PST = Paste.Paste(message)
|
|
|
|
else:
|
2016-06-30 14:36:47 +02:00
|
|
|
publisher.debug("Script DomClassifier is idling 1s")
|
2014-09-05 10:41:00 +02:00
|
|
|
time.sleep(1)
|
|
|
|
continue
|
|
|
|
paste = PST.get_p_content()
|
|
|
|
mimetype = PST._get_p_encoding()
|
|
|
|
if mimetype == "text/plain":
|
2014-09-08 16:51:43 +02:00
|
|
|
c.text(rawtext=paste)
|
2014-09-05 10:41:00 +02:00
|
|
|
c.potentialdomain()
|
|
|
|
c.validdomain(rtype=['A'], extended=True)
|
2014-09-17 17:19:03 +02:00
|
|
|
localizeddomains = c.include(expression=cc_tld)
|
2014-09-05 10:41:00 +02:00
|
|
|
if localizeddomains:
|
2014-09-17 17:19:03 +02:00
|
|
|
print(localizeddomains)
|
|
|
|
publisher.warning('DomainC;{};{};{};Checked {} located in {}'.format(
|
|
|
|
PST.p_source, PST.p_date, PST.p_name, localizeddomains, cc_tld))
|
|
|
|
localizeddomains = c.localizedomain(cc=cc)
|
2014-09-05 10:41:00 +02:00
|
|
|
if localizeddomains:
|
2014-09-17 17:19:03 +02:00
|
|
|
print(localizeddomains)
|
|
|
|
publisher.warning('DomainC;{};{};{};Checked {} located in {}'.format(
|
|
|
|
PST.p_source, PST.p_date, PST.p_name, localizeddomains, cc))
|
2014-09-05 10:41:00 +02:00
|
|
|
except IOError:
|
|
|
|
print "CRC Checksum Failed on :", PST.p_path
|
|
|
|
publisher.error('Duplicate;{};{};{};CRC Checksum Failed'.format(
|
|
|
|
PST.p_source, PST.p_date, PST.p_name))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|