text stringlengths 0 828 |
|---|
else: |
info(""=> Txt record query failed, sleeping 5 secs"") |
time.sleep(5) |
if not record: |
error(""=> Txt record query failed after %d tries"" % count) |
sys.exit(3) |
return record" |
4460,"def copy_sig(sig, opts, isdiff): |
""""""Deploy a sig"""""" |
info(""[+] \033[92mDeploying signature:\033[0m %s"" % sig) |
if isdiff: |
sourcefile = os.path.join(opts.workdir, '%s.cdiff' % sig) |
destfile = os.path.join(opts.mirrordir, '%s.cdiff' % sig) |
else: |
sourcefile = os.path.join(opts.workdir, '%s.cvd' % sig) |
destfile = os.path.join(opts.mirrordir, '%s.cvd' % sig) |
deploy_signature(sourcefile, destfile, opts.user, opts.group) |
info(""=> Deployed signature: %s"" % sig)" |
4461,"def update_sig(queue): |
""""""update signature"""""" |
while True: |
options, sign, vers = queue.get() |
info(""[+] \033[92mChecking signature version:\033[0m %s"" % sign) |
localver = get_local_version(options.mirrordir, sign) |
remotever = vers[sign] |
if localver is None or (localver and int(localver) < int(remotever)): |
info(""=> Update required local: %s => remote: %s"" % |
(localver, remotever)) |
info(""=> Downloading signature: %s"" % sign) |
status, code = download_sig(options, sign, remotever) |
if status: |
info(""=> Downloaded signature: %s"" % sign) |
copy_sig(sign, options, 0) |
else: |
if code == 404: |
error(""=> \033[91mSignature:\033[0m %s not found"" % sign) |
error(""=> \033[91mDownload failed:\033[0m %s code: %d"" |
% (sign, code)) |
else: |
info( |
""=> No update required L: %s => R: %s"" % (localver, remotever)) |
queue.task_done()" |
4462,"def update_diff(opts, sig): |
""""""Update diff"""""" |
for _ in range(1, 6): |
info(""[+] \033[92mDownloading cdiff:\033[0m %s"" % sig) |
status, code = download_sig(opts, sig) |
if status: |
info(""=> Downloaded cdiff: %s"" % sig) |
copy_sig(sig, opts, 1) |
else: |
if code == 404: |
error(""=> \033[91mSignature:\033[0m %s not found"" % sig) |
error(""=> \033[91mDownload failed:\033[0m %s code: %d"" |
% (sig, code))" |
4463,"def create_dns_file(opts, record): |
""""""Create the DNS record file"""""" |
info(""[+] \033[92mUpdating dns.txt file\033[0m"") |
filename = os.path.join(opts.mirrordir, 'dns.txt') |
localmd5 = get_file_md5(filename) |
remotemd5 = get_md5(record) |
if localmd5 != remotemd5: |
create_file(filename, record) |
info(""=> dns.txt file updated"") |
else: |
info(""=> No update required L: %s => R: %s"" % (localmd5, remotemd5))" |
4464,"def download_diffs(queue): |
""""""Download the cdiff files"""""" |
while True: |
options, signature_type, localver, remotever = queue.get() |
for num in range(int(localver), int(remotever) + 1): |
sig_diff = '%s-%d' % (signature_type, num) |
filename = os.path.join(options.mirrordir, '%s.cdiff' % sig_diff) |
if not os.path.exists(filename): |
update_diff(options, sig_diff) |
queue.task_done()" |
4465,"def work(options): |
""""""The work functions"""""" |
# pylint: disable=too-many-locals |
record = get_record(options) |
_, mainv, dailyv, _, _, _, safebrowsingv, bytecodev = record.split(':') |
versions = {'main': mainv, 'daily': dailyv, |
'safebrowsing': safebrowsingv, |
'bytecode': bytecodev} |
dqueue = Queue(maxsize=0) |
dqueue_workers = 3 |
info(""[+] \033[92mStarting workers\033[0m"") |
for index in range(dqueue_workers): |
info(""=> Starting diff download worker: %d"" % (index + 1)) |
worker = Thread(target=download_diffs, args=(dqueue,)) |
worker.setDaemon(True) |
worker.start() |
mqueue = Queue(maxsize=0) |
mqueue_workers = 4 |
for index in range(mqueue_workers): |
info(""=> Starting signature download worker: %d"" % (index + 1)) |
worker = Thread(target=update_sig, args=(mqueue,)) |
worker.setDaemon(True) |
worker.start() |
for signature_type in ['main', 'daily', 'bytecode', 'safebrowsing']: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.