def send_to_repeater_post_form_data_body(self, host, payload): req = self._requests[host]['POST'] or self._requests[host][ 'PUT'] or self._requests[host]['GET'] if req and self._callbacks and self._helpers: info = req[0] body = req[1] nobody = body[:info.getBodyOffset()].tostring() rstripoffset = info.getBodyOffset() - len(nobody.rstrip()) headers = body[:info.getBodyOffset() - rstripoffset].tostring() try: self._overrideheaders[host] except KeyError: self._overrideheaders[host] = [] headers = override_headers(headers, self._overrideheaders[host]) boundary = "---------------------------%s" % random_string() headers = override_headers(headers, [ ("Content-Type", "multipart/form-data, boundary=%s" % boundary) ]) headers = override_uri(headers, method="POST") content = json.loads(payload) if isinstance(content, list): content = content[0] repeater_body = StringUtil.toBytes( string_join( headers, body[info.getBodyOffset() - rstripoffset:info.getBodyOffset()].tostring(), multipart(data=querify(clean_dict(content)), boundary=boundary))) self._callbacks.sendToRepeater( info.getUrl().getHost(), info.getUrl().getPort(), info.getUrl().getProtocol() == 'https', repeater_body, 'GraphQL - POST form-data #%s' % self._index) self._index += 1
def send_to_repeater_get_query(self, host, payload): req = self._requests[host]['POST'] or self._requests[host][ 'PUT'] or self._requests[host]['GET'] if req and self._callbacks and self._helpers: info = req[0] body = req[1] nobody = body[:info.getBodyOffset()].tostring() rstripoffset = info.getBodyOffset() - len(nobody.rstrip()) metadata = body[:info.getBodyOffset() - rstripoffset].tostring() try: self._overrideheaders[host] except KeyError: self._overrideheaders[host] = [] metadata = override_headers(metadata, self._overrideheaders[host]) # remove Content-Type on GET requests metadata = re.sub(r'(?m)^Content-Type:.*\n?', '', metadata) content = json.loads(payload) if isinstance(content, list): content = content[0] metadata = override_uri(metadata, method="GET", query=urlencode( querify(clean_dict(content)))) repeater_body = StringUtil.toBytes( string_join( metadata, body[info.getBodyOffset() - rstripoffset:info.getBodyOffset()].tostring())) self._callbacks.sendToRepeater( info.getUrl().getHost(), info.getUrl().getPort(), info.getUrl().getProtocol() == 'https', repeater_body, 'GraphQL - GET query #%s' % self._index) self._index += 1
def send_to_repeater_post_urlencoded_body(self, host, payload): req = self._requests[host]['POST'] or self._requests[host][ 'PUT'] or self._requests[host]['GET'] if req and self._callbacks and self._helpers: info = req[0] body = req[1] nobody = body[:info.getBodyOffset()].tostring() rstripoffset = info.getBodyOffset() - len(nobody.rstrip()) headers = body[:info.getBodyOffset() - rstripoffset].tostring() try: self._overrideheaders[host] except KeyError: self._overrideheaders[host] = [] headers = override_headers(headers, self._overrideheaders[host]) headers = override_headers( headers, [("Content-Type", "application/x-www-form-urlencoded")]) headers = override_uri(headers, method="POST") content = json.loads(payload) if isinstance(content, list): content = content[0] repeater_body = StringUtil.toBytes( string_join( headers, body[info.getBodyOffset() - rstripoffset:info.getBodyOffset()].tostring(), urlencode(querify(clean_dict(content))))) self._callbacks.sendToRepeater( info.getUrl().getHost(), info.getUrl().getPort(), info.getUrl().getProtocol() == 'https', repeater_body, 'GraphQL - POST urlencoded #%s' % self._index) self._index += 1