summaryrefslogblamecommitdiffstats
path: root/sploit/rev/gadget.py
blob: cc697238f690747d60b3f5c9a0d10a21c13da984 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                        
                                               

          
                         


                                   

                                                                              




                                                                               
                 

                                           

                                           
                          



                                                           
from dataclasses import dataclass, field
from sploit.types.index_entry import IndexEntry

@dataclass
class Gadget(IndexEntry):
    """
    Basic gadget description object

    base (int): The location this gadget is found at.  What `base` is relative
    to depends on context.

    asm (list[re.Match]): A list of assembly instructions matched by the gadget
    search query.
    """

    base: int = 0
    asm: list = field(default_factory=list)

    def __repr__(self):
        """Return human-readable Gadget."""
        s = hex(self.base)
        if len(self.asm) > 0:
            asm = "; ".join([ m.string for m in self.asm ])
            s += f", '{asm}'"
        return f"Gadget({s})"