Esempio n. 1
0
def add2whatweb(open_target_path, port):
    whatweb_logfile = '{}_{}.json'.format(open_target_path, port)
    remove_tmp(whatweb_logfile)
    os.system(
        "whatweb -q --no-errors --wait=10 -t 255 -i {} --url-suffix=':{}' --log-json={}"
        .format(open_target_path, port, whatweb_logfile))
    with open(whatweb_logfile, 'r') as logf:
        lines = json.load(logf)
        for target in lines:
            save2es(target)
    whatwebdb.decr('scanning')
    remove_tmp(whatweb_logfile)
Esempio n. 2
0
def add2whatweb(target, port):
    whatwebdb.sadd('scaned', '{}_{}'.format(target, port))
    whatwebdb.incr('scanning')
    logfile = 'tmp/{}_{}.json'.format(target.replace('/', '-'), port)
    if os.path.exists(logfile):
        os.system('rm {}'.format(logfile))
    os.system("whatweb --no-errors -t 255 {} --url-suffix=':{}' --log-json={}".
              format(target, port, logfile))
    with open(logfile, 'r') as logf:
        lines = json.load(logf)
        for line in lines:
            save2es.delay(line)
    whatwebdb.decr('scanning')
Esempio n. 3
0
def masscan(target, port):
    whatwebdb.incr('scanning')
    masscan_result_path = '/tmp/tmp_{}_{}'.format(target.replace('/', '_'),
                                                  port)
    results = os.popen(
        'masscan -p{0} {1} --rate=500 -oL {2} && cat {2}'.format(
            port, target, masscan_result_path)).read().split('\n')[1:-2]
    remove_tmp(masscan_result_path)
    for result in results:
        print(result)
        ip = result.split(" ")[3]
        ip_db.sadd('{}_{}'.format(target, port), ip)
    open_target_path = masscan_result_path + '.txt'
    remove_tmp(open_target_path)
    with open(open_target_path, 'a+') as f:
        for i in ip_db.smembers('{}_{}'.format(target, port)):
            f.writelines(i + '\n')
    if len(ip_db.smembers('{}_{}'.format(target, port))):
        add2whatweb(open_target_path, port)
    else:
        whatwebdb.decr('scanning')