MCPcopy Create free account
hub / github.com/qilingframework/qiling / init_security_cookie

Method init_security_cookie

qiling/loader/pe.py:803–815  ·  view source on GitHub ↗
(self, pe: pefile.PE, image_base: int)

Source from the content-addressed store, hash-verified

801 self.ql.os.KUSER_SHARED_DATA = kusd_obj
802
803 def init_security_cookie(self, pe: pefile.PE, image_base: int):
804 if not Process.directory_exists(pe, 'IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG'):
805 return
806
807 cookie_rva = pe.DIRECTORY_ENTRY_LOAD_CONFIG.struct.SecurityCookie - pe.OPTIONAL_HEADER.ImageBase
808
809 # get a random cookie value but keep the two most significant bytes zeroes
810 #
811 # rol rcx, 10h ; rcx = cookie
812 # test cx, 0FFFFh
813 cookie = secrets.randbits(self.ql.arch.bits - 16)
814
815 self.ql.mem.write_ptr(cookie_rva + image_base, cookie)
816
817class QlLoaderPE(QlLoader, Process):
818 def __init__(self, ql: Qiling, libcache: bool):

Callers 1

loadMethod · 0.80

Calls 2

directory_existsMethod · 0.80
write_ptrMethod · 0.80

Tested by

no test coverage detected