Example #1
0
def writeObjectToFile(object,filename):     
    file=makeopen(filename)
    
    xstream=XStream(DomDriver()) 
    file.write(xstream.toXML(object))
    
    file.close()
Example #2
0
    def execute(self, data):
        if not self.is_jython:
            print '[!] This module can only be used in jython!'
            return data

        # turn data into a Java object
        bis = io.ByteArrayInputStream(data)
        ois = io.ObjectInputStream(bis)
        obj = ois.readObject()

        # converting Java object to XML structure
        xs = XStream()
        xml = xs.toXML(obj)
        return xml
Example #3
0
    def execute(self, data):
        if not self.is_jython:
            print '[!] This module can only be used in jython!'
            return data

        # turn data into a Java object
        bis = io.ByteArrayInputStream(data)
        ois = io.ObjectInputStream(bis)
        obj = ois.readObject()

        # converting Java object to XML structure
        xs = XStream()
        xml = xs.toXML(obj)
        return xml
    def deserial(self, data):
        if not self.is_jython:
            print '[!] This module can only be used in jython!'
            return data

        try:
            # turn data into a Java object
            bis = io.ByteArrayInputStream(data)
            ois = io.ObjectInputStream(bis)
            obj = ois.readObject()

            # converting Java object to XML structure
            xs = XStream()
            xml = xs.toXML(obj)
            return xml
        except Exception, e:
            print '[!] Caught Exception. Could not convert.\n'
            return data
Example #5
0
    def deserial(self, data):
        if not self.is_jython:
            print '[!] This module can only be used in jython!'
            return data

        try:
        # turn data into a Java object
            bis = io.ByteArrayInputStream(data)
            ois = io.ObjectInputStream(bis)
            obj = ois.readObject()

            # converting Java object to XML structure
            xs = XStream()
            xml = xs.toXML(obj)
            return xml
        except  Exception, e:
            print '[!] Caught Exception. Could not convert.\n'
            return data
Example #6
0
    def deserializeStream(self):
        """
        Deserialize stream, put the result inside self.output
        """
        bis = io.ByteArrayInputStream(self.input)
        ois = io.ObjectInputStream(bis)
        i = 0

        while True:
            # Block raw data ?
            block_data = []
            try:
                while True:
                    byte = BinaryUtils.tohex(ois.readByte())
                    #raw_byte = chr(int(byte, 16))
                    #block_data.append(raw_byte)
                    block_data.append(byte)
            except:
                if len(block_data) > 0:
                    #print 'Block data detected - length = {0}:'.format(len(block_data))
                    self.output.append(('block', block_data))
                    i += 1
                    print

            # Object ?
            try:
                obj = ois.readObject()

                # converting Java object to XML structure
                xs = XStream()
                xml = xs.toXML(obj)
                #self.output += xml + '\n'
                self.output.append(('object', xml))
                i += 1
                continue
            except:
                pass

            # if we arrive here, it means there is nothing more
            break