(self, body=True)
| 170 | self.do_GET(body=False) |
| 171 | |
| 172 | def do_GET(self, body=True): |
| 173 | sent = False |
| 174 | try: |
| 175 | logging.info('path::' + self.path) |
| 176 | if blockPaths(self.path): return |
| 177 | hn = hostname |
| 178 | for _ in req_headers: |
| 179 | if _[0] in self.path: |
| 180 | for k,v in _[1].items(): |
| 181 | if k=='Host': hn=v |
| 182 | url = 'https://' + hn + self.path.replace(domain,hostname.split('.',1)[1]) |
| 183 | # Parse request |
| 184 | print('\n//'+self.command) |
| 185 | print(LIGHTGREEN + url + RESET) |
| 186 | req_header = self.parseHeaders() |
| 187 | # Call the target hostname |
| 188 | resp = self.s.get(url, headers=injectHeaders(req_header, url, self.headers['Content-Length'], self.path), verify=False, allow_redirects=True,) |
| 189 | sent = True |
| 190 | if resp.history: |
| 191 | for r in resp.history: |
| 192 | print('Redirection: '+BOLD+CYAN+'[',r.status_code,'] ',r.url, RESET) |
| 193 | # Respond with the requested data |
| 194 | self.sendRespHeaders(resp) |
| 195 | if body: |
| 196 | inj_resp = injectRespBody(resp.content, self.path) |
| 197 | self.send_header('Content-Length', len(inj_resp)) |
| 198 | self.end_headers() |
| 199 | self.wfile.write(inj_resp) |
| 200 | else: |
| 201 | self.send_header('Content-Length', len(resp.content)) |
| 202 | self.end_headers() |
| 203 | return |
| 204 | except Exception as e: |
| 205 | logging.error(RED + str(e)) |
| 206 | logging.debug(e, exc_info=True) |
| 207 | # exit() |
| 208 | finally: |
| 209 | # self.finish() |
| 210 | if not sent: |
| 211 | self.send_error(200, 'No Content') |
| 212 | logging.info('sending [200] with no content to target') |
| 213 | |
| 214 | def do_POST(self, body=True): |
| 215 | sent = False |
no test coverage detected