Skip to content

Instantly share code, notes, and snippets.

@in7egral
Created September 5, 2016 13:35
Show Gist options
  • Save in7egral/3582e3f74f5abd998b6f07f042c73ff4 to your computer and use it in GitHub Desktop.
Save in7egral/3582e3f74f5abd998b6f07f042c73ff4 to your computer and use it in GitHub Desktop.
from idc import *
from idaapi import *
def getSysctlSegment():
addr = 0
seg = SegByName("__sysctl_set")
if seg != BADADDR:
addr = SegByBase(seg)
return addr
def processMacPolicy(addr):
# indexes checked on iOS 8.4.1
name_addr = Qword(addr + 5 * 8)
handler_addr = Qword(addr + 6 * 8)
desc_addr = Qword(addr + 8 * 8)
name = GetString(name_addr, -1, ASCSTR_C)
desc = GetString(desc_addr, -1, ASCSTR_C)
handler_name = GetFunctionName(handler_addr)
if handler_addr == 0:
print '%s: %s [ no handler ]' % (name, desc)
return
if handler_name and handler_name[:4] != 'sub_':
print '%s: %s [ %x (%s) ]' % (name, desc, handler_addr, handler_name)
else:
print '%s: %s [ %x ]' % (name, desc, handler_addr)
seg = getSysctlSegment()
if seg != BADADDR:
seg_end = SegEnd(seg)
x = seg
while x < seg_end:
mp = Qword(x)
processMacPolicy(mp)
x = x + 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment