示例#1
0
 def __init__(self, nofile=False, xmltype="svg11"):
     self.nofile = nofile
     if xmltype == self.SVG11:
         self.gen = XMLGen(["dtds/svg11-flat.dtd"], self.SVG11)
     elif xmltype == self.SVG10:
         self.gen = XMLGen(["dtds/svg10.dtd"], self.SVG10)
     elif xmltype == self.XHTML1:
         self.gen = XMLGen(["dtds/xhtml1-transitional.dtd", "dtds/html5.dtd"], self.XHTML1)
示例#2
0
class MangleXML(MangleAgent):
    """
    Inject errors in a valid XML file.
    """
    SVG11="svg11"
    SVG10="svg10"
    XHTML1="xhtml1"

    def __init__(self, nofile=False, xmltype="svg11"):
        self.nofile = nofile
        if xmltype == self.SVG11:
            self.gen = XMLGen(["dtds/svg11-flat.dtd"], self.SVG11)
        elif xmltype == self.SVG10:
            self.gen = XMLGen(["dtds/svg10.dtd"], self.SVG10)
        elif xmltype == self.XHTML1:
            self.gen = XMLGen(["dtds/xhtml1-transitional.dtd", "dtds/html5.dtd"], self.XHTML1)
            #self.gen = XMLGen("dtds/html5.dtd", self.XHTML1)
            #self.gen = XMLGen("dtds/loose.dtd", self.XHTML1)
            #self.gen = XMLGen("dtds/xhtml11.dtd", self.XHTML1)

    def mangleData(self, data):
        if self.nofile:
            return str(self.gen.fuzz())
        return BSFuzzer(data).fuzz()