├── README.md ├── generatePseudoCode.py └── getSVCs.py /README.md: -------------------------------------------------------------------------------- 1 | hopperScripts 2 | ============= 3 | 4 | A collection of custom scripts for use with Hopper disassembler. 5 | 6 | - Pseudo code exporter. (Exports to custom path within $HOME) 7 | - Script for iOS to locate supervisor calls (WIP) 8 | -------------------------------------------------------------------------------- /generatePseudoCode.py: -------------------------------------------------------------------------------- 1 | from os.path import exists, expanduser, split 2 | from os import makedirs 3 | 4 | doc = Document.getCurrentDocument() 5 | seg = doc.getCurrentSegment() 6 | 7 | # get proc count 8 | procCount = seg.getProcedureCount() 9 | homeDir = expanduser("~") 10 | head, appName = split(doc.getExecutableFilePath()) 11 | path = homeDir + '/hopperDumps/' + appName + '/' 12 | if not exists(path): 13 | makedirs(path) 14 | 15 | # iterate through procs 16 | i = 0 17 | while i < procCount: 18 | # get proc 19 | proc = seg.getProcedureAtIndex(i) 20 | # get proc's name 21 | name = seg.getNameAtAddress(proc.getEntryPoint()) 22 | if name: 23 | # clean the name of any unsavoury chars 24 | items = ["[", "]", ":"] 25 | for item in items: 26 | name = name.replace(item, "") 27 | name = name.replace(" ", "__") 28 | 29 | # grab the decompilation 30 | output = proc.decompile() 31 | 32 | # open up a file handler for the name 33 | with open(path + name +'.pseu', 'w') as outFile: 34 | outFile.write(output + '\n') 35 | i += 1 36 | 37 | print "[*] Pseudo code export complete. Export located at: %s" % (path) -------------------------------------------------------------------------------- /getSVCs.py: -------------------------------------------------------------------------------- 1 | def svcCall(seg, adr): 2 | #(0x80 == 128) (0xDF == 223) 3 | if seg.readByte(adr) == 128 and seg.readByte(adr + 1) == 223: 4 | return True 5 | return False 6 | 7 | doc = Document.getCurrentDocument() 8 | 9 | for seg_id in range(0, doc.getSegmentCount()): 10 | seg = doc.getSegment(seg_id) 11 | 12 | seg_start = seg.getStartingAddress() 13 | seg_stop = seg_start + seg.getLength() 14 | 15 | adr = seg_start 16 | while adr + 1 <= seg_stop: 17 | if svcCall(seg, adr): 18 | print("[+] SVC found at: %s", hex(adr)) 19 | adr += 1 20 | 21 | --------------------------------------------------------------------------------