def getDefaultLogin(request):
    # Init of the view getDefaultLogin
    try:
        # Pool call
        response, repool = sendPool(request, 'getDefaultLogin')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter routerBrand (Optional - Default cisco)
            routerBrand = str(request.POST.get('routerBrand', 'cisco'))

            # Execute, get result and show it
            result = ht.getModule('ht_router').getDefaultLogin(
                routerBrand=routerBrand)
            if request.POST.get('is_async_getDefaultLogin', False):
                return JsonResponse({"data": returnAsModal(result)})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_getDefaultLogin', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
def zipDirectory(request):
    # Init of the view zipDirectory
    try:
        # Pool call
        response, repool = sendPool(request, 'zipDirectory')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter new_folder_name
            new_folder_name = request.POST.get('new_folder_name')

            # Execute, get result and show it
            result = ht.getModule('ht_unzip').zipDirectory(
                new_folder_name=new_folder_name)
            if request.POST.get('is_async_zipDirectory', False):
                return JsonResponse({"data": returnAsModal(result)})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_zipDirectory', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
Esempio n. 3
0
def traceroute(request):
    # Init of the view traceroute
    try:
        # Pool call
        response, repool = sendPool(request, 'traceroute')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter domain_or_ip
            domain_or_ip = request.POST.get('domain_or_ip')

            # Execute, get result and show it
            result = ht.getModule('ht_scapy').traceroute(
                domain_or_ip=domain_or_ip)
            if request.POST.get('is_async_traceroute', False):
                return JsonResponse({"data": returnAsModal(result)})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_traceroute', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
def checkIP(request):
    # Init of the view checkIP
    try:
        # Pool call
        response, repool = sendPool(request, 'checkIP')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter ip
            ip = request.POST.get('ip')

            # Parameter score (Optional - Default False)
            score = request.POST.get('score', False)

            # Parameter totalReports (Optional - Default False)
            totalReports = request.POST.get('totalReports', False)

            # Parameter abuseipdb_api (Optional - Default None)
            abuseipdb_api = request.POST.get('abuseipdb_api', None)
            if not abuseipdb_api:
                abuseipdb_api = None

            # Execute, get result and show it
            result = ht.getModule('ht_abuseipdb').checkIP(
                ip=ip,
                score=score,
                totalReports=totalReports,
                abuseipdb_api=abuseipdb_api)
            if request.POST.get('is_async_checkIP', False):
                return JsonResponse({"data": returnAsModal(result)})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_checkIP', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
Esempio n. 5
0
def searchCVE(request):
    # Init of the view searchCVE
    try:
        # Pool call
        response, repool = sendPool(request, 'searchCVE')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter cve_id (Optional - Default )
            cve_id = request.POST.get('cve_id', '')
            if not cve_id:
                cve_id = None

            # Execute, get result and show it
            result = ht.getModule('ht_cve').searchCVE(cve_id=cve_id)
            if request.POST.get('is_async_searchCVE', False):
                return JsonResponse({"data": returnAsModal(result)})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_searchCVE', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
Esempio n. 6
0
def trainFromZip(request):
    try:
        if len(request.FILES) != 0:
            objectdetection = ht.getModule('ht_objectdetection')
            first_folder_name = None
            filenameZip = None
            uploaded_file_urlZip = 'trained.clf'

            if 'image_models_zip' in request.FILES:
                zip_to_train = request.FILES['image_models_zip']
                first_folder_name = request.POST.get('first_folder_name', None)
                if not first_folder_name:
                    first_folder_name = zip_to_train.name.split('.')[0]
                filenameZip, location, uploaded_file_urlZip = saveFileOutput(
                    zip_to_train, "objectdetection", "ai")

            n_neighbors = int(request.POST.get('neighbors', 1))

            if filenameZip:
                image_final = objectdetection.trainFromZip(
                    uploaded_file_urlZip,
                    model_path='{f}.clf'.format(f=filenameZip.split('.')[0]),
                    trainZipFile=uploaded_file_urlZip,
                    first_folder_name=first_folder_name,
                    n_neighbors=n_neighbors)
                if request.POST.get('is_async_trainFromZip', False):
                    data = {'data': image_final}
                    return JsonResponse(data)
                return renderMainPanel(request=request, popup_text=image_final)
            return renderMainPanel(request=request)

    except Exception as e:
        Logger.printMessage(message='trainFromZip',
                            description=str(e),
                            is_error=True)
        return renderMainPanel(request=request, popup_text=str(e))
Esempio n. 7
0
def crypt_file(request):
    this_conf = config['ht_crypter_crypt_file']
    if len(request.FILES) != 0:
        if request.FILES['filename']:
            # Get file
            myfile = request.FILES['filename']

            # Get Crypter Module
            crypter = ht.getModule('ht_crypter')

            # Save the file
            filename, location, uploaded_file_url = saveFileOutput(
                myfile, "crypter", "av_evasion")

            # Compile Exe
            compile_exe = False
            if request.POST.get('compile_exe', '') == 'on':
                compile_exe = True

            tmp_new_file_name = filename.split('.')[0]
            if not '.' in tmp_new_file_name:
                tmp_new_file_name = '{name}.py'.format(name=tmp_new_file_name)
            new_file_name = os.path.join(location, tmp_new_file_name)

            drop_file_name = filename
            if not '.' in drop_file_name:
                drop_file_name = '{name}.{ext}'.format(
                    name=drop_file_name, ext=filename.split('.')[1])

            iterate_count = 1

            if request.POST.get('iteratecount'):
                try:
                    iterate_count = int(request.POST.get('iteratecount'))
                    if iterate_count < 1:
                        iterate_count = 1
                except:
                    pass

            prime_length = 2
            if request.POST.get('prime_length'):
                try:
                    prime_length = int(request.POST.get('prime_length'))
                    if prime_length < 1:
                        prime_length = 2
                except:
                    pass

            is_last = False
            if iterate_count == 1:
                is_last = True

            crypted_file = crypter.crypt_file(filename=uploaded_file_url,
                                              new_file_name=new_file_name,
                                              drop_file_name=drop_file_name,
                                              prime_length=prime_length,
                                              iterate_count=iterate_count,
                                              is_last=is_last,
                                              compile_exe=compile_exe)

            if crypted_file:
                if os.path.isfile(crypted_file):
                    with open(crypted_file, 'rb') as fh:
                        if compile_exe:
                            new_file_name = '{name}.exe'.format(
                                name=new_file_name.split('.')[0])
                        response = HttpResponse(
                            fh.read(),
                            content_type="application/{type}".format(
                                type=new_file_name.split('.')[1]))
                        response[
                            'Content-Disposition'] = 'inline; filename=' + os.path.basename(
                                crypted_file)
                        return response
                        os.remove(uploaded_file_url)
                        os.remove(crypted_file)
            else:
                Logger.printMessage(message='crypt_file',
                                    description=this_conf['bad_saved'],
                                    is_error=True)
            return renderMainPanel(request=request)

    return renderMainPanel(request=request)
Esempio n. 8
0
def crawl(request):
    # Init of the view crawl
    try:
        # Pool call
        response, repool = sendPool(request, 'crawl')
        if response or repool:
            if repool:
                return HttpResponse(response)
            return JsonResponse({"data": str(response)})
        else:
            # Parameter url
            url = request.POST.get('url')

            # Parameter depth (Optional - Default 100)
            depth = request.POST.get('depth', 100)

            # Parameter proxies (Optional - Default None)
            proxies = request.POST.get('proxies', None)
            if not proxies:
                proxies = None

            # Parameter proxyhost (Optional - Default None)
            proxyhost = request.POST.get('proxyhost', None)
            if not proxyhost:
                proxyhost = None

            # Parameter proxyuser (Optional - Default None)
            proxyuser = request.POST.get('proxyuser', None)
            if not proxyuser:
                proxyuser = None

            # Parameter proxypassword (Optional - Default None)
            proxypassword = request.POST.get('proxypassword', None)
            if not proxypassword:
                proxypassword = None

            # Parameter proxyport (Optional - Default None)
            proxyport = request.POST.get('proxyport', None)
            if not proxyport:
                proxyport = None

            # Parameter proxysecure (Optional - Default http)
            proxysecure = request.POST.get('proxysecure', 'http')

            # Execute, get result and show it
            result = ht.getModule('ht_spider').crawl(
                url=url,
                depth=depth,
                proxies=proxies,
                proxyhost=proxyhost,
                proxyuser=proxyuser,
                proxypassword=proxypassword,
                proxyport=proxyport,
                proxysecure=proxysecure)
            if request.POST.get('is_async_crawl', False):
                return JsonResponse({"data": result})
            return renderMainPanel(request=request, popup_text=result)
    except Exception as e:
        if request.POST.get('is_async_crawl', False):
            return JsonResponse({"data": str(e)})
        return renderMainPanel(request=request, popup_text=str(e))
Esempio n. 9
0
def predictFromZip(request):
    this_conf = config['ht_objectdetection_predictFromZip']
    try:
        if len(request.FILES) != 0:

            if 'image_file_test_zip' in request.FILES:
                objectdetection = ht.getModule('ht_objectdetection')

                image_to_test_zip = request.FILES['image_file_test_zip']
                first_folder_name = request.POST.get('first_folder_name', None)

                filename, location, uploaded_file_url = saveFileOutput(
                    image_to_test_zip, "objectdetection", "ai")

                if not first_folder_name:
                    first_folder_name = image_to_test_zip.split('.')[0]

                filenameZip = None
                uploaded_file_urlZip = this_conf['default_model']
                modelfile = request.POST.get('dropdown_modelfile_pred')

                if 'image_models_zip_pred' in request.FILES:
                    zip_to_train = request.FILES['image_models_zip_pred']
                    first_folder_name_zip = request.POST.get(
                        'first_folder_name_zip', None)
                    if not first_folder_name_zip:
                        first_folder_name_zip = zip_to_train.name.split('.')[0]
                    filenameZip, location, uploaded_file_urlZip = saveFileOutput(
                        zip_to_train, "objectdetection", "ai")

                n_neighbors = int(request.POST.get('neighbors_pred', 1))

                if filenameZip:
                    image_final = objectdetection.predictFromZip(
                        uploaded_file_url,
                        model_path='{f}.clf'.format(
                            f=filenameZip.split('.')[0]),
                        first_folder_name=first_folder_name,
                        trainZipFile=uploaded_file_urlZip,
                        first_folder_name_training_zip=first_folder_name_zip,
                        n_neighbors=n_neighbors)
                else:
                    image_final = objectdetection.predictFromZip(
                        uploaded_file_url,
                        model_path=modelfile,
                        first_folder_name=first_folder_name)

                with open(image_final, 'rb') as fh:
                    response = HttpResponse(
                        fh.read(),
                        content_type="application/{type}".format(
                            type=filename.split('.')[1]))
                    response[
                        'Content-Disposition'] = 'inline; filename=' + os.path.basename(
                            image_final)
                    return response
            if request.POST.get('is_async_predictFromZip', False):
                data = {'data': this_conf['need_params']}
                return JsonResponse(data)
            return renderMainPanel(request=request,
                                   popup_text=this_conf['need_params'])

    except Exception as e:
        Logger.printMessage(message='predictFromZip',
                            description=str(e),
                            is_error=True)
        return renderMainPanel(request=request, popup_text=str(e))