Exemple #1
0
    def append_sequence_item(self, responseId, requestId=''):
        topItem = self.sequenceStepsTreeWidget.topLevelItem(
            self.sequenceStepsTreeWidget.topLevelItemCount() - 1)
        if topItem is None:
            current_max = 0
        else:
            current_max = int(topItem.text(0))
        stepnum = str(current_max + 1)

        row = self.Data.read_responses_by_id(self.cursor, responseId)
        if not row:
            return

        self.sequenceResponseIds.add(responseId)

        responseItems = interface.data_row_to_response_items(row)

        url = responseItems[ResponsesTable.URL]
        method = responseItems[ResponsesTable.REQ_METHOD]
        contentType = responseItems[
            ResponsesTable.RES_CONTENT_TYPE].lower().strip()
        charset = ContentHelper.getCharSet(contentType)
        if contentType and ';' in contentType:
            contentType = contentType[0:contentType.index(';')]

        reqHeaders = responseItems[ResponsesTable.REQ_HEADERS]
        reqData = responseItems[ResponsesTable.REQ_DATA]
        requestHeaders, requestBody, rawRequest = ContentHelper.combineRaw(
            reqHeaders, reqData)

        resHeaders = responseItems[ResponsesTable.RES_HEADERS]
        resData = responseItems[ResponsesTable.RES_DATA]
        responseHeaders, responseBody, rawResponse = ContentHelper.combineRaw(
            resHeaders, resData, charset)

        sequence_item = {
            'responseUrl': url,
            'responseId': responseId,
            'rawResponse': rawResponse,
            'rawRequest': rawRequest,
            'method': method,
        }

        self.sequence_items[stepnum] = sequence_item
        status = self.check_pattern_match(sequence_item)
        item = QTreeWidgetItem([stepnum, status, method, contentType, url])
        self.sequenceStepsTreeWidget.addTopLevelItem(item)

        self.hide_media_type_item(item, contentType)

        self.formCapture.process_target_request(responseId, requestId, method,
                                                url, reqHeaders, reqData)

        return item
Exemple #2
0
    def fill_from_response(self, url, headers, body, content_type = None):
        if not url:
            url = 'about:blank'

        if not content_type:
            content_type = ContentHelper.getContentTypeFromHeaders(headers)

        charset = ContentHelper.getCharSet(content_type)

        qurl = QUrl.fromEncoded(url)

        # TODO: improve setting for non-html content, especially css
        self.setContent(body, content_type, qurl)
Exemple #3
0
    def append_sequence_item(self, responseId, requestId = ''):
        topItem = self.sequenceStepsTreeWidget.topLevelItem(self.sequenceStepsTreeWidget.topLevelItemCount()-1)
        if topItem is None:
            current_max = 0
        else:
            current_max = int(topItem.text(0))
        stepnum = str(current_max + 1)

        row = self.Data.read_responses_by_id(self.cursor, responseId)
        if not row:
            return

        self.sequenceResponseIds.add(responseId)

        responseItems = interface.data_row_to_response_items(row)

        url = responseItems[ResponsesTable.URL]
        method = responseItems[ResponsesTable.REQ_METHOD]
        contentType = responseItems[ResponsesTable.RES_CONTENT_TYPE].lower().strip()
        charset = ContentHelper.getCharSet(contentType)
        if contentType and ';' in contentType:
            contentType = contentType[0:contentType.index(';')]

        reqHeaders = responseItems[ResponsesTable.REQ_HEADERS]
        reqData = responseItems[ResponsesTable.REQ_DATA]
        requestHeaders, requestBody, rawRequest = ContentHelper.combineRaw(reqHeaders, reqData)

        resHeaders = responseItems[ResponsesTable.RES_HEADERS]
        resData = responseItems[ResponsesTable.RES_DATA]
        responseHeaders, responseBody, rawResponse = ContentHelper.combineRaw(resHeaders, resData, charset)

        sequence_item = {
            'responseUrl' : url,
            'responseId' : responseId,
            'rawResponse' : rawResponse,
            'rawRequest' : rawRequest,
            'method' : method,
            }

        self.sequence_items[stepnum] = sequence_item
        status = self.check_pattern_match(sequence_item)
        item = QTreeWidgetItem([stepnum, status, method, contentType, url])
        self.sequenceStepsTreeWidget.addTopLevelItem(item)

        self.hide_media_type_item(item, contentType)

        self.formCapture.process_target_request(responseId, requestId, method, url, reqHeaders, reqData)

        return item
Exemple #4
0
    def fill_internal(self, Id):

        self.clear()

        if not Id:
            return

        self.responseId = Id
        self.requestResponse = self.framework.get_request_response(Id)
        rr = self.requestResponse

        confirmedState = Qt.Unchecked
        if rr.confirmed and rr.confirmed.lower() in ['y', '1', 'true']:
            confirmedState = Qt.Checked
        self.confirmedButtonStateChanged(confirmedState)

        self.requestScintilla.setText(rr.rawRequest)

        self.attachLexer(self.responseScintilla, rr.responseContentType,
                         rr.responseBody)
        self.responseScintilla.setText(
            ContentHelper.convertBytesToDisplayText(rr.rawResponse))
        self.hexBodyScintilla.setText(self.hexDumper.dump(rr.responseBody))
        self.contentResults = self.generateExtractorResults(
            rr.responseHeaders, rr.responseBody, rr.responseUrl, rr.charset)
        self.notesTextEdit.setText(rr.notes)
        self.handle_tab_currentChanged(self.tabwidget.currentIndex())
Exemple #5
0
    def populate_response_content(self, url, req_headers, req_body, res_headers, res_body, res_content_type = ''):
            
        self.request_url = url
        self.request_headers = req_headers
        self.request_body = req_body
        self.response_headers = res_headers
        self.response_body = res_body
        self.response_content_type = res_content_type

        if self.showRequest:
            self.reqReqEdit.setText(ContentHelper.getCombinedText(self.request_headers, self.request_body, ''))

        # TODO: should support different lexers based on content type
        lexerInstance = Qsci.QsciLexerHTML(self.reqResEdit)
        lexerInstance.setFont(self.framework.get_font())
        self.reqResEdit.setLexer(lexerInstance)
        # TODO: should verify trailing newlines?
        self.reqResEdit.setText(ContentHelper.getCombinedText(self.response_headers, self.response_body, self.response_content_type))

        self.do_render_apply(self.tabWidget.currentIndex())
Exemple #6
0
    def analyze_response(self, response):
        # return Need Sequence, Run Again
        if not self.session_detection:
            return True, False

        is_insession = False
        is_outofsession = False

        charset = ContentHelper.getCharSet(response.content_type)
        responseHeaders, responseBody, rawResponse = ContentHelper.combineRaw(
            response.headers, response.body, charset)
        rawResponse_lower = ''

        if self.use_insession_re:
            if self.re_insession.search(rawResponse):
                is_insession = True
        elif self.insession_pattern:
            rawResponse_lower = rawResponse.lower()
            if -1 != rawResponse_lower.find(self.insession_pattern):
                is_insession = True

        if self.use_outofsession_re:
            if self.re_outofsession.search(rawResponse):
                is_outofsession = True
        elif self.outofsession_pattern:
            if '' == rawResponse_lower:
                rawResponse_lower = rawResponse.lower()
            if -1 != rawResponse_lower.find(self.outofsession_pattern):
                is_outofsession = True

        if is_insession and not is_outofsession:
            return False, False
        elif not is_insession and is_outofsession:
            return True, True
        elif not is_insession and not is_outofsession:
            return False, False
        else:
            # conflicted, so run sequence, but not item
            return True, False
Exemple #7
0
    def analyze_response(self, response):
        # return Need Sequence, Run Again
        if not self.session_detection:
            return True, False

        is_insession = False
        is_outofsession = False

        charset = ContentHelper.getCharSet(response.content_type)
        responseHeaders, responseBody, rawResponse = ContentHelper.combineRaw(response.headers, response.body, charset)
        rawResponse_lower = ''

        if self.use_insession_re:
            if self.re_insession.search(rawResponse):
                is_insession = True
        elif self.insession_pattern:
            rawResponse_lower = rawResponse.lower()
            if -1 != rawResponse_lower.find(self.insession_pattern):
                is_insession = True

        if self.use_outofsession_re:
            if self.re_outofsession.search(rawResponse):
                is_outofsession = True
        elif self.outofsession_pattern:
            if '' == rawResponse_lower:
                rawResponse_lower = rawResponse.lower()
            if -1 != rawResponse_lower.find(self.outofsession_pattern):
                is_outofsession = True

        if is_insession and not is_outofsession:
            return False, False
        elif not is_insession and is_outofsession:
            return True, True
        elif not is_insession and not is_outofsession:
            return False, False
        else:
            # conflicted, so run sequence, but not item
            return True, False
    def fill_internal(self, Id):

        self.clear()

        if not Id:
            return

        self.responseId = Id
        self.requestResponse = self.framework.get_request_response(Id)
        rr = self.requestResponse

        confirmedState = Qt.Unchecked
        if rr.confirmed and rr.confirmed.lower() in ['y', '1', 'true']:
            confirmedState = Qt.Checked
        self.confirmedButtonStateChanged(confirmedState)

        self.requestScintilla.setText(rr.rawRequest)

        self.attachLexer(self.responseScintilla, rr.responseContentType, rr.responseBody)
        self.responseScintilla.setText(ContentHelper.convertBytesToDisplayText(rr.rawResponse))
        self.hexBodyScintilla.setText(self.hexDumper.dump(rr.responseBody))
        self.contentResults = self.generateExtractorResults(rr.responseHeaders, rr.responseBody, rr.responseUrl, rr.charset)
        self.notesTextEdit.setText(rr.notes)
        self.handle_tab_currentChanged(self.tabwidget.currentIndex())
Exemple #9
0
 def _doCombineResponse(self):
     self._responseUTF8Headers, self._responseUTF8Body, self._rawResponse = ContentHelper.combineRaw(self.responseHeaders, self.responseBody, self.charset)
     self._combinedResponse = True
Exemple #10
0
 def _doCombineRequest(self):
     self._requestUTF8Headers, self._requestUTF8Body, self._rawRequest = ContentHelper.combineRaw(self.requestHeaders, self.requestBody)
     self._combinedRequest = True
Exemple #11
0
 def _doCombineResponse(self):
     self._responseUTF8Headers, self._responseUTF8Body, self._rawResponse = ContentHelper.combineRaw(
         self.responseHeaders, self.responseBody, self.charset)
     self._combinedResponse = True
Exemple #12
0
 def _doCombineRequest(self):
     self._requestUTF8Headers, self._requestUTF8Body, self._rawRequest = ContentHelper.combineRaw(
         self.requestHeaders, self.requestBody)
     self._combinedRequest = True