注:本文出发点系分享一个好玩的题目,为避免一些不愉快的事情发生,91ri对文章略做修改,希望看文的朋友不要恶意加群骚扰,谢谢。
早上刷某乎,看到妹子找程序员的帖子,然后出了个题,解决问题的才可以进入相关的“交友群”。
虽然啥也看不懂,但是看起来蛮好玩的样子:
begin 777 portal.bin <span class="hljs-literal">M</span>(R!796QC;VUE#0H-"B,C(<span class="hljs-label">$ME</span>>0T*#0I24T$@4'5B;&EC(<span class="hljs-label">$ME</span>>3H@*<span class="hljs-label">$XL</span>(#<<span class="hljs-literal">I</span> <span class="hljs-keyword">M</span>#0I.(#T@,C,<span class="hljs-literal">S</span>(<span class="hljs-string">"H@30T*32!I<R!T:&4@9W)E871E<W0@9F]U<BUD:6=I="</span>!P <span class="hljs-keyword">M</span><FEM92!T:&%T(&UA:V5S(<span class="hljs-label">$X</span>@96YD('=I=&@@,C,S#0H-"B,C(<span class="hljs-label">$5N8W</span>)Y<'1E M9<span class="hljs-string">"!!=61I="</span>!142!<span class="hljs-keyword">G</span><F]<span class="hljs-keyword">U</span><<span class="hljs-string">"!N=6UB97(-"</span>@T*5&AE($%U9&ET(%%1(&=R;W5P <span class="hljs-literal">M</span>(&YU;6)<span class="hljs-keyword">E</span><B!I<R!<span class="hljs-keyword">E</span>;F-R>7!T960@=VET:"!T:&4@*BI24T$@4'5B;&EC(<span class="hljs-label">$ME</span> <span class="hljs-keyword">M</span>>2HJ+@T*#0I@8&`-<span class="hljs-string">"D-/3D-!5"</span>A<span class="hljs-label">$14</span>-265!4*#<span class="hljs-label">$Y</span>-S,W,BDN=&]3=')I;F<<span class="hljs-literal">H</span> <span class="hljs-keyword">M</span>*2P@1<span class="hljs-label">$5</span>#4EE05<span class="hljs-string">"@S,S,P-SDI+G1O4W1R:6YG*"</span><span class="hljs-keyword">DI</span>#0I@8&`-"@T*(R!#05!4 M0TA!#0I5<V4@=&AI<R!<span class="hljs-keyword">G</span>:7-T(')<span class="hljs-keyword">E</span>=FES:6]<span class="hljs-keyword">N</span>(&`W9#(S939E.3DY-&)B-F9A M93@W-&1A8C,U930V9F0W-6(Y9&0Q-6)E8"!R97-<span class="hljs-keyword">U</span>;'0@87,@0T%05$-(02X- !"@`` ` end
好久没玩 CTF,手有点痒,所以就支起摊子开动了。
开始一头雾水,完全不知道该干啥,盯着这一坨字符串看了半天,旁边一同事说了句每行开头都是 M,然后就搜了下每一行都是M开头,还真找到了这个,真是大千世界,无奇不有:
(1)UUENCODE编码:这是很早以前在UNIX上使用的编码方式,其主要特征是:编码以<span class="hljs-keyword">BEGIN</span>开头,以<span class="hljs-keyword">END</span>结尾,并且每一行字母都以英文字母M开头。
随便找了一个UUENCODE在线解码,扔进去之后就有能看懂的东西了:
<span class="hljs-comment">## Key</span> <span class="hljs-type">RSA</span> <span class="hljs-type">Public</span> <span class="hljs-type">Key</span>: (N, <span class="hljs-number">7</span>) N = <span class="hljs-number">233</span> * M M = <span class="hljs-number">9001</span> N = <span class="hljs-number">2097233</span> (<span class="hljs-number">2097233</span>, <span class="hljs-number">7</span>) M <span class="hljs-keyword">is</span> the greatest four-digit prime that makes N <span class="hljs-keyword">end</span> <span class="hljs-keyword">with</span> <span class="hljs-number">233</span> <span class="hljs-comment">## Encrypted Audit QQ group number</span> <span class="hljs-type">The</span> <span class="hljs-type">Audit</span> <span class="hljs-type">QQ</span> group number <span class="hljs-keyword">is</span> encrypted <span class="hljs-keyword">with</span> the **<span class="hljs-type">RSA</span> <span class="hljs-type">Public</span> <span class="hljs-type">Key</span>**. <span class="hljs-type">CONCAT</span>(<span class="hljs-type">DECRYPT</span>(<span class="hljs-number">197372</span>).toString(), <span class="hljs-type">DECRYPT</span>(<span class="hljs-number">333079</span>).toString()) <span class="hljs-comment"># CAPTCHA</span> <span class="hljs-type">Use</span> this gist revision `<span class="hljs-number">7</span>d23e6e9994bb6fae874dab35e46fd75b9dd15be` <span class="hljs-literal">result</span> <span class="hljs-keyword">as</span> <span class="hljs-type">CAPTCHA</span>.
哦,原来是RSA,虽然以前没在搞懂这玩意,但是还是了解一点,在加上强大的 Google,先看看原理:
先解决题目里 M 的问题,说是使得 N 尾数是 233 的最大四位数,一个脚本就搞定:
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">999</span>, <span class="hljs-number">10000</span>): n = <span class="hljs-number">233</span> * i <span class="hljs-keyword">if</span> n % <span class="hljs-number">1000</span> == <span class="hljs-number">233</span>: <span class="hljs-keyword">print</span> i
然后就是用 RSA 解密了,当然不用自己动手了,找到这个:
改了下原来的 keyGeneration 函数和主函数:
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">keyGeneration</span><span class="hljs-params">(keyLength)</span>:</span> p = <span class="hljs-number">233</span> q = <span class="hljs-number">9001</span> n = p * q fn = (p-<span class="hljs-number">1</span>) * (q-<span class="hljs-number">1</span>) e = <span class="hljs-number">7</span> d = computeD(fn, e) <span class="hljs-keyword">return</span> (n, e, d) <span class="hljs-comment">#Unit Testing</span> (n, e, d) = keyGeneration(<span class="hljs-number">1024</span>) M1 = decryption(<span class="hljs-number">197372</span>, d, n) M2 = decryption(<span class="hljs-number">333079</span>, d, n) <span class="hljs-keyword">print</span> M1 <span class="hljs-keyword">print</span> M2
就得到群号了,这里就不贴了,233。
不过好像还没完,要验证码才能加入,又是个坑。
<span class="hljs-comment"># CAPTCHA</span> <span class="hljs-type">Use</span> this gist revision `<span class="hljs-number">7</span>d23e6e9994bb6fae874dab35e46fd75b9dd15be` <span class="hljs-literal">result</span> <span class="hljs-keyword">as</span> <span class="hljs-type">CAPTCHA</span>.
开始没想,以为就是 7d23e6e9994bb6fae874dab35e46fd75b9dd15be
, 提交之后就给我拒了,拒绝理由还给我个 400 Bad Request
, 挺专业!
仔细看了下发现好像是 git commit 的 hash,所以可能他的意思就是这次提交的代码的结果,clone 了他的gist,查了下 log 发现还真有这次提交,reset 过去之后就是 Roman Hitman,还好刚才在 Google 的时候发现某大神以前写的脚本,跑了一下得到了这些东西:
## Questions <span class="hljs-number">1</span>. The answer to life, the universe, <span class="hljs-literal">and</span> everything? Google 之 <span class="hljs-number">2</span>. The tenth Fibonacci number? Google 之 <span class="hljs-number">3</span>. <span class="hljs-escape">`C</span>ONCAT(Date.FromKeyword(<span class="hljs-string">"GFW sensive day"</span>).Format(<span class="hljs-string">"MMDD"</span>, <span class="hljs-string">"ISO-8601"</span>), Date.Now.Format(<span class="hljs-string">"DDmm"</span>, , <span class="hljs-string">"ISO-8601"</span>))<span class="hljs-escape">` </span> # Join US <span class="hljs-label">QQ Group:</span> * Group number is **CONCAT(D321 O1454 B10101110)** * Verify CAPTCHA is <span class="hljs-escape">`C</span>ONCAT('K', ANSWER(Q1), ANSWER(Q2), ANSWER(Q3))<span class="hljs-escape">` </span> <span class="hljs-label">QQ group number:</span> <span class="hljs-number">32181xxx</span> <span class="hljs-label">QQ verify code:</span> Z4255060402XX
一激动赶紧把验证码扔过去测试了一下,被拒绝了。
看了下 Date.Now.Format
和 now 有关以为得自己拼接,然后拿 php 弄出来这个(这里有个小插曲就是斐波拉契数列的第10个数是55,不是34,详细见百度百科黑体加粗提示):
K<span class="hljs-number">4255</span>Ju<span class="hljs-label">nJunSunSunWedWed0303</span>
扔过去还是不对,就读了下 RomanHitman 源码,才发现是这个作者把开头的字母换成了Z,估计是想留个坑给别人吧,也怪我不仔细,改过了再跑一下就好了。
终于看到了Accept。
然后,我就默默的跑来写攻略的,果然是应该注孤生的。
PS:看了下群相册,居然还有什么终极三问,因为我也不知道同时掉水里该救谁,所以还是退了吧!
嗯,至此,所有的坑都踩完了,感觉心好累。
【via@Tairy】