-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathps3_syscon.py
98 lines (67 loc) · 2.27 KB
/
ps3_syscon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
'''
PS3 Syscon Loader by SocraticBliss (R)
Dedicated to zecoxao <3
ps3_syscon_loader.py: IDA loader for reading Sony PlayStation(R) 3 Syscon Firmware files
'''
from idaapi import *
from idc import *
import idaapi
import idc
import struct
# Load Processor Details...
def processor(processor, til):
# Processor
idc.set_processor_type(processor, SETPROC_LOADER)
# Assembler
idc.set_target_assembler(0x0)
# Type Library
idc.add_default_til(til)
# Compiler
idc.set_inf_attr(INF_COMPILER, COMP_GNU)
# Loader Flags
idc.set_inf_attr(INF_LFLAGS, LFLG_PC_FLAT)
# Assume GCC3 names
idc.set_inf_attr(INF_DEMNAMES, DEMNAM_GCC3)
# Analysis Flags
idc.set_inf_attr(INF_AF, 0xC7FFFFD7)
# PROGRAM START
# Open File Dialog...
def accept_file(f, n):
try:
if not isinstance(n, (int, long)) or n == 0:
return 'PS3 - Syscon Full Firmware' if f.read(4) == '\x18\xF0\x9F\xE5' else 0
except:
pass
# Load Input Binary...
def load_file(f, neflags, format):
print('# PS3 Syscon Loader')
# PS3 Syscon Processor and Library
processor('arm', 'gnulnx_arm')
print('# Creating ROM Segment...')
address = 0x0
end = address + f.size()
f.file2base(address, address, end, FILEREG_PATCHABLE)
idaapi.add_segm(0x0, address, end, 'ROM', 'CODE', 0x0)
# Processor Specific Segment Details
idc.set_segm_addressing(address, 0x1)
idc.set_segm_alignment(address, saAbs)
idc.set_segm_combination(address, scPriv)
idc.set_segm_attr(address, SEGATTR_PERM, SEGPERM_MAXVAL)
idc.set_default_sreg_value(address, 'T', 0x0)
idc.set_default_sreg_value(address, 'DS', 0x1)
print('# Waiting for the AutoAnalyzer to Complete...')
idaapi.auto_wait()
# Create some missing functions...
while address < end:
address = idaapi.find_binary(address, end, '?? B5', 0x10, SEARCH_DOWN)
idaapi.create_insn(address)
# Pablo escobar
if idc.print_insn_mnem(address + 2) in ['LDR', 'MOVS', 'SUB']:
idc.add_func(address)
else:
idaapi.do_unknown(address)
address += 4
print('# Done!')
return 1
# PROGRAM END