Conversion to python3, using 2to3.
This commit is contained in:
parent
eecf68dc98
commit
3a6041ccac
@ -50,7 +50,7 @@ def setBaseDir(mybasedir):
|
|||||||
class AboutScyther(wx.Dialog):
|
class AboutScyther(wx.Dialog):
|
||||||
def __init__(self,parent,mybasedir=None):
|
def __init__(self,parent,mybasedir=None):
|
||||||
|
|
||||||
from Version import SCYTHER_GUI_VERSION
|
from .Version import SCYTHER_GUI_VERSION
|
||||||
global basedir
|
global basedir
|
||||||
|
|
||||||
self.text = '''
|
self.text = '''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from __future__ import division # 2.2+-only
|
# 2.2+-only
|
||||||
"""
|
"""
|
||||||
Scyther : An automatic verifier for security protocols.
|
Scyther : An automatic verifier for security protocols.
|
||||||
Copyright (C) 2007-2013 Cas Cremers
|
Copyright (C) 2007-2013 Cas Cremers
|
||||||
@ -25,14 +25,14 @@ from __future__ import division # 2.2+-only
|
|||||||
""" Import externals """
|
""" Import externals """
|
||||||
import wx
|
import wx
|
||||||
import os
|
import os
|
||||||
from Misc import *
|
from .Misc import *
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Icon
|
from . import Icon
|
||||||
import Preference
|
from . import Preference
|
||||||
import Error
|
from . import Error
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
try:
|
try:
|
||||||
@ -74,7 +74,7 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
Preference.doNotUsePIL()
|
Preference.doNotUsePIL()
|
||||||
raise Error.PILError
|
raise Error.PILError
|
||||||
else:
|
else:
|
||||||
print "Unknown file type %s." % (self.filetype)
|
print("Unknown file type %s." % (self.filetype))
|
||||||
|
|
||||||
# TODO self.Bind(wxSizeEvent
|
# TODO self.Bind(wxSizeEvent
|
||||||
self.update(True)
|
self.update(True)
|
||||||
@ -142,7 +142,7 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
self.Image.SetBitmap(image.ConvertToBitmap())
|
self.Image.SetBitmap(image.ConvertToBitmap())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "Unknown file type %s." % (self.attack.filetype)
|
print("Unknown file type %s." % (self.attack.filetype))
|
||||||
|
|
||||||
self.SetVirtualSize((virtualwidth,virtualheight))
|
self.SetVirtualSize((virtualwidth,virtualheight))
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import sys
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Misc
|
from . import Misc
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -28,12 +28,12 @@ import os.path
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Settingswindow
|
from . import Settingswindow
|
||||||
import Scytherthread
|
from . import Scytherthread
|
||||||
import Icon
|
from . import Icon
|
||||||
import About
|
from . import About
|
||||||
import Editor
|
from . import Editor
|
||||||
import Preference
|
from . import Preference
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ from Scyther import Misc as MiscScyther
|
|||||||
from Scyther import FindDot
|
from Scyther import FindDot
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Temporary
|
from . import Temporary
|
||||||
import Preference
|
from . import Preference
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
try:
|
try:
|
||||||
|
@ -32,15 +32,15 @@ from subprocess import Popen,PIPE
|
|||||||
def confirm(question):
|
def confirm(question):
|
||||||
answer = ''
|
answer = ''
|
||||||
while answer not in ('y','n'):
|
while answer not in ('y','n'):
|
||||||
print question,
|
print(question, end=' ')
|
||||||
answer = raw_input().lower()
|
answer = input().lower()
|
||||||
return answer == 'y'
|
return answer == 'y'
|
||||||
|
|
||||||
def exists(func,list):
|
def exists(func,list):
|
||||||
return len(filter(func,list)) > 0
|
return len(list(filter(func,list))) > 0
|
||||||
|
|
||||||
def forall(func,list):
|
def forall(func,list):
|
||||||
return len(filter(func,list)) == len(list)
|
return len(list(filter(func,list))) == len(list)
|
||||||
|
|
||||||
def uniq(li):
|
def uniq(li):
|
||||||
result = []
|
result = []
|
||||||
|
@ -49,7 +49,7 @@ from time import localtime,strftime
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Makeimage
|
from . import Makeimage
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class Preferences(dict):
|
|||||||
"""
|
"""
|
||||||
Copy dict into self.
|
Copy dict into self.
|
||||||
"""
|
"""
|
||||||
for x in d.keys():
|
for x in list(d.keys()):
|
||||||
self[x] = d[x]
|
self[x] = d[x]
|
||||||
|
|
||||||
def parse(self,line):
|
def parse(self,line):
|
||||||
@ -164,13 +164,13 @@ class Preferences(dict):
|
|||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
print "Preferences:"
|
print("Preferences:")
|
||||||
for k in self.keys():
|
for k in list(self.keys()):
|
||||||
print "%s=%s" % (k, self[k])
|
print("%s=%s" % (k, self[k]))
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
||||||
print "Saving preferences"
|
print("Saving preferences")
|
||||||
prefpath = preflocs[-1]
|
prefpath = preflocs[-1]
|
||||||
if not os.access(prefpath,os.W_OK):
|
if not os.access(prefpath,os.W_OK):
|
||||||
os.makedirs(prefpath)
|
os.makedirs(prefpath)
|
||||||
@ -215,7 +215,7 @@ def init():
|
|||||||
def get(key,alt=None):
|
def get(key,alt=None):
|
||||||
global prefs
|
global prefs
|
||||||
|
|
||||||
if key in prefs.keys():
|
if key in list(prefs.keys()):
|
||||||
return prefs[key]
|
return prefs[key]
|
||||||
else:
|
else:
|
||||||
return alt
|
return alt
|
||||||
@ -223,7 +223,7 @@ def get(key,alt=None):
|
|||||||
def getkeys():
|
def getkeys():
|
||||||
global prefs
|
global prefs
|
||||||
|
|
||||||
return prefs.keys()
|
return list(prefs.keys())
|
||||||
|
|
||||||
def set(key,value):
|
def set(key,value):
|
||||||
global prefs
|
global prefs
|
||||||
|
@ -33,11 +33,11 @@ import Scyther.Error
|
|||||||
from Scyther.Misc import *
|
from Scyther.Misc import *
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Preference
|
from . import Preference
|
||||||
import Attackwindow
|
from . import Attackwindow
|
||||||
import Icon
|
from . import Icon
|
||||||
import Error
|
from . import Error
|
||||||
import Makeimage
|
from . import Makeimage
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
if Preference.havePIL:
|
if Preference.havePIL:
|
||||||
@ -114,7 +114,7 @@ class ScytherThread(threading.Thread):
|
|||||||
# verification start
|
# verification start
|
||||||
try:
|
try:
|
||||||
claims = scyther.verify(storePopen=self.storePopen)
|
claims = scyther.verify(storePopen=self.storePopen)
|
||||||
except Scyther.Error.ScytherError, el:
|
except Scyther.Error.ScytherError as el:
|
||||||
claims = None
|
claims = None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -464,7 +464,7 @@ class ScytherRun(object):
|
|||||||
# which makes error reporting somewhat easier
|
# which makes error reporting somewhat easier
|
||||||
try:
|
try:
|
||||||
Scyther.Scyther.Check()
|
Scyther.Scyther.Check()
|
||||||
except Scyther.Error.BinaryError, e:
|
except Scyther.Error.BinaryError as e:
|
||||||
# e.file is the supposed location of the binary
|
# e.file is the supposed location of the binary
|
||||||
text = "Could not find Scyther binary at\n%s" % (e.file)
|
text = "Could not find Scyther binary at\n%s" % (e.file)
|
||||||
Error.ShowAndExit(text)
|
Error.ShowAndExit(text)
|
||||||
|
@ -28,7 +28,7 @@ import sys
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Preference
|
from . import Preference
|
||||||
import Scyther.Claim as Claim
|
import Scyther.Claim as Claim
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@ -19,7 +19,7 @@ def scanThis(fn,f,rewritelist,cnt):
|
|||||||
mapping.append((lhs,rhs))
|
mapping.append((lhs,rhs))
|
||||||
|
|
||||||
fp = open(fn,"r")
|
fp = open(fn,"r")
|
||||||
for rl in fp.xreadlines():
|
for rl in fp:
|
||||||
l = rl
|
l = rl
|
||||||
if f != None:
|
if f != None:
|
||||||
l = f(l)
|
l = f(l)
|
||||||
@ -34,7 +34,7 @@ def convertEm(f=None,path=".",rewritelist=[],newdir=".",oldext="",newext=None):
|
|||||||
cnt = 1
|
cnt = 1
|
||||||
for fn in fl:
|
for fn in fl:
|
||||||
ffn = os.path.join(path,fn)
|
ffn = os.path.join(path,fn)
|
||||||
print "Processing",ffn
|
print("Processing",ffn)
|
||||||
s = scanThis(ffn,f,rewritelist,cnt)
|
s = scanThis(ffn,f,rewritelist,cnt)
|
||||||
if newext == None:
|
if newext == None:
|
||||||
fn2 = fn
|
fn2 = fn
|
||||||
@ -44,7 +44,7 @@ def convertEm(f=None,path=".",rewritelist=[],newdir=".",oldext="",newext=None):
|
|||||||
fp = open(ffn2,"w")
|
fp = open(ffn2,"w")
|
||||||
fp.write(s)
|
fp.write(s)
|
||||||
fp.close()
|
fp.close()
|
||||||
print "Produced",ffn2
|
print("Produced",ffn2)
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
|
|
||||||
def preprocess(s):
|
def preprocess(s):
|
||||||
@ -55,7 +55,7 @@ def preprocess(s):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
convertEm(f=preprocess,rewritelist=["@OracleA","@executability","@OracleB"],path=".",newdir="mpa",oldext=".spdl")
|
convertEm(f=preprocess,rewritelist=["@OracleA","@executability","@OracleB"],path=".",newdir="mpa",oldext=".spdl")
|
||||||
print "Done."
|
print("Done.")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -34,8 +34,8 @@ def stripRowEnd(l):
|
|||||||
# Assume ends with \\, split by dtl
|
# Assume ends with \\, split by dtl
|
||||||
endstr = "\\\\"
|
endstr = "\\\\"
|
||||||
if not l.endswith(endstr):
|
if not l.endswith(endstr):
|
||||||
print "Error: some line does not end with \\\\"
|
print("Error: some line does not end with \\\\")
|
||||||
print ">>%s<<" % (l)
|
print(">>%s<<" % (l))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
return l[:-len(endstr)]
|
return l[:-len(endstr)]
|
||||||
@ -63,7 +63,7 @@ def scanAttackFile(fn):
|
|||||||
prot = None
|
prot = None
|
||||||
role = None
|
role = None
|
||||||
claim = None
|
claim = None
|
||||||
for rawline in fp.xreadlines():
|
for rawline in fp:
|
||||||
|
|
||||||
l = rawline.strip()
|
l = rawline.strip()
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ def scanAttackFile(fn):
|
|||||||
attl[i] = x[1:-1]
|
attl[i] = x[1:-1]
|
||||||
|
|
||||||
ak = (prot,role,claim)
|
ak = (prot,role,claim)
|
||||||
if ak not in attackmap.keys():
|
if ak not in list(attackmap.keys()):
|
||||||
attackmap[ak] = set()
|
attackmap[ak] = set()
|
||||||
attackmap[ak].add(tuple(attl))
|
attackmap[ak].add(tuple(attl))
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ def mpaTable(attackmap):
|
|||||||
s += "\\begin{longtable}{|l|lll|l|}\n"
|
s += "\\begin{longtable}{|l|lll|l|}\n"
|
||||||
s += "\\hline\n"
|
s += "\\hline\n"
|
||||||
for kk in sorted(ALLCLAIMS):
|
for kk in sorted(ALLCLAIMS):
|
||||||
if kk not in attackmap.keys():
|
if kk not in list(attackmap.keys()):
|
||||||
continue
|
continue
|
||||||
(prot,role,claim) = kk
|
(prot,role,claim) = kk
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ def mpaTable2(attackmap,tabtype="tabular",options=""):
|
|||||||
|
|
||||||
# To find the number of columns, we first need to find all protocols involved in two-protocol attacks
|
# To find the number of columns, we first need to find all protocols involved in two-protocol attacks
|
||||||
involved = set()
|
involved = set()
|
||||||
for kk in attackmap.keys():
|
for kk in list(attackmap.keys()):
|
||||||
for atl in attackmap[kk]:
|
for atl in attackmap[kk]:
|
||||||
# convert tuple back to list
|
# convert tuple back to list
|
||||||
att = list(atl)
|
att = list(atl)
|
||||||
@ -210,7 +210,7 @@ def mpaTable2(attackmap,tabtype="tabular",options=""):
|
|||||||
s += "\\hline\n"
|
s += "\\hline\n"
|
||||||
last = None
|
last = None
|
||||||
for kk in sorted(ALLCLAIMS):
|
for kk in sorted(ALLCLAIMS):
|
||||||
if kk not in attackmap.keys():
|
if kk not in list(attackmap.keys()):
|
||||||
continue
|
continue
|
||||||
(prot,role,claim) = kk
|
(prot,role,claim) = kk
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ def mpaTable3(attackmaps,tabtype="tabular",options=""):
|
|||||||
involved = set()
|
involved = set()
|
||||||
allkeys = set()
|
allkeys = set()
|
||||||
for (attackmap,symbs) in attackmaps:
|
for (attackmap,symbs) in attackmaps:
|
||||||
for kk in attackmap.keys():
|
for kk in list(attackmap.keys()):
|
||||||
allkeys.add(kk)
|
allkeys.add(kk)
|
||||||
for atl in attackmap[kk]:
|
for atl in attackmap[kk]:
|
||||||
# convert tuple back to list
|
# convert tuple back to list
|
||||||
@ -298,7 +298,7 @@ def mpaTable3(attackmaps,tabtype="tabular",options=""):
|
|||||||
s += "\\hline\n"
|
s += "\\hline\n"
|
||||||
last = None
|
last = None
|
||||||
for kk in sorted(ALLCLAIMS):
|
for kk in sorted(ALLCLAIMS):
|
||||||
if kk not in attackmap.keys():
|
if kk not in list(attackmap.keys()):
|
||||||
continue
|
continue
|
||||||
(prot,role,claim) = kk
|
(prot,role,claim) = kk
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ def mpaTable3(attackmaps,tabtype="tabular",options=""):
|
|||||||
se = tuple([ch])
|
se = tuple([ch])
|
||||||
sl += "& "
|
sl += "& "
|
||||||
for (attackmap,symb) in attackmaps:
|
for (attackmap,symb) in attackmaps:
|
||||||
if kk in attackmap.keys():
|
if kk in list(attackmap.keys()):
|
||||||
if se in attackmap[kk]:
|
if se in attackmap[kk]:
|
||||||
sl += symb
|
sl += symb
|
||||||
break
|
break
|
||||||
@ -341,7 +341,7 @@ def scanClaimList(fn):
|
|||||||
fp = open("gen-%s-claims.txt" % (fn),"r")
|
fp = open("gen-%s-claims.txt" % (fn),"r")
|
||||||
|
|
||||||
claimmap = {}
|
claimmap = {}
|
||||||
for rawline in fp.xreadlines():
|
for rawline in fp:
|
||||||
|
|
||||||
l = rawline.strip()
|
l = rawline.strip()
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ def scanClaimFile(fn):
|
|||||||
fp = open("gen-%s-correctclaims.tex" % (fn),"r")
|
fp = open("gen-%s-correctclaims.tex" % (fn),"r")
|
||||||
|
|
||||||
claimmap = {}
|
claimmap = {}
|
||||||
for rawline in fp.xreadlines():
|
for rawline in fp:
|
||||||
|
|
||||||
l = rawline.strip()
|
l = rawline.strip()
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ def scanClaimFile(fn):
|
|||||||
if not FFUNC(prot):
|
if not FFUNC(prot):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if prot not in claimmap.keys():
|
if prot not in list(claimmap.keys()):
|
||||||
claimmap[prot] = {}
|
claimmap[prot] = {}
|
||||||
|
|
||||||
cll = splitStrip(dtl[1],";")
|
cll = splitStrip(dtl[1],";")
|
||||||
@ -404,7 +404,7 @@ def scanClaimFile(fn):
|
|||||||
for dt in cll:
|
for dt in cll:
|
||||||
(role,claim) = roleClaim(dt)
|
(role,claim) = roleClaim(dt)
|
||||||
|
|
||||||
if role not in claimmap[prot].keys():
|
if role not in list(claimmap[prot].keys()):
|
||||||
claimmap[prot][role] = set()
|
claimmap[prot][role] = set()
|
||||||
|
|
||||||
claimmap[prot][role].add(claim)
|
claimmap[prot][role].add(claim)
|
||||||
@ -420,7 +420,7 @@ def scanClaimFile(fn):
|
|||||||
def getRoleClaims(rcmap):
|
def getRoleClaims(rcmap):
|
||||||
|
|
||||||
rc = set()
|
rc = set()
|
||||||
for role in rcmap.keys():
|
for role in list(rcmap.keys()):
|
||||||
for claim in rcmap[role]:
|
for claim in rcmap[role]:
|
||||||
rc.add((role,claim))
|
rc.add((role,claim))
|
||||||
|
|
||||||
@ -459,8 +459,8 @@ def typeScanMatrix(cml,onlyChanged = False):
|
|||||||
alltrue = True
|
alltrue = True
|
||||||
for (txt,cm) in cml:
|
for (txt,cm) in cml:
|
||||||
verdict = badverdict
|
verdict = badverdict
|
||||||
if prot in cm.keys():
|
if prot in list(cm.keys()):
|
||||||
if role in cm[prot].keys():
|
if role in list(cm[prot].keys()):
|
||||||
if claim in cm[prot][role]:
|
if claim in cm[prot][role]:
|
||||||
verdict = goodverdict
|
verdict = goodverdict
|
||||||
if verdict == badverdict:
|
if verdict == badverdict:
|
||||||
@ -518,8 +518,8 @@ def typeScanMatrix2(cml,onlyChanged = False,additive = False):
|
|||||||
res = ""
|
res = ""
|
||||||
for (txt,cm) in cml:
|
for (txt,cm) in cml:
|
||||||
verdict = badverdict
|
verdict = badverdict
|
||||||
if prot in cm.keys():
|
if prot in list(cm.keys()):
|
||||||
if role in cm[prot].keys():
|
if role in list(cm[prot].keys()):
|
||||||
if claim in cm[prot][role]:
|
if claim in cm[prot][role]:
|
||||||
verdict = goodverdict
|
verdict = goodverdict
|
||||||
if verdict == badverdict:
|
if verdict == badverdict:
|
||||||
@ -582,8 +582,8 @@ def typeScanMatrix3(hd1,hd2,cml,f,onlyChanged = False,tabletype="longtable"):
|
|||||||
resl = []
|
resl = []
|
||||||
for cm in cml:
|
for cm in cml:
|
||||||
verdict = badverdict
|
verdict = badverdict
|
||||||
if prot in cm.keys():
|
if prot in list(cm.keys()):
|
||||||
if role in cm[prot].keys():
|
if role in list(cm[prot].keys()):
|
||||||
if claim in cm[prot][role]:
|
if claim in cm[prot][role]:
|
||||||
verdict = goodverdict
|
verdict = goodverdict
|
||||||
if verdict == badverdict:
|
if verdict == badverdict:
|
||||||
@ -660,11 +660,11 @@ def docWrite(fn,tex,author=None,title=None):
|
|||||||
|
|
||||||
def docMake(fn,tex,author=None,title=None):
|
def docMake(fn,tex,author=None,title=None):
|
||||||
|
|
||||||
import commands
|
import subprocess
|
||||||
|
|
||||||
docWrite(fn,tex,author,title)
|
docWrite(fn,tex,author,title)
|
||||||
cmd = "pdflatex %s" % (fn)
|
cmd = "pdflatex %s" % (fn)
|
||||||
commands.getoutput(cmd)
|
subprocess.getoutput(cmd)
|
||||||
|
|
||||||
def f1(resl):
|
def f1(resl):
|
||||||
txtl = []
|
txtl = []
|
||||||
|
@ -32,7 +32,7 @@ def parseArgs():
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if opts.protocol not in ["nsl","bke","nsl-priv-noprop","nsl-pub-nap","bke-nap"]:
|
if opts.protocol not in ["nsl","bke","nsl-priv-noprop","nsl-pub-nap","bke-nap"]:
|
||||||
print "I don't know the %s protocol." % (opts.protocol)
|
print("I don't know the %s protocol." % (opts.protocol))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
return (opts,args)
|
return (opts,args)
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ def message1 (label,inrole):
|
|||||||
|
|
||||||
return msg
|
return msg
|
||||||
else:
|
else:
|
||||||
print "Hmm, I don't know how to create the first message for protocol %s" % (opts.protocol)
|
print("Hmm, I don't know how to create the first message for protocol %s" % (opts.protocol))
|
||||||
|
|
||||||
def message2 (label,inrole):
|
def message2 (label,inrole):
|
||||||
global P,variant,opts
|
global P,variant,opts
|
||||||
@ -205,7 +205,7 @@ def message2 (label,inrole):
|
|||||||
|
|
||||||
return msg
|
return msg
|
||||||
else:
|
else:
|
||||||
print "Hmm, I don't know how to create the final message for protocol %s" % (opts.protocol)
|
print("Hmm, I don't know how to create the final message for protocol %s" % (opts.protocol))
|
||||||
|
|
||||||
def message (label,inrole):
|
def message (label,inrole):
|
||||||
global P,opts
|
global P,opts
|
||||||
@ -338,7 +338,7 @@ def main():
|
|||||||
global opts
|
global opts
|
||||||
|
|
||||||
(opts,args) = parseArgs()
|
(opts,args) = parseArgs()
|
||||||
print protocol(args)
|
print(protocol(args))
|
||||||
|
|
||||||
# Only if main stuff
|
# Only if main stuff
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
# and sincerely hope on gives a complete proof.
|
# and sincerely hope on gives a complete proof.
|
||||||
# we slowly refine the tests.
|
# we slowly refine the tests.
|
||||||
#
|
#
|
||||||
import commands
|
import subprocess
|
||||||
|
|
||||||
def startset():
|
def startset():
|
||||||
mainlist = [11, 15]
|
mainlist = [11, 15]
|
||||||
print "Starting with", mainlist
|
print("Starting with", mainlist)
|
||||||
return mainlist
|
return mainlist
|
||||||
|
|
||||||
def tuplingchoice(heur,variant,P,runs,latupling):
|
def tuplingchoice(heur,variant,P,runs,latupling):
|
||||||
@ -37,15 +37,15 @@ def tuplingchoice(heur,variant,P,runs,latupling):
|
|||||||
#s += " | scyther -a -r%i --summary" % runs
|
#s += " | scyther -a -r%i --summary" % runs
|
||||||
|
|
||||||
# Show what we're doing
|
# Show what we're doing
|
||||||
print s
|
print(s)
|
||||||
|
|
||||||
#s += " | grep \"complete\""
|
#s += " | grep \"complete\""
|
||||||
out = commands.getoutput(s)
|
out = subprocess.getoutput(s)
|
||||||
if out == "":
|
if out == "":
|
||||||
#print "Okay"
|
#print "Okay"
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print out
|
print(out)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def testvariant(h,v,p,r):
|
def testvariant(h,v,p,r):
|
||||||
@ -55,11 +55,11 @@ def testvariant(h,v,p,r):
|
|||||||
return tuplingchoice (h,v,p,r, True)
|
return tuplingchoice (h,v,p,r, True)
|
||||||
|
|
||||||
def scan(testlist, P, runs):
|
def scan(testlist, P, runs):
|
||||||
print "Testing using P %i and %i runs." % (P,runs)
|
print("Testing using P %i and %i runs." % (P,runs))
|
||||||
for i in testlist:
|
for i in testlist:
|
||||||
print "Testing protocol %i." % (i)
|
print("Testing protocol %i." % (i))
|
||||||
for h in range (0,32):
|
for h in range (0,32):
|
||||||
print "Heuristic %i:" % (h)
|
print("Heuristic %i:" % (h))
|
||||||
testvariant (h,i,P,runs)
|
testvariant (h,i,P,runs)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
# We test all variants [0..31] until we are sure they work. Thus,
|
# We test all variants [0..31] until we are sure they work. Thus,
|
||||||
# we slowly refine the tests.
|
# we slowly refine the tests.
|
||||||
#
|
#
|
||||||
import commands
|
import subprocess
|
||||||
|
|
||||||
def startset():
|
def startset():
|
||||||
return range(0,32)
|
return list(range(0,32))
|
||||||
|
|
||||||
mainlist = [11, 15]
|
mainlist = [11, 15]
|
||||||
print "Starting with", mainlist
|
print("Starting with", mainlist)
|
||||||
return mainlist
|
return mainlist
|
||||||
|
|
||||||
def tuplingchoice(variant,P,runs,latupling):
|
def tuplingchoice(variant,P,runs,latupling):
|
||||||
@ -30,7 +30,7 @@ def tuplingchoice(variant,P,runs,latupling):
|
|||||||
#s += " | scyther -a -r%i --summary" % runs
|
#s += " | scyther -a -r%i --summary" % runs
|
||||||
#print s
|
#print s
|
||||||
s += " | grep \"Fail\""
|
s += " | grep \"Fail\""
|
||||||
out = commands.getoutput(s)
|
out = subprocess.getoutput(s)
|
||||||
if out == "":
|
if out == "":
|
||||||
#print "Okay"
|
#print "Okay"
|
||||||
return True
|
return True
|
||||||
@ -53,15 +53,15 @@ def removeattacks (testlist, P, runs):
|
|||||||
return okaylist
|
return okaylist
|
||||||
|
|
||||||
def scan(testlist, P, runs):
|
def scan(testlist, P, runs):
|
||||||
print "Testing using P %i and %i runs." % (P,runs)
|
print("Testing using P %i and %i runs." % (P,runs))
|
||||||
results = removeattacks (testlist, P, runs)
|
results = removeattacks (testlist, P, runs)
|
||||||
if len(results) < len(testlist):
|
if len(results) < len(testlist):
|
||||||
attacked = []
|
attacked = []
|
||||||
for i in range(0,len(testlist)):
|
for i in range(0,len(testlist)):
|
||||||
if testlist[i] not in results:
|
if testlist[i] not in results:
|
||||||
attacked.append(testlist[i])
|
attacked.append(testlist[i])
|
||||||
print "Using P %i and %i runs, we find attacks on %s" % (P,runs, str(attacked))
|
print("Using P %i and %i runs, we find attacks on %s" % (P,runs, str(attacked)))
|
||||||
print "Therefore, we are left with %i candidates: " % (len(results)), results
|
print("Therefore, we are left with %i candidates: " % (len(results)), results)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@ -71,9 +71,9 @@ def main():
|
|||||||
for rundiff in range(0,5):
|
for rundiff in range(0,5):
|
||||||
candidates = scan(candidates,P,P+rundiff)
|
candidates = scan(candidates,P,P+rundiff)
|
||||||
|
|
||||||
print
|
print()
|
||||||
print "Good variants:"
|
print("Good variants:")
|
||||||
print candidates
|
print(candidates)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -52,7 +52,7 @@ def evaluate(fn,prefix=""):
|
|||||||
fstderr.seek(0)
|
fstderr.seek(0)
|
||||||
|
|
||||||
res = ""
|
res = ""
|
||||||
for l in fstdout.xreadlines():
|
for l in fstdout:
|
||||||
res += prefix + l.strip() + "\n"
|
res += prefix + l.strip() + "\n"
|
||||||
#for l in fstderr.xreadlines():
|
#for l in fstderr.xreadlines():
|
||||||
# print l
|
# print l
|
||||||
@ -72,7 +72,7 @@ def main():
|
|||||||
cnt = 1
|
cnt = 1
|
||||||
tres = ""
|
tres = ""
|
||||||
for (prefix,fn) in sorted(fl):
|
for (prefix,fn) in sorted(fl):
|
||||||
print "Evaluating %s (%i/%i)" % (fn,cnt,len(fl))
|
print("Evaluating %s (%i/%i)" % (fn,cnt,len(fl)))
|
||||||
res = evaluate(prefix+fn, "%s\t" % (fn))
|
res = evaluate(prefix+fn, "%s\t" % (fn))
|
||||||
fp.write(res)
|
fp.write(res)
|
||||||
tres += res
|
tres += res
|
||||||
@ -83,7 +83,7 @@ def main():
|
|||||||
fp.write(tres)
|
fp.write(tres)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
print res
|
print(res)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
# Note 2: this code assumes that both scyther-linux and dot can be found in the
|
# Note 2: this code assumes that both scyther-linux and dot can be found in the
|
||||||
# environment (i.e. PATH variable)
|
# environment (i.e. PATH variable)
|
||||||
#
|
#
|
||||||
import os,sys,commands
|
import os,sys,subprocess
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
tempcount = 0
|
tempcount = 0
|
||||||
@ -59,7 +59,7 @@ def scyther_to_dotfile():
|
|||||||
tmpdotfile = generateTemp('dot')
|
tmpdotfile = generateTemp('dot')
|
||||||
|
|
||||||
command = "%s --plain --dot-output %s > %s" % (scythername, args, tmpdotfile)
|
command = "%s --plain --dot-output %s > %s" % (scythername, args, tmpdotfile)
|
||||||
output = commands.getoutput(command)
|
output = subprocess.getoutput(command)
|
||||||
return (output,tmpdotfile)
|
return (output,tmpdotfile)
|
||||||
|
|
||||||
def dotfile_to_pdffile(dotfile,outfile=None):
|
def dotfile_to_pdffile(dotfile,outfile=None):
|
||||||
@ -72,10 +72,10 @@ def dotfile_to_pdffile(dotfile,outfile=None):
|
|||||||
# it fit to a landscape page
|
# it fit to a landscape page
|
||||||
dotdata = open(dotfile, "r")
|
dotdata = open(dotfile, "r")
|
||||||
f = None
|
f = None
|
||||||
for line in dotdata.xreadlines():
|
for line in dotdata:
|
||||||
if (line.find('digraph') == 0):
|
if (line.find('digraph') == 0):
|
||||||
f = os.popen("dot -Gsize='11.0,8.0' -Gratio=fill -Tps >>%s" % (tmp),'w')
|
f = os.popen("dot -Gsize='11.0,8.0' -Gratio=fill -Tps >>%s" % (tmp),'w')
|
||||||
print >>f, line
|
print(line, file=f)
|
||||||
dotdata.close()
|
dotdata.close()
|
||||||
|
|
||||||
if not f:
|
if not f:
|
||||||
@ -96,18 +96,18 @@ def dotfile_to_pdffile(dotfile,outfile=None):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
(output,dotfile) = scyther_to_dotfile()
|
(output,dotfile) = scyther_to_dotfile()
|
||||||
print output
|
print(output)
|
||||||
pdffile = dotfile_to_pdffile(dotfile)
|
pdffile = dotfile_to_pdffile(dotfile)
|
||||||
os.unlink(dotfile)
|
os.unlink(dotfile)
|
||||||
if pdffile:
|
if pdffile:
|
||||||
commands.getoutput("kpdf %s" % pdffile)
|
subprocess.getoutput("kpdf %s" % pdffile)
|
||||||
os.unlink(pdffile)
|
os.unlink(pdffile)
|
||||||
else:
|
else:
|
||||||
print "No graphs generated."
|
print("No graphs generated.")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
main()
|
main()
|
||||||
else:
|
else:
|
||||||
print "Please provide the name of an input file."
|
print("Please provide the name of an input file.")
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
# Attack
|
# Attack
|
||||||
#
|
#
|
||||||
|
|
||||||
import Trace
|
from . import Trace
|
||||||
import Term
|
from . import Term
|
||||||
#import Classification
|
#import Classification
|
||||||
from Misc import *
|
from .Misc import *
|
||||||
|
|
||||||
class Attack(object):
|
class Attack(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -47,7 +47,7 @@ class Attack(object):
|
|||||||
def getInvolvedAgents(self):
|
def getInvolvedAgents(self):
|
||||||
result = []
|
result = []
|
||||||
for run in self.semiTrace.runs:
|
for run in self.semiTrace.runs:
|
||||||
for agent in run.roleAgents.values():
|
for agent in list(run.roleAgents.values()):
|
||||||
result.append(agent)
|
result.append(agent)
|
||||||
return uniq(result)
|
return uniq(result)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
# Claim
|
# Claim
|
||||||
#
|
#
|
||||||
|
|
||||||
import Term
|
from . import Term
|
||||||
|
|
||||||
def stateDescription(okay,n=1,caps=False):
|
def stateDescription(okay,n=1,caps=False):
|
||||||
if okay:
|
if okay:
|
||||||
|
@ -29,7 +29,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
""" Import internals """
|
""" Import internals """
|
||||||
import Misc
|
from . import Misc
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
DOTLOCATION = None
|
DOTLOCATION = None
|
||||||
|
@ -40,15 +40,15 @@ You need at least Python 2.4 to use this program.
|
|||||||
def confirm(question):
|
def confirm(question):
|
||||||
answer = ''
|
answer = ''
|
||||||
while answer not in ('y','n'):
|
while answer not in ('y','n'):
|
||||||
print question,
|
print(question, end=' ')
|
||||||
answer = raw_input().lower()
|
answer = input().lower()
|
||||||
return answer == 'y'
|
return answer == 'y'
|
||||||
|
|
||||||
def exists(func,list):
|
def exists(func,list):
|
||||||
return len(filter(func,list)) > 0
|
return len(list(filter(func,list))) > 0
|
||||||
|
|
||||||
def forall(func,list):
|
def forall(func,list):
|
||||||
return len(filter(func,list)) == len(list)
|
return len(list(filter(func,list))) == len(list)
|
||||||
|
|
||||||
def uniq(li):
|
def uniq(li):
|
||||||
result = []
|
result = []
|
||||||
@ -123,12 +123,12 @@ def safeCommand(cmd, storePopen=None):
|
|||||||
if storePopen != None:
|
if storePopen != None:
|
||||||
storePopen(p)
|
storePopen(p)
|
||||||
sts = p.wait()
|
sts = p.wait()
|
||||||
except KeyboardInterrupt, EnvironmentError:
|
except KeyboardInterrupt as EnvironmentError:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
print "Wile processing [%s] we had an" % (cmd)
|
print("Wile processing [%s] we had an" % (cmd))
|
||||||
print "unexpected error:", sys.exc_info()[0]
|
print("unexpected error:", sys.exc_info()[0])
|
||||||
print
|
print()
|
||||||
sts = -1
|
sts = -1
|
||||||
raise # For now still raise
|
raise # For now still raise
|
||||||
|
|
||||||
@ -142,15 +142,15 @@ def panic(text):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import Tkinter
|
import tkinter
|
||||||
except:
|
except:
|
||||||
print text
|
print(text)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
print text
|
print(text)
|
||||||
|
|
||||||
root = Tkinter.Tk()
|
root = tkinter.Tk()
|
||||||
w = Tkinter.Label(root, justify=Tkinter.LEFT, padx = 10, text=text)
|
w = tkinter.Label(root, justify=tkinter.LEFT, padx = 10, text=text)
|
||||||
w.pack()
|
w.pack()
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import StringIO
|
import io
|
||||||
import tempfile
|
import tempfile
|
||||||
try:
|
try:
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -40,10 +40,10 @@ except ImportError:
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther components """
|
""" Import scyther components """
|
||||||
import XMLReader
|
from . import XMLReader
|
||||||
import Error
|
from . import Error
|
||||||
import Claim
|
from . import Claim
|
||||||
from Misc import *
|
from .Misc import *
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ def getCacheDir():
|
|||||||
|
|
||||||
# Check if user chose the path
|
# Check if user chose the path
|
||||||
cachedirkey = "SCYTHERCACHEDIR"
|
cachedirkey = "SCYTHERCACHEDIR"
|
||||||
if cachedirkey in os.environ.keys():
|
if cachedirkey in list(os.environ.keys()):
|
||||||
tmpdir = os.environ[cachedirkey]
|
tmpdir = os.environ[cachedirkey]
|
||||||
if tmpdir == "":
|
if tmpdir == "":
|
||||||
# Special value: if the variable is present, but equals the empty string, we disable caching.
|
# Special value: if the variable is present, but equals the empty string, we disable caching.
|
||||||
@ -126,7 +126,7 @@ def CheckSanity(program):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.isfile(program):
|
if not os.path.isfile(program):
|
||||||
raise Error.BinaryError, program
|
raise Error.BinaryError(program)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ def EnsureString(x,sep=" "):
|
|||||||
return sep.join(newlist)
|
return sep.join(newlist)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Error.StringListError, x
|
raise Error.StringListError(x)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
@ -177,7 +177,7 @@ def getScytherBackend():
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
""" Unsupported"""
|
""" Unsupported"""
|
||||||
raise Error.UnknownPlatformError, sys.platform
|
raise Error.UnknownPlatformError(sys.platform)
|
||||||
|
|
||||||
program = os.path.join(getBinDir(),scythername)
|
program = os.path.join(getBinDir(),scythername)
|
||||||
return program
|
return program
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#
|
#
|
||||||
# Term
|
# Term
|
||||||
#
|
#
|
||||||
import Trace
|
from . import Trace
|
||||||
from Misc import *
|
from .Misc import *
|
||||||
|
|
||||||
class InvalidTerm(TypeError):
|
class InvalidTerm(TypeError):
|
||||||
"Exception used to indicate that a given term is invalid"
|
"Exception used to indicate that a given term is invalid"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#
|
#
|
||||||
# Trace
|
# Trace
|
||||||
#
|
#
|
||||||
from Misc import *
|
from .Misc import *
|
||||||
|
|
||||||
class InvalidAction(TypeError):
|
class InvalidAction(TypeError):
|
||||||
"Exception used to indicate that a given action is invalid"
|
"Exception used to indicate that a given action is invalid"
|
||||||
@ -79,7 +79,7 @@ class SemiTrace(object):
|
|||||||
def getPrecedingEvents(self,event,previous=[]):
|
def getPrecedingEvents(self,event,previous=[]):
|
||||||
# If it is cached return cached version
|
# If it is cached return cached version
|
||||||
if event.preceding != None:
|
if event.preceding != None:
|
||||||
return filter(lambda x: x not in previous,event.preceding)
|
return [x for x in event.preceding if x not in previous]
|
||||||
preceding = []
|
preceding = []
|
||||||
for prec in event.getBefore():
|
for prec in event.getBefore():
|
||||||
preceding.append(prec)
|
preceding.append(prec)
|
||||||
@ -90,7 +90,7 @@ class SemiTrace(object):
|
|||||||
preceding.extend(self.getPrecedingEvents(fol))
|
preceding.extend(self.getPrecedingEvents(fol))
|
||||||
preceding = uniq(preceding)
|
preceding = uniq(preceding)
|
||||||
event.preceding = preceding
|
event.preceding = preceding
|
||||||
preceding = filter(lambda x: x not in previous,preceding)
|
preceding = [x for x in preceding if x not in previous]
|
||||||
return preceding
|
return preceding
|
||||||
|
|
||||||
# Returns -1 if the first event has to be before the second one
|
# Returns -1 if the first event has to be before the second one
|
||||||
@ -175,7 +175,7 @@ class ProtocolDescription(object):
|
|||||||
|
|
||||||
# Find event by label
|
# Find event by label
|
||||||
def findEvent(self,eventlabel,eventType=None):
|
def findEvent(self,eventlabel,eventType=None):
|
||||||
for (role,descr) in self.roledescr.items():
|
for (role,descr) in list(self.roledescr.items()):
|
||||||
for event in descr:
|
for event in descr:
|
||||||
if event.label == eventlabel:
|
if event.label == eventlabel:
|
||||||
if eventType == None or isinstance(event,eventType):
|
if eventType == None or isinstance(event,eventType):
|
||||||
@ -206,7 +206,7 @@ class ProtocolDescription(object):
|
|||||||
# that are in the precedingEvents of a certain event
|
# that are in the precedingEvents of a certain event
|
||||||
def getPrecedingLabelSet(self,eventlabel):
|
def getPrecedingLabelSet(self,eventlabel):
|
||||||
events = self.getPrecedingEvents(eventlabel)
|
events = self.getPrecedingEvents(eventlabel)
|
||||||
events = filter(lambda x: isinstance(x,EventRead),events)
|
events = [x for x in events if isinstance(x,EventRead)]
|
||||||
return [x.label for x in events]
|
return [x.label for x in events]
|
||||||
|
|
||||||
# Calculate the roles in preceding labelset that is all roles that
|
# Calculate the roles in preceding labelset that is all roles that
|
||||||
@ -219,7 +219,7 @@ class ProtocolDescription(object):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = ''
|
s = ''
|
||||||
for x in self.roledescr.values():
|
for x in list(self.roledescr.values()):
|
||||||
for e in x:
|
for e in x:
|
||||||
s += str(e) + "\n"
|
s += str(e) + "\n"
|
||||||
return s
|
return s
|
||||||
@ -318,7 +318,7 @@ class EventClaim(Event):
|
|||||||
# agents
|
# agents
|
||||||
def ignore(self):
|
def ignore(self):
|
||||||
for untrusted in self.run.attack.untrusted:
|
for untrusted in self.run.attack.untrusted:
|
||||||
if untrusted in self.run.roleAgents.values():
|
if untrusted in list(self.run.roleAgents.values()):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ except:
|
|||||||
try:
|
try:
|
||||||
from elementtree import ElementTree
|
from elementtree import ElementTree
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print """
|
print("""
|
||||||
ERROR:
|
ERROR:
|
||||||
|
|
||||||
Could not locate either the [elementtree] or the [cElementTree] package.
|
Could not locate either the [elementtree] or the [cElementTree] package.
|
||||||
@ -56,7 +56,7 @@ Please install one of them in order to work with the Scyther python interface.
|
|||||||
The [cElementTree] packages can be found at http://effbot.org/zone/celementtree.htm
|
The [cElementTree] packages can be found at http://effbot.org/zone/celementtree.htm
|
||||||
|
|
||||||
Note that you can still use the Scyther binaries in the 'Bin' directory.
|
Note that you can still use the Scyther binaries in the 'Bin' directory.
|
||||||
"""
|
""")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
## Simply pick cElementTree
|
## Simply pick cElementTree
|
||||||
@ -65,10 +65,10 @@ Note that you can still use the Scyther binaries in the 'Bin' directory.
|
|||||||
#useiter = False
|
#useiter = False
|
||||||
#from elementtree import ElementTree
|
#from elementtree import ElementTree
|
||||||
|
|
||||||
import Term
|
from . import Term
|
||||||
import Attack
|
from . import Attack
|
||||||
import Trace
|
from . import Trace
|
||||||
import Claim
|
from . import Claim
|
||||||
|
|
||||||
class XMLReader(object):
|
class XMLReader(object):
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class XMLReader(object):
|
|||||||
# value
|
# value
|
||||||
return Term.TermVariable(name,None)
|
return Term.TermVariable(name,None)
|
||||||
else:
|
else:
|
||||||
raise Term.InvalidTerm, "Invalid term type in XML: %s" % tag.tag
|
raise Term.InvalidTerm("Invalid term type in XML: %s" % tag.tag)
|
||||||
|
|
||||||
def readEvent(self,xml):
|
def readEvent(self,xml):
|
||||||
label = self.readTerm(xml.find('label'))
|
label = self.readTerm(xml.find('label'))
|
||||||
@ -188,7 +188,7 @@ class XMLReader(object):
|
|||||||
pass
|
pass
|
||||||
return Trace.EventClaim(index,label,followlist,role,etype,argument)
|
return Trace.EventClaim(index,label,followlist,role,etype,argument)
|
||||||
else:
|
else:
|
||||||
raise Trace.InvalidAction, "Invalid action in XML: %s" % (xml.get('type'))
|
raise Trace.InvalidAction("Invalid action in XML: %s" % (xml.get('type')))
|
||||||
|
|
||||||
def readRun(self,xml):
|
def readRun(self,xml):
|
||||||
assert(xml.tag == 'run')
|
assert(xml.tag == 'run')
|
||||||
@ -276,7 +276,7 @@ class XMLReader(object):
|
|||||||
elif event.tag == 'timebound':
|
elif event.tag == 'timebound':
|
||||||
claim.timebound = True
|
claim.timebound = True
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr,"Warning unknown tag in claim: %s" % claim.tag
|
print("Warning unknown tag in claim: %s" % claim.tag, file=sys.stderr)
|
||||||
|
|
||||||
claim.analyze()
|
claim.analyze()
|
||||||
return claim
|
return claim
|
||||||
@ -353,6 +353,6 @@ class XMLReader(object):
|
|||||||
# this list
|
# this list
|
||||||
self.varlist = attack.variables
|
self.varlist = attack.variables
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr,"Warning unknown tag in attack: %s" % event.tag
|
print("Warning unknown tag in attack: %s" % event.tag, file=sys.stderr)
|
||||||
return attack
|
return attack
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#
|
#
|
||||||
# Set prefix for __all__
|
# Set prefix for __all__
|
||||||
#
|
#
|
||||||
import Scyther
|
from . import Scyther
|
||||||
|
|
||||||
# Provide scope
|
# Provide scope
|
||||||
__all__ = ["Scyther"]
|
__all__ = ["Scyther"]
|
||||||
|
@ -34,17 +34,17 @@ import sys
|
|||||||
try:
|
try:
|
||||||
from constraint import *
|
from constraint import *
|
||||||
except:
|
except:
|
||||||
print "Could not import constraint solver module."
|
print("Could not import constraint solver module.")
|
||||||
print "For more information, visit"
|
print("For more information, visit")
|
||||||
print " http://labix.org/python-constraint"
|
print(" http://labix.org/python-constraint")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
problem = Problem()
|
problem = Problem()
|
||||||
problem.addVariables(range(0, 16), range(1, 16+1))
|
problem.addVariables(list(range(0, 16)), list(range(1, 16+1)))
|
||||||
problem.addConstraint(AllDifferentConstraint(), range(0, 16))
|
problem.addConstraint(AllDifferentConstraint(), list(range(0, 16)))
|
||||||
problem.addConstraint(ExactSumConstraint(34), [0,5,10,15])
|
problem.addConstraint(ExactSumConstraint(34), [0,5,10,15])
|
||||||
problem.addConstraint(ExactSumConstraint(34), [3,6,9,12])
|
problem.addConstraint(ExactSumConstraint(34), [3,6,9,12])
|
||||||
for row in range(4):
|
for row in range(4):
|
||||||
@ -54,7 +54,7 @@ def test():
|
|||||||
problem.addConstraint(ExactSumConstraint(34),
|
problem.addConstraint(ExactSumConstraint(34),
|
||||||
[col+4*i for i in range(4)])
|
[col+4*i for i in range(4)])
|
||||||
solutions = problem.getSolutions()
|
solutions = problem.getSolutions()
|
||||||
print solutions
|
print(solutions)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ def render_best_attack(fn,cid):
|
|||||||
render_dot(dotfile,"png")
|
render_dot(dotfile,"png")
|
||||||
render_dot(dotfile,"pdf")
|
render_dot(dotfile,"pdf")
|
||||||
|
|
||||||
print "%s; %s" % (fn,cl)
|
print("%s; %s" % (fn,cl))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ def fileandline(fn,linenos):
|
|||||||
ln = 1
|
ln = 1
|
||||||
done = 0
|
done = 0
|
||||||
sz = len(linenos)
|
sz = len(linenos)
|
||||||
for l in fp.xreadlines():
|
for l in fp:
|
||||||
if str(ln) in linenos:
|
if str(ln) in linenos:
|
||||||
print l
|
print(l)
|
||||||
scyther_json(l)
|
scyther_json(l)
|
||||||
done = done + 1
|
done = done + 1
|
||||||
if done >= sz:
|
if done >= sz:
|
||||||
|
@ -18,7 +18,7 @@ Arguments:
|
|||||||
def countlines(fn):
|
def countlines(fn):
|
||||||
count = 0
|
count = 0
|
||||||
fh = open(fn,'r')
|
fh = open(fn,'r')
|
||||||
for l in fh.xreadlines():
|
for l in fh:
|
||||||
count = count + 1
|
count = count + 1
|
||||||
fh.close()
|
fh.close()
|
||||||
return count
|
return count
|
||||||
@ -26,7 +26,7 @@ def countlines(fn):
|
|||||||
def marker(jobcount,todo):
|
def marker(jobcount,todo):
|
||||||
left = todo - jobcount
|
left = todo - jobcount
|
||||||
dperc = int((100 * jobcount) / todo)
|
dperc = int((100 * jobcount) / todo)
|
||||||
print "echo \"Sent %i out of %i jobs, hence %i left. %i%% done.\"" % (jobcount,todo,left,dperc)
|
print("echo \"Sent %i out of %i jobs, hence %i left. %i%% done.\"" % (jobcount,todo,left,dperc))
|
||||||
|
|
||||||
def main(fn,step,optlist):
|
def main(fn,step,optlist):
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ def main(fn,step,optlist):
|
|||||||
jobcount = 0
|
jobcount = 0
|
||||||
done = 0
|
done = 0
|
||||||
|
|
||||||
for l in fh.xreadlines():
|
for l in fh:
|
||||||
if buf == 0:
|
if buf == 0:
|
||||||
s = "bsub %s ./json-scyther.py %s" % (" ".join(optlist),fn)
|
s = "bsub %s ./json-scyther.py %s" % (" ".join(optlist),fn)
|
||||||
s += " %i" % (ln)
|
s += " %i" % (ln)
|
||||||
|
@ -36,13 +36,13 @@ class ProgressBar(object):
|
|||||||
def start(self):
|
def start(self):
|
||||||
if self.widgets:
|
if self.widgets:
|
||||||
if len(self.widgets) > 0:
|
if len(self.widgets) > 0:
|
||||||
print self.widgets[0],
|
print(self.widgets[0], end=' ')
|
||||||
|
|
||||||
def update(self,count):
|
def update(self,count):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
print " Done."
|
print(" Done.")
|
||||||
|
|
||||||
|
|
||||||
def SimpleProgress():
|
def SimpleProgress():
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Try to get wxPython
|
# Try to get wxPython
|
||||||
try:
|
try:
|
||||||
import wx.adv
|
import wx
|
||||||
except ImportError,err:
|
except ImportError as err:
|
||||||
from Scyther import Misc
|
from Scyther import Misc
|
||||||
|
|
||||||
errmsg = "Problem with importing the required [wxPython] package."
|
errmsg = "Problem with importing the required [wxPython] package."
|
||||||
|
@ -50,8 +50,8 @@ def simpleRun(args):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pars = sys.argv[1:]
|
pars = sys.argv[1:]
|
||||||
if len(pars) == 0:
|
if len(pars) == 0:
|
||||||
print usage()
|
print(usage())
|
||||||
else:
|
else:
|
||||||
print simpleRun(" ".join(pars))
|
print(simpleRun(" ".join(pars)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ TEST2 = "--max-runs=4"
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import externals """
|
""" Import externals """
|
||||||
import commands
|
import subprocess
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ def findProtocols():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
cmd = "find -iname '*.spdl'"
|
cmd = "find -iname '*.spdl'"
|
||||||
plist = commands.getoutput(cmd).splitlines()
|
plist = subprocess.getoutput(cmd).splitlines()
|
||||||
nlist = []
|
nlist = []
|
||||||
for prot in plist:
|
for prot in plist:
|
||||||
if filterProtocol(prot):
|
if filterProtocol(prot):
|
||||||
@ -143,35 +143,35 @@ def main():
|
|||||||
global TEST0,TEST1,TEST2
|
global TEST0,TEST1,TEST2
|
||||||
|
|
||||||
list = findProtocols()
|
list = findProtocols()
|
||||||
print "Performing delta analysis"
|
print("Performing delta analysis")
|
||||||
print
|
print()
|
||||||
print "String 0 (used for both): '%s'" % TEST0
|
print("String 0 (used for both): '%s'" % TEST0)
|
||||||
print "String 1: '%s'" % TEST1
|
print("String 1: '%s'" % TEST1)
|
||||||
print "String 2: '%s'" % TEST2
|
print("String 2: '%s'" % TEST2)
|
||||||
print
|
print()
|
||||||
print "After filtering, we are left with the following protocols:", list
|
print("After filtering, we are left with the following protocols:", list)
|
||||||
print
|
print()
|
||||||
maxcount = len(list)
|
maxcount = len(list)
|
||||||
count = 1
|
count = 1
|
||||||
delta = 0
|
delta = 0
|
||||||
for prot in list:
|
for prot in list:
|
||||||
perc = (100 * count) / maxcount
|
perc = (100 * count) / maxcount
|
||||||
print "[%i%%] %s: " % (perc,prot),
|
print("[%i%%] %s: " % (perc,prot), end=' ')
|
||||||
res = ScytherDiff(prot)
|
res = ScytherDiff(prot)
|
||||||
if res != None:
|
if res != None:
|
||||||
print
|
print()
|
||||||
print "-" * 72
|
print("-" * 72)
|
||||||
print prot
|
print(prot)
|
||||||
print "-" * 72
|
print("-" * 72)
|
||||||
print res
|
print(res)
|
||||||
delta = delta + 1
|
delta = delta + 1
|
||||||
else:
|
else:
|
||||||
print "No interesting delta found."
|
print("No interesting delta found.")
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
print
|
print()
|
||||||
print "Analysis complete."
|
print("Analysis complete.")
|
||||||
print "%i out of %i protocols differed [%i%%]." % (delta,maxcount,(100 * delta)/maxcount)
|
print("%i out of %i protocols differed [%i%%]." % (delta,maxcount,(100 * delta)/maxcount))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
124
gui/test-mpa.py
124
gui/test-mpa.py
@ -44,14 +44,14 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from progressbarDummy import *
|
from progressbarDummy import *
|
||||||
PROGRESSBAR = False
|
PROGRESSBAR = False
|
||||||
print """
|
print("""
|
||||||
Missing the progressbar library.
|
Missing the progressbar library.
|
||||||
|
|
||||||
It can be downloaded from:
|
It can be downloaded from:
|
||||||
|
|
||||||
http://code.google.com/p/python-progressbar/
|
http://code.google.com/p/python-progressbar/
|
||||||
|
|
||||||
"""
|
""")
|
||||||
|
|
||||||
FOUND = []
|
FOUND = []
|
||||||
ALLMPA = []
|
ALLMPA = []
|
||||||
@ -227,7 +227,7 @@ def MyScyther(protocollist,filt=None,options=[],checkpickle=True):
|
|||||||
# arguments to call
|
# arguments to call
|
||||||
s.options = (" ".join(sorted(uniq(opts)))).strip()
|
s.options = (" ".join(sorted(uniq(opts)))).strip()
|
||||||
if OPTS.debug:
|
if OPTS.debug:
|
||||||
print s.options
|
print(s.options)
|
||||||
|
|
||||||
for protocol in sorted(protocollist):
|
for protocol in sorted(protocollist):
|
||||||
s.addFile(protocol)
|
s.addFile(protocol)
|
||||||
@ -356,7 +356,7 @@ def verifyMPAlist(mpalist,claimid,options=[]):
|
|||||||
global OPTS, ARGS
|
global OPTS, ARGS
|
||||||
|
|
||||||
if OPTS.debug:
|
if OPTS.debug:
|
||||||
print time.asctime(), mpalist, claimid, options
|
print(time.asctime(), mpalist, claimid, options)
|
||||||
|
|
||||||
if not verifyMPAattack(mpalist,claimid,options):
|
if not verifyMPAattack(mpalist,claimid,options):
|
||||||
global FOUND
|
global FOUND
|
||||||
@ -367,7 +367,7 @@ def verifyMPAlist(mpalist,claimid,options=[]):
|
|||||||
|
|
||||||
# This is an MPA attack!
|
# This is an MPA attack!
|
||||||
if OPTS.debug:
|
if OPTS.debug:
|
||||||
print "I've found a multi-protocol attack on claim %s in the context %s." % (claimid,str(mpalist))
|
print("I've found a multi-protocol attack on claim %s in the context %s." % (claimid,str(mpalist)))
|
||||||
|
|
||||||
att = Attack(claim,mpalist)
|
att = Attack(claim,mpalist)
|
||||||
FOUND.append(att)
|
FOUND.append(att)
|
||||||
@ -442,9 +442,9 @@ def foundToDicts(attacklist = []):
|
|||||||
pn = str(att.protocol())
|
pn = str(att.protocol())
|
||||||
cl = att.claimid()
|
cl = att.claimid()
|
||||||
|
|
||||||
if pn not in res.keys():
|
if pn not in list(res.keys()):
|
||||||
res[pn] = {}
|
res[pn] = {}
|
||||||
if cl not in res[pn].keys():
|
if cl not in list(res[pn].keys()):
|
||||||
res[pn][cl] = set()
|
res[pn][cl] = set()
|
||||||
res[pn][cl].add(att)
|
res[pn][cl].add(att)
|
||||||
return res
|
return res
|
||||||
@ -464,13 +464,13 @@ def findAllMPA(protocolset,options=[],mpaoptions=[]):
|
|||||||
|
|
||||||
# Find all correct claims in each protocol
|
# Find all correct claims in each protocol
|
||||||
(protocolset,correct,cpcount) = getCorrectIsolatedClaims(protocolset,options)
|
(protocolset,correct,cpcount) = getCorrectIsolatedClaims(protocolset,options)
|
||||||
print "Investigating %i correct claims in %i protocols." % (len(correct), cpcount)
|
print("Investigating %i correct claims in %i protocols." % (len(correct), cpcount))
|
||||||
|
|
||||||
mpaprots = []
|
mpaprots = []
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
if len(correct) == 0:
|
if len(correct) == 0:
|
||||||
print "Nothing to do."
|
print("Nothing to do.")
|
||||||
return res
|
return res
|
||||||
|
|
||||||
if OPTS.verbose:
|
if OPTS.verbose:
|
||||||
@ -479,27 +479,27 @@ def findAllMPA(protocolset,options=[],mpaoptions=[]):
|
|||||||
"""
|
"""
|
||||||
pmapclaims = {}
|
pmapclaims = {}
|
||||||
for (protocol,claimid) in correct:
|
for (protocol,claimid) in correct:
|
||||||
if protocol not in pmapclaims.keys():
|
if protocol not in list(pmapclaims.keys()):
|
||||||
pmapclaims[protocol] = set()
|
pmapclaims[protocol] = set()
|
||||||
pmapclaims[protocol].add(claimid)
|
pmapclaims[protocol].add(claimid)
|
||||||
print "Protocols with correct claims:"
|
print("Protocols with correct claims:")
|
||||||
if len(pmapclaims.keys()) == 0:
|
if len(list(pmapclaims.keys())) == 0:
|
||||||
print " None."
|
print(" None.")
|
||||||
else:
|
else:
|
||||||
for pk in pmapclaims.keys():
|
for pk in list(pmapclaims.keys()):
|
||||||
print " %s, %s" % (pk, pmapclaims[pk])
|
print(" %s, %s" % (pk, pmapclaims[pk]))
|
||||||
print
|
print()
|
||||||
left = set()
|
left = set()
|
||||||
for p in protocolset:
|
for p in protocolset:
|
||||||
if p not in pmapclaims.keys():
|
if p not in list(pmapclaims.keys()):
|
||||||
left.add(p)
|
left.add(p)
|
||||||
print "Protocols with no correct claims:"
|
print("Protocols with no correct claims:")
|
||||||
if len(left) == 0:
|
if len(left) == 0:
|
||||||
print " None."
|
print(" None.")
|
||||||
else:
|
else:
|
||||||
for p in left:
|
for p in left:
|
||||||
print " %s" % (p)
|
print(" %s" % (p))
|
||||||
print
|
print()
|
||||||
|
|
||||||
# output of all claims (only if latex required)
|
# output of all claims (only if latex required)
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ def findAllMPA(protocolset,options=[],mpaoptions=[]):
|
|||||||
if OPTS.latex:
|
if OPTS.latex:
|
||||||
pmapclaims = {}
|
pmapclaims = {}
|
||||||
for (protocol,claimid) in correct:
|
for (protocol,claimid) in correct:
|
||||||
if protocol not in pmapclaims.keys():
|
if protocol not in list(pmapclaims.keys()):
|
||||||
pmapclaims[protocol] = set()
|
pmapclaims[protocol] = set()
|
||||||
pmapclaims[protocol].add(claimid)
|
pmapclaims[protocol].add(claimid)
|
||||||
|
|
||||||
@ -640,19 +640,19 @@ def findAllMPA(protocolset,options=[],mpaoptions=[]):
|
|||||||
fp.write("\\end{tabular}\n")
|
fp.write("\\end{tabular}\n")
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print "Summary:"
|
print("Summary:")
|
||||||
print
|
print()
|
||||||
print "We scanned %i protocols with options [%s]." % (len(protocolset),options)
|
print("We scanned %i protocols with options [%s]." % (len(protocolset),options))
|
||||||
print "We found %i correct claims." % (len(correct))
|
print("We found %i correct claims." % (len(correct)))
|
||||||
print "We then scanned combinations of at most %i protocols with options [%s]." % (OPTS.maxprotocols,alloptions)
|
print("We then scanned combinations of at most %i protocols with options [%s]." % (OPTS.maxprotocols,alloptions))
|
||||||
if OPTS.pickle:
|
if OPTS.pickle:
|
||||||
print "However, just precomputing now, hence we are not drawing any conclusions."
|
print("However, just precomputing now, hence we are not drawing any conclusions.")
|
||||||
else:
|
else:
|
||||||
print "We found %i MPA attacks." % (len(FOUND))
|
print("We found %i MPA attacks." % (len(FOUND)))
|
||||||
print "The attacks involve the claims of %i protocols." % (len(mpaprots))
|
print("The attacks involve the claims of %i protocols." % (len(mpaprots)))
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print
|
print()
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@ -674,37 +674,37 @@ def showDiff(reslist):
|
|||||||
Show difference between (opts,mpaopts,attacklist) tuples in list
|
Show difference between (opts,mpaopts,attacklist) tuples in list
|
||||||
"""
|
"""
|
||||||
if len(reslist) == 0:
|
if len(reslist) == 0:
|
||||||
print "Comparison list is empty"
|
print("Comparison list is empty")
|
||||||
return
|
return
|
||||||
|
|
||||||
(opt1,mpaopt1,al1) = reslist[0]
|
(opt1,mpaopt1,al1) = reslist[0]
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print "Base case: attacks for \n [%s]:" % (opt1 + mpaopt1)
|
print("Base case: attacks for \n [%s]:" % (opt1 + mpaopt1))
|
||||||
print
|
print()
|
||||||
print len(al1)
|
print(len(al1))
|
||||||
for a in al1:
|
for a in al1:
|
||||||
print "Base attack: %s" % (a)
|
print("Base attack: %s" % (a))
|
||||||
|
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print
|
print()
|
||||||
|
|
||||||
for i in range(0,len(reslist)-1):
|
for i in range(0,len(reslist)-1):
|
||||||
(opt1,mpaopt1,al1) = reslist[i]
|
(opt1,mpaopt1,al1) = reslist[i]
|
||||||
(opt2,mpaopt2,al2) = reslist[i+1]
|
(opt2,mpaopt2,al2) = reslist[i+1]
|
||||||
|
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print "Comparing the attacks for \n [%s] with\n [%s]:" % (opt1 + mpaopt1, opt2 + mpaopt2)
|
print("Comparing the attacks for \n [%s] with\n [%s]:" % (opt1 + mpaopt1, opt2 + mpaopt2))
|
||||||
print
|
print()
|
||||||
print len(al1), len(al2)
|
print(len(al1), len(al2))
|
||||||
for a in al2:
|
for a in al2:
|
||||||
if a not in al1:
|
if a not in al1:
|
||||||
print "Added attack: %s" % (a)
|
print("Added attack: %s" % (a))
|
||||||
for a in al1:
|
for a in al1:
|
||||||
if a not in al2:
|
if a not in al2:
|
||||||
print "Removed attack: %s" % (a)
|
print("Removed attack: %s" % (a))
|
||||||
|
|
||||||
print "-" * 70
|
print("-" * 70)
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -758,7 +758,7 @@ def exploreTree( i, choices , l, options = [], mpaoptions = []):
|
|||||||
res = []
|
res = []
|
||||||
for (txt,arg) in cl:
|
for (txt,arg) in cl:
|
||||||
|
|
||||||
print "For choice %i, selecting options %s" % (i,txt)
|
print("For choice %i, selecting options %s" % (i,txt))
|
||||||
if mpaonly:
|
if mpaonly:
|
||||||
o1 = []
|
o1 = []
|
||||||
o2 = arg
|
o2 = arg
|
||||||
@ -811,23 +811,23 @@ def fullScan(l, options = [], mpaoptions = []):
|
|||||||
invprots.add(str(prot))
|
invprots.add(str(prot))
|
||||||
|
|
||||||
if not OPTS.pickle:
|
if not OPTS.pickle:
|
||||||
print "The bottom line: we found %i protocols with multi-protocol attacks from a set of %i protocols." % (len(attprots),len(allprots))
|
print("The bottom line: we found %i protocols with multi-protocol attacks from a set of %i protocols." % (len(attprots),len(allprots)))
|
||||||
print
|
print()
|
||||||
|
|
||||||
print "Multi-protocol attacks were found on:"
|
print("Multi-protocol attacks were found on:")
|
||||||
for prot in sorted(list(allprots & attprots)):
|
for prot in sorted(list(allprots & attprots)):
|
||||||
print " %s" % (prot)
|
print(" %s" % (prot))
|
||||||
print
|
print()
|
||||||
|
|
||||||
print "No multi-protocol attacks were found on these protocols, but they caused MPA attacks:"
|
print("No multi-protocol attacks were found on these protocols, but they caused MPA attacks:")
|
||||||
for prot in sorted(list((allprots - attprots) & invprots)):
|
for prot in sorted(list((allprots - attprots) & invprots)):
|
||||||
print " %s" % (prot)
|
print(" %s" % (prot))
|
||||||
print
|
print()
|
||||||
|
|
||||||
print "These protocols were not involved in any MPA attacks:"
|
print("These protocols were not involved in any MPA attacks:")
|
||||||
for prot in sorted(list((allprots - attprots) - invprots)):
|
for prot in sorted(list((allprots - attprots) - invprots)):
|
||||||
print " %s\t[%s]" % (prot,PROTNAMETOFILE[prot])
|
print(" %s\t[%s]" % (prot,PROTNAMETOFILE[prot]))
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ def bigTest():
|
|||||||
nl = l
|
nl = l
|
||||||
|
|
||||||
# Report list
|
# Report list
|
||||||
print "Performing multi-protocol analysis for the following protocols:", nl
|
print("Performing multi-protocol analysis for the following protocols:", nl)
|
||||||
|
|
||||||
fullScan(l)
|
fullScan(l)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user