Skip to content

Commit

Permalink
Merge pull request #18 from secureworks/script-make-pcap-py3
Browse files Browse the repository at this point in the history
python3 compatibility for make_pcap_poc.py
  • Loading branch information
counterthreatunit authored Dec 30, 2019
2 parents 14473db + 289e533 commit afc9267
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/make_pcap_poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
def print_debug(msg):
global DEBUG
if msg and DEBUG:
print "\t%s" % msg
print("\t%s" % msg)

def print_error(msg):
print "ERROR! %s" % msg
print("ERROR! %s" % msg)
sys.exit(1)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
Expand All @@ -56,11 +56,11 @@ def print_error(msg):
print_error("FlowSynth script file \'%s\' does not exist! Update the path in this script (%s)." % (flowsynth_script, sys.argv[0]))
try:
flowsynth = imp.load_source('flowsynth', flowsynth_script)
except Exception, e:
except Exception as e:
print_error("Could not import flowsynth or load from file \'%s\'. Error:\n%s" % (flowsynth_script, e))

def usage():
print "Usage: make_pcap_poc.py <poc_file> [<output_file>]"
print("Usage: make_pcap_poc.py <poc_file> [<output_file>]")
sys.exit(1)

if len(sys.argv) < 2:
Expand All @@ -77,15 +77,15 @@ def usage():
if result:
cve = result.group('CVE')

print "Creating pcap for %s" % cve
print("Creating pcap for %s" % cve)

if len(sys.argv) > 2:
pcap_file = sys.argv[2]
else:
pcap_file = "%s_%s.pcap" % (cve, os.getpid())

# make the flowsynth file
fs_fh = tempfile.NamedTemporaryFile()
fs_fh = tempfile.NamedTemporaryFile(mode='w')
print_debug("FlowSynth file: %s" % fs_fh.name)

client_ip = "192.168.%d.%d" % (random.randint(0,255), random.randint(0,255))
Expand Down Expand Up @@ -122,5 +122,5 @@ def usage():

fs_fh.close()

print "Done. Wrote pcap to:\n%s" % pcap_file
print("Done. Wrote pcap to:\n%s" % pcap_file)

0 comments on commit afc9267

Please sign in to comment.