def ex(self): # print(self.options) if self.options['Editor']: os.system("vi %s" % J(MODULE_PATH, self.module_name + '.py')) raise SystemExit("0") if self.options['thread'] > 1: self.exe = Exe(self.options['thread']) LogControl.i('thread: %d' % self.options['thread'], txt_color='blue') if self.options['add_data']: self.add_res(self.options['add_data']) raise SystemExit("0") if self.options['delete_data']: self.del_res() raise SystemExit("0") self.parser() try: if not isinstance(self.payloads, (list, dict, tuple,)): # LogControl.wrn("check here") self.run(self.options) # LogControl.wrn("check here1") raise SystemExit(0) for payload in self.payloads: self.options['payload'] = payload LogControl.title("load payload: ", colored(payload, attrs=['underline', 'bold']) , txt_color="blue",end="\r") self.run(self.options) except (KeyboardInterrupt, InterruptedError): LogControl.i("~~bye") raise SystemExit(0)
def _decode_raw(self): ok = False for e in BASE_ENCODING: try: self.content = self.raw_response.content.decode(e) ok = True break except UnicodeDecodeError: L.title(e, " err") continue if not ok: self.content = self.raw_response.content.decode("iso-8859-1")
def load_res(self, name): for f in os.listdir(self.RES_DIR): if f.lower().find(name) != -1: LogControl.title("load file", f) return J(self.RES_DIR, f)
def __init__(self, url, show_process=True, cookie=True, session=None, **kargs): self.session = session if show_process: with show_pro("Geting", str(url) + " | " + str(kargs)): if isinstance(url, requests.models.Response): self.raw_response = url else: if cookie: if not self.session: self.session, self.raw_response = to(url, cookie=True, **kargs) else: _, self.raw_response = to(url, cookie=True, session=self.session, **kargs) else: if self.session: self.raw_response = to(url, session=self.session, **kargs) else: self.raw_response = to(url, **kargs) else: if isinstance(url, requests.models.Response): self.raw_response = url else: if cookie: self.session, self.raw_response = to(url, cookie=True, **kargs) else: if self.session: self.raw_response = to(url, session=self.session, **kargs) else: self.raw_response = to(url, **kargs) self.show_process = show_process self.url = self.raw_response.url self.encoding = self.raw_response.encoding.lower() # L.err(self.encoding) # check if encoding is iso-8859-1 self.encoding = ERR_ENCODING_2_RIGHT.get(self.encoding, self.encoding) try: self.content = self.raw_response.content.decode(self.encoding) except UnicodeDecodeError as e: L.err(e) L.title(self.encoding + "error", "try another charset") self._decode_raw() self.content = re.sub(r'(\n)+', '\n', self.content) self.Soup = BeautifulSoup(self.content, "html.parser") self.Base = copy.copy(self.Soup)
def do_export(self, name): data = self.export(name) output = dict_cmd({'output[path to save]': "./pdf.pdf"}) fpath = output['output[path to save]'] LogControl.title('to',output_to_pdf(data, fpath))