Exemplo n.º 1
0
    def post(self, request):

        try:

            # Getting the data from POST-ed data.
            data = request.data.get("data")

            # Checking if data is not specified.
            if not data:
                raise Exception("No data was specified.")

            # Converting JSON string to dictionary.
            data = loads(data)

            # Getting dump from POST-ed data and deserializing back into object.
            dump = Dump.deserialize(data["dump"])

            # Saving the Registry Hives.
            RegistryHive(dump).save()

            # Returning the response.
            return HttpResponse('{"success":1, "status":"Registry Hive analysis complete."}')

        except Exception as ex:

            # Returning any exception messages.
            return HttpResponse('{"success":0, "error":"%s"}' % str(ex))
Exemplo n.º 2
0
    def post(self, request):

        try:
            # Getting data from api request
            data = request.data.get("data")

            if not data:
                raise Exception("No data was specified.")

            # converting JSON string to dictionary.
            data = loads(data)

            # get data form post req and deserialize it into the dump object
            dump = Dump.deserialize(data["dump"])

            Handle(dump).save()

            return HttpResponse('{"success":1, "status":"Handles Analyzes complete."}')

        except Exception as ex:
            # Returning any exception messages.
            return HttpResponse('{"success":0, "error":"%s"}' % str(ex))

        finally:
            pass
Exemplo n.º 3
0
    def post(self, request):
        global start_time
        start_time = time.time()
        global start_at
        start_at = datetime.now().ctime()
        try:

            # Getting the data from POST-ed data.
            data = request.data.get("data")

            # Checking if data is not specified.
            if not data:
                raise Exception("No data was specified.")

            # Getting the User ID.
            platform = request.data.get("platform")

            # Checking if User ID was not specified.
            if not platform:
                raise Exception("No platform was specified.")

            # Converting JSON string to dictionary.
            data = loads(data)

            # Getting User and Zip object from data.
            user = User.objects.get(pk=request.session["api_user"])

            # Saving upload information in the database.
            upload = Upload(user, data["dump_location"], platform)
            upload.save()

            # Saving dump information in the database.
            dump = Dump(upload)
            dump.save()

            # Returning the response.
            return HttpResponse('{"success":1, "status":"Basic image analysis complete.", "data":%s}'
                                % ('{"upload":%s, "dump":%s}' % (upload.serialize().replace("\\", "/"),
                                                                 dump.serialize().replace("\\", "/"))))

        except Exception as ex:

            # Returning any exception messages.
            return HttpResponse('{"success":0, "error":"%s"}' % str(ex))

        finally:
            pass
Exemplo n.º 4
0
    def post(self, request):

        #  convert date into appropriate format
        temp = time.time() - start_time
        hours = temp // 3600
        temp = temp - 3600 * hours
        minutes = int(temp // 60)
        sec = int(temp - 60 * minutes)

        # end time of dump analuzed completely
        end_time = datetime.now().ctime()

        try:
            # get data from request
            print (type(request.data))
            # print (request.data.get("data"))
            # data = loads(request.data)
            print("data", request.data)
            data = request.data.get("data")

            if not data:
                raise Exception("no data provided")

            # convert json data into dictionary
            data = loads(data)

            # Getting dump from POST-ed data and deserialize back into object.
            dump = Dump.deserialize(data["dump"])

            if dump:
                process = models.Process.objects.filter(dump=dump.model)
                total_process = len(process)

                thread = models.Thread.objects.filter(dump=dump.model)
                total_thread = len(thread)

                dll = models.DLL.objects.filter(dump=dump.model)
                total_dll = len(dll)

                handles = models.Handle.objects.filter(dump=dump.model)
                total_handles = len(handles)

                reghives = models.RegistryHive.objects.filter(dump=dump.model)
                total_reghives = len(reghives)

                network = models.NetworkConnection.objects.filter(dump=dump.model)
                total_network = len(network)

                # Returning the response.
                return HttpResponse('{"success":1, "status":"analysis complete." , "data":%s}' % (
                    '{"total_process":%s,"total_thread":%s,"total_dll":%s,"total_handles":%s,"total_reghives":%s,"total_network":%s,"time_min":%s,"time_sec":%s,"start_time":"%s","end_time":"%s"}' % (
                        total_process, total_thread, total_dll, total_handles, total_reghives, total_network, minutes,
                        sec,
                        start_at, end_time)))

        except Exception as ex:
            # Returning any exception messages.
            return HttpResponse('{"success":0, "error":"%s"}' % str(ex))
Exemplo n.º 5
0
    def post(self, request):

        try:
            # print (request.data.get("data"))
            # Getting the data from POST-ed data.
            data = request.data.get("data")

            # Checking if data is not specified.
            if not data:
                raise Exception("No data was specified.")

            # Converting JSON string to dictionary.
            data = loads(data)

            # Getting dump from POST-ed data and deserializing back into object.
            dump = Dump.deserialize(data["dump"])

            # Checking if Operating System of the dump is Windows XP.
            print(dump.profile.startswith("Win"))
            if dump.profile.startswith("Win"):
                # pass
                # Saving open network connections data.
                NetworkConnection(dump).save()

            # Getting JSON data of upload from data and deserializing into object.
            upload = Upload.deserialize(data["upload"])

            # Changing status of dump to "analyzed" in the database.
            upload.update_status()

            dump.update_endtime();

            # Returning the response.
            # session['newdump'] = 17
            request.session['newdump'] = dump.model.pk
            return HttpResponse('{"success":1, "status":"Done!", "dump":%s}' % dump.model.pk)

        except Exception as ex:

            # Returning any exception messages.
            return HttpResponse('{"success":0, "error":"%s"}' % str(ex))

        finally:

            # Removing session variables.
            if request.session.get("api_user") is not None:
                del request.session["api_user"]