Ejemplo n.º 1
0
def add_job_hashcat(job, charset, maxlen, minlen, hashtype, attacktype, hashes):
	tooeasy = 4
	for i in range(minlen, maxlen+1):
		if i <= tooeasy:
			print "too easy"
			retval = celery.send_task('crackling.tasks.newjob', ['hashcat', hashtype, attacktype, hashes, dict(minlen=i, maxlen=i, charset=charset, one=charset, mask='?1'*i)], queue='crackling')
			jobtask = JobTask(job=job, taskid=retval)
			jobtask.save()
			print "***task sent*** %s" % str(retval)
		else:
			masks = gen_mask(charset, i)
			for mask in masks:
				retval = celery.send_task('crackling.tasks.newjob', ['hashcat', hashtype, attacktype, hashes, dict(minlen=i, maxlen=i, charset=charset, one=mask['1'], two=mask['2'], three=mask['3'], four=mask['4'], mask=mask['mask'])], queue='crackling')
				jobtask = JobTask(job=job, taskid=retval)
				jobtask.save()
				print "***task sent*** %s" % str(retval)
Ejemplo n.º 2
0
def add_job_ocllite(job, charset, maxlen, minlen, hashtype, attacktype,
                    hashes):
    ocllitework = 1000000000
    for i in range(minlen, maxlen + 1):
        numcombinations = len(charset)**i
        skip = 0
        limit = 0
        while skip < numcombinations:
            if (limit + ocllitework) > numcombinations:
                limit = numcombinations
            else:
                limit += ocllitework
            print "min,max %d skip %d limit %d mask %s" % (i, skip, limit,
                                                           ('?1' * i))
            retval = celery.send_task('crackling.tasks.newjob', [
                'ocllite', hashtype, attacktype, hashes,
                dict(minlen=i,
                     maxlen=i,
                     one=charset,
                     mask=('?1' * i),
                     skip=skip,
                     limit=limit)
            ],
                                      queue='crackling')
            jobtask = JobTask(job=job, taskid=retval)
            jobtask.save()
            print "***task sent*** " + str(retval)
            skip = limit
Ejemplo n.º 3
0
def add_job_hashcat(job, charset, maxlen, minlen, hashtype, attacktype,
                    hashes):
    tooeasy = 4
    for i in range(minlen, maxlen + 1):
        if i <= tooeasy:
            print "too easy"
            retval = celery.send_task('crackling.tasks.newjob', [
                'hashcat', hashtype, attacktype, hashes,
                dict(minlen=i,
                     maxlen=i,
                     charset=charset,
                     one=charset,
                     mask='?1' * i)
            ],
                                      queue='crackling')
            jobtask = JobTask(job=job, taskid=retval)
            jobtask.save()
            print "***task sent*** %s" % str(retval)
        else:
            masks = gen_mask(charset, i)
            for mask in masks:
                retval = celery.send_task('crackling.tasks.newjob', [
                    'hashcat', hashtype, attacktype, hashes,
                    dict(minlen=i,
                         maxlen=i,
                         charset=charset,
                         one=mask['1'],
                         two=mask['2'],
                         three=mask['3'],
                         four=mask['4'],
                         mask=mask['mask'])
                ],
                                          queue='crackling')
                jobtask = JobTask(job=job, taskid=retval)
                jobtask.save()
                print "***task sent*** %s" % str(retval)
Ejemplo n.º 4
0
def add_job_ocllite(job, charset, maxlen, minlen, hashtype, attacktype, hashes):
	ocllitework = 1000000000
	for i in range(minlen, maxlen+1):
		numcombinations = len(charset) ** i
		skip = 0
		limit = 0
		while skip < numcombinations:
			if (limit + ocllitework) > numcombinations:
				limit = numcombinations
			else:
				limit += ocllitework
			print "min,max %d skip %d limit %d mask %s" % (i, skip, limit, ('?1'*i))
			retval = celery.send_task('crackling.tasks.newjob', ['ocllite', hashtype, attacktype, hashes, dict(minlen=i, maxlen=i, one=charset, mask=('?1'*i), skip=skip, limit=limit)], queue='crackling')
			jobtask = JobTask(job=job, taskid=retval)
			jobtask.save()
			print "***task sent*** " + str(retval)
			skip = limit
Ejemplo n.º 5
0
def tasks(request):
    """
    POST /tasks/
    在Celery中创建一条任务
    :param request:
    :return:
    """
    if request.method != 'POST':
        return HttpResponseNotAllowed(['POST'])
    else:
        task_data = json.loads(request.body)
        task = task_data['task']
        args = task_data.get('args', [])
        kwargs = task_data.get('kwargs', {})
        countdown = task_data.get('countdown')
        routing_key = task_data.get('routingKey')

        if countdown > TASK_COUNTDOWN_THRESHOLD:
            eta = datetime.utcnow() + timedelta(seconds=countdown)
            id = str(uuid.uuid4())
            data = {
                'task': task,
                '_id': id,
                'args': args,
                'kwargs': kwargs,
                'eta': eta,
                'routing_key': routing_key
            }
            stash_to_mongo(data)
            data = {"taskId": id, "status": "stashed"}
            return HttpResponse(json.dumps(data),
                                content_type='application/json')

        else:
            expires = task_data.get('expires')
            result = celery.send_task(task,
                                      serializer='json',
                                      args=args,
                                      kwargs=kwargs,
                                      countdown=countdown,
                                      routing_key=routing_key,
                                      expires=expires)
            data = {'taskId': result.task_id, 'status': "pending"}
            return HttpResponse(json.dumps(data),
                                content_type='application/json')
Ejemplo n.º 6
0
def tasks(request):
    """
    POST /tasks/
    在Celery中创建一条任务
    :param request:
    :return:
    """
    if request.method != 'POST':
        return HttpResponseNotAllowed(['POST'])
    else:
        task_data = json.loads(request.body)
        task = task_data['task']
        args = task_data.get('args', [])
        kwargs = task_data.get('kwargs', {})
        countdown = task_data.get('countdown')
        routing_key = task_data.get('routingKey')

        if countdown > TASK_COUNTDOWN_THRESHOLD:
            eta = datetime.utcnow() + timedelta(seconds=countdown)
            id = str(uuid.uuid4())
            data = {'task': task, '_id': id, 'args': args, 'kwargs': kwargs, 'eta': eta, 'routing_key': routing_key}
            stash_to_mongo(data)
            data = {
                "taskId": id,
                "status": "stashed"
            }
            return HttpResponse(json.dumps(data), content_type='application/json')

        else:
            expires = task_data.get('expires')
            result = celery.send_task(task, serializer='json', args=args, kwargs=kwargs, countdown=countdown,
                                      routing_key=routing_key, expires=expires)
            data = {
                'taskId': result.task_id,
                'status': "pending"
            }
            return HttpResponse(json.dumps(data), content_type='application/json')