Example #1
0
def reg(request):
    new_user = Users()
    new_user.username = request.POST['username'].lower()
    new_user.password = hashlib.md5(
        request.POST['password'].encode('utf-8')).hexdigest()
    new_user.log_file = request.POST['username'].lower() + '_log.log'
    new_user.save()
    personal_logging(new_user.log_file, 'Registration!')
    return JsonResponse({'response': 'ok'})
Example #2
0
def deauth(request):
    if 'Login' not in request.POST and 'password' not in request.POST:
        return JsonResponse({"response": "filed error"})
    username = request.POST['username'].lower()
    try:
        user = Users.objects.get(username=username)
    except Users.DoesNotExist:
        return JsonResponse({"response": "denied"})
    user.token = ''
    user.status = '0'
    user.save()
    personal_logging(user.log_file, 'Deauthorization!')
    return JsonResponse({"response": "ok"})
Example #3
0
def add_to_stack(request):
    if 'username' not in request.POST or 'token' not in request.POST or 'emails' not in request.POST or \
            'sender' not in request.POST or 'sender_password' not in request.POST or 'subject' not in request.POST or \
            'body_name' not in request.POST or 'method' not in request.POST or 'country' not in request.POST or \
            'description' not in request.POST:
        return JsonResponse({'response': 'field error'})
    try:
        the_user = Users.objects.get(username=request.POST['username'])
    except Users.DoesNotExist:
        return JsonResponse({'response': 'denied'})
    if request.POST['token'] != the_user.token:
        return JsonResponse({"response": "denied"})
    email_count = 0
    emls = request.POST['emails']
    emails = emls.split(",")
    for email in emails:
        email_count += 1
        new_stack = Stack()
        new_stack.sender = request.POST['sender']
        new_stack.sender_password = request.POST['sender_password']
        new_stack.email = email
        new_stack.subject = request.POST['subject']
        try:
            new_stack.body = Templates.objects.get(
                name=request.POST['body_name']).body
        except Templates.DoesNotExist:
            new_stack.body = request.POST['body_name']
        new_stack.method = request.POST['method']
        new_stack.date_add = date.today()
        new_stack.country = request.POST['country']
        new_stack.description = request.POST['description']
        new_stack.ftp_host = request.POST['host']
        new_stack.ftp_login = request.POST['user']
        new_stack.ftp_password = request.POST['pswd']
        new_stack.who_hacked = request.POST['username']
        new_stack.status = '0'
        new_stack.save()
        personal_logging(the_user.log_file, 'New attacking :' + email)
        del new_stack
    if email_count > 0:
        if get_config('attacking') == '0':
            atk = Attacking()
            atk.start()
        if get_config('checking_ftp') == '0':
            check = CheckFtp()
            check.start()
    logging('add_to_stack',
            '{0} added emails to stack.'.format(the_user.username))
    return JsonResponse({'response': 'ok', 'emails_add': email_count})
Example #4
0
def auth(request):
    if 'Login' not in request.POST and 'password' not in request.POST:
        return JsonResponse({"response": "filed error"})
    username = request.POST['username'].lower()
    try:
        user = Users.objects.get(username=username)
    except Users.DoesNotExist:
        return JsonResponse({"response": "denied"})
    hash_pswd = hashlib.md5(
        request.POST['password'].encode('utf-8')).hexdigest()
    if hash_pswd != user.password:
        return JsonResponse({"response": "denied"})
    token = generate_token()
    user.token = token
    user.status = '1'
    user.save()
    personal_logging(user.log_file, 'Authorization!')
    return JsonResponse({
        "response": "ok",
        "username": username,
        "token": token
    })
Example #5
0
def load_template(request):
    if 'username' not in request.POST or 'token' not in request.POST or 'name' not in request.POST or \
            'description' not in request.POST or 'template' not in request.POST:
        return JsonResponse({'response': 'filed error'})
    try:
        the_user = Users.objects.get(username=request.POST['username'])
    except Users.DoesNotExist:
        return JsonResponse({'response': 'denied'})
    if request.POST['token'] != the_user.token:
        return JsonResponse({"response": "denied"})
    template = Templates()
    template.name = request.POST['name']
    template.body = request.POST['template']
    template.description = request.POST['description']
    template.owner = request.POST['username']
    template.save()
    personal_logging(the_user.log_file,
                     'Add template: {0}'.format(request.POST['name']))
    logging(
        'add_to_stack',
        '{0} added template {1} to templates.'.format(the_user.username,
                                                      request.POST['name']))
    return JsonResponse({"response": "ok"})