Ejemplo n.º 1
0
    def __init__(self, ql: Qiling):
        super(QlOsLinux, self).__init__(ql)

        self.ql = ql

        cc: QlCC = {
            QL_ARCH.X86: intel.cdecl,
            QL_ARCH.X8664: intel.amd64,
            QL_ARCH.ARM: arm.aarch32,
            QL_ARCH.ARM64: arm.aarch64,
            QL_ARCH.MIPS: mips.mipso32,
            QL_ARCH.RISCV: riscv.riscv,
            QL_ARCH.RISCV64: riscv.riscv,
        }[ql.archtype](ql)

        self.fcall = QlFunctionCall(ql, cc)

        self.thread_class = None
        self.futexm = None
        self.fh = None
        self.function_after_load_list = []
        self.elf_mem_start = 0x0
        self.load()

        if self.ql.archtype == QL_ARCH.X8664:
            ql_x8664_set_gs(self.ql)
Ejemplo n.º 2
0
    def __init__(self, ql: Qiling):
        super().__init__(ql)

        self.entry_point = 0
        self.running_module = None
        self.PE_RUN = True
        self.heap = None  # Will be initialized by the loader.

        cc: QlCC = {32: intel.cdecl, 64: intel.ms64}[ql.archbit](ql)

        self.fcall = QlFunctionCall(ql, cc)
Ejemplo n.º 3
0
    def __init__(self, ql: Qiling):
        super(QlOsMacos, self).__init__(ql)

        self.ql = ql
        self.fcall = QlFunctionCall(ql, intel.macosx64(ql.arch))

        self.ql.counter = 0
        self.ev_manager = QlMacOSEvManager(self.ql)
        self.policy_manager = QlMacOSPolicy(self.ql, self.ev_manager)
        self.RUN = True
        self.hook_ret = {}
        self.load()
Ejemplo n.º 4
0
        def __make_fcall_selector(atype: QL_ARCH) -> Callable[[int], QlFunctionCall]:
            """ [internal] Generate a fcall selection function based on the required calling
            convention. This is unique to 32-bits Windows, which may need to call both CDECL
            and STDCALL functions. The 64-bits version, on the other hand, always use MS64.

            To maintain the same behavior across Windows versions, the fcall selection function
            for 64-bit is designed to ignore the calling convention identifier and always return
            a MS64 fcall instance.
            """

            __fcall_objs = {
                fncc.STDCALL: QlFunctionCall(ql, intel.stdcall(ql)),
                fncc.CDECL  : QlFunctionCall(ql, intel.cdecl(ql)),
                fncc.MS64   : QlFunctionCall(ql, intel.ms64(ql))
            }

            __selector = {
                QL_ARCH.X86  : lambda cc: __fcall_objs[cc],
                QL_ARCH.X8664: lambda cc: __fcall_objs[fncc.MS64]
            }

            return __selector[atype]
Ejemplo n.º 5
0
    def __init__(self, ql: Qiling):
        super(QlOsBlob, self).__init__(ql)

        self.ql = ql

        cc: QlCC = {
            QL_ARCH.X86   : intel.cdecl,
            QL_ARCH.X8664 : intel.amd64,
            QL_ARCH.ARM   : arm.aarch32,
            QL_ARCH.ARM64 : arm.aarch64,
            QL_ARCH.MIPS  : mips.mipso32
        }[ql.archtype](ql)

        self.fcall = QlFunctionCall(ql, cc)
Ejemplo n.º 6
0
    def __init__(self, ql: Qiling):
        super().__init__(ql)

        self.entry_point = 0
        self.running_module: str
        self.smm: SmmEnv
        self.PE_RUN: bool
        self.heap: QlMemoryHeap  # Will be initialized by the loader.

        self.on_module_enter: MutableSequence[Callable[[str], bool]] = []
        self.on_module_exit: MutableSequence[Callable[[int], bool]] = []

        cc: QlCC = {32: intel.cdecl, 64: intel.ms64}[ql.arch.bits](ql.arch)

        self.fcall = QlFunctionCall(ql, cc)
Ejemplo n.º 7
0
    def __init__(self, ql: Qiling):
        super(QlOsQnx, self).__init__(ql)

        self.ql = ql

        cc: QlCC = {
            QL_ARCH.X86: intel.cdecl,
            QL_ARCH.X8664: intel.amd64,
            QL_ARCH.ARM: arm.aarch32,
            QL_ARCH.ARM64: arm.aarch64,
            QL_ARCH.MIPS: mips.mipso32,
            QL_ARCH.RISCV: riscv.riscv,
            QL_ARCH.RISCV64: riscv.riscv,
            QL_ARCH.PPC: ppc.ppc,
        }[ql.arch.type](ql.arch)

        self.fcall = QlFunctionCall(ql, cc)

        self.thread_class = None
        self.futexm = None
        self.fh = None
        self.function_after_load_list = []
        self.elf_mem_start = 0x0
        self.load()

        # use counters to get free Ids
        self.channel_id = 1
        # TODO: replace 0x400 with NR_OPEN from Qiling 1.25
        self.connection_id_lo = 0x400 + 1
        self.connection_id_hi = NTO_SIDE_CHANNEL + 1
        # map Connection Id (coid) to Process Id (pid) and Channel Id (chid)
        self.connections = {}
        self.connections[0] = QnxConn(SYSMGR_PID,
                                      SYSMGR_CHID,
                                      fd=self.stdin.fileno())
        self.connections[1] = QnxConn(SYSMGR_PID,
                                      SYSMGR_CHID,
                                      fd=self.stdout.fileno())
        self.connections[2] = QnxConn(SYSMGR_PID,
                                      SYSMGR_CHID,
                                      fd=self.stderr.fileno())
        self.connections[SYSMGR_COID] = QnxConn(SYSMGR_PID, SYSMGR_CHID)