Esempio n. 1
0
        def do_POST(self):
            guid = ""
            try:
                guid = self.path.split('?', 1)[1]
            except:
                Log.log_error("Invalid request no GUID", self.path)
                self.return_data()
                return

            self.db.update_checkin(guid)

            length = int(self.headers.getheader("Content-Length"))
            data = self.rfile.read(length)
            try:
                data = self.rc4.crypt(base64.b64decode(data))
            except:
                Log.log_error("Invalid base64 data received", self.path)
                self.return_data()
                return

            parser = HTTPDParser(config)
            self.output = base64.b64encode(
                self.rc4.crypt(parser.parse_cmd(guid, data)))

            self.return_data()
Esempio n. 2
0
        def do_POST(self):

            if self.path.split("/")[1] == "api":
                server_api = ServerApi(self.config, self)
                self.output = server_api.process()
                self.return_json()
                return

            length = 0
            if not self.headers.getheader("Content-Length") == None:
                length = int(self.headers.getheader("Content-Length"))

            data = self.rfile.read(length)
            try:
                data = json.loads(data)
                data["Data"] = self.rc4.crypt(base64.b64decode(data["Data"]))
            except:
                Log.log_error("Invalid base64 data received or bad decryption",
                              self.path)
                self.return_data()
                return

            guid = ""
            try:
                guid = Utils.validate_guid(data["ID"])
            except:
                Log.log_error("Invalid request no GUID", self.path)
                self.return_data()
                return

            if not guid == None:
                self.db.update_checkin(guid)

                parser = HTTPDParser(config)
                output = parser.parse_cmd(guid, data["Data"], data["UUID"])
                if not output == None:
                    uuid = output[:36]
                    output = output[37:]
                    self.output = base64.b64encode(self.rc4.crypt(output))
                    self.output = json.dumps({
                        "UUID": uuid,
                        "ID": guid,
                        "Data": self.output
                    })
                else:
                    self.output = json.dumps({
                        "UUID":
                        None,
                        "ID":
                        guid,
                        "Data":
                        Utils.gen_str(random.randrange(10, 1000))
                    })
                self.return_json()
                return
            else:
                self.output = Utils.load_file(
                    "html/%s" % self.config.get("http-default-404"))

            self.return_data()
Esempio n. 3
0
        def do_POST(self):
            if self.path.split('/')[1] == 'api':
                server_api = ServerApi(self.config, self)
                self.output = server_api.process()
                self.return_json()
                return

            length = 0
            if not self.headers.getheader('Content-Length') == None:
                length = int(self.headers.getheader('Content-Length'))

            data = self.rfile.read(length)
            try:
                data = json.loads(data)
                data['Data'] = self.rc4.crypt(base64.b64decode(data['Data']))
            except:
                Log.log_error('Invalid base64 data received or bad decryption',
                              self.path)
                self.return_data()
                return

            guid = ''
            try:
                guid = Utils.validate_guid(data['ID'])
            except:
                Log.log_error('Invalid request no GUID', self.path)
                self.return_data()
                return

            if not guid == None:
                self.db.update_checkin(guid, str(self.client_address[0]))

                parser = HTTPDParser(config)
                output = parser.parse_cmd(guid, data['Data'], data['UUID'])
                if not output == None:
                    uuid = output[:36]
                    output = output[37:]
                    self.output = \
                        base64.b64encode(self.rc4.crypt(output))
                    self.output = json.dumps({
                        'UUID': uuid,
                        'ID': guid,
                        'Data': self.output
                    })
                else:
                    self.output = json.dumps({
                        'UUID':
                        None,
                        'ID':
                        guid,
                        'Data':
                        Utils.gen_str(random.randrange(10, 1000))
                    })
                self.return_json()
                return
            else:
                self.output = Utils.load_file(
                    'html/%s' % self.config.get('http-default-404'))

            self.return_data()
Esempio n. 4
0
 def do_POST(self):
     if self.path.split("/")[1] == "api":
         server_api = ServerApi(self.config, self)
         self.output = server_api.process()
         self.return_json()
         return 
     
     guid = ""
     try:
         guid = Utils.validate_guid(self.path.split('?', 1)[1])
     except:
         Log.log_error("Invalid request no GUID", self.path)
         self.return_data()
         return
         
     if not guid == None:
         self.db.update_checkin(guid)
     
         length = 0
         if not self.headers.getheader("Content-Length") == None:
             length = int(self.headers.getheader("Content-Length"))
         data = self.rfile.read(length)
         try:
             data = self.rc4.crypt(base64.b64decode(data))
         except:
             Log.log_error("Invalid base64 data received", self.path)
             self.return_data()
             return 
         
         parser = HTTPDParser(config)
         self.output = base64.b64encode(self.rc4.crypt(parser.parse_cmd(guid, data)))
     else:
         self.output = Utils.load_file("html/%s" % self.config.get("http-default-404"))
         
     self.return_data()
Esempio n. 5
0
 def do_POST(self):
     guid = ""
     try:
         guid = self.path.split('?', 1)[1]
     except:
         Log.log_error("Invalid request no GUID", self.path)
         self.return_data()
         return
         
     self.db.update_checkin(guid)
 
     length = int(self.headers.getheader("Content-Length"))
     data = self.rfile.read(length)
     try:
         data = self.rc4.crypt(base64.b64decode(data))
     except:
         Log.log_error("Invalid base64 data received", self.path)
         self.return_data()
         return 
     
     parser = HTTPDParser(config)
     self.output = base64.b64encode(self.rc4.crypt(parser.parse_cmd(guid, data)))
     
     self.return_data()