Exemplo n.º 1
0
 def run(self, arg):
     """
     run function for XML Importer plugin.
     
     Args:
         arg: Integer, a non-zero value enables auto-run feature for
              IDA batch (no gui) processing mode. Default is 0.
     """
     st = idc.set_ida_state(idc.IDA_STATUS_WORK)
     xml = idaxml.XmlImporter(idaxml.PLUGIN, arg)
     try:
         try:
             xml.import_xml()
         except idaxml.Cancelled:
             msg = "XML Import cancelled!"
             print "\n" + msg
             idc.warning(msg)
         except idaxml.MultipleAddressSpacesNotSupported:
             msg = "XML Import cancelled!"
             msg += "\n\nXML Import does not currently support"
             msg += "\nimporting multiple address spaces."
             print "\n" + msg
             idc.warning(msg)
         except:
             msg = "***** Exception occurred: XML Importer failed! *****"
             print "\n" + msg + "\n", sys.exc_type, sys.exc_value
             idc.warning(msg)
     finally:
         xml.cleanup()
         idc.set_ida_state(st)
Exemplo n.º 2
0
def load_file(li, neflags, format):
    """
    Load the file into database

    @param li: a file-like object which can be used to access the input data
    @param neflags: options selected by the user, see loader.hpp
    @return: 0-failure, 1-ok
    """
    global event, element
    if ida_idp.get_idp_name() == None:
        ida_idp.set_processor_type("metapc", ida_idp.SETPROC_LOADER)
    status = 0
    st = idc.set_ida_state(idc.IDA_STATUS_WORK)
    xml = idaxml.XmlImporter(idaxml.LOADER, 0)
    try:
        status = xml.import_xml()
    except idaxml.Cancelled:
        msg = "XML PROGRAM import cancelled!"
        print "\n" + msg
        idc.warning(msg)
    except idaxml.MultipleAddressSpacesNotSupported:
        msg = "XML Import cancelled!"
        msg += "\n\nXML Import does not currently support"
        msg += "\nimporting multiple address spaces."
        print "\n" + msg
        idc.warning(msg)
    except:
        print "\nHouston, we have a problem!"
        msg = "***** Exception occurred: XML loader failed! *****"
        print "\n" + msg + "\n", sys.exc_type, sys.exc_value
        print event, element.tag, element.attrib
        idc.warning(msg)
    finally:
        idc.set_ida_state(st)
        xml.cleanup()
        return status