some small fixes

This commit is contained in:
Mari Wahl 2014-10-25 02:21:38 -04:00
parent 43b52a7902
commit 90152b4ed3
2 changed files with 65 additions and 7 deletions

View File

@ -1,7 +0,0 @@
# CSAW CTF 2014 - Cryptography Problems
#### psifer school
[My write-up](https://gist.github.com/bt3gl/a8617848ccb37e56034d)

View File

@ -0,0 +1,65 @@
#!/usr/bin/env python
import os
import sys
import binascii
"""
Shark the Ripper Tool
For packet capture CTF problems:
Follow TCP Steam > Hex Dump > (Select Client/Server Chat) > Save As
Then input the file, followed by offset(s) where you want to cut.
-mandy
"""
if len(sys.argv) < 2:
print "Oh ffs, seriously?"
print "Usage: " + sys.argv[0] + " pasted_wireshark_hex_dump.txt START_OFFSET END_OFFSET"
sys.exit()
if os.path.isfile( sys.argv[1] ):
with open( sys.argv[1] ) as f:
filecontents = f.read()
if len( sys.argv ) > 2:
if len( sys.argv ) == 4:
start = sys.argv[2]
end = sys.argv[3]
else:
start = sys.argv[2]
end = "FFFFFFFF"
cut = True
if len( start ) != 8 or len( end ) != 8:
print "Invalid offset size"
sys.exit()
else:
cut = False
output = ""
if cut == True:
start_cutting = False
for row in filecontents.split("\n"):
if row != "":
if row[:8] == start:
start_cutting = True
if row[:8] == end:
start_cutting = False
if start_cutting == True:
output += row[10:][:48].replace(" ", "")
else:
for row in filecontents.split("\n"):
if row != "":
output += row[10:][:48].replace(" ", "")
output = binascii.unhexlify(output)
with open( sys.argv[1] + ".out", 'w') as output_file:
output_file.write( output )