Exemple #1
0
def new_session(request):
    if request.method == 'POST':
        #session_name = request.POST["name"]

        node_name = request.POST["node"]
        node = get_object_or_404(Node, name=node_name)

        hashfile = get_object_or_404(Hashfile, id=request.POST['hashfile_id'])

        crack_type = request.POST["crack_type"]
        if crack_type == "dictionary":
            rule = request.POST["rule"] if request.POST["rule"] != "None" else None
            wordlist = request.POST["wordlist"]
        elif crack_type == "mask":
            mask = request.POST["mask"]

        device_type = int(request.POST["device_type"])
        brain_mode = int(request.POST["brain_mode"])

        if request.POST["end_datetime"]:
            end_timestamp = int(datetime.strptime(request.POST["end_datetime"], "%m/%d/%Y %I:%M %p").timestamp())
        else:
            end_timestamp = None

        session_name = ("%s-%s" % (hashfile.name, ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(12)))).replace(" ", "_")

        if "debug" in request.POST:
            hashcat_debug_file = True
        else:
            hashcat_debug_file = False

        hashcat_api = HashcatAPI(node.hostname, node.port, node.username, node.password)
        if crack_type == "dictionary":
            res = hashcat_api.create_dictionary_session(session_name, hashfile, rule, wordlist, device_type, brain_mode, end_timestamp, hashcat_debug_file)
        elif crack_type == "mask":
            res = hashcat_api.create_mask_session(session_name, hashfile, mask, device_type, brain_mode, end_timestamp, hashcat_debug_file)

        if res["response"] == "error":
            messages.error(request, res["message"])
            return redirect('Hashcat:hashfiles')

        messages.success(request, "Session successfully created")

        session = Session(
                name=session_name,
                hashfile=hashfile,
                node = node,
                potfile_line_retrieved=0,
        )
        session.save()

    return redirect('Hashcat:hashfiles')
Exemple #2
0
def new_session(request):
    if request.method == 'POST':
        #session_name = request.POST["name"]

        node_name = request.POST["node"]
        node = get_object_or_404(Node, name=node_name)

        hashfile = get_object_or_404(Hashfile, id=request.POST['hashfile_id'])

        crack_type = request.POST["crack_type"]
        if crack_type == "dictionary":
            rule = request.POST[
                "rule"] if request.POST["rule"] != "None" else None
            wordlist = request.POST["wordlist"]
        elif crack_type == "mask":
            mask = request.POST["mask"]

        session_name = ("%s-%s" % (hashfile.name, ''.join(
            random.choice(string.ascii_uppercase + string.digits)
            for _ in range(12)))).replace(" ", "_")

        hashcat_api = HashcatAPI(node.hostname, node.port, node.username,
                                 node.password)
        if crack_type == "dictionary":
            res = hashcat_api.create_dictionary_session(
                session_name, hashfile, rule, wordlist)
        elif crack_type == "mask":
            res = hashcat_api.create_mask_session(session_name, hashfile, mask)

        if res["response"] == "error":
            messages.error(request, res["message"])
            return redirect('Hashcat:hashfiles')

        messages.success(request, "Session successfully created")

        session = Session(
            name=session_name,
            hashfile=hashfile,
            node=node,
            potfile_line_retrieved=0,
        )
        session.save()

    return redirect('Hashcat:hashfiles')