def do_jsbeautify(self,line): try: import jsbeautifier l = line.split(" ") if len(l) < 2: self.help_jsbeautify() else: OPTIONS = ['slice','obj'] option = l[0] if option not in OPTIONS: print "Invalid option" return False id = l[1] response, size = CTCore.get_response_and_size(id, "all") name = CTCore.get_name(id) if option == "slice": offset = int(l[2]) length = l[3] bytes, length = get_bytes(response,offset,length) js_bytes = bytes res = jsbeautifier.beautify(js_bytes) print res if option == "obj": res = jsbeautifier.beautify(response) obj_num = CTCore.add_object("jsbeautify",res,id=id) print " JavaScript Beautify of object {} ({}) successful!".format(str(id), name) print " New object created: {}".format(obj_num) + newLine except Exception,e: print str(e)
def do_ungzip(self,line): try: l = line.split(" ") if (l[0] == ""): self.help_ungzip() else: id = l[0] body, sz = get_response_size(id, "all") name = CTCore.get_name(id) import gzip decomp = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(body)) page = decomp.read() obj_num = CTCore.add_object("ungzip",page,id=id) print " GZIP Decompression of object {} ({}) successful!".format(str(id), name) print " New object created: {}".format(obj_num) + newLine except Exception,e: print str(e)
def do_ungzip(self, line): try: l = line.split(" ") if (l[0] == ""): self.help_ungzip() else: id = l[0] body, sz = get_response_size(id, "all") name = CTCore.get_name(id) import gzip decomp = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(body)) page = decomp.read() obj_num = CTCore.add_object("ungzip", page, id=id) print " GZIP Decompression of object {} ({}) successful!".format( str(id), name) print " New object created: {}".format(obj_num) + newLine except Exception, e: print str(e)
def do_jsbeautify(self, line): try: line = str(line) import jsbeautifier l = line.split(" ") if len(l) < 2: self.help_jsbeautify() else: OPTIONS = ['slice', 'obj'] option = l[0] if option not in OPTIONS: self.retval = "Invalid option" return False id = l[1] response, size = CTCore.get_response_and_size(id, "all") name = CTCore.get_name(id) if option == "slice": offset = int(l[2]) length = l[3] bytes, length = get_bytes(response, offset, length) js_bytes = bytes res = jsbeautifier.beautify(js_bytes) self.retval = res if option == "obj": res = jsbeautifier.beautify(response) obj_num = CTCore.add_object("jsbeautify", res, id=id) self.retval = " JavaScript Beautify of object {} ({}) successful!".format( str(id), name) self.retval += " New object created: {}".format( obj_num) + newLine except Exception, e: self.retval = str(e)