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q+
Qf8
Qf4
Kf3
Qd6
Ke3
Qe6
Kf4
Qe5
Qa5+
Qe5
Qc5
Qg1+
Qg2+
Qg4+
Qg1
Ke4
Kf3
Kf4
Qe3
Kg5
Kf4
Kg3
Kg2
Qxd2
Kg1
Kg2
Kg3
from scapy.all import *
import re
filename = 'final.pcap'
count = 0
readthis = PcapReader('final.pcap')
#readthis = PacketList([p for p in readthis if p[IP].src == '172.17.0.2'])
for p in readthis:
if TCP in p and p[TCP].dport == 5000 and p[TCP].payload:
deliver = p[TCP].payload
# print deliver
deliver_string = str(deliver)
if '/image' in deliver_string:
attachment_string= re.search('filename=.*.svg',str(deliver_string)).group(0)
attachment_string=attachment_string.strip(".svg")
attachment_string=attachment_string.strip('filename="')
attach_id= int(attachment_string)
print "Saving "+str(count)+"th image"
image_collect = re.search('<?.*</svg>', str(deliver_string)).group(0)
fname=str(attach_id)+".svg"
count = count+1
with open(fname, 'w') as f:
f.write('<?xml version="1.0" encoding="utf-8" ?>')
f.write('')
f.write(image_collect)
f.close()
#print p[TCP].payload
from scapy.all import *
import re
filename = 'final.pcap'
count = 0
readthis = PcapReader('final.pcap')
#readthis = PacketList([p for p in readthis if p[IP].src == '172.17.0.2'])
for p in readthis:
if TCP in p and p[IP].src == '10.100.28.4' and p[TCP].payload:
deliver = p[TCP].payload
deliver_string = str(deliver)
if 'HTTP/1.0 200 OK' in deliver_string:
print deliver_string[-5:]
fname='compmove.txt'
with open(fname, 'a') as f:
f.write("")
f.write(deliver_string[-4:])
f.write("")
f.close()
from bs4 import BeautifulSoup as BS
for x in xrange(0, 202):
print "[+] Dumping "+str(x)+" th svg"
fname = str(x)+".svg"
try:
with open(fname, 'r') as f:
compyl = f.read()
soup = BS(compyl, 'lxml')
length = len(soup.findAll('text'))
for i in xrange(0, length):
cipher = "".join(map(str, soup.findAll('text')[i].text)).replace(" ","")
with open('ciphertext.txt', 'a') as f1:
f1.write(cipher)
f1.close()
except IOError:
with open('ciphertext.txt','a') as f1:
f1.write('\n*************************\n')
f1.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment