本文整理汇总了Python中CTCore类的典型用法代码示例。如果您正苦于以下问题:Python CTCore类的具体用法?Python CTCore怎么用?Python CTCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_ziplist
def do_ziplist(self, line):
try:
line = str(line)
import zipfile
l = line.split(" ")
if (l[0] == ""):
self.help_ziplist()
else:
id, size = get_id_size(line)
if in_range(id):
response, size = CTCore.get_response_and_size(id, "all")
name = CTCore.get_name(id)
fp = StringIO.StringIO(response)
fp.write(response)
zfp = zipfile.ZipFile(fp, "r")
self.retval = " " + str(len(zfp.namelist())) + \
" Files found in zip object {} ({}):".format(
str(id),name) + newLine
for cnt, fl in enumerate(zfp.namelist()):
self.retval += " [Z] " + str(cnt + 1) + " : " + fl
cnt += 1
self.retval += newLine
except Exception,e:
self.retval = "Error unzipping object: " + str(e)
示例2: do_jsbeautify
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)
示例3: main
def main(args):
file_path = args[1]
print("[A] Analyzing PCAP: " + args[1])
parse_pcap.run(file_path)
print(CTCore.newLine + "[+] Traffic Activity Time: " + CTCore.activity_date_time.strftime('%a, %x %X'))
print("[+] Conversations Found:" + CTCore.newLine)
CTCore.show_conversations()
start_ws = True
if (len(args) > 2):
if args[2].lower() == "-s":
start_ws = False
else:
CTCore.PORT = int(args[2])
if (start_ws):
try:
CTCore.web_server = server()
CTCore.web_server.start()
time.sleep(0.1) # Fixes graphic issues
CTCore.web_server_turned_on = True
except Exception,e:
print "[E] Error starting Web Service:"
if str(e).find("Errno 1004") > 0 or str(e).find("Errno 98") > 0:
print " Port " + str(CTCore.PORT) + " is already Taken."
print " Change the port using 'CapTipper.py <pcap_file> [port=80]' or use '-s' to disable web server"
print " Proceeding without starting the web server..." + CTCore.newLine
else:
print " " + str(e)
示例4: do_ls
def do_ls(self, line):
try:
l = line.split(" ")
if (l[0] == ""):
CTCore.list_pcap(".")
else:
CTCore.list_pcap(os.path.expanduser(l[0]))
except Exception,e:
print str(e)
示例5: do_urlb64d
def do_urlb64d(self, line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_urlb64d()
else:
id = int(l[0])
if in_range(id):
CTCore.urlb64d(id)
except Exception,e:
print str(e)
示例6: do_hexdump
def do_hexdump(self,line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_hexdump()
else:
id, size = get_id_size(line)
response, size = CTCore.get_response_and_size(id, size)
name = CTCore.get_name(id)
print "Displaying hexdump of object {} ({}) body [{} bytes]:".format(id, name, size)
print newLine + hexdump(response) + newLine
except Exception,e:
print str(e)
示例7: do_body
def do_body(self, line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_body()
else:
id, size = get_id_size(line)
response, size = CTCore.get_response_and_size(id, size)
name = CTCore.get_name(id)
print "Displaying body of object {} ({}) [{} bytes]:".format(id, name, size)
CTCore.show_errors()
print newLine + response
except Exception,e:
print str(e)
示例8: main
def main(args, pcap_file):
if not os.path.exists(args.dump[0]):
os.makedirs(args.dump[0])
CTCore.pcap_file = pcap_file[0]
if(args.report is not None):
CTCore.b_auto_ungzip = True
parse_pcap.run(CTCore.pcap_file)
# If chosen just to dump files and exit
if (args.dump is not None):
try:
CTCore.ungzip_all()
CTCore.dump_all_files(args.dump[0],True)
except Exception, ed:
print ed
示例9: do_load
def do_load(self, line):
# try:
# CTCore.load_pcap(line)
# except Exception, e:
# print str(e)
try:
l = line.split(" ")
if (l[0] == ""):
self.help_load()
else:
CTCore.load_pcap(line)
exit(0)
except Exception,e:
print str(e)
示例10: do_req
def do_req(self, line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_req()
else:
id, size = get_id_size(line)
request, size = CTCore.get_request_size(id, "all")
name = CTCore.get_name(id)
print "Displaying request for object {} ({}) [{} bytes]:".format(id, name, size)
CTCore.show_errors()
print newLine + request
except Exception,e:
print str(e)
示例11: do_vt
def do_vt(self,line):
try:
line = str(line)
l = line.split(" ")
if (l[0] == ""):
self.help_vt()
else:
if not CTCore.VT_APIKEY:
print newLine + "No Virus Total API key found, please enter your API key:",
CTCore.VT_APIKEY = raw_input()
id = int(l[0])
body, sz = CTCore.get_response_and_size(id, "all")
name = CTCore.get_name(id)
self.retval = " VirusTotal result for object {} ({}):".format(str(id),name) + newLine
hash = hashlib.md5(StringIO.StringIO(body).getvalue()).hexdigest()
vtdata = CTCore.send_to_vt(hash, CTCore.VT_APIKEY)
if vtdata[0] != -1:
jsonDict = vtdata[1]
if jsonDict.has_key('response_code'):
if jsonDict['response_code'] == 1:
if jsonDict.has_key('scans') and jsonDict.has_key('scan_date') \
and jsonDict.has_key('total') and jsonDict.has_key('positives') and jsonDict.has_key('permalink'):
self.retval += " Detection: {}/{}".format(jsonDict['positives'], jsonDict['total'])
self.retval += " Last Analysis Date: {}".format(jsonDict['scan_date'])
self.retval += " Report Link: {}".format(jsonDict['permalink']) + newLine
if jsonDict['positives'] > 0:
self.retval += " Scan Result:"
for av in jsonDict['scans']:
av_res = jsonDict['scans'][av]
if av_res.has_key('detected') and av_res.has_key('version') and av_res.has_key('result') and av_res.has_key('update'):
if av_res['detected']:
self.retval += "\t{}\t{}\t{}\t{}".format(av, av_res['result'], av_res['version'], av_res['update'])
else:
self.retval += " Missing elements in Virus Total Response"
else:
self.retval += " File not found in VirusTotal"
else:
self.retval += " Response from VirusTotal isn't valid"
else:
self.retval += vtdata[1]
self.retval += newLine
except Exception,e:
self.retval = str(e)
示例12: do_strings
def do_strings(self, line):
try:
l = line.split(" ")
if (l[0] == ""):
self.help_strings()
else:
id, size = get_id_size(line)
response, size = CTCore.get_response_and_size(id, "all")
name = CTCore.get_name(id)
print "Strings found in object {} ({}) [{} bytes]:".format(id, name, size)
strings = CTCore.get_strings(response)
print (newLine.join(str for str in strings))
except Exception,e:
print str(e)
示例13: run
def run(file_path):
conn_dict = OrderedDict()
try:
if file_path != '-':
infile = io.open(file_path, "rb")
else:
infile = sys.stdin
try:
pcap_file(conn_dict, infile)
finally:
time.sleep(0.1)
CTCore.sort_convs()
infile.close()
finally:
for conn in conn_dict.values():
conn.finish()
示例14: check_path
def check_path(path,type="file"):
directory = os.path.dirname(path)
if type == "file" and os.path.isdir(path):
CTCore.alert_message("Please specify a full path and not a folder",msg_type.ERROR)
return False
if not os.path.isdir(directory):
print newLine + " Directory {} doesn't exists. Create? (Y/n):".format(directory),
ans = raw_input()
if ans.lower() == "y" or ans == "":
os.makedirs(directory)
return True
else:
return False
else:
return True
示例15: do_hexdump
def do_hexdump(self, line, xor=None, custsize=None):
try:
line = str(line)
l = line.split(" ")
if (l[0] == ""):
self.help_hexdump()
else:
id, size = get_id_size(line)
if custsize:
size = custsize
response, size = CTCore.get_response_and_size(id, size)
name = CTCore.get_name(id)
self.retval = "Displaying hexdump of object {} ({}) body [{} bytes]:".format(id, name, size)
self.retval += newLine + hexdump(response) + newLine
except Exception,e:
self.retval = str(e)