Beispiel #1
0
def nmap_tasks():
    scantypes = [
        "-sT", "-sT", "-sS", "-sA", "-sW", "-sM", "-sN", "-sF", "-sX", "-sU"
    ]

    if request.method == "POST":
        if 'targets' in request.form:
            targets = request.form["targets"]
        else:
            abort(401)

        options = ""
        scani = int(
            request.form['scantype']) if 'scantype' in request.form else 0
        if 'ports' in request.form and len(request.form['ports']):
            portlist = "-p " + request.form['ports']
        else:
            portlist = ''
        noping = '-P0' if 'noping' in request.form else ''
        osdetect = "-O" if 'os' in request.form else ''
        bannerdetect = "-sV" if 'banner' in request.form else ''
        options = "{0} {1} {2} {3} {4}".format(scantypes[scani], portlist,
                                               noping, osdetect, bannerdetect)
        _celery_task = celery_nmap_scan.delay(targets=str(targets),
                                              options=str(options))
        NmapTask.add(user_id=current_user.id, task_id=_celery_task.id)
        return redirect(url_for('nmap.nmap_tasks'))

    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    return render_template('nmap_tasks.html', tasks=_nmap_tasks)
Beispiel #2
0
def nmap_tasks():
    scantypes = [ "-sT", "-sT", "-sS", "-sA", "-sW", "-sM",
            "-sN", "-sF", "-sX", "-sU" ]

    if request.method == "POST":
        if 'targets' in request.form:
            targets = request.form["targets"]
        else:
            abort(401)

        options = ""
        scani = int(request.form['scantype']) if 'scantype' in request.form else 0
        if 'ports' in request.form and len(request.form['ports']):
            portlist = "-p " + request.form['ports']
        else:
            portlist = ''
        noping = '-P0' if 'noping' in request.form else ''
        osdetect = "-O" if 'os' in request.form else ''
        bannerdetect = "-sV" if 'banner' in request.form else ''
        options = "{0} {1} {2} {3} {4}".format(scantypes[scani],
                                                  portlist,
                                                  noping,
                                                  osdetect,
                                                  bannerdetect)
        _celery_task = celery_nmap_scan.delay(targets=str(targets),
                                              options=str(options))
        NmapTask.add(user_id=current_user.id, task_id=_celery_task.id)
        return redirect(url_for('nmap.nmap_tasks'))

    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    return render_template('nmap_tasks.html', tasks=_nmap_tasks)
Beispiel #3
0
def nmap_tasks():
    scantypes = [ "-sT", "-sT", "-sS", "-sA", "-sW", "-sM",
            "-sN", "-sF", "-sX", "-sU" ]

    if request.method == "POST":
        if 'targets' in request.form:
            targets = request.form["targets"]
        else:
            abort(401)

        if 'comment' in request.form:
            comment = request.form["comment"]
        else:
            comment = ""

        if 'run_now' in request.form:
            run_now = True
        else:
            run_now = False

        scani = int(request.form['scantype']) if 'scantype' in request.form else 0
        if 'ports' in request.form and len(request.form['ports']):
            portlist = "-p " + request.form['ports']
        else:
            portlist = ''
        noping = '-P0' if 'noping' in request.form else ''
        osdetect = "-O" if 'os' in request.form else ''
        bannerdetect = "-sV" if 'banner' in request.form else ''
        options = "{0} {1} {2} {3} {4}".format(scantypes[scani],
                                               portlist,
                                               noping,
                                               osdetect,
                                               bannerdetect)

        """ use either eta OR countdown! """
        _c_eta = datetime.datetime.utcnow() + datetime.timedelta(seconds=0)
        _c_exp = datetime.datetime.utcnow() + CELERY_TASK_EXPIRES
        _celery_task = celery_nmap_scan.apply_async(eta=_c_eta,
                                                    expires=_c_exp,
                                                    kwargs={'targets': str(targets),
                                                            'options': str(options)})

        NmapTask.add(user=current_user,
                     task_id=_celery_task.id,
                     comment=comment)

        return redirect(url_for('nmap.nmap_tasks'))

    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    return render_template('nmap_tasks.html', tasks=_nmap_tasks)
Beispiel #4
0
def nmap_tasks_json():
    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    _jtarray = []
    for _ntask in _nmap_tasks:
        tdict = {'id': _ntask.id, 'status': _ntask.status, 'ready': 0}
        if _ntask.result and 'done' in _ntask.result:
            tdict.update({'progress': float(_ntask.result['done'])})
        elif _ntask.result and 'report' in _ntask.result:
            tdict.update({'progress': 100})
        else:
            tdict.update({'progress': 0})
        if _ntask.status in READY_STATES:
            tdict.update({'ready': 1})
        _jtarray.append(tdict)

    return json.dumps(_jtarray)
Beispiel #5
0
def nmap_tasks_json():
    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    _jtarray = []
    for _ntask in _nmap_tasks:
        tdict = {'id': _ntask.id,
                 'status': _ntask.status,
                 'ready': 0}
        if _ntask.result and 'done' in _ntask.result:
            tdict.update({'progress': float(_ntask.result['done'])})
        elif _ntask.result and 'report' in _ntask.result:
            tdict.update({'progress': 100})
        else:
            tdict.update({'progress': 0})
        if _ntask.status in READY_STATES:
            tdict.update({'ready': 1})
        _jtarray.append(tdict)

    return json.dumps(_jtarray)
Beispiel #6
0
def nmap_compare():
    _nmap_tasks = NmapTask.find(user_id=current_user.id)
    _report = NmapTask.get_all_reports(_nmap_tasks)
    return render_template('nmap_compare.html', reports=_report)