def __init__(self):
     ida_bytes.data_format_t.__init__(
         self,
         "py_w32rsrcstring",
         1,
         "Resource string")
     self.cache_node = ida_netnode.netnode("$ py_w32rsrcstring", 0, 1)
Beispiel #2
0
 def __init__(self, title, nitems=100, dirspec_log=True, flags=0):
     flags |= ida_kernwin.CH_NOIDB
     flags |= ida_kernwin.CH_MULTI
     flags |= ida_kernwin.CH_HAS_DIRTREE
     ida_kernwin.Choose.__init__(self,
                     title,
                     [
                         ["First",
                          10
                        | ida_kernwin.Choose.CHCOL_PLAIN
                        | ida_kernwin.Choose.CHCOL_DRAGHINT
                        | ida_kernwin.Choose.CHCOL_INODENAME
                         ],
                         ["Second", 10 | ida_kernwin.Choose.CHCOL_PLAIN],
                         ["Third", 10 | ida_kernwin.Choose.CHCOL_PLAIN],
                     ],
                     flags=flags)
     self.debug_items = False
     self.dirspec_log = dirspec_log
     self.dirtree = None
     self.dirspec = None
     self.netnode = ida_netnode.netnode()
     self.netnode.create("$ idapython_tree_view %s" % title)
     for i in range(nitems):
         self._new_item()
Beispiel #3
0
    def __init__(self):
        node = ida_netnode.netnode()
        node.create("$ PE header")
        
        super().__init__(PE_Header_IDA.packinfo, node.valobj())

        self.__describe_pe_signature()
        self.__describe_pe_magic()
Beispiel #4
0
def save_ines_hdr_as_blob():
    hdr_node = ida_netnode.netnode()

    if (not hdr_node.create(INES_HDR_NODE)):
        return False
    buf = create_string_buffer(INES_HDR_SIZE)
    memmove(buf, addressof(hdr), sizeof(hdr))
    return hdr_node.setblob(buf.raw, 0, 'I')
Beispiel #5
0
    def load_netnode(self):
        """
        Load members from the custom netnode.
        """
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)
        self._repo = node.hashval('repo') or None
        self._branch = node.hashval('branch') or None
        self._tick = int(node.hashval('tick') or '0')

        logger.debug("Loaded netnode: repo=%s, branch=%s, tick=%d" %
                     (self._repo, self._branch, self._tick))
Beispiel #6
0
    def __init__(self):
        self.vu = None

        self.node = ida_netnode.netnode()
        if not self.node.create(NETNODE_NAME):
            # node exists
            self.load()
        else:
            self.stored = []

        return
Beispiel #7
0
    def load_netnode_old(self):
        self._plugin.logger.warning(
            "Old idb detected, please save your idb as a new snapshot")
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

        self._project = node.hashstr("group") or None
        self._binary = node.hashstr("project") or None
        self._snapshot = node.hashstr("database") or None
        self._tick = int(node.hashstr("tick") or "0")

        # Replacing old netnode in local idb
        node.kill()
        self.save_netnode()
Beispiel #8
0
def save_trainer_as_blob(li):
    node = ida_netnode.netnode()

    if (not INES_MASK_TRAINER(hdr.rom_control_byte_0)):
        return False

    li.seek(INES_HDR_SIZE)
    buffer = li.read(TRAINER_SIZE)
    if (not node.create("$ Trainer")):
        return False
    if (not node.setblob(buffer, TRAINER_SIZE, 0, 'I')):
        msg("Could not store trainer to netnode!\n")

    return True
Beispiel #9
0
    def save_netnode(self):
        """Save data into our custom netnode."""
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

        if self._project:
            node.hashset("project", str(self._project))
        if self._database:
            node.hashset("database", str(self._database))
        if self._tick:
            node.hashset("tick", str(self._tick))

        self._plugin.logger.debug(
            "Saved netnode: project=%s, database=%s, tick=%d" %
            (self._project, self._database, self._tick))
Beispiel #10
0
def get_pdb_name():
    """
    Return the PDB filename as stored in the PE header.
    """
    pe_nn = ida_netnode.netnode('$ PE header', 0, False)
    if pe_nn == ida_netnode.BADNODE:
        return ""

    pdb_filepath = pe_nn.supstr(0xFFFFFFFFFFFFFFF7)
    if not pdb_filepath:
        return ""

    pdb_name = os.path.basename(pdb_filepath)
    return pdb_name
Beispiel #11
0
    def save_netnode(self):
        """
        Save members to the custom netnode.
        """
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)
        if self._repo:
            node.hashset('repo', str(self._repo))
        if self._branch:
            node.hashset('branch', str(self._branch))
        if self._tick:
            node.hashset('tick', str(self._tick))

        logger.debug("Saved netnode: repo=%s, branch=%s, tick=%d" %
                     (self._repo, self._branch, self._tick))
Beispiel #12
0
    def load_netnode(self):
        """
        Load data from our custom netnode. Netnodes are the mechanism used by
        IDA to load and save information into a database. IDArling uses its own
        netnode to remember which project and database a database belongs to.
        """
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

        self._project = node.hashval("project") or None
        self._database = node.hashval("database") or None
        self._tick = int(node.hashval("tick") or "0")

        self._plugin.logger.debug(
            "Loaded netnode: project=%s, database=%s, tick=%d" %
            (self._project, self._database, self._tick))
Beispiel #13
0
def save_prg_rom_pages_as_blobs(li, count):
    node = ida_netnode.netnode()

    li.seek(TRAINER_SIZE if INES_HDR_SIZE +
            (INES_MASK_TRAINER(hdr.rom_control_byte_0)) else 0)

    for i in range(count):
        buffer = li.read(PRG_PAGE_SIZE)
        prg_node_name = "$ PRG-ROM page %d" % i
        if (not node.create(prg_node_name)):
            return False
        if (not node.setblob(buffer, 0, 'I')):
            msg("Could not store PRG-ROM pages to netnode!\n")

    return True
Beispiel #14
0
    def save_netnode(self):
        """Save data into our custom netnode."""
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

        # node.hashset does not work anymore with direct string
        # use of hashet_buf instead
        # (see https://github.com/idapython/src/blob/master/swig/netnode.i#L162)
        if self._project:
            node.hashset_buf("project", str(self._project))
        if self._database:
            node.hashset_buf("project", str(self._database))
        if self._tick:
            node.hashset_buf("project", str(self._tick))

        self._plugin.logger.debug(
            "Saved netnode: project=%s, database=%s, tick=%d" %
            (self._project, self._database, self._tick))
Beispiel #15
0
    def load_netnode(self):
        """
        Load data from our custom netnode. Netnodes are the mechanism used by
        IDA to load and save information into an idb. IDArling uses its own
        netnode to remember which project, binary and snapshot an idb belongs to.
        """
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)
        if node.hashstr("database"):
            self.load_netnode_old()
        else:
            self._project = node.hashstr("project") or None
            self._binary = node.hashstr("binary") or None
            self._snapshot = node.hashstr("snapshot") or None
            self._tick = int(node.hashstr("tick") or "0")

        self._plugin.logger.debug(
            "Loaded netnode: project=%s, binary=%s, snapshot=%s, tick=%d" %
            (self._project, self._binary, self._snapshot, self._tick))
Beispiel #16
0
    def save_netnode(self):
        """Save data into our custom netnode."""
        node = ida_netnode.netnode(Core.NETNODE_NAME, 0, True)

        # node.hashset does not work anymore with direct string
        # use of hashet_buf instead
        # (see https://github.com/idapython/src/blob/master/swig/netnode.i#L162)
        if self._project:
            node.hashset_buf("project", str(self._project))
        if self._binary:
            node.hashset_buf("binary", str(self._binary))
        if self._snapshot:
            node.hashset_buf("snapshot", str(self._snapshot))
        # We need the test to be non-zero as we need to reset and save tick=0
        # when saving an IDB to a new snapshot
        if self._tick != -1:
            node.hashset_buf("tick", str(self._tick))

        self._plugin.logger.debug(
            "Saved netnode: project=%s, binary=%s, snapshot=%s, tick=%d" %
            (self._project, self._binary, self._snapshot, self._tick))
Beispiel #17
0
 def __init__(self):
     self.__penode = ida_netnode.netnode()
     self.__penode.create(peutils_t.PE_NODE)
Beispiel #18
0
# Careful: there is a callback called when the IDB is closed or when we connect
# to the server so the netnode is recreated if idarling is running which we want
# to avoid.
# A workaround is to temporarily disable idarling by removing the plugin so it
# does not load to avoid the netnode to be recreated but it is annoying.
# A better way is to set IDAUSR to a path that does not exists so no plugin is loaded
# see ida_noplugin.bat
import ida_netnode
NETNODE_NAME = "$ idarling"
node = ida_netnode.netnode(NETNODE_NAME)
if ida_netnode.exist(node):
    node.kill()
    print('[+] \"%s\" node killed in action' % NETNODE_NAME)
else:
    print('[x] \"%s\" node does not exist' % NETNODE_NAME)
Beispiel #19
0
 def _nn(self):
     return ida_netnode.netnode("$rematch", 0, True)