<![CDATA[Vlads Blog]]>https://blog.v-lad.orgRSS for NodeWed, 13 Feb 2019 00:25:54 GMT<![CDATA[CodeBreaker 2018, Final Remarks]]>https://blog.v-lad.org/codebreaker2018-final-remarks/https://blog.v-lad.org/codebreaker2018-final-remarks/Sat, 12 Jan 2019 00:00:00 GMT<p>Codebreaker challenges are always fun and educational. This year’s it was especially good. It span multiple areas reverse engineering and blockchain. Thank you NSA for putting this up together. Looking forward to 2019 challenge.</p><![CDATA[CodeBreaker2018 walkthrough, Task 7 Refunds]]>https://blog.v-lad.org/codebreaker2018_task7/https://blog.v-lad.org/codebreaker2018_task7/Fri, 11 Jan 2019 00:00:00 GMT<p>Our final task is to take over an Escrow contract and refund the money back to the victims who paid.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 20.86864406779661%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAxklEQVQY04WOywrCMBBF802KSxci+Oq/KG5EEB8foQi6UPtt2pSmavMSqoXrTIprA4d75yaZGdFdnNBbnjFcXTAgWEfrGNEmpvocPMN+SLBGmwvaswMa4y2akx1a0z36yxM68yPE/fHA9ZbglkhImUKmKRJSztgz7DOVQxuLQpugxlo4wnsP6xxldS6qqsI9z5ETrEqp4FWWBc/6pKHvssS/86FeQmtdN+DPREE1Tzc0sSh0UMvb0BYM1875kP3urHX1G//CF46oFLvEKa6tAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-ea2733924acbb20b6cc89a291b3a7d9f-082a3.png" srcset="/static/assignment-ea2733924acbb20b6cc89a291b3a7d9f-59f9a.png 163w, /static/assignment-ea2733924acbb20b6cc89a291b3a7d9f-00530.png 325w, /static/assignment-ea2733924acbb20b6cc89a291b3a7d9f-082a3.png 650w, /static/assignment-ea2733924acbb20b6cc89a291b3a7d9f-4a1ce.png 944w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>After completing <a href="../codebreaker2018_task6">task 6</a>, the solution of this task is pretty simple. </p> <p>Let’s recap of what we have learned so far:</p> <ul> <li>We understand the entire message flow of the ransomware</li> <li>We can substitute ransom contracts with our ‘patched’ versions</li> <li>We cannot change anything about the Escrow contract itself</li> <li>Looks like the attackers have not withdrawn the money from the Escrow</li> </ul> <p>So, what we need to do is:</p> <ul> <li>Find a flaw in the ransomware blockchain </li> <li>Exploit the flow to take the money from the Escrow </li> <li>Refund it back to victims</li> </ul> <p>Let’s take a look at the message diagram:</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 63.79821958456973%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABrklEQVQ4y22TiW7DMAxD8/8/OmA94vjO0Wh8nlIU2Aqwkm2JpmlnMv3WdbXWmv33O8/TXq/XiL13q7WOehBCsH3fx3opZXBMRsNx2CFcjRTt22aHYs55kHQVE2natHaJIL8Ax7Tpr6sRNBE2jZNIHvNs9zlYEUmWsiSCotgUE+QQolh91fu7SAfhWBSuxY2oRXKaGpGNNVdENsdoS0pWlTNffQ2OiebM7kxoofmYuEoxOQoXeZQUs+oeInyKkPHoEegvg5ABpgpdl8DVFM0FlOi4EfPVeBMJecUW+QwyylVPH/Pl8pBds3uIfPKnfPxeFlvwiRtWE/PvOuG9ASdhbXhIgulSVPx4UcqCCDlmzMnKMlsVqMGC7tZQh9cNQdgh/B7ZUX1ndkPdl245pqjnUqTwHLZk1aHsrfbPkTWJuYDdMDd9KF5qs9hXixqjOAjjUmIa4+KvIX0qHB4i/fIQUpFFf3+zGm/4KVLGV030Z0NfESnkE++H2wxezHEYv4EiPREs4KLAqBfumg/eyxwbTge35MZuyld/6MRdt0t+gS8FZP9SEp+i+vhKxlek/AcBoPZbuvqWrgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-082a3.png" srcset="/static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-59f9a.png 163w, /static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-00530.png 325w, /static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-082a3.png 650w, /static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-dba21.png 975w, /static/msg_uml1-bad82f0ac823f76b2b83b0192ff95929-ea8e1.png 1011w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>and this method</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 17.5764192139738%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAA8klEQVQY00WQ3VKCUBSFT1lBdpNjhBlxoyWJNIlAODi9Av7AwcCjUNr0/i+w2hyb6eKbb2bt2Wv2OezSzlCj2pzMceWspZVhKvPmKIPynMqsRh1ymR1Z47jP0Xic46Qfg127W+hve9Ru+59oTSqiJHZoOjnOrQSNwRKsP/8jxqlc/kfmvVjO2F20h/H+AyP6RjfYoTcTMKcCul/BDAvKNngID9DdDKbHyQKtlwKaL3AbCOnO+AOaQ5fbKZgx+0InLKEFW9xMCtyHdDGVaB4VRyXabo7utILu0eyVCsc5LqwVfcOKnp+QE6jWEspggbOnBX4B2h5+jkQSP/IAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/regransom-a775eb01befbd3d0060b955da530e16e-082a3.png" srcset="/static/regransom-a775eb01befbd3d0060b955da530e16e-59f9a.png 163w, /static/regransom-a775eb01befbd3d0060b955da530e16e-00530.png 325w, /static/regransom-a775eb01befbd3d0060b955da530e16e-082a3.png 650w, /static/regransom-a775eb01befbd3d0060b955da530e16e-6cb7c.png 916w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>as well as this one</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 47.66483516483517%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAABjElEQVQoz42SZ47bMBSEdY5YVLXEJrGoWd6N19kFcv8jTUZyCRA4QX58eKREDueVRCuLzhk4ZxGDheoclO7QaIfWeATv0fLM9m0aInpr0UsL0xpoo9H3Pe/6PW4kfl0Q1hWntwt+XC84cR2GgPE0wzH62KHXikgMnYE3koISTX1EWZaoqorUqOsaRVEgiTFio+s6OLoxfDXLBYoq38mLDGma7hwO6XOdihRCiN/79LZP4jBATxFH30PSkRwDmraFVgquZ9pNi4wHsyz7L5IQAjbRcRzh6dD7QKcB75cPjPMMked0I56Iu7jYePFQEn3Eupx2N7KVsKzXYDXObMBqFXwhEMoMgel7csxfCz0FpVT4/vWJj+uVXXKY6PLnPOCNqS/LBEnxoiz2tDXruYmmu+DN7Z8knXUYzmcM04iJaQfilhk6Bmi6VKxrx2jY2bFmk+7p/tVh2zQwSsNyvqwxqNoGmTxCUkCzBFpuzemhWYqc9dwuPeJLwX0c0gNH4obgPnuMyZ1vj3//SPXBL3aQH+ETgB1MAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/decrypt_cb-6231c902d8f927ebaa9b07757b4d0ca6-082a3.png" srcset="/static/decrypt_cb-6231c902d8f927ebaa9b07757b4d0ca6-59f9a.png 163w, /static/decrypt_cb-6231c902d8f927ebaa9b07757b4d0ca6-00530.png 325w, /static/decrypt_cb-6231c902d8f927ebaa9b07757b4d0ca6-082a3.png 650w, /static/decrypt_cb-6231c902d8f927ebaa9b07757b4d0ca6-35f9d.png 728w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Looks like the attackers decided to be “Gentlemen” and provided refund option in case they fail to decrypt the encrypted file. Also it looks like the ransom contracts can re-register themselves as many times as they want given that they have been authenticated once by the Oracle.</p> <p>So let’s modify our ransom contract again to do the following:</p> <ol> <li>Register with the Escrow as zero ransom contract</li> <li>Call <em>payRansom</em> on the escrow giving it 0 ether</li> <li>When Escrow calls our <em>requestKey</em> method we will first give a corrupted version of the key to the Escrow and then re-register ourselves as a contract with Ransom amount of 300 ETH.</li> <li>Oracle will fail to decrypt and will indicate failure to the Escrow by calling <em>DecryptCallbackMethod</em> with authResult = False</li> <li>Escrow receives a failure notification and automatically refunds us. However, because we changed the refund amount at step 3, the Escrow is going to refund us with 300 ETH not zero which we initially paid</li> <li>PROFIT</li> </ol> <p>This is a blockchain equivalent of going to the store, changing the price sticker to 1 penny, buying the item, tampering with the receipt to make it look like we bought it for $3000, damaging the item, returning it back to the store for the refund of $3000.</p> <p>Note that operations in step 3 have to be done exactly in this order. This is because registering new ransom contract creates a new contract record in the <code class="language-text">victimMap</code> mapping. Which means the Escrow will consider this newly registered contract to be unauthenticated. It will therefore refuse the <em>decryptKey</em> request from the new contract. Doing these operations in the order listed in step 3 seems unreliable, but actually it’s not. We are guaranteed that our substitution of ransom amount is going to happen before the oracle gets the decrypt event by the atomic nature of the Ethereum transactions. All changes to the contracts and posting of the events are made public once the block is acknowledged by the miners.</p> <p>Here is our test for this scenario [http://bit.ly/2Db5Eu4].</p> <p>And of course it fails</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 82.38897396630934%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsSAAALEgHS3X78AAAB70lEQVQ4y32UaXKDMAyFOUp2soclCYTsQNZp7n8cVZ9aM5Sm/aGxLawnPT0Z73A4yPV6lePxKGVZyvP5lKIoZTqdynA4NBuNRmbdblc6nY6tzX2/37fVm81mkue5lApyPp3koMBFXshuu5XFYmHAk8lEwiAw0F6vZ8FNc36Py0VRaIUnq3K/31uCo1a+Wq0kyzIZj8dvQepAbu+t12u5XC5aVW5g0H48HhLHsQEFWtl8PrcqoVg3R7UO6u12O6vwdrtZ/wAnCXQxwDCAObs1DENL2P0GqygTjDAXreym4lwV8K7gj/vdxOJsfjWS2Xf9hm+vxfi+/7NCf+BXtKwqXcmOAK1Wq0axLe12+5eyvyijYpZtZauqbjYbSZPE9vQw0X0URZogsjMiLZdLU77XoFpRZs64RMBXcGgrtlSf6xcsHBgx78AMEDHoDWOSqzj0ipkkASAuQaDAzGyk1Ubqa/auAuRymqYWBGVGB2pRyCAP3wb9N9w22HGsFQRfr8I1no+u+XWri1K3qofQSNPEnhaAzBZJUJmVM373BOmp8xPr/O5ZeoPBQE767Ojj+Xw2e328bC5508xcrr5E55VWkNypzwzTZ8ArQMpEPX4GBHCJNw0AvcUPAC1xFQFCIXX6FWX32/nrt+T2BLwbk6Yon1g77aq0ciXBAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/exp_fail-a16037529f3dc27c2180754093d61647-082a3.png" srcset="/static/exp_fail-a16037529f3dc27c2180754093d61647-59f9a.png 163w, /static/exp_fail-a16037529f3dc27c2180754093d61647-00530.png 325w, /static/exp_fail-a16037529f3dc27c2180754093d61647-082a3.png 650w, /static/exp_fail-a16037529f3dc27c2180754093d61647-4c327.png 653w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>It fails because we didn’t ‘patch’ our contract yet.</p> <p>Again we are sticking to the principles of TDD. First we run the test to illustrate the problem. We run this test to make sure it fails, if it doesn’t fail it was not a valid test, we do whatever is needed to make the test pass.</p> <p>The ‘patch’ for the Ransom contract is <a href="http://bit.ly/2sBg68d">here</a></p> <p>We run the test again.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 60.709914320685435%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAABUklEQVQoz42Sa46CQBCEOYsiiLwGFUTeICjx/vcpp3ozm10X4v7odKOZb6qrxrpcLsjzHFmWST+dTojjGP7hgCiK9KwQhgFs28Zut/tY1u12Q13XqJsGwzBgmiaUZQXf97HZbLDdbqWWDi9dYo3jKMCiKNE2LcZx0nOBg1ZIIA+t1RLUSpJEVvQ8TyBUxlVZYRjKN//b7/dwXVe6mRcVVlUlqhq98vP5xP1+R5qm4mmWpVBKfYNZZiZ0EagSJd71fY+2bTHozmCMkiAI4DiO+EiA8XR1Zd5GYNd1aLSX9JRgpk8wbSDw36FwNSZLCGGEUxV9M6sZVT+VrQKZMJ/O4/HAPM8Czq9XSZr+spdl+fWt+/F4/PWM/qzMMKiMKhkKveQl/J3FmUB2hsVQGJS3Fgq94sHz+Szr8mCsn4yrfXPe6l3RIpAemXdH38w6nx7zWsovV5Bu1b2bKTYAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/exp_pass-8a3df197fcf9b28e88c1931984bcdf73-082a3.png" srcset="/static/exp_pass-8a3df197fcf9b28e88c1931984bcdf73-59f9a.png 163w, /static/exp_pass-8a3df197fcf9b28e88c1931984bcdf73-00530.png 325w, /static/exp_pass-8a3df197fcf9b28e88c1931984bcdf73-082a3.png 650w, /static/exp_pass-8a3df197fcf9b28e88c1931984bcdf73-5d0c4.png 817w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>And it passes this time.</p> <p>Let’s check the account balances</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 28.219852337981955%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAAA8UlEQVQY022Q3VKFMAyEef9nVJHDoaWFA/SXAjprEoHxwotvMtkm220rpTVCiHDeC94H6bkyl+acQ4wR67oKpRQYY2DtIOcxJdR1jcq7GcEvN1cfvUOKdMkywRPbmnHsBV8Xx4a9ZJmJNM/aoyFDq58whO25tlDPRvrBdHgNPaHprEOOCxkkMo43a/JIgS53E44t47N+QzUYBaFXmEaD0Wrp2WR+WcynxstiSOwnt6GfxbCp31Hp7gGj2tO0+01HlZOzGadkjZf+M2Q9XAk/KCEvcBI3j1I55XJW1niYdU7y97lMyYFMA32Hw/dR0NIf/gDao8inu6A7mgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-082a3.png" srcset="/static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-59f9a.png 163w, /static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-00530.png 325w, /static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-082a3.png 650w, /static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-dba21.png 975w, /static/acc_bal-b87d73d640e5b0f24c9dc0e83568a4b4-e5952.png 1219w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Great, we managed to get 9 Ether out of the owner. Even better, because the transfer is done in the context of <em>DecryptCallback</em>, Oracle is paying for the gas.</p> <p>Now let’s go and use this exploit on the real blockchain.</p> <p>Note that we transferred only 9 ether except of 300 requested by the assignment. This is because of the default Ganache settings of 100 ether on each account. I have tried to make this walkthrough as simple as possible, but still educational. Changing default ganache settings would make this walkthrough more complex than it already is.</p> <ul> <li>Go back to RemixIDE and upload our new EvilRansom contract to the workspace.</li> <li>Deploy the new contract using the same technique we’ve used in <a href="../codebreaker2018_task6">task 6</a></li> <li>Verify that the new contract has deployed by checking blockchain events using our notebook or just call the method <em>getEscrowAddressForVictim</em> of the Registry to verify that new contract has registered correctly</li> <li>Once you’ve verified, that the new contract is there. Make a 0 either payment to the escrow and enjoy your 300 ETH refund back.</li> <li>In order to get the credit for this task you have to actually send 100 ether to each of the victims who have paid the ransom. Can’t keep to yourself.</li> <li>Once you send the ether to the victims, go ahead and submit your escrow contract address to the challenge</li> </ul> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 9.421841541755889%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAYElEQVQI11WMWQ6AIAxEuf/tRCMURdziEldOMNpGPvx4mUnaeaq/awzRC9zbyyEcBDtrmDmTdGsBu2jp5ZTB7wbdVQlpm1BJOMYG4STQkouAkwUC9w8W8o3eH7+Zd/cXPueHkQTbKAwtAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/task7-solution-69f52d8626b20e1dfc8559dec3a380bc-082a3.png" srcset="/static/task7-solution-69f52d8626b20e1dfc8559dec3a380bc-59f9a.png 163w, /static/task7-solution-69f52d8626b20e1dfc8559dec3a380bc-00530.png 325w, /static/task7-solution-69f52d8626b20e1dfc8559dec3a380bc-082a3.png 650w, /static/task7-solution-69f52d8626b20e1dfc8559dec3a380bc-3d088.png 934w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Sorry, there are no screenshots for the lasts steps. I am writing this more than a week after completing the challenge. Applying Task 7 exploit to the real blockchain permanently corrupts the Escrow contract so it is not possible to repeat this again.</p> <p>If you followed me along, you have completed entire challenge. Congratulations!</p><![CDATA[CodeBreaker2018 walkthrough, Task 6 Loophole]]>https://blog.v-lad.org/codebreaker2018_task6/https://blog.v-lad.org/codebreaker2018_task6/Thu, 10 Jan 2019 00:00:00 GMT<p>In this task we are going to trick the attackers to reveal us the decryption key without paying any ransom.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 25.531914893617024%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAABAUlEQVQY0zWPXU7DMBCEcwSEOAF/AipuA+IVVP6uUfFW0faEEP8ksZ0qtqsmD0lVhl2nfRh9o9n1apxdvMxxPV3g7n2Jq+k3JsTbtyUmH6tEztkzj7r/XOH8eY6ThxlOH2c4e/rCzesCl3QrK4zDj9AQuiRVkKVBrkrIooJQY8azXBX4lQVEUULRjuB5YZLy9M4ibDtkXbuFbxoE7xGDxybGpNEHhMD5yMCkva5tsRsGDH2fuBv65P/2e2S8VNc1HMvVsM5hvV4nclaTd+SNsbD2SIuqMslXZqQhth015GWlFEkjzwWEkJBSQmudyEdi3KR23o8tI//goKY5NCf11PIf8kFVFBFmUdEAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-6f6e38e8605d88f7988d1b2bdd702ed0-082a3.png" srcset="/static/assignment-6f6e38e8605d88f7988d1b2bdd702ed0-59f9a.png 163w, /static/assignment-6f6e38e8605d88f7988d1b2bdd702ed0-00530.png 325w, /static/assignment-6f6e38e8605d88f7988d1b2bdd702ed0-082a3.png 650w, /static/assignment-6f6e38e8605d88f7988d1b2bdd702ed0-a5eea.png 940w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Before we dive in, it will help to get familiar with Ethereum smart contracts and distributed applications. Here is some good reading material:</p> <ul> <li> <p><a href="https://amzn.to/2RANAkW">Mastering Ethereum</a> by by Andreas M. Antonopoulos</p> </li> <li> <p><a href="http://bit.ly/2AKVxKZ">Ethernaut</a> - series of exercises, that show how to exploit various loopholes in Ethereum blockchain. Nicole Zhu prepared an excellent set of <a href="http://bit.ly/2VYfLd8">Walkthrough Solutions</a> to these exercises. Try doing the exercises first before proceeding with the walkthrough. All of the Ethernaut exercises are very valuable for gaining insight into the inner workings of the blockchain. However, for the purpose of this challenge you need to only go through exercises 1 to 8.</p> </li> </ul> <p>Our approach is to build the model of the ransomware, and then experiment with the model to see how we can exploit it. Ethereum comes with some great tools to do it. We won’t be doing any reverse engineering here because attackers gave us their source code to the smart contracts to “prove” that we will get the funds. The only piece we are missing is the code to the <em>Oracle</em> daemon that watches blockchain and posts decryption keys when it detects that the ransom has been paid.</p> <p>We will use the following tools</p> <ul> <li><a href="http://bit.ly/2HcuWvY">Truffle/Solidity suite</a> a prime toolset for building Ethereum smart contracts using solidity language.</li> <li><a href="http://bit.ly/2FtqSFE">Ganache</a> testing tool that lets you run the blockchain on your computer</li> <li><a href="http://bit.ly/2QQ9Brw">Remix IDE</a> web based IDE for developing and testing smart contracts</li> <li><a href="http://bit.ly/2AKEJDy">Metamask wallet</a> Ethereum wallet for web Chrome and Firefox browsers.</li> <li><a href="http://bit.ly/2srsqI3">NPM/Node environment</a> Javascript development tools, needed to setup Truffle</li> <li>For the editor you can use anything you want. I find that <a href="http://bit.ly/2VTE2ks">Visual Studio Code</a> offers the best support for Solidity language. You’ll to install Solidity/Etherium plugin separately.</li> </ul> <p>Let’s begin</p> <h2>Preparations</h2> <p>Install <a href="http://bit.ly/2srsqI3">Node and NPM</a> on your computer if you don’t have it installed yet. You’ll need a sufficiently modern version. I used Node version 10.7 and NPM 6.4.1. Best way to do it on OSX is to use the brew package manager.</p> <p>Also, I like to use the desktop app version of the Ganache. It makes it more clear to see what’s going on with the dev-blockchain. To install it simply download it from their <a href="http://bit.ly/2FtqSFE">website</a> and follow instructions. </p> <p>To install Truffle framework use the following command:</p> <p> <code class="language-text">npm install -g truffle</code></p> <h2>Start the project</h2> <p>Once you have everything installed, create a new directory and run the following command inside:</p> <p> <code class="language-text">trfulle init</code></p> <p>After the above command configures new project, copy the contracts provided by challenge to the ‘contracts’ directory.</p> <p>Next, we are going to write some unit tests to understand the transaction flow between different contracts. There are two ways to write unit tests for Solidity smart contracts. The first one is to use solidity language itself and the second one is to use Javascript. We will be using the Javascript method because we’ll need to simulate complex actions between different contracts and off-the-chain entities like <em>Victim</em> and <em>Oracle</em></p> <p>We will be using a ‘solidity-coverage’ tool to see how much code we get to cover by our tests and to make sure we explore all the edge cases. Install the tool using the following command.</p> <p> <code class="language-text">npm install solidity-coverage</code></p> <p>Our initial setup is <a href="http://bit.ly/2TPaHG8">here</a></p> <p>By default Ganache gives us 10 accounts with a 100 ETH balance on each. We will use them as follows:</p> <ul> <li>Account 0 — ransomware OWNER, ultimate recipient of all the ransoms</li> <li>Account 1 — ORACLE, an off-chain software daemon that will authorize ransom registration and release keys when ransom is paid</li> <li>Account 2 — VICTIM, A person who got infected with ransomware</li> </ul> <p>Note that there is a distinction between <em>victim account</em>, <em>victim_id</em> and <em>ransom contract</em>. First is an Ethereum address of the wallet that belongs to a real user. Second is just an ID number it has no meaning in the Ethereum universe, it is just a number, the last is the smart contract that holds victims encrypted key</p> <p>Same distinction applies to <em>owner</em> and <em>escrow</em>. The first is the wallet address that belongs to a real person, second is the address of the smart contract that holds the funds deposited by the victim until withdrawn by the owner or refunded back to the victim.</p> <p>Our initial test scenario is <a href="http://bit.ly/2FA1Xzu">here</a>. Let’s look at the interesting part.</p> <p>We pick arbitrary number 0x5500 as our victim ID</p> <div class="gatsby-highlight" data-language="[es6]"><pre class="language-[es6]"><code class="language-[es6]">29: let victimId = 0x5500; // Victim ID</code></pre></div> <p>And then create initial contracts</p> <div class="gatsby-highlight" data-language="[es6]"><pre class="language-[es6]"><code class="language-[es6]">40: // Deploy contracts 39: registry = await Registry.new(oracle, {from: owner}); 40: escrow = await Escrow.new(registry.address, oracle, {from: owner}); 41: ransom = await Ransom.new(victimId, &quot;Hello&quot;, victim, registry.address, 55);</code></pre></div> <p>So let’s measure our test coverage we have so far. We’ll use the following command:</p> <p><code class="language-text">./node_modules/.bin/solidity-coverage</code></p> <p>This will compile contracts using a special version of solidity compiler that instruments the code, and will run them against a special version of ganache that records coverage events from instrumentation. When done it creates the following report</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 615px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 38.86178861788618%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABfElEQVQoz1VRy1LCMBTt7/sF7nTjQt0w486N+MLH+EZFCn3QNE1CsS3iQIuFHm/agpiZM+fm5NwzyY3h922MGEccSPg9C1EgIBwXfl/XEiHzIWwXiVDwuj1iiZHPofsmwxBv949QroeICzCzB2N8dov49Bpx8xrJ6Q2ik6uSS5201ZmG1sqzc+Iz8javMLm4K7VVvzH5+gJQYLlcViioJmWR53/7GvliAaUUGGOIkwRFUfWtWMMQZoDIkfgJFGGIdEDPv7xDPp5gLkNkvkDGJbFE6nGkLCih9YUIEfdsDDtm1c8VDPt5AP7mYWYzzF2f2EOw14DcP8J3+6MM00EZhcysATKn8mnoWj69gj+8rPeGoLBRl60DU5eB7xzA2dqmebaQkmnatTE1HYL9L3BO3rD9DvXyjqzWDKcjIC16ElfltTOCahyD7x4iad3jJ4xKLRM0DiYwDyqf5pyePLZcfJrWWjf0h9BUUejh1thcRT30NTZ8+hN0r17LWvsFDVxRBeb0y3gAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/coverage-3b8c94d15a6abbcc8eabc46099b95156-341a3.png" srcset="/static/coverage-3b8c94d15a6abbcc8eabc46099b95156-be368.png 163w, /static/coverage-3b8c94d15a6abbcc8eabc46099b95156-0f89e.png 325w, /static/coverage-3b8c94d15a6abbcc8eabc46099b95156-341a3.png 615w" sizes="(max-width: 615px) 100vw, 615px" /> </span> </span> </p> <p>Not much. We just run the constructors of the contracts. And Ransom’s and Escrow constructors attempt to register with the Registry.</p> <p>We can also use truffle development console to poke around the contracts.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 98.96142433234421%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAACQElEQVQ4y41U2ZKCQAzkU7zLA5QbAfEoL0ARyuv//yQ7HRjXg9r1oSuZgelkOsko0+mUgiAg3/fJcRzSNI2GwyGpoxH7sLqu02AwoE6nQ91u92HffUCJoogA13XJtm3yPI8QBNbzymCWZdUS1QVgwv1+T8fjkQ6Hg0BKp9OJ19jPsozm8zm1Wq3arD4yXC6XFMcxEzBpmlJRFJTnOWWCGP5qtXoh/AucIQiRHZMKmyQJZcJPBTmAoO12++Pwe3ZM6PsBH8C1UBhZIOgIXeHbQsNms8lZStTpx4RBENJysWDS2WzGxLBYh2FIoQgQiTVugr1F9a+qqrVZK/gBwl8vF7rdbqzd/X6ni1ifz2e2RZHzP/h2u15ZV8sya3VVQhF9u92yVtAxTmL2UeE4TljP3W7H/8CH3mmScivVEuJ6IEJ0FOXVHqjIi0cHYK8MnJJpmtRoNFhDXB2ArzgOGtqqGtshV0wLoqPJYR1h8Q0+rFN9H4/HPEXQEhMFcIbHnUumPaUoMGke6mRaDlcakwICWXW7Ikb1JTl3hQBGtd/vVxoG5UHXERmZOh8cjzWODIykFdlgnmFBwPOujhggelw5nEWcjWGYNJnoApOXfpP6lAfaL+tn7bgnkWH5CPwC2coskNE34/bc4ApeFEtUDAt5Ja26InT5bzI+2gblR+UA+YTxGrq6HvmiCCgEyP8jq0avnOX1es12s9kwQAo9dQHDML4n7PV6fBB9JQ9iD2J/8xh8EIIM1wTw1D+/xN88V+/4AVMHdfHYhOdUAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/run_test_from_cons-40d63b4f3f4ea12bb28c587de9810d5f-082a3.png" srcset="/static/run_test_from_cons-40d63b4f3f4ea12bb28c587de9810d5f-59f9a.png 163w, /static/run_test_from_cons-40d63b4f3f4ea12bb28c587de9810d5f-00530.png 325w, /static/run_test_from_cons-40d63b4f3f4ea12bb28c587de9810d5f-082a3.png 650w, /static/run_test_from_cons-40d63b4f3f4ea12bb28c587de9810d5f-0bcfb.png 674w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>or run tests against Ganache client</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 496px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 40.725806451612904%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABE0lEQVQoz4VR2W6DQBDjW7iP5UyAFMKGkAIBIZX//xl3Z1okUtH2wRp2dsbYXq2RErfbDVKBvsuyxPvjgaqqUBYl3i4XeJ4H27bhui58z4fnetyj6jjOV9/3eUYr1cLplCFNUyRJgjzPmTTLMoShgBACQRDwkmma/0LbFMZxzH8RImQSOhOiKFLEISsyDINBi5ZlHUKjS1JAcjdbdEFWqNqq7m1t1jbSn+Rap/IaxxHP8YlpmjDPM5Zlwbp+KKzcIwzDgL7v0XUdpGxeSF8IKbv6ekV3v6tBibqu0bYtmqZhAsqRbG5qCER2pI4Jadj5tkWg/GhQ13XGPnBrZ/NXyxT2OT+rV035pYui4Af4K/gNRzOfgFrzXaEtNLMAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/run_test_against_ganache-0faf2c752d769a0a93678668cf039e0c-cdbb0.png" srcset="/static/run_test_against_ganache-0faf2c752d769a0a93678668cf039e0c-cc844.png 163w, /static/run_test_against_ganache-0faf2c752d769a0a93678668cf039e0c-0c441.png 325w, /static/run_test_against_ganache-0faf2c752d769a0a93678668cf039e0c-cdbb0.png 496w" sizes="(max-width: 496px) 100vw, 496px" /> </span> </span> </p> <p>After running against local ganache, let’s look at the accounts’ status in the Ganache</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 59.01060070671378%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAACJUlEQVQoz22R63ISQRCF92kMiRBBElGCQUgCBGNZpeVLGC2rAkJAhErUX/p2Vrjfl3u4s7vcOfYMLKLJ1p46Pd09O9/2CG/dR3h3Zscbtx3OEztev3LDeWzDqeMYbtcJzk6dcND6pcvB46MXz2G1mGE7PIDdalnLcWSDi/YLT40GHJpNMD7Swmreh0G3A/OTx9jTa8mNMOp3cWAy4tmeHgbtNvRUt1lM2DfooNdqoNveglbzALqdLew+1ED49OEcH8/fw//Zg18/wggHfbgOBxD54kckdIlLnxffwkF8jwRxFfIjFPDhJ/Vdfw0g4PfSPi98Xg/pAj7PBYRqpYZG4xbD0RiT6RzT2QKT2dJn8wXmc+bAVHVeX/A1vVybj1CrVDAayhgqEkbK0pkUebCON8Xy3U4LstRfr9n+8VAhyRDiN7+RTcUh5jPci/k08pkkcukE0okoMskYCrkUSsUs1TLotOrIZ2ldyPJ4OlYwGUkkmUuoiAUM+h0M5T4UqcddlSKtfCPH1G3fQh506Y8GRCX9IyEZuyGCJVWWqBiZSKeLhQxylGN0jFzt6XWavI/11CriilD+S1guF3kTo1Ol0v4vlbDdrENa/dUdwnQiRifGl3REwE6ulAo0J6KjWTEyllNrg157OcNiDvX7CMU8G26Dn8jEZnOf1BojbTaq/MMsvksYjyJFt5lORlczS/MbL5KzW2VS58ny/W6LE5YZYbXECTf1B2GnHAAdd4ZkAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ganache_init-88a077ddbfc2d51633f10b49b1fe2561-082a3.png" srcset="/static/ganache_init-88a077ddbfc2d51633f10b49b1fe2561-59f9a.png 163w, /static/ganache_init-88a077ddbfc2d51633f10b49b1fe2561-00530.png 325w, /static/ganache_init-88a077ddbfc2d51633f10b49b1fe2561-082a3.png 650w, /static/ganache_init-88a077ddbfc2d51633f10b49b1fe2561-6b3b6.png 849w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Nothing much has changed. We see that the OWNER (account 0) was charged some small amount (0.08 ETH) for the contract deployment. It is actually a significant amount on the real Ethereum network, about $8 USD in Jan 2019. This is because test networks tend to have much higher gas prices. On a real Ethereum network the gas is much cheaper.</p> <p>Now let’s write more tests to model the entire exchange. But before doing it let’s tweak the ransom contract a bit. We see that the Ransom contract expects to be payed 100 ether to release the encryption key.</p> <p>However, the default Ganache setup gives only 100 ether to each account. Problem is that for each transaction in Ethereum we need to pay gas money. We don’t have enough Ether to run the simple scenario. What we can do is change the Ransom contract to lower the ransom price. Let’s set the ransom amount to 2 ether, that’s more reasonable. <a href="http://bit.ly/2TNlwbv">Here</a> is the change.</p> <p>Now let’s study the contracts and discern the protocol.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 65.30398322851153%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAADvElEQVQ4y3VRW0wcVRg+QYFSaOqlmko0FKQUtAoaG6OJlT4Yook8NU20mBh8MNJGfNG0MdZadisLmGgiYFofTCXVRhajVtfCtnvDxbK0DMvKusPeZy9zvzAzZ+cwm4xnePc8/d/5vv/8/3c+oCjKA4IgzPGiXA/+52RyufsYlt2bSCT6CGKtgyTJ7nw+34vvfv/m0qXdtoZhmI8FQTwHoKI8iBDylkhyl03MXb1ad8Pj2ZPcTD5bLpV7S6WS49+NjWdia9FuVVVDPM+/uTMknT5cgXDh9OBgg411TfvENM3zIJzLdULD8IV5vgVMTtcwoniG4Th3IpMZZwVxRtV14tOFhX24p0avVHycopx1r6y0FUVxAGP/j+vrj4L+/loFwosqhKMgmE4/YROBYrHVblIN4yIecA0cfak+LQgv6xAuzVD5feBAy70VhG6VOO5CZGOjv0TTX2Gd95dk8jEwMrLzoKLrLuCNxztlCH0+imqxV+d1fUSC8Ipdx2X5acyF/ST55Exo8XEFb1iU5dPh6PobZKH4PsYL7ni82V4E9zkFTRsFy7Lco2xvB1Ytq+NFy9olVqtOEaHZxXT6tayiDIuGESTy+cFIMjWkmOYSa5qnHBx/fwahV7eq1WDINFuHLKsR97kEw5gAf7Fsj2QYgduVyqFORWngt7edmHBHSPKjTYY9LyG06LGs/aBUqJURCtIIDQHLqkkaxjEbz0tS2wlJauQQcnEQTgAPQRwStrZ8cysrO5ZpSfqMk+Vri2trfdjWgIiT/W55+WHQ1FQnaVqgKElv27pooXAEY/+3weAjtmVGlh2sLI+CMMd125bDqtrRnEo14EkOHuq//pPJ/JzjhSnM+VYsq+UshHvUatXPInTmT5pupwzjBLbsDyJ04LhlNYimOYqdjQPv5uZT+DMDCxTVDoaHaxlNc3Cq6r6+unokTtPHeVVdcoXD+0FbWz2+96UY5twdkjyVounPBV2/MRuPt4LJyQZaVUfpra1x4E+luuRK5dYiy+5YFiqVC3bKrlDoIVIQjuGUb8ey2XeJZPIdXN+lZPktW3eHol7AusD1QqEZjI3dY6fMa5oL/BaLPcdp2t9/ZDJdYGpqd0lVJ/CkudlI5Pm1QuGkzd3NZgdCicTruF5Ki+IHoL29jmCYV3AooSsEcfDw5ct7GQjHOV3/Anji8S4s/GGeolrB9HRdWVU/ZDXty52Pl6QebPOneYI4OuP395Ql6XuyXH7PG432+qLRvmgiEfj65s22JqezcZUkx2Kp1Nh/8HG5KhRXwoEAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-082a3.png" srcset="/static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-59f9a.png 163w, /static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-00530.png 325w, /static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-082a3.png 650w, /static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-dba21.png 975w, /static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-1823f.png 1300w, /static/uml_seq-e03896c597e40e2fbb66c11a20bf2ee2-e9718.png 1908w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Here is the UML diagram.</p> <p>And here is the protocol</p> <ol start="0"> <li>At the start there are three personal accounts in the Ethereum. The First account is the owner of the block chain, shown as OWNER. The second account is the off-chain oracle daemon shown as ORACLE T third account is the infected Victim account,</li> </ol> <p>Also, sometime earlier, the owner registered two smart contracts being REGISTRY and ESCROW. REGISTRY was created first and it knows all about the OWNER and ORACLE accounts. ESCROW was created after and knows about OWNER, ORACLE and REGISTRY. These two contracts are shared between all the infected victims All of the following transactions take place after infection. Transaction boundaries are shown as green squares. All the smart contract calls inside the square represent a single transaction and must be included in a single block. The transaction is recorded into the block chain if only if all the calls within the box are completed successfully. Note that the ORACLE daemon acts outside of the chain, so oracle sees the events after the transaction is completed and its result is recorded in the blockchain.</p> <ol> <li> <p>Once a victim is infected the owner creates a copy RANSOM contract. The following parameters are supplied to the RANSOM constructor <em>victim_id</em>, <em>encrypted_key</em>, <em>victim address</em>, <em>registry address</em> and <em>one time password</em> (<em>otp</em>). The RANSOM constructor sends a RegisterVictim message to the REGISTRY supplying <em>victim_id</em> and <em>otp</em> which in turn publishes <em>AuthEvent</em> event to the block chain. The <em>AuthEvent</em> contents include <em>victim_id</em>, <em>registry address</em>, <em>otp</em> and <em>owner address</em>. Once the event is posted transaction 1 is completed.</p> </li> <li> <p>Once ORACLE sees <em>AuthEvent</em> on the blockchain it verifies <em>OTP</em> and starts a new transaction by posting an <em>Authcallback</em> message to the REGISTRY contract. The <em>Authcallback</em> message includes <em>victim_id</em>, <em>ransom</em> and <em>escrow</em> addresses and a Boolean value of <em>True</em> that indicates successful authentication. REGISTRY forwards an <em>Authcallback</em> message to both ESCROW and RANSOM contracts. When RANSOM receives the <em>Authcallback</em> message it posts the <em>RegisterRansom</em> message to the ESCROW. Parameters of <em>RegisterRansom</em> include <em>ransom_amount</em>, <em>victim_id</em>, and victim address Once ESCROW updates its tables with the information received in the RegisterRansom message, the transaction 2 is completed.</p> </li> <li> <p>At some point VICTIM gathers funds and pays the ransom by sending a <em>PayRansom</em> message to ESCROW that includes <em>victim_id</em> and a copy of the <em>encrypted file</em>. Together with a <em>PayRansom</em> message the victim sends requested amount of ether. Once ESCROW receives a <em>PayRansom</em> message it looks up the victim’s RANSOM contract address and sends back a <em>RequestKey</em> message with no parameters. RANSOM receives the <em>RequestKey</em> message and in turn sends a <em>DecryptKey</em> message back to the ESCROW. <em>DecryptKey</em> has two parameters <em>victim_id</em> and <em>encrypted key</em>. Once ESCROW gets the <em>DecryptKey</em> message it posts <em>DecryptEvent</em> event to the blockchain. <em>DecryptEvent</em> contains the following parameters <em>victim_id</em>, <em>encrypted_key</em>, <em>encryptedFile</em> Once <em>DecryptEvent</em> is recorded by the blockchain the transaction 3 is completed.</p> </li> </ol> <ol start="4"> <li> <p>When ORACLE sees <em>DecryptEvent</em>, it decrypts the encrypted key, then uses it to decrypt the encrypted file and sends a <em>DecryptCallback</em> message to the ESCROW. <em>DecryptCallback</em> message includes <em>victim_id</em>, <em>decrypted_key</em> and Boolean value of true that indicates that oracle decrypted the file successfully. Once ESCROW receives <em>DecryptCallbackEvent</em> with <em>victim_id</em> and decrypted key it stores the key on the blockchain and sends a <em>FulfillContract</em> message to the RANSOM. At this point transaction 4 completes.</p> </li> <li> <p>After one or more contract have been fulfilled the OWNER can send a ‘Withdraw funds’ message to the ESCROW to request the collected ether to be transferred back to the OWNER account. A <em>WithdrawFunds</em> message includes the amount to be withdrawn and the owner account address. Once ESCROW receives a WithdrawFunds message it transfers the requested amount to the OWNER account at any point after. Transaction 5 is completed.</p> </li> <li> <p>Victim can call RANSOM contract’s to getDecryptionKey method to request decryption key. When RANSOM gets getDecryptionKey call, it forwards it to the ESCROW which in turn returns back stored decryption key sent by the ORACLE. This is not shown on the diagram, because it is a ‘view’ only transaction that does not affect the state of the blockchain, therefore it is not even seen by miners.</p> </li> </ol> <p>Let’s <a href="http://bit.ly/2RR5GPO">implement</a> the above scenario as a test.</p> <p>And let’s measure the coverage again.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 570px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 43.68421052631579%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABxklEQVQoz5WSW2/aQBBG/eerSk3bJL8hvaXKQ/vUKq3SlFsCOGAwBQIBg43BELCxuQQM9ul6o+alUqXu6mh2vm9mtdKs4t57bB92gpBQxGC+gD3MJi5zN5DabhuxDNaEmz1Lf8V85kstYbV4YLPeslltGdkOStOs0hk26IweqRsa/Umbek+j0a9Kres0xbnCnV2nbf/i1qphjFsYzi1Jf2tQk16tU0IpdlOU+tknymaOm15GxrKZaBlJkie+aqS5bv/gqnVBofvzSU/QrCuUzXLJf61whzse400mhKv1X7YyHOQY21lCL03kpwnnOeLxCQyeCw7AFljPwP1EvKqLuhRxkCWSZGQ+Nb8yM8/ZzTMouqnStG8YuSrToCgoUeme8q38govKoeC15HvlmN44w9Qvce8XJdNAxXHzNO7O6ZiXQlNRykONmlPB8DSsRRk70Llsn3GSf8UH9Zj3xSMZ3xReku99wfSrWIH2yKJCzyuh91M07JzUlLyhU7V1+p7OMKjiBHXSrTPeXh/wsXDEaeFQxnciz7Y/M/Ib2OJS20/qdSzxkJqRoSkGMhSaIj+dIIoF0Z59tPvnTBL/T60kTvpjsSOZ/wbFQY4bjwKVfQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/coverage_tests-ddd80a8408b1f36e64f0d0b88519e1b1-c2f3a.png" srcset="/static/coverage_tests-ddd80a8408b1f36e64f0d0b88519e1b1-40c67.png 163w, /static/coverage_tests-ddd80a8408b1f36e64f0d0b88519e1b1-5088c.png 325w, /static/coverage_tests-ddd80a8408b1f36e64f0d0b88519e1b1-c2f3a.png 570w" sizes="(max-width: 570px) 100vw, 570px" /> </span> </span> </p> <p>Much better this time. We have covered must of the code except for some minor edge cases and failures.</p> <p>Running this scenario on the local Ganache a couple of times shows that victim funds have depleted by 4 ether and the owner account balance has increased by the same amount.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 37.58782201405152%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABEUlEQVQoz4WR6W7CQAyE8/4PSAXkvu9s7gCtBs9CokWt1B8jx+PI/jKxyizBoBqotkLf1VqqrXW/e5yzzqNCWxfI0whj30rf47bOoumQlUQ+0jhA6NtIQg+xKPRsBO4VvnNBFDjIklDP6jJDW+X6fXo8+H1fcd/mQxYvTkOn9bqq9GX2fDZn6zzoJVWRYpn6D7KD8EXnwCeRiISkJmX09llJzEUEIG2RRXrp47Z8EvIzeH0n4Utmv1PS25YRqhHCPNE++1+EJGFWwZuIgZOYPmscugdp15RCmEuurhDG/xD23UFlkpk5mhnS/ytHy7l8wT6f4Nlnobzq62aNpZKO80b+cC3L2KeSM5f/PDZNRlLqCenQWkWYcy3hAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/balance_simp_t_after-71c80c0eddc0476be9b3ab806d26e222-082a3.png" srcset="/static/balance_simp_t_after-71c80c0eddc0476be9b3ab806d26e222-59f9a.png 163w, /static/balance_simp_t_after-71c80c0eddc0476be9b3ab806d26e222-00530.png 325w, /static/balance_simp_t_after-71c80c0eddc0476be9b3ab806d26e222-082a3.png 650w, /static/balance_simp_t_after-71c80c0eddc0476be9b3ab806d26e222-cd061.png 854w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>You seeing a decrease of 4 and not 2, because I ran the scenario twice before taking this screenshot. Note that 0.33 ETH went missing. Gas prices on local Ganache are very high.</p> <p>So having completed the test, let’s see how can we exploit this</p> <p>Nothing from <a href="http://bit.ly/2AKVxKZ">standard bag of tricks</a> seems to work. Maybe the solution lies in the interaction of different pieces.</p> <p>Let’s look at the message flow chart again.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 63.79821958456973%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABrElEQVQ4y22TiW7DMAxD8/8/OqDrUsd3jlbj8+RiwFaAlQ+JpmhnMf32fbfWmv33e71e9nw+R+y9W6115IMQgp3nOfZLKYNjMQquyy5hFpJ0HoddijnnQdKVTKTo0N4UwXgCjuXQX1chaCJsmieRfD0edn8EKyLJUpZEUBSbYoIcQhSrrnp9F+kgHJvC3DyI2mRMUSNysNaKyB4x2paSVY1Zr74Hx0Jx5nQWtNF8TtylmDEKN3mUFLPyvkS4ipD5qBGoL4OQCaYKXZfA1RStBZSo3ajEsB/2KYJIF9gin0FGufKpY71MDzk1u4fIZ7xK0W1dbbvfrJZs3dffecL7ADphb3jIANOlqHh7UcqCLoY2o1DiZlUgBwu6W0MeXjcEYYfw07Kj+smcdts2+9BN0/JsC1uy8lD2VvunZS1iLuA0zE2/FG/4CDRHcRDGpcQ05sVfQ/qtcHiIkukhpCKL/v4g+ZTiTaTMZ070Z0NdESnkC++H2wyeTDvM30CRbhgLVvkKRr5w13rwWtY4cLm4JTf20Hj3h0489TQYT/ClgOxfSuJTVB1fyfiKNP4G3Gn2UtfIkOsAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-082a3.png" srcset="/static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-59f9a.png 163w, /static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-00530.png 325w, /static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-082a3.png 650w, /static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-dba21.png 975w, /static/uml_seq_exploit-a48958857b20d704fccdad1a37e68a6a-ea8e1.png 1011w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>If we can slip in our own Ransom contract with the amount set to zero, we should be able to get the key with paying 0 ether in ransom. Which means not paying it at all, except for a small amount used for the gas.</p> <p>We already saw that by modifying the Escrow contract we can set the ransom amount to 2 ether only. Let’s try setting it to something even lower, how about 0 wei. But first let’s try it in our simulation environment.</p> <p>Let’s make a new contract and call it ZeroRansom, by making a copy of a standard Ransom contract, and then modify it to demand zero Wei for the ransom.</p> <p><a href="http://bit.ly/2SZGAfa">Here</a> is the modification.</p> <p>Let’s give it a try.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 607px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 66.22734761120263%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABjElEQVQ4y42T6ZKCQAyEeRUvUFEGkEFFQO5jef/nyabjYhVYrv5IwQzwTac7GGEYku/7dDqdSCmXtA7IcRzabDZS6/Vaarwf99+VURQlFUVB5/OZsiyj+/1OVVVTXdeUJMkE/g3UqJuG2rYR4PV6lUrTVGDYOxwOE5WfoMZut6P9fk+maU5aXK1Wz3vLsqS+ad/QWkubeZ5zqxWVZUkNq+77nobhh7quJ9iSpon4/LFleATvAOi6TqDwD2vsR7cb6SAge9bFWyAeXi4XCQYVMwCKoTRjL5VS7GVI261Fy+XyBTCHGyZ7gyAAG8OI41jWURSR53mE0ToejwS/Rx/fhWQo15XW2rYVCNShdVHI+zgAQFgDtfgIAW3/QppDJeWEDQewKitRiTkEHLCE1SKwx4ymfM3Fgoi7GhVPWoaimoMoylJgCGQYBjlADuFnmEf8TQGHg4INWNu2/QqENzrU0hZehG8A+z5/5LlkcbIIY6zFYvG8x6zOf08Do+Ao5wHgU11XPV8cx+S/miv8BedNk4HgtFmKAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/with_zero_wei-1da36e42e45a03ee5acee5a2f970aac4-ed03d.png" srcset="/static/with_zero_wei-1da36e42e45a03ee5acee5a2f970aac4-82a22.png 163w, /static/with_zero_wei-1da36e42e45a03ee5acee5a2f970aac4-008b9.png 325w, /static/with_zero_wei-1da36e42e45a03ee5acee5a2f970aac4-ed03d.png 607w" sizes="(max-width: 607px) 100vw, 607px" /> </span> </span> </p> <p>It works! We have got the key by paying 0 WEI.</p> <p>Let’s look at the balances</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 49.156939040207526%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAAB3ElEQVQoz01QiU4aURSdb2nrAqGiAkbbJk37T01NTJFFxGiXxI9ramWHgWEbhpk3m4DHex6FdJIz555z33t3MU6zRzjJHOFtYg+f3mVxnNpH5iCJ08wBDlMJnOWOkdrfxcezLHLpJNLJHTm7i88fTvA+l8ah6L03rzQSO69h5C/Ocf71C0qFPO5/VHF3XcJNpYS7ahnVq6LEZZSLl/h5W9HebaWISrmA++9V/BLv5qqA4mVeo5D/BmMytTGwLETxExYrYPkMrP5hKT8h/VE//8fL1Rqb/OYzwsBHHIUgE0GgtrHvK0RhsNU6L56vPLhzB8pzxVtrIo4CGLWH32g8/oHZbaLVeERb0G3X0WnW0Kr/1Tlyr9NAv9tCt1WHY4+032s3MBr08BQpLGJf2Ifhew68+QzKnQnboGbsOlOtCWqCOSLwXQRqvo6ViyjwBErDqEsldjUwO9JFU8PqdzGyTPR77TWkM/o8w5hFmvUHmOLZE0t3togDDWM2HYGwxxYmo4HGVGJ6ZA3xxsO+XB7qPDtz7LEGJ4lDtYXRll11WjXd0VD2wQt8jA/QmwhvioxF81GOyx1b0jGLhaLZnd4hL3IsU0Yhc1x6m/Go6WvNvLCSnbM4C7IIC7A77vAFVXOu9DBzSLIAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ganache_after_0_wei-16aeb5cf16941a801f18adb1ac8c69f1-082a3.png" srcset="/static/ganache_after_0_wei-16aeb5cf16941a801f18adb1ac8c69f1-59f9a.png 163w, /static/ganache_after_0_wei-16aeb5cf16941a801f18adb1ac8c69f1-00530.png 325w, /static/ganache_after_0_wei-16aeb5cf16941a801f18adb1ac8c69f1-082a3.png 650w, /static/ganache_after_0_wei-16aeb5cf16941a801f18adb1ac8c69f1-bdb59.png 771w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Looks like everybody’s balance is still close to 100 ETH. Just some gas money was spent.</p> <p>So, if we can deploy this ‘improved’ contract instead of the standard escrow contract, we can recover the key without paying any money.</p> <p>Looks like Ransom contracts self-register on construction. It seems that all we need to do is just construct it with standard parameters.</p> <p>To explore our progress on the real block chain we will use our exploratory notebook we have developed for <a href="../codebreaker2018_task4/">Task 4</a>.</p> <p>Use <a href="http://bit.ly/2CkZKF6">this version</a> to run it on your own computer. Or you can use <a href="http://bit.ly/2D12FnY">this version</a> to run it on Google Collaboratory platform without downloading or installing anything.</p> <p>For that we need to set us up with <a href="http://bit.ly/2AKEJDy">Metamask wallet</a> and <a href="http://bit.ly/2QQ9Brw">Remix IDE</a>. We’ll use the Web version of Remix IDE.</p> <p>First follow instructions on the Challenge resources page to install Metmask client and connect it to the Challenge blockchain. Then click on <a href="http://bit.ly/2QQ9Brw">this link</a> to open Remix IDE.</p> <p>You will see something like this:</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 54.487632508833926%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsSAAALEgHS3X78AAACaklEQVQoz22SWU8aYRSGhwGVUeOFSkVRlGUYVnEDVFS0boiKshWUoLXWpWrXxLap1Sa9aZP+6KcHtC5JL56c+TL53u99zznKWGyWickUU8lFIc1kcoPhkQWCoTih8C3hSALDGEX3jdyiRzFCMbyCS4/gC44xEp8jPrOMYu+L0drmw2I1sHlrhGdu6A2fofXnUHs279jALNVszwr1cxbNmcXpX8IbWMQ/nCYgdPWMo7R3BFGUfhQRbDJyDCaP6Z0+QPUXhCKmRi1gMm5R6zVQwjyY5vnaAfun19SOr6gcfKG7Ly5adTHFgbk1gEXfoj9xiHf+BMWTRfVu/YcsJn0by+AqA6N5XFNV+oa38SRr6MmqaJmcDYeq5kcTJ474IbbYHtZQEVUuKiJiuqN+VuVRRWqzO0MyVWSzeEqh9pH5pQrNVvc/QQeqOLSKoP/5BaGVd7jnjrBNiHCwREugSLPENzcE649so+k57ANphlPnzJV+oofLONzZB8F65CZjC1uiRr/0sDexR3ukjOLauMWZEdYkrlzyrNOdOGC2+ovJ4g8ShRtmqr9J7f155FALoXmrdIaOxOElifw10/lvRNOX6AtviWQ+EVj5QKtRQ3WW6YjuMbR2iHv9CPfGMa7M6wYPDrUItsgR9ugJ04XvzJXrXBHLfmV88zOpnRtmKze0+15icuxgce+Kc3E7uPmUe4dtATpjh3TFj2mLVmiRoWiRF0JJVkX65kij9K1KXInvlb0M5LH48/Ivh/kRT4YyNH+BvvQe3/I53qUzjNULPItv6E2+kt7uy35Kje/zTL7bR3aln7L8PhmUL3fPX1EIVvD3i7T8AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/remix_ide_open-24d963cf08469d251a24278f62ae6566-082a3.png" srcset="/static/remix_ide_open-24d963cf08469d251a24278f62ae6566-59f9a.png 163w, /static/remix_ide_open-24d963cf08469d251a24278f62ae6566-00530.png 325w, /static/remix_ide_open-24d963cf08469d251a24278f62ae6566-082a3.png 650w, /static/remix_ide_open-24d963cf08469d251a24278f62ae6566-dba21.png 975w, /static/remix_ide_open-24d963cf08469d251a24278f62ae6566-1823f.png 1300w, /static/remix_ide_open-24d963cf08469d251a24278f62ae6566-a2c7e.png 1415w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Click on a button pointed by the arrow to upload the provided contracts to the IDE storage.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 412px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 83.25242718446603%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAADTElEQVQ4y5WS7VNaRxSHLyIvCqgkaooSvChwgYtIgBEB5V0U5FV8j5MmzpDJtM1o2iTaaZ1Opx/ayT/99HDjJGam7aQffrNnz+4++ztnVylUamRyWyTXs2wWK5S3d0ikMxSrdZrtPrXdPUPNTp/dvQ79g2MarR71ZpsdmedLNXLF6p0qKLlC2ThcqtVl3CYvyexmkUJlm1K1bqyN4mq9YezJbhWNXHl719DoTHarRCqTM6RsbJap1Ftye49275B6o0N6Y1M2lcXhvrhri5uOsd7sDMjki+JKLqs1JN818hv5MpqeQF9LoXi8aeYfJZhfSGJzhJiaDjPzICbScbhCTLujKIpH5iGcLh+umU18K0MW1ef4AheshIcEIi9Rg0O8/guUSYeGYvbjcQXxOpdRLAFsNtFEEKuMVtsyZouOxd7DOtHF5nxOOPEnTzIfSKx/IC4axaupv5hduEFxTen4AwWiWpGalsZlXhRH3js9Fi1gcaxh8RxhFi3E3xLN/IEn9h5v/Gf8yVvmom/5Jv2OUOEWZWJSY0nNsRwqMfsoSdDhY86uGjDTmM8AjzvFYXAHm9ZAzb8k27olWnmD3nhDanCNvnfFXP4FjuSZOJzWSaT25Msc3Tl6TGhKZd6+JPEIuCjAGOaVNpPhgYxdrNqAh/FznNFj3E9ODVm1fRS1Je0b90vzI/IYOmPmpU/QgEvFM6kaQIsAxwXoiA5QltvYIof4s6/Qcj+wtntF/uiaROuSqbUT2W8AFo1eGbHJ9wmqOlWcZi8mRwxL4CNwLNDBFOwJuEWscImW/55U70d2vv0NR+xQzo0A9/UF1IfpruSRwwmth2mlw5gAR4psvSZTuya+c0nu8D3u5NN/AN6Hmj73cPzOoUnA1og4FbhvfWi4XEhdEKi+ItG++hfgF04/Aq3BLu74iVGqM3ZCaOs7pmNnzGXOUYtD5tef4Yof/wfwnkOzQ8eu9XGvnRpAa/iA2cQzVotX6OXXFE5/oXnxOxsH774SOHIY6jI1arq/hV0/wBLpG7FJvpHib6PIaAp0vxaoYwv1mBmVJA4t8g89qRe4V5/Kyx7xIHXGw/Q5s6L/WbL00L/H9OoZtY6UuH1Dcvcnivu/ku/eEGte8jdP0PcaJzOa2QAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screeen" title="" src="/static/upload_contracts-4cec6fae82c8477ac18ce4f3dd3cacd0-77b70.png" srcset="/static/upload_contracts-4cec6fae82c8477ac18ce4f3dd3cacd0-a6449.png 163w, /static/upload_contracts-4cec6fae82c8477ac18ce4f3dd3cacd0-17fc1.png 325w, /static/upload_contracts-4cec6fae82c8477ac18ce4f3dd3cacd0-77b70.png 412w" sizes="(max-width: 412px) 100vw, 412px" /> </span> </span> </p> <p>Upload all the contracts Ransom, Escrow, ZeroRansom and Registry. Then make sure that the version of solidity compiler used by IDE actually matches the versions that our contracts are written in.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 477px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 43.39622641509434%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABnElEQVQoz4WQ0VMSURSHL2CmsoAmqIwIAsHayq7oAuWkk9qDOamRjdgqoEHT1EjWNDw1g9lf/nXu0vTSjDx8c869Z+/vfnvVTOIE2/1NuXbLxrM7H9sdYNo/yeT7jD+soNSisCxkRhObuyFr3rFUGLBs/iJdvCVtSv9kQHihj5rqEDLaBI1LAkJwBCpR/Ux2u0+i2mOh9o242yO+ec38ixusnS/Mrl+h7I8E7C4hZzQqVemwstUjVm6Q2vXI77dY2vGYf+6RLB2Tsw7IrR4QKR6iHh8TFAL3oFLuMDBcOiXzsklhv01yyyO92yRcPkPl60wW3xAz9YE6wcL9qPGVd0TXW0yV3hNda4ppi7DtYTgXRJxzxopvxazuMyrMD1ysfMDZ+0Fh+xrr1Vec19/lPduEJOiBeSKG8hv5o2HN/a3/OPp/T2UPGRPLmY22bzm5esaE1ZDa8E2j5aZfNZG1c39uiPmEdSrrC39uOMO5Pqf0DdrmkXtJotZlVoynJdxfVzvEheTmJ9m/Yu5pV77p+EzLM+mZ7rWM7vUFfwCNNha2LmtG/AAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/contract_sol_source-0d50c36d1e30a1964b596fd0dfbd5270-858e0.png" srcset="/static/contract_sol_source-0d50c36d1e30a1964b596fd0dfbd5270-ac85c.png 163w, /static/contract_sol_source-0d50c36d1e30a1964b596fd0dfbd5270-8def3.png 325w, /static/contract_sol_source-0d50c36d1e30a1964b596fd0dfbd5270-858e0.png 477w" sizes="(max-width: 477px) 100vw, 477px" /> </span> </span> </p> <p>Click on this button here.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 504px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 70.63492063492063%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAADSklEQVQ4y22S60+bZRiHn1IGPdJyKAVWCu3bQoFCC5SeGDBPUeakUAGBAeKYUCJjgCZLPGzJlqgZiDBZZxANTBZnzETj/KQf5ieT/VOXd1/w8MEPV3533vt5nvd3H5Qn9j5a701qItex+texaDmM9jbMjnasFdETyiOYnR26WoQyVzf2yk5s/8mb5HyxpQWlmsdQTaOokGjrBNboDGdsbVS5ongb0zQU8PVytj7JWW9SV63pPPUNSSGFT+tDCw7grunCWBJAFQUyGIWiwBAGUVv4DdSZIJnsArt7j/gs/5Cte0d8svU1O/cfsrFzwN7hMY9/fSr8QTw1LK7KhTqKTUF5MDjMv4xgbZ/AYAqRTA4xPrPO4qUl5ufWmJB4bPKqztTsOjNvvUdu+Qat4ZewO9pwOtsosTSjCq6UuFPaCea2cb3k6toY9e4ozeUBXO4uGvy92MrkYmUHjvJ2bI5WvR1V1V14GtLUeRKUWkOokpZRCphax7GIO0d0Wj4GefHybW4d/MY7R8+Y33vK+Mc/ML31i/CEyTvHTAlz+d/JHf7J0rfPmNz4CYszgiqTITi7ZnF2zlCduEJF95uYbS2kwwOE4q+j9YwS7BHtHiHQndX5Ow5KTotl8UvsDb964lA7v0h18m15bJ66dI663iWKzZJQLsEplJ3i+B/sglv65hP1YbC0olyxaRnEpO6wIjZHWWSaxvAFLl+9Re7dT1m/cZe1D7d1Vj/4/CT+aEfX67fz9L88h0V20eVJYSjVhzKM8XTKxuYsRVqGaDzDna19tvNHfHP0M/sPjtk//PGf+KuDx+T3v+fBoydkx5YwmYPUyhANhnpU+Wn/7JEpvZdV4lIpSSjbaUlmveTnV3Z5YTXPxZvfURMaxFKq6ecqq6IEmp6TaXee3HNL/2oEz7klalILojlUsR9l9Io26hhKfPgTYwTSkzQPzOKojWOyNsneCaIme0iWuvADD8oeuUSluHLF57F3TOFKLuBLXCOYXCMg6JpYxRtZxNuxSH34Cr7uZfw9K2jxa/gFX2wZLSFnU+uoQpluWZe69CK1KXHav0J8cJPUK5skhdRgQTfovbitx6kLm/Rl7nFu6Athl74hiV+7S//wlwyM3OcvcFfeI7y31BsAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/set_sol_version-4b7558c3193295c118663d481202ccec-13662.png" srcset="/static/set_sol_version-4b7558c3193295c118663d481202ccec-04233.png 163w, /static/set_sol_version-4b7558c3193295c118663d481202ccec-a96f0.png 325w, /static/set_sol_version-4b7558c3193295c118663d481202ccec-13662.png 504w" sizes="(max-width: 504px) 100vw, 504px" /> </span> </span> </p> <p>And select correct version 0.4.24. You need to do this because Solidity is a very rapidly evolving platform, the language itself changes almost every month, to the point that it source code could quickly become unparsable by the current compilers.</p> <p>Open all the four contracts you just have uploaded in the tabs by clicking on their filenames and then once all of them are opened press (ctrl-s / cmd-s) to compile.</p> <p>If it worked correctly you should see something like this.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 398px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 124.12060301507537%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAZCAYAAAAxFw7TAAAACXBIWXMAAAsSAAALEgHS3X78AAAEJ0lEQVQ4y62U21NbVRSHd0IESyslEGgCVAiRpECAQAJJSCiQAuEa7gKaEEAuItWWJFxLw+UYaAIlnUKh4Mg442gd3/Q/8EH7pE+OzuiTTzqIM211Kg/O/Nzn5EC5jnb04Tvf2metvbL3zp5DBOc1OCvORo17DW2+T9Ey+xFeZR7ANvYeql33UDe6SdlAjWsNNZ511I5soH7yfbTOPeBrP0HD1AeISTRCcE4NIozKwZnINISFpUAouIgw4cucRaIUipw3zwvPxmwNIUmURM7hEQoI2YYkVk8fKbSzAkRAIakHkJ8Sp3K1grNquqqs0MrOpINEa+l7iQEZugbor3Qiv9QOU0V3CGs3zJVvUHo4m6jZd2zObO2B3uJAhDgXoqhszoJItqEORBStwYcff4aHX3+Hh998j53fd7Hzxy5+ffIUP+882ueX3x5j+8mf2H78FI92/8K3P/6ES+mlUKqKkaetQeSLdNXhSrr6l3IgFqshS9LjgkwHSXwuYuM0kF40QG1qR6axlbNK1whZYgGkCfmIl2m5WBSu4M+RP8vITLrlKA0dSCkyHvaQxYiVW3Dzi230b30J9+c/oG/rKyQlFyJdXY7omCwky83IzKlCrq4OqowyrqmAbUgiM+gjjm8m5YmHQJSMeEUJJPIi6mKIkwxHfngvTuCRgESk0XPMeA0J2d2QZnVBtkd2F6TqTsSmtUGibIckjaLqoDXOQ3XcWB2C7RFDe5HMcgam2jswVN+GoWoJeoqxZhn6ygBMtrso3MtRjNXLXM7A1QRpLsjFbK6keRPqK16QDMssvRLLKCi7BX1FAIaKRejL/TBYF7mxvsIPbSmDItsaihs3UdywcYzL9fdhadqChtaSC/oBKMvGoLB4oCillLh5PEgtcXExZzZXOoJXKMft4XokFl4FMQ2MonmWQd2kF43TDJqZeR4fWo54n7njbmHoLt70gFjenkLHu7fQNMWg3eeHYykIe2AZ9sV/IHDQQTgCSyh7ZxIk2dqH/C4P8hxu5L4+jJyOa9B0XD/ROZxPyLVfg5bOT7O9BVLpmYFzMYC2GQbOpSX03ltF78pKiNVTWDlgLqZz7gZR5b4Bwq7K6vLCcnUS5ddvwuqeRoVrOuQjHModMEvVyAwKutwglxqHUDx0A6b+cZgHxqnHeI8fsrmf54QcO+fy4ATUrfRfrp1g0HN7Efb5BXT6/RhYX8Xg5joGN9b+PWz9/RXYxqdBUqv7UdDtgbbTDR2FtdbheoY95LxTHIqH6XY9UDUMgRh7R9Hk9aF2bAZ1E7OwTc7R+zjP0cT7JJqmFw6MF+jYB1MfvYflw17Y/QG0eBm0UtpmfXAG76DrOekOBlHpngI5l9eO+CIn4szOfUsKHc9FrNFO53XifD792hBFPYjc9v+QSnsJlY0QqijK/wjf4293OcRxtnT5UgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/compiled_source-b7d9022234cd6a9368968da3be29934b-80aa5.png" srcset="/static/compiled_source-b7d9022234cd6a9368968da3be29934b-efb04.png 163w, /static/compiled_source-b7d9022234cd6a9368968da3be29934b-7b959.png 325w, /static/compiled_source-b7d9022234cd6a9368968da3be29934b-80aa5.png 398w" sizes="(max-width: 398px) 100vw, 398px" /> </span> </span> </p> <p>Now, let’s try to talk to the existing contacts. Switch to the run tub of the IDE by selecting ‘Run’ item in the top right menu.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 514px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 142.6070038910506%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAdCAYAAACqhkzFAAAACXBIWXMAAAsSAAALEgHS3X78AAAEqElEQVRIx62VyU9bVxTGn43BI2CMZ3jYfh7BGNsYbMDGhKQkJYwODlMcptCmBChDGFoWUdW0iIpCAh0Y1DSEKmqkSB2VZNNsqm4qddFV1f/m67nPWGXTRUIXP59zbb3P5537nXs5hbwWKmUd5BSlXABa43nYWybhaL2JUksMDmczJJoAqup6YbQnYRLOQahuh8HWjJqGNCzOVriCneC9bTA5WsCZwqvgo2swBlegcs6hwDEFWUkEUo0fNXwYJkMQytJayIsCUOlCUJYEUaivRaEhIuYaylW6MBTaIPLUfnCcNw3OQ/iyyIMZFOgi4M0hNFQlYaV/FTytqBCSWZxJOH0XIHjPi2unmyp2JWG2RCCTu8BJXd2QunpEJEIXFP5+cKoA2lv7sX/8HJsPnuHew+fY2P8B218/w+bhT/jy25d4+suf+PG3v3ExvUhVFRJWEnSToLsXOSQkmu8fgLo4iLbom+geXEBbxyS60rPoHZhD99VZtPdO0XoGqaF5XJt4HzWRHmi1fugNIchVXhJ2doOjKsXo6IS08ioc5jCcfB2MZTFoiv0wWOpgExIwmCMoMYRPCKHCEYfJGkW50AwbtUKhqQSnpFcsqEyDRXVgCLpwBnxpNerSK1j4/i9MP/4DU9/8jsFPvsP1nRcY2X2BzNbPyNx7hvG9l+Lvt4jJr35FkSkKThcZRXH4uoghOiGi0IZQao2hwt8OvvIS+KpLKPddFOErc/z7vcXzBiyuC9kKzY1vwdz4NoyxG7A23UR5chqSknrqhZ7QEcUnsLyU0J6iiDCDy3OCkwi0mWQbTc0wGIXBa1RlBuqaaxBCPZhd3sDqh1/g4/vHInc2DrD6wQ4+2j7C3e2HxBG29p+gL7MIDfnTVBGHTOkjcU8KOaRuso47BVfgMpZW13Hn7ufY2j3C5s5DfLr7CJufHWPn4ImYr28eYnfvMa4OzUKhcMFoDEMms4MrqR2BLjIGLetjKAN9bBISZRW9ioLQEEpCjsaxdVxee4Seu09hjw5CpRBE7+lJyOU5B2sZaxMPjvWO9bE8MQUTiVkp5mvDVLodEnK+lJAUOGHy0kaEe2GL9KHI2oB88ly+2puNRJ6SmZoqZJWxKtnusgqLKPe2vAdffBW+BGNFjK76eQiRd+GonYE7tghP0xKxDG/TCtyNt+GNr6AquQYua5UbKIu/A775FswUG7ruI3F5G/ETmtq3kOjcQbyDrbfQmjrAud49Yl/MWyhvTR3iQvoB6+EoSuvGRPT14zCRhfj4AviG+VPMiZTHstEeX4Y9sSxGW3xJzFm0Nd0GJ6dRU9L8siiniVGThWQUOaGDRrKLRvIUrhOcnf+N+CF0Zh9wdCCfxBTVg2QfOjA8V4jUK8Epq4eRQ+EfQmF4FPLqAaqk55XFREGZegY58hTTUBpmzyYosQwhB2capCtg5GyCUh89eALn7YI80H9GQTeb4SxMRM52/EyCpxf/hyCzRw52FRScVVDmuwKZr4/81weZNyV6kFX52oLmxnFYmiZQlqATOz4BXf0oCqr6xRvwtQT10RFYSIiJFofZ2NEIUpWvXaEqOARNaBhqQllDBycdYWfp4T9czqJzJDsE3AAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/go_run_tab-d85633f033300941db713369be0e56a6-1d31c.png" srcset="/static/go_run_tab-d85633f033300941db713369be0e56a6-816d2.png 163w, /static/go_run_tab-d85633f033300941db713369be0e56a6-4d5a3.png 325w, /static/go_run_tab-d85633f033300941db713369be0e56a6-1d31c.png 514w" sizes="(max-width: 514px) 100vw, 514px" /> </span> </span> </p> <p>We will not be deploying our contracts to the blockchain, rather we’ll attach newly compiled code to the already deployed contracts. For that we need contract addresses.<br> We can get Escrow and Ransom addresses from the ransom note left to us by the attackers. To attach to the Escrow, select it from the list of contracts and then enter the address next to the ‘At address’ button. Once done click on the green ‘At address’ button to make an attachment.</p> <p>Do the same for the Ransom contract using the address given in the ransom note We are not given the address of the registry, but it can be easily found via our exploratory notebook.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 13.247863247863249%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAArklEQVQI1z2N22rCUBBF8539rz4L/QB/oVDRhz6K+lIULJhzm5xLlJhUzHKIxYE1mw0ze1fdH+TDN3bxTvr5QmLGWoP3XtWRSyK3BSmFppwRWWHMh96tcfFMbDPDMND3/aTV7QZmP2f7+cbvboY0hbo+aZidkEYIIhoQlYRzG0JYkvKRqAWlbem67kU1XgrX60AdEtbrYwhTkDFm0uCf3qr3zmmZ537nf8bnHscXD7dw4Q4cHFVjAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/registry_addr-154fb8e260481433d05712235b604dd3-082a3.png" srcset="/static/registry_addr-154fb8e260481433d05712235b604dd3-59f9a.png 163w, /static/registry_addr-154fb8e260481433d05712235b604dd3-00530.png 325w, /static/registry_addr-154fb8e260481433d05712235b604dd3-082a3.png 650w, /static/registry_addr-154fb8e260481433d05712235b604dd3-bc8ae.png 702w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>If you did everything correctly, you should see something like this.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 461px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 129.71800433839476%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAYAAAC3g3x9AAAACXBIWXMAAAsSAAALEgHS3X78AAAFoElEQVRIx6WV2VdTVxTGL6NCpWqYEsaEEIKoVIaARCxzEGoRBAEZBBlUJhEHBqdVHCuKgIi2la4uBQKEKYQ5ICIqOIFaUakvXX3sX/F13xO0aNdqH/rwy9735Ox9vrPPPvdyGxTxsJdFYo1vOkRb88HZB8Nz03aI3EJhae2L9f4JsLJTQLoxBut842DtpISXXzxsXYLhLI+E9+YkWAp8wHGuUGzZCc7YyhvcFxvAWXjB0i4QTp7RcJSr4OARBREt5CCPYj6Pi9c2CGUR9H8UVgk3szg+nuUwlkGhyiFB9j6Qum+FUOSH5NQi6Ean0aUdR0fPGIYnZvDs1/eYfPAMo3cfYmxyBkP6aTyeX0BichmpWg1jI2cGx1lDEZYOTmC7CS4SJdZaeyMxtRiDE7PoGboPTf9d9AxOoUs3CXWPHupePTq0E9CNPcLF2mZIpF/D1MwNnJELjE3ElNAOivAMcLb2vnD3CMVKCxm+TdiHwfEZdLLAhxii5LztJ/iFdPpHGJ58gp9btPD2iaEkjksJXcm3NSS0sfOF2G0rDTgjNi4XY1PPmLrppwuYebGIR/PvmL03+woPnr9h44t//ImMvUcpZi1MTCWfKhSLlXBxDqCBNYiLz8Pz1+/x5OUiZuffYnbuDR6/eIepmTmcPV+PX1q1GL//FK8Wf0dqWglTZWYmhrmZ+O8acpyEfpwIB3ArPOlkI2AvDYNQGs6wJ0TuEbASBsJWHAKhezideKShM0gVx4kMsdQ2AdF0ysFRWUjfdwqpuceRX3YRWUXV/6SwGjkHzyG7+Ayyl57zyy6gsPwyCo7VoKSyFgJHJTaF0pYz9pShhk7tEtHWOYQ2zTDU3aNo6xqBumv0o99C//G08tCcOx2DuN0+wOBbTOIWjI3KJHDpVd+jZuQeym7cwclOHRr6RtDW0oWODi3U6l60tnajs7MfOp0eAwPjGNAtQX5f3yj0+vtI3V1EW7ZAIO2W81buQHRaIbbtLkRkygHEJu/Hzp35SEraj8TEfYykXQeQSk2/nJSUQmRklqKo+BSClAmUUICAiExwjuu3wzM0FxvCciBVZsIvMheqmD0IV2UywqIyEBqZjpCINOaHRRl8VWw2nFyDmDKOE7ID8ufbJrzgCvKap5F0th1p9cM4rX6I9m7aNtWunWrTSvXja8bT0UdXspfGNCPoH32ArNxylszcnG4MZwN/vm2EPrvg4JcCEWHjnQj+2c4nGSbiaJJP7eG0DMflRDBr5BpNc7fRSyEcQfEHwXmE5UFGW5YEZ0G8JQv8s1twNizkO2AkjoHxvyGJZZi4xVJyFfy/KQAnclRA7hkGF3EQO3qZRwjrfv4WGJpWtFSjD4g+Q8jutEDgDUfPcHBfrtkIO5ECAhsfCGx9yA/AasFXsFhF70crL1hY8Xb9R/jxlZaejBUMOSxXrYORqRRO66gMmWWNuD7wG2o1L3G16yVO3ZxgnP5hAlXX6JDIP35tBCebxnDi+hiqm6fQ0LuAup7XaOpfQGMfWYrPLGuiaxsCLjq5AkdqelF8pg0l59qRW/ET9h67+YnNPnKD+dlHbyCv6habV3JWjdLz7ThI9vClbqiSqyCicnEZpQ24pn2LmvbnuNwxx1RVkSLeHrnch8qGIRymBSvqB1F+VYcTTXpc6Zxncxu651GnmUM9qd1d0mBQqNpVjtILGhScvo3C71qQV3mLqeKV8Da/qhk5FT8yP7eSH29m83iKq3l7B4conimUhVINSWHTwCJqadWrmheorBtAeW0/qkjZUVJ2onEEhy5qmLryWi1OXh9FXTfVm2re2PuKVJLVvkHaB4WcKXW5CY+EWeMVHkvIYLLyg5Ubxvhnc9nHuQYrgZGZlBKJ4eQVRZ8Ed2rgZXDSuP/k8xhjGcVJ4uAcmEyfU48E/F9M5PSBl8ZTwhT8BTztHfY0FYE0AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/attached_ctr-5465490b487c6b666510d445d2a01ef7-48bac.png" srcset="/static/attached_ctr-5465490b487c6b666510d445d2a01ef7-c91ed.png 163w, /static/attached_ctr-5465490b487c6b666510d445d2a01ef7-80a13.png 325w, /static/attached_ctr-5465490b487c6b666510d445d2a01ef7-48bac.png 461w" sizes="(max-width: 461px) 100vw, 461px" /> </span> </span> </p> <p>To verify that we have attached to the correct contracts try invoking some of the contract’s methods. To invoke a method, expand the contract by clicking a small triangle button on the left side. Then select the name of the method you want to invoke, if required enter parameter values, then click on the method name to invoke it.</p> <p>Here is an example of a method invocation:</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 453px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 160.04415011037528%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAYAAAASYli2AAAACXBIWXMAAAsSAAALEgHS3X78AAAGFklEQVRIx6WWfVCU1xXG310W5CPAwrILC7vAIgsLC8LyaQiVj2CDIBqjphAT40eJIWobianRVhHkayokQY0xhCgKSNToOKPJtEJkAUMbURFJ08mknc7UJjWdyXQSk/z7633fd7vZzHQyOv3jmefcc889e59z73vPSrWNzbx+5Sod53/HwbEpdrx5EkmKRdLE3x8kC1KgA2nD7m6GP/4LPZcmOTY9R9vpd/+/hCsbd9PtdvOrE8Psu/Ae23r7fzyhZP3xhMZNlaRcbMA+VE/K+Qas3bXqIm08Gm3C98Hyjwj2+nwh++Q1ckJdTCoBaZn42dLQpTjxszo8i+MEzEoCY3QuySml6CMzhS/GMxfrAzVWmpcqWDis5kJcWVVkZVSStWAJ2bnVAkvJyqkiN7+GouJVLCqrZeFDK8lyVeFS5gVyqr12jkCoMU9OGI9OSiJAm+xFYIhDQdADDnTzkrHaiikUyUJC05kXnOqd/wGCU9CGOJGC013oHykhvKyY8PJiQoseRKtLQuufhMZfZd08OwFBYkHAfGWs9f8ve2zh95Pjg9ORDBsWM//cz0nofQrb0HosnauVAmvEoWj9EtB4D0UciEb1y7ZWPjRNvOJT5701tGAMyiY7pYq0+HLsllIyXNUUCIm5hStYkCNqmVeDq2C5wtn5y8gU83kLV4iYVWSKOsplkHeolXcYVlpE9OYaotZVYtpUjWF1hdiZR44uyUda0g9l+oz9fCVH1JVhE3ITu+tIPLSGmB3LfK7C/cAr2YxByiTVuAhrcAHBUrJSZP9AO7r7gbgNyilH1JQQ1/o4UVuqiN75KKaGaiHZpki4dwjJOpsqWb+ihPmH1pLUUov9lbXENi5TJSindw/QWH2+ZUWyiRAh0xKRh1WfL2y7Wg/PVVHrY/UZe67I/0JQGlLJsq1s6zrHM03HaWgZZP1LvazbfoQNO3pZ2/gaG196kyefP8jTLxxm3YtHFDzXPMiWfcNsbR3m+fZhtrS+Tf2uPiLjS5CqnthF16nrtPZP0jn4B17Yf5aGPSfY1nGaLS1DCm/eO6DYWwVkbjoySkufm319Y7QfddMs7MbOM0QlliEt37SD1jMXaHztGI2Hj3Po4giTE1NcvjyB2/0BY5cnmRifUtjtvoJ77AqjI27eHx3n0u8vC/8E7707gsm4AMlvPtL6PV2cv/05vVPXOPnnTzk4MkF5+c+oWPyEQJ2HBSrqeNgD2ZZ9sr34p2soK68lMDBZvYdrXmxj6E+f0HVxlL6rN0ULuIDdvohURymOtDKVHSqnpZfjdFaQ7nzYC2dGhYgrR6dLVBNubHmFk598ypGpad6YnuHCX//GF3e+4B+ffc4dwZ8JlnH777f58st/c/fuN3z99V0FX311l2+//Y5/3vkX8fGFQrLY5dPbOzk6PsOr58c4cHGSQfd1xsY+YPT9SS6NjDM6OsGHH85w7dotpqdnmb42q7LAVaHo+o053ON/xGzOFc+/uHLOXz7JkkudlJ/czUNDO1k/eohbNz8SC2eYmbml4MaNWWZnP+Km8N+4PqvwzM054b/F3NzHXBXK4uLyRUKxw8BFuUT9ohLrpqWYnqsk5zdr2f/bw7S1H6Cj4wDtHQfZ1/oqbW2q3dzczd693WK+R/h6aGrqYvPmXUToxXfsb1ffwwhNBinmUmyRRZgfyMMQnUe4wUVoRBZhkdnoo3IICs1QxuGGbGE7Vb+ICQiWm5oeuZUoj4OhtgJLVx3GncvR/7qG/J4GBgbO0nd0mOMnznB84B2O9Z9WuF+Mjx47JVj4ZLv/FAND5zgxeJY460L1lEOK8rA8uxRHw2psDcsp2rVRSBXSWl6mXciUpTY3v6zKFmXY07TfO25t7VHs+vrthIWmfi853M9JkvknWCMXEhOWR1RMPgaBqBiPLfqyPDbFFhBpylVgii1UxvqobOVB1ojnS5FsemYJSWfqie5+nLi3nsLY8pjakESA5JeoQOOBatsUeOdEnPwYe1tAkMuFZV0Vjo0rcTy7CueGVYQEp3r/etwbfFqARkogLDADS8yDmA0FJMQVE2F0icaTjL/oxf6B9wAlzq5I/g9rYmtxnmE4twAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/invoke_method-f221f8134fbb8fd5a4732e1d84a9edda-a6d6e.png" srcset="/static/invoke_method-f221f8134fbb8fd5a4732e1d84a9edda-15e3f.png 163w, /static/invoke_method-f221f8134fbb8fd5a4732e1d84a9edda-daecb.png 325w, /static/invoke_method-f221f8134fbb8fd5a4732e1d84a9edda-a6d6e.png 453w" sizes="(max-width: 453px) 100vw, 453px" /> </span> </span> </p> <p>Note that the Escrow contract doesn’t have any executable methods open to the public except for the payRansom which requires payment.</p> <p>Let’s try to deploy our ‘patched’ version of the ransom contract.</p> <p>To deploy, it first select ZeroRansom contract from contract list, then expand the Deploy dialog, and then enter the parameters for the contract’s constructor.</p> <ul> <li>Use the <em>victim_id</em> from the ransom note</li> <li>For the encryption key use the one you got by solving <a href="../codebreaker2018_task2/">task 2</a></li> <li><em>victim_adrress</em> comes from the ransom note as well</li> <li>the registry address comes from the exploratory notebook shown above</li> <li>Now the only parameter left is authToken. Let’s use the information given to us in <a href="../codebreaker2018_task3/">task 3</a></li> </ul> <p>You should get something like this:</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 450px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 69.33333333333334%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAAC2UlEQVQ4y5WU2U9TQRTGL7SFLizFIihhsUArDZsIxo3IA4tBxGDwARJFFOHFxAcxgEbqA0IispbElAI+YCmlpQutFMJOVRBoRDTx3/k8M624vKgPv5wzM+d897t3Zq4gSLMhSLIgROiCMVwDQcggMv+PMA0kqiIIFdX30P/KAn2PEV19Exh948H03BrMzhVMuf6O2bmMGe8Geg2TSEy9AKGgsAot9/Wov/UQjc0deNDajUdPXqK1oxetj/+Bjhe8vqGpDdHKHHIrpCAuoRC63MsIE6fThIIQE5JQ/BPJL2s/IvWEqyGSnoQgjtQgPqEAOXkVEInVKC2rg8lkxsDAKIaHxzBimIBheBxDQ2PBOGii3ASDYZxqjDAaJ1FcfJ2+YRoi5LQHYqkGMkUWjiXRBxWSUFPThIWFVdjtXrhcPrjdC3A43vKcYbd7DscsLi1toKy8nvdKmKCIHMqjdEhNO0+Txw8FbTYPZkmUCbjdPjid83AR7EEOikzMZpvjteUhwUOHyiN5UKcXQyRJR/W1O/D5VjE97eJNVquLcidvZmL2WS9mZub4Ay0WJ/zvdnCl6jY3wwUlMi3i4vORknqOC16tboTXu8SLrVY3F56acnBRNmZibI5FM837/R9RWdnwu2BSylmcUF+ElHL2yvPzK9wRE2AOLRYHF5kld8yZzR7EOuPG7u5nequ7PwXFUi3t8mlkZF4CO0K1tS3Y3NzCxuY2AoEvvGFvj3HA852dfWxvBbCx9gHrq+/xKXCA8tI66k1EhCLkkG1KrJKuoJCMojNVaG/v4eifDaBT3w898bSzD13PDejuHsGg4TWci+uYdi/Cs+zHzeY2iCIz6Rxqg4LMGbPMBAXhKBEdQhEiipCG1pORX3IDk1+/oce1iH46NhO7+0jRltBaGv0TFDrIlbmQRmdzZLE5UCjzgsSFoDyKojw2F7KYbMSoTkGVWAgV3TAWlTRmdczhdySeR53ZOFRSAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/deploy_ransom-e7b99facfc7828af9149125f4069a80b-68fa0.png" srcset="/static/deploy_ransom-e7b99facfc7828af9149125f4069a80b-650be.png 163w, /static/deploy_ransom-e7b99facfc7828af9149125f4069a80b-02245.png 325w, /static/deploy_ransom-e7b99facfc7828af9149125f4069a80b-68fa0.png 450w" sizes="(max-width: 450px) 100vw, 450px" /> </span> </span> </p> <p>Once you enter these parameters, press the green transact button Since contract deployment requires gas money, you get the metamask prompt asking for confirmation to spend $.20 for gas</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 376px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 159.30851063829786%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAYAAAASYli2AAAACXBIWXMAAAsSAAALEgHS3X78AAAEMElEQVRIx6VWW4scRRTuv+G7Lz4n4IssRpMHiUFRsxuN4IMP0SUuqPFBfBG8REVBVAiCYAh498Ef4AY06oqSTZY12bnPTs99erqnu6en792f51RNjzOT3dkNFvNR011VX53z1TmnS9F1HYZhgHvbtuG6LobDIbrdLjqdjoDW08Rzr9eDpmnwPA++7yMIgkk/Go2Qz+ehRFEoXoRhiCiKJsgmZwsyWJaNmqoK4k6nK9But+F6ATbXf4KCu2y+H6BS3SWSDiqVKlQir9VUYXW5WoXiejZula6Rqw656pAFlnA5SRKBOE5gmpawlKVh11gax6H5Y/C8NE1x63YOytDRcf36jzTBJJ00NBoN0koT1vAkhq4bwgIeY1JVraHVapNlNQHehFu9rkIJQ9YshR+ECEk7RkDvXM+H54/B+oVyPIpjJLRJzB6Me57P4+vrv0LxabLW16HWGwJN2rlB4D57ZwwGgjgI6aCCWchNAxA1Hjn1piR0yR2b9NONgVjMPaNPrvJmNmnqj63M+gySVBIeO3FRnvLmjZtYv3oVuVxu4to0phdPk80SJjh64gIU1qFcqRDpDRRLpTtcmsa+FhLSNMEDy69Ily17KFx06LTYooNI5gl9QRjj+Nk3oPDLPoVCu9MTMZW5mPWLLJ5GkhDhs2NCDlLbtkTAiucR5bMz2teqAy3Mlcr46+Y2/skVRUz1tD5alKMs9qEspNBhDY88ukrFgQLVDigbvBSmn5KrMnA5Q3hsBnOnHwm9Q4y8UGTKqRcuLigORHiYNiSu9jAR/59//VNJaJomlaM+BgNzJoenIedZKJE8nNN5itlWq4VCsYhyuSLGn1l7VxL2+31RSA0KncWEJgqFAqpUpvL5HJrNJra2tnB7Z0cSniOX00O6ttc8LrjNVkekKLenXxpbKOteLCvIAnBt5HmTTcZ9Mv5z5vw7kjBzKzmAkI0U9ZEkMvQ+nKFNvQ7LlFKdXXtPupwtOKjFcQSH6mTXsNDUTOiWg0ZvgLZui/EHz7wmLezRF42F5rhadCjddgt/bpewrSXYqI1Q1ENsNHz83fTF+NLpC7MuZwvnD0COSdViEiyIEtAPI9dDvUWf1748lNOrb995yvufeor5EfbIMrkGDKXLK3dh4V5SzLf7H1+TFv5fZAe6tDw+FCnQXvhPP9ZuL0SEMJaET734Fn0CRMjIXeJJ8E7HX3qIkJKbP3eeDoVrGd8UuMjyRSm7z/DHWxReukk4dG/5YtPAR39oAu//puGD3wnUf7xBz9d62LViPLT8MhRexBclbhz1XEnqdF/h6i3y1XPRtVwsfVnFvZ/kcfxKFU9+V8Nj30gc/byEez7cwc9VFw+vvAqFLcny0yFL+eqmU1px4nMLAw+a7eHk1zUcocUnv9rFyg8qnvi2huXvVRy7XMF9nxXwS93FudVL+Bcsk3N5jCO8xgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ask_for_gas-b5a452d1c35b38e7cb21af05fa341d61-014a6.png" srcset="/static/ask_for_gas-b5a452d1c35b38e7cb21af05fa341d61-2eb9b.png 163w, /static/ask_for_gas-b5a452d1c35b38e7cb21af05fa341d61-7e663.png 325w, /static/ask_for_gas-b5a452d1c35b38e7cb21af05fa341d61-014a6.png 376w" sizes="(max-width: 376px) 100vw, 376px" /> </span> </span> </p> <p>Press confirm, and wait a little bit. In a few seconds you should see notification from the metamask that the transaction has been completed. Click on the metamask icon in your browser extension bar, to confirm that our contract was deployed.</p> <p><img src="./confrim_deploy.png" alt="screen"></p> <p>You should also see a new ZeroRansom contract in the deployed contract list of Remix IDE. Now let’s try to interact with it.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 29.131886477462437%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABjUlEQVQY00WRQUsbQRiGJ7sbg9Ga1HVNs1iMZtW0GiHGaGsoNEVEJKCJukkT123VxBYUEUEtqJde6qGXovQgXnvrtfde+reefhsPHh5m3oF55v0YFX25SX/OZ7jYwnmzS/rdZ5KvPxCfqRMTBuYaxPN1ye8xxtcxnAp7X3/w7fcf2p++0GqfdTg4vKK9f456MtJCG/QYmjmisv+d8s51Z132rimsXNI8vsU7+Unt8JbI0B5he4vTu1/c/P2HUs+FhGALz4SkCKcbPM15WAUfe+Ej5qzHQMHDLu5Iqya903WhRk+2RsipoqfXyF7sUrw/oavbwTBGCHeNCmk0PYWK55sMvvKx5rdlvG2icjmademf3aJ7ykWfqKDSqyhnFU32xtgasbdFku4SZiKHaT1gJfJEezOoWK7REQUE0qBRIOzpiGsYmSqaSLTxCqGxB6G5WMJ2lwlJO6UNo4JmWoqQLjkmY5lzvhBIffok98kjwXlAZFJaitTIyIe82CA8UcUqlUi5ZfSIjGmMoocf+Q96ycKsVT15HgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-082a3.png" srcset="/static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-59f9a.png 163w, /static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-00530.png 325w, /static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-082a3.png 650w, /static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-dba21.png 975w, /static/interact_zero_ransom-4157e9ed9e82cf35f858376304ee1da5-84fa2.png 1198w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>There seems to be a problem. The contract doesn’t know its attached Escrow, it is not authenticated, and getDecryptionKey method just fails straight away. Calling ‘getRansomForVictim’ method of the registry contract gives the old contract address not the new one. This doesn’t seem right.</p> <p>Let’s use the exploratory notebook to check the state of the blockchain. More specifically let’s see the AuthEvents.</p> <p>Our AuthEvent was posted correctly.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 37.28350045578851%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABOElEQVQoz11R2W6DMBDk//+tSR6iNMHGJkDKZQgCAuZoprvO0apIo1mPl/Ee3jDOyPMCSisIKXA+nxHHMWk5six7cJohNSnyiuMURVG4u5Tirutwu93Q9z2GYYBn7YKqqnCJIpfI8UAJ0zTBWvvGZJ/nfzqbMNh0HEd46/cdIwm10lC+xHazRRgEaFt6uX+8zMyVuGpYJ34ZMdjoxR7o44pKKXHY73Hc7aA/NvD9I+JLgiAKoKMQX0kCQx101EFL4Ir+mv4argvqukZMs+OWG4obU6EsC5SmRN1UKAzpxmCmH+Z1xbIsmOfZwY3jOQZm725HXK/1exkJVRIRCyGgtXaQQrp71mOadUTgcxiGjnk5rwW5lnmTvu9DUtun08nFAc2Rcfg8OGZj8czhx5RSTmPDpmncrLnKHwTFDg683cUnAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-082a3.png" srcset="/static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-59f9a.png 163w, /static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-00530.png 325w, /static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-082a3.png 650w, /static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-dba21.png 975w, /static/nb_auth_events-0f175c719bbea03c22aadb197ffc5213-62368.png 1097w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>And this is the callback event coming from Oracle.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 34.26704014939309%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABDUlEQVQoz52R2W6DMBBF+f+fywtJpBAo+2J2byxuuB1D1UVJX2rpaK5Glj0+doSckKYp7v4dYRjulGWJqqpQ1zUYY0etGFhH9GzPtmexe4UQmKZpxzHLhJzlqPsGSqu9Oc8zlmX5F47iEsMwYOx7SCmhlYRZVhhjnljXFauxfOYXOOaxQTQNypsH1z3jfDqhznMM40gM6MceI2XOOTg9TRGSslIKWusn6MB3ZFGEq+vicr0g8AN45NN/8xHEAW6hhzAKkdEljLwK8sabFlIden4etjtcJ40kSXbsR7Rt+z3RyI9K2IkFadFCYqEn/+nwQU66rvv6sTiOkWUZcpqoKIpf2V4qyLNd27bh1foAdAYWa6hQotEAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-082a3.png" srcset="/static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-59f9a.png 163w, /static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-00530.png 325w, /static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-082a3.png 650w, /static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-dba21.png 975w, /static/oracle_cb_fail-822017086322bbde3d3272a183b04a2a-f3459.png 1071w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>The good news is that Oracle did respond to our attempt to register, the bad news is that it did not recognize it as valid registration.</p> <p>This is because the OTP value is time sensitive, and only valid within a very short period after it was generated. We need to find a way to generate them ourselves.</p> <h3>Side note</h3> <p>Querying events on the block chain could involve scanning every single block stored on the chain. You could get an overwhelming number of results or more likely the client will just drop your request if number of blocks is too large.</p> <p>In order to avoid this, we must limit the range of blocks we are scanning for the events. That’s what <code class="language-text">fromBlock</code> and <code class="language-text">toBlock</code> parameters are used for in the above examples. We always scan to the most recent block but we need to set the starting block to something mined not very long time ago.</p> <p>Use the exploratory notebook to find out the most recent block number.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 32.07282913165266%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAAA4UlEQVQY032QzY6EIBCEef8n8z43o8lOYuKIgIrNv1ID7HXdTr5AQnd1FSznjFrWWnRdh9fr1eCc46nqzBOsPLcm7x36vscwDBjHEdM0QQiBzzxDSol1XdsSIsJ/xa47I6QM5yPoPKG1hlIKooicxsAU56aeDYJzDjFGhBD+hEXrQFyADo2f9xvLskBtGwRfkHaJyxmklJDuu5DbvQo+we7S4I2FK8I1YnVXXRoy0HyGXRfE9YOoBKLeEb0vg8+i7EoXSO0gfbZ/2qq7IrzvB44S0/nwG5FOhE0iFPEg+WPkL/S70AGTnb0/AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/recent_block-69de18d5b2b62ace3f04bc71f5ff8188-082a3.png" srcset="/static/recent_block-69de18d5b2b62ace3f04bc71f5ff8188-59f9a.png 163w, /static/recent_block-69de18d5b2b62ace3f04bc71f5ff8188-00530.png 325w, /static/recent_block-69de18d5b2b62ace3f04bc71f5ff8188-082a3.png 650w, /static/recent_block-69de18d5b2b62ace3f04bc71f5ff8188-72ddd.png 714w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Then subtract a 1000 from this value and use the new value with the fromBlock parameter.</p> <p>So back to our task. </p> <h3>Making oracle accept ‘fake’ contracts</h3> <p>We need Oracle to accept deployment of our fake contracts. Looks like we cannot reuse old OTPs, probably because they expire quickly. We need to reverse engineer gen<em>otp function of libclient</em>crypt.so, so that we can generate the OTP values ourselves.</p> <p>I’ll skip the Radare part, it is very similar to what we did in <a href="../codebreaker2018_task2">Task 2</a>.</p> <p><a href="http://bit.ly/2RrPdCk">Here</a> is extracted code and test routines.</p> <p>To test the code we need to know a valid OTP code and the exact time it was generated We can get this information from the <code class="language-text">victim_identification</code> file given to us in <a href="../codebreaker2018_task3/">Task 3</a>.</p> <p>One small obstacle, the <code class="language-text">gen_otp</code> routine requires the timestamp value to be in epoch time format, not a human readable string. We’ll use the <a href="http://bit.ly/2FAoHPS">Epoch converter</a> web app to convert it. Once we have it we can run out test to validate the model</p> <p>Now we can try registering the the Ransom contract again. All we need is the current OTP.</p> <p>To get it let’s head over to the <a href="http://bit.ly/2FAoHPS">Epoch converter</a> site again and request a new timestamp for the time that is about 2-3 minutes from now. Since we don’t know at what time the OTP expires, lets use 35 for the seconds value to match the number that we saw in the <code class="language-text">victims_information</code> file.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 29.766803840877916%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAAA5klEQVQY042QW6uDMBCE/f+/TVBQFDX1TfASjUYbrbc52aXpeWwDw+yG8GV2vfu+Qee6LpznyU53JFf/euittywLhmHANE1o25Y1juOn77oOUkr7psfzaaAniWkQGHsBrR7WC6uHDfNiqGeMQV3XDCDQPM/sdE+J13WF1pqhxqxQqoVsMpaS4l3nOI83kFL4vv9RkiSI4xhlWaKqKv7IjU/6OrJSCkEQMCgMQ6RpijzPkWUZoiiCEAJFUbDok77veQ1NU9tpNGEs6H/XHhU0mhOl2Pcdx3GwqHY9Oa1g2zZ26l0yB/wDaa3LqgBmm7oAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/epoch_cvt-2c63e95ce4b1b6e460d6fd767e878417-082a3.png" srcset="/static/epoch_cvt-2c63e95ce4b1b6e460d6fd767e878417-59f9a.png 163w, /static/epoch_cvt-2c63e95ce4b1b6e460d6fd767e878417-00530.png 325w, /static/epoch_cvt-2c63e95ce4b1b6e460d6fd767e878417-082a3.png 650w, /static/epoch_cvt-2c63e95ce4b1b6e460d6fd767e878417-b127f.png 729w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Then we change our test to use this new timestamp value and run the model again.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 566px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 40.45936395759717%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABKklEQVQoz01RV7KEMAzLVegdAgFCG+oP97+Qn+W32dkPjewUWbbVaC1dz0PHddFxnoR8GAbq+55605NuNJnOkB0tjeMo52VZCuq6oTzLJS7ynMIwJHWx0MlC+77Tsiz0vq98bNuWuq6juqooiiKK45iSJBH2PO8LiASMUBCRgtDDDiE6z7PE67qSZafIwcaYLzv3hoGCIhgEwiis7DT9t8eYOB75Q8Wu4Kyua4mbphEgd1x97rMsE8A5hBXa01pLdThD23ABcTicmbdtk3PkYLxzgHNw22oZidI8K1TCMuASBSAAJ6hcFIUMHY6cK7cUd+fOwMr3fen9vm+Z43Ecshi4/hXKP1vE+4w3i/mhTfxFqw4KB0CapuIIDOvOHYTcnPAOoohRxAn+4g+mFfju5XQhgQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/new_otp-749f4eab78329ad7dd3bb6936bc4afb2-26639.png" srcset="/static/new_otp-749f4eab78329ad7dd3bb6936bc4afb2-fa49e.png 163w, /static/new_otp-749f4eab78329ad7dd3bb6936bc4afb2-ae880.png 325w, /static/new_otp-749f4eab78329ad7dd3bb6936bc4afb2-26639.png 566w" sizes="(max-width: 566px) 100vw, 566px" /> </span> </span> </p> <p>We got our new OTP.</p> <p>Let’s try deploying this contract again, using the same arguments as before, but with the new OTP value.</p> <p>After deployment is confirmed, let’s look at the blockchain events again</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 29.364161849710978%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABAUlEQVQY04WQ2U7DMBBF8///RnlISaGK6yX7qsRu4jh5uIxdhBBFwtLRzHg8i29kjMEw9Bj6HnrW8PFmN7jdYd/3wE//PyK7beiVQpsySK7wniToOIeeJlhrsa4r7GoD3l+W5Rsf/yZyxw5dlhDXK15OJ7wSH8kFTDDcJIeqFG7FDSlPUVUVmqZG07bQwwBT15jHESsNtl9EPvl2PiOOY6RpSgUNhJDg1EwqCZUriExAKIEsy0LTkd6YrsNdm6dtoztp1lFypIm+mWeep6DHRnK4zT1wDxYq0vMMozX243jW0Hcv6ctFUQTrN/CbSCkDQgpw0pQxFqyiuzzPUdN3/zqfQfnGRDyVd1IAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/reg_otp-515dcf11ed999f0e299e3bb93bfcdbe0-082a3.png" srcset="/static/reg_otp-515dcf11ed999f0e299e3bb93bfcdbe0-59f9a.png 163w, /static/reg_otp-515dcf11ed999f0e299e3bb93bfcdbe0-00530.png 325w, /static/reg_otp-515dcf11ed999f0e299e3bb93bfcdbe0-082a3.png 650w, /static/reg_otp-515dcf11ed999f0e299e3bb93bfcdbe0-c493a.png 865w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Great, this time it worked.</p> <p>Now let’s poke at it with RemixIDE.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 445px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 79.7752808988764%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsSAAALEgHS3X78AAAC2UlEQVQ4y5WS7UvTURTH757c5swhhL8929qczWczQ6ykSCRTSyQznxHDRLMhWGKDxIeVZA+W09ScZiUa9UYoIiUdmhpkc1PCLBWSEISgP+Hb3W8KBknuxYdz7rnn3O85h0sySywYmPmNx6Nr6Hy7goaeCdRTmp5Ms9R122Hpn0G9bRINvR9Y29g3ha6RNXTRmqf2n2xt7/g6CqsegsQnl6CqZQiX6nooNpRc70BFbQcumx+h0tyJ8tp21nfHtnCfq5v6Wa5Z+lFz8xmKTPcRFpcFknu1EQOLX9E6aseDsUkMfVmE0+mCy+HEgmseTsccxQnXnBsXHLOfsbS4hNXlFax8W2b9XxsbKC4ygRAJSNaVG3i1+gOtIxPonZ2HdXwaSk08ApkYMPJYMLJ/QOMyxSHI5B7kyjj47TGCcINAsqvq8eL7Kqz2afQ5FtA2NgXCoxeEoSgo8l2iBOFoQDIrzOic+oSml69x5817NA+/g484mCaowaGKHK5mFwR5HqM1pKDmFobX1tE+PoO+2QX0fJyDQKinlypPkrco8lIQM2hCmLUUkbZyhLeXgivSetS8eWgrP6DgJLTDF6Gy5UP9vBDK7jwQgWZzf0pPp3+h3Ga32CYuTT0KrTUfuuZc6O7lQ2u5ALF/CMRiAyR+ByCk44voTkWiYAhFeoh9DfAR6ljrKwlhLZe3b1OEPuxWkApCEapNgl6ZCC2TgBBjEsJjTiM6Nh3G8GQYI5IRFnWKtRE0bghNQkR0CiIPpiIqNg0Be6PZL8MV7AfxT0yAojoTgWVpYCrOgClNA19CVQU6cH304NPOeLRLvjCYhbct5vbZO3oWiAysJdIM2lUHHfV2DrR3c6FqPAfCV++wq91Aly8lRuiYY1BLD8OX0C/DCaLqOnYEr+DTkaXHj0BlzoKsLB1yUwbklWchoMtmRxR5Ca0hAdknoB0shqrlPDQdeVC35dCRNTt8mf/zB2UhH2lH8/S9AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/good_zero_ransom-913822700182fdfd9780dd899d7b6e00-86b8a.png" srcset="/static/good_zero_ransom-913822700182fdfd9780dd899d7b6e00-54bfc.png 163w, /static/good_zero_ransom-913822700182fdfd9780dd899d7b6e00-4b3b5.png 325w, /static/good_zero_ransom-913822700182fdfd9780dd899d7b6e00-86b8a.png 445w" sizes="(max-width: 445px) 100vw, 445px" /> </span> </span> </p> <p>Much better, now the new contract is authenticated and attached to the Escrow.</p> <p>All we need to do now is to call payRansom method of the escrow contract giving it 0 ether. Note that payRansom contract has two parameters <code class="language-text">vicitmId</code> which we know and the <code class="language-text">encryptedFile</code> which is given to us in this assignment. There is a small problem with <code class="language-text">encryptedFile</code>. It’s a JSON string, and RemixIDE doesn’t work with them properly. It just passed them into the call verbatim, which results in an invalid JSON-RPC call. To make it work we need to first <em>JSON stringify</em> it.</p> <p>We can use the browser console for that.</p> <p>If you work in Chrome on Mac, press Cmd-Ctrl-I then follow example below.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 15.091678420310295%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAo0lEQVQI1yVO2w6DIBTz/79tZt42jTeMgkaXTJmCvnUFH5r2HA5tAzNNMHWNo6pwkE3bwjQNbCtg+x5GCL5x33W45hmnUjjHEVaS+ddpt3O317wg2Hi4PEKsUQydZtBZhi1JyS/oPPfwc1HASImdAR4M3Rm6s4DTv7KEGQYEH9GhD0MoGqoognoScULEN79zqOSeJXmhycpWK8092M7hS63Z+A+NmdtDAQS5TAAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-082a3.png" srcset="/static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-59f9a.png 163w, /static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-00530.png 325w, /static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-082a3.png 650w, /static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-dba21.png 975w, /static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-1823f.png 1300w, /static/json_stringify-04a3dd65b99481c1ac7346f2b5c61a6a-7bcef.png 1418w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Cut and paste output of the <code class="language-text">JSON.stringify</code> to the REMIX IDE encrypted file parameter and press the green <em>payRansom</em> button.</p> <p>Again you get a Metmask prompt asking whether it’s ok to spend a few cents on gas. Once the transaction is confirmed, let’s have a look at our ransom contract again.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 437px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 86.49885583524028%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAADPUlEQVQ4y5WS/U/UdRzAv/fAcd4EDzi47/E97w4OvTtQkDvcKtMY3gmkrTUaDpLNHrDrt+xIQq/cwApFFLTsUlB5qDQ7IdM5a9YkqfQAbct8aK2t5d/x6vP9Hqi5mvHDa+/HvR8+74+0OXaI7tErdB39nncSF9m6O8kbe06zbd8ZYj1jbO1OalJF9au09X5J5+AEXccus2dkknePXxb6JNGOBFJjtJv4oQu81X+W2N4krdsHaO04TDR+VGOLsKPxQaJvH2NLxxGNV3cM0tYjmvaO07F/nPbeMWGPEW6IIb3eP8D+C9/ReXKcruQ5Rn+aIpWaYWb6OtdmfiZ1dZopYav69NQMV6+kuPHLTe7c+o1bN29r+t2/7tK+bReSZEWKD50i+ceffDyZ4sTt3/ngmwnC615gbbiJcKQ5Tbj5nq76IyJeW9eisa52E+s3vIg/UCMKOpHeTIwwdP0GfV9f0uSO45+LQJ5gkSAn3fWRqLkFSDoXUltimIOXfqDn/Ld8OPEj8eFTZGR60evdGIxF6A2eR2IwetCJfElajLRz8As+u3aHA2cnGE39yu6T57UkLah2nC/V78VoPNPHs5++z/Pj+4j0bUdndM+/4Fx+Tns98nAT9o8akYeayOt8Jl1QDepd96S20qz9T/2hwsrOBopPvIwz0Yx7ZDOOXQ2imyKQBYUCxyzyf+iO9HXVCVUybD6cwadYsfY5/Guexv94Hb7SMOXB9VQI/GURAssiLKuo02R5ZT1eXw2+5bWsXLmBmlAExVYmpnOn3z5TLiO39DGUYDVy5RryA09gtVWSaw+Rkx/Emi/0giA2uYpFwl4oYrIcosJTRZUnSIkSxJIVIGPBUozmJUjOvRsp+qoV5yctuE6/RGH/xtmVHQ+t7MAkbCVTwW12slD3YEyZXVtgyC5BKX0Sb7CGkqowloIy7S3S/8qlkW1yU5xVpJFluu/XzR3rwaOYleXYyldhL1+NXayc7Q1hWODTsFsD+G1+vHk+rNl+9Oa032T5N/xkmJciuQ42U3zxNZShTbjPvYJzoAWLmGKF1UOhxY3J4Lp/wf+DMXcJi0PV+FbV4l9dj0VMbNA5scx9bnX9eXzwvwHO/kEZ8Fm7RwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ransom_fulfilled-68107484c301e85801c15d3ff6339b03-03b4d.png" srcset="/static/ransom_fulfilled-68107484c301e85801c15d3ff6339b03-81e9b.png 163w, /static/ransom_fulfilled-68107484c301e85801c15d3ff6339b03-47bc4.png 325w, /static/ransom_fulfilled-68107484c301e85801c15d3ff6339b03-03b4d.png 437w" sizes="(max-width: 437px) 100vw, 437px" /> </span> </span> </p> <p>All we need to do is press the getDecryptionKey button get the key and submit it as the answer.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 10.367170626349893%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAZUlEQVQI103MzRJAMAwEYO//dqVlaP1rKQcU51VhcPhmk5lNArt3aFaFzhVoXX5bc8hJIOlDjyG1kcdpjg2DHAV13v5PMB6anumtgnYljM9mUciseHBKaWOkAyfXXs+KuteN3j4nMgKSINen34QAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="Solved" title="" src="/static/task6-solved-b44b4df2c7c01ca46b4efeb6af102a12-082a3.png" srcset="/static/task6-solved-b44b4df2c7c01ca46b4efeb6af102a12-59f9a.png 163w, /static/task6-solved-b44b4df2c7c01ca46b4efeb6af102a12-00530.png 325w, /static/task6-solved-b44b4df2c7c01ca46b4efeb6af102a12-082a3.png 650w, /static/task6-solved-b44b4df2c7c01ca46b4efeb6af102a12-167dc.png 926w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>And now on to the final <a href="./codebreaker2018_task7">Task 7</a></p><![CDATA[CodeBreaker2018 walkthrough, Task 5 Containment]]>https://blog.v-lad.org/codebreaker2018_task5/https://blog.v-lad.org/codebreaker2018_task5/Wed, 09 Jan 2019 00:00:00 GMT<p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 14.347357065803667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAApUlEQVQI11WKyw7BUBRF+xMY+IGGxCv+BjEkTVo+gxihD1+nb/Q+JCKpWbd7T4kYrOy91zlGxzpitArQtVwMnQA920Pf9hUexusTzOUBjckGzem2ZvbLlkLf2vMdBo4Pc7GHEWcXhEn+ISOS/IoozYlznJKLkv8d6q799091+XjCEJyDEByMFeC0GaQQkFKAk2Pk7mqz4gapfmqnstBe4lWWQFXhDZmtvkq3NbcCAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-612e16fda143d1a91d0e48bfcfe4b860-082a3.png" srcset="/static/assignment-612e16fda143d1a91d0e48bfcfe4b860-59f9a.png 163w, /static/assignment-612e16fda143d1a91d0e48bfcfe4b860-00530.png 325w, /static/assignment-612e16fda143d1a91d0e48bfcfe4b860-082a3.png 650w, /static/assignment-612e16fda143d1a91d0e48bfcfe4b860-419f1.png 927w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>In this task we are asked to find out which hosts were infected on our network given the victim IDs we have discovered in <a href="../codebreaker2018_task4">Task 4</a>.</p> <p>What do we know so far:</p> <ul> <li>We have a list of all VictimIDs</li> <li>We can the generate the correct VictimIDs the given IP address and OTP</li> <li>We know the IP range for our network is 10.47.0.0/16 (2^16)</li> <li>We know that OTPs are 6 digit numbers (roughly 2^20)</li> </ul> <p>Given the above we are looking at the problem space with the size of 2^16 * 2^20. This is roughly 10^10 tries. In these days of cloud computing, multi-core CPUs seems pretty feasible to brute force. Looks like 100 something cores cluster will be able to to crack this in a few minutes.</p> <h2>Configure CI server</h2> <p>These days when faced with this type of tasks, I use continuous integration (CI) servers. My favorite one is <a href="http://bit.ly/2TNA6je">Go.CD</a>. Unfortunately, the particular feature that we’ll need to solve this task cheaply and efficiently is only available in the enterprise version. So, we will go with <a href="http://bit.ly/2TQ3Pbd">Jenkins</a>.</p> <p>To solve this task I have launched a brand new Jenkins server using standard configuration. After initial setup, we need to install the following plugins:</p> <ul> <li>Amazon EC2</li> <li>GitHub API</li> <li>Job DSL</li> <li>Chucknorris</li> <li>Github</li> <li>Matrix Project</li> <li>Matrix Reloaded</li> <li>Timestamper</li> </ul> <p>The only Jenkins job that we will create by hand is the seed job, which will bring up the rest of the jobs.</p> <p>To create the seed job first click the ‘New Item’ link on the main page of Jenkins. </p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 430px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 90.23255813953487%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsSAAALEgHS3X78AAACoUlEQVQ4y61Ty04UQRStX9HELQZlgYk79/6DKxNZAQsTIpKwwahbNy5MMCI4Iq50oWBYGIyQYISBpJGBeWQe3dXP6u6Z6e6qPlY3zdDAaCTxJic3qcepc+69Re6NjODF82d4+vgRHk5NYXLyAWZmZjA9PY2JiQmMj49jdHQUY2Nj/wQiA0/u38XtWzdx6fIVXB0YwPDwDQwOXsPQ9aHkwMUw+3oWq8sfsViYw6uFlygszuPt0kKKxfdvUHg3fyGQUATwwwDt0MP/CGIbOtraDzDThqGa0Js6Qh6Dy00uYkRhiCiKJHhf8DRHiOM4IzQ1sOoaHIvBpDYcN4Co7YOvFBB3272X41hkiM8hCUopKpUKCKVNrH//DJN1cVg3ECW7gY9oYwV8cxVi+xti+Wg+YiHOEdZqFSiKIhU6NiplBaruQDVcNKkDQ5Ifh6B18J9fj8jrB6nKE9VHZJ7no/SrnmZiWTaq5RKo4UC3PBgZoiBIbpxc9hiEsgm+sQxR2kbMZd2yvUA29LD1Aa5vgRiyGcq+DluzQGsqHGpBb+jQ6hSCi5Q0sdgjlkSiugfR8XuEnUjHknIHTkBBdFnD/eIqTKeTWk4gcsqOrcVniPOWo04X7MsaQtsB0XQd61tbsJ02NJ2hJWsYBGE2Drx3Kc054nxDIs+DNT+H0DRBTNvFXs2Am8yhtGnJOdRqGpoVFarMQTc4peaU4myt0+1CYw6orD3xXIa6nDvD8dCUdhuUwW0Hfa2djeN1zjk6vp86I44cm4NqSdbQl/VjcmwYvHZwTsnfcOrrqdTEp40yWklDZA1rLQsRFxf6v3ly4rpe3wOJDSGL/yckAy6y5uTtE8YYyuVDFItF7OzsYHd3F41GA7Ztw5RdsyyrL5qqDlPm5OG8yt+v9Q2Hfo11rwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/new_item-80b7eb99b30f2c932095633fb58af394-ee361.png" srcset="/static/new_item-80b7eb99b30f2c932095633fb58af394-f64b6.png 163w, /static/new_item-80b7eb99b30f2c932095633fb58af394-a9565.png 325w, /static/new_item-80b7eb99b30f2c932095633fb58af394-ee361.png 430w" sizes="(max-width: 430px) 100vw, 430px" /> </span> </span> </p> <p>Then select <em>Freestyle Project</em> as the project type. On the configuration screen select the checkbox <em>Github Project</em> and enter <a href="http://bit.ly/2MbtTer">https://github.com/vladistan/codebreaker-2018-jenkins-seed/</a> for <em>Github Project URL</em>. Also, enter <a href="http://bit.ly/2MbtTer">https://github.com/vladistan/codebreaker-2018-jenkins-seed.git</a> as git repository URL. Make sure to pay attention to both URLs they look the same, but the last one ends with <em>.git</em> </p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 80.89430894308943%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsSAAALEgHS3X78AAACAklEQVQ4y31U2ZKjMAyc//+/3YdkCCThBnNjA8nQozZxKrUhS5VKxlitllrma11X8KmaDt/eCVmWoSxLFEXx4hUKWSuxuq5RVRWapsEwDOi6Dl3fAw+cLweotZHgEr181FpDKbUBipWSRGUJyqqGHkdM0wRjDPquRSnnmq63GMR6AhqzgeR5blmSBYGNkeC+g7kcYVQBLWCj7G9JS2RyXgv4DqBBFEUIwxBpmtr3eZ4xC8C8LJvlMeYi2fbFbreb3e8HvQ94vV6RJAlGKWt8lDZJ4OaXbV2XmKQarhf7bYaqd0pmEMt1xv5xzzK0jAQ08jFpSUS2skdRlKpE0GEf0CnIXtIb6RMZkI2JA5imsmCuHVSYU8D1+q/KVOoaRlujRRQeZJJF+rRkIZZGYfn5wbJIqQ+G9Pf73fo3wH40wqp+Zmc5bT+gTiPUFw+NrMnaVdG2rVW6kfnluXdR5CNZMYCHL5cLzuezVf3oeTgcDgiCwJrv+zIRMUZJmucl2r05ZDayoroE5Oi4eaTn+2t/Kdzx20MqnmTWPUAyZAABXSDVpndgbp8Dffr7B8nJw8jBFpw3QNcjqhfHsS2bxoEnS17Lp0k1RXhF7AcYtN4vmdkJyItP8FcA+xN4sVbOZKyIPf/UQ7LiTSEYvevpJ7M/CJts+AxIhly7vw6D/mf27Mtd/gXFvs7BwJMo9QAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-082a3.png" srcset="/static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-59f9a.png 163w, /static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-00530.png 325w, /static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-082a3.png 650w, /static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-dba21.png 975w, /static/jenkins_job_url-5ad5804144a5f72261a3f640a5429947-28d97.png 1230w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>In the build triggers configure it to <em>Poll SCM</em> and enter <code class="language-text">H/2 * * * *</code> as the schedule. With this schedule string the Jenkins server will poll the GitHub seed-job repository every two minutes, and when it detects the changes it will apply them to existing jobs right away.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 42.395833333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABH0lEQVQoz52S626DMAyFef9HnKbCqg06SEJukAt0Z7YRk9r9mDSkT8aQHB/HaZz3GIYBfd9L1FoLMUaUWpHrhrLvKDEgzwolJ5RSfrGsCcZGNCF4tO2FaEVwHEc4a4+FaUW2GvmjRb6+IutPKVJyfhCrtSDEFf1o0ag5oO2uuN1umOcZlsQMOUyF3L1fkN5ekLxFpo3sNpPYM6VkElwwTCQ4O4+enHlqPaUkcV1XbOSEK9f7Fyq1XM9c4iPbtknLyjg03jtx5pwTWOw/z05F+dwbdsQvJ9zyORhjjORnMc6P4la+/0B54A7JTMMLebNSSiIPpus6GRJPfpxGTNMk/zk+w0NktDY0ZX84PK8Mww74LBluf1mWP+F1IQQ4H/ENa4RmXWBd0NcAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/jenkins_build_schedule-0ba4b2dee10543be98b22eb8e2691be2-082a3.png" srcset="/static/jenkins_build_schedule-0ba4b2dee10543be98b22eb8e2691be2-59f9a.png 163w, /static/jenkins_build_schedule-0ba4b2dee10543be98b22eb8e2691be2-00530.png 325w, /static/jenkins_build_schedule-0ba4b2dee10543be98b22eb8e2691be2-082a3.png 650w, /static/jenkins_build_schedule-0ba4b2dee10543be98b22eb8e2691be2-81189.png 960w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Scroll down to the <em>Build</em> section and click on the <em>Add Build Step</em> button. When pop-up appears, select <em>Process Job DSLs</em></p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 43.214285714285715%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABOElEQVQoz42RWW+CQBRG/f8/rH1o0vSlbrgU0DKggAs6K55eNF1s7DLJyZ3JHU6+y/Scc0RRxGq1om1bjLWYIPXQYDYVZltfqkrR6RTd7C93jLlJL4RAmqaMxyPmScJeLdDPD+hkgonHF7r9WqEHj5h6jfUeKx9bEX+n56VZliWJyBIRr3PFehHTHA6cAO0DRjZ6PkSvMkx31vrnhJ1wv9sRv8yp64rPdTrjpH+c9tFZgm1Pv8o+hGW1YTKLGUczFq85Vb3DuoDrEk4H53RW/FZkt8a8Gtl5y2jZcD8ouesX3AtPsWGYw7OCWB1w7v0R7N9C6zTb3ZZoMpWEEVmm5P8dpekkpUdLNeb3Ma9G7hJuthXL1yVKZeRFTp53KIqioGmaP1NdJQzB44MjtEHwX7icz73znf/xBrAZtRLTEHHfAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/add_build_step-bcd1b058df7d337b0a32439e4d4ee4a9-082a3.png" srcset="/static/add_build_step-bcd1b058df7d337b0a32439e4d4ee4a9-59f9a.png 163w, /static/add_build_step-bcd1b058df7d337b0a32439e4d4ee4a9-00530.png 325w, /static/add_build_step-bcd1b058df7d337b0a32439e4d4ee4a9-082a3.png 650w, /static/add_build_step-bcd1b058df7d337b0a32439e4d4ee4a9-b5dc6.png 840w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Configure DSL build step to look for the job definitions on the file system, and enter <code class="language-text">**/*.groovy</code> as the DSL script filename pattern.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 62.82828282828282%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABlElEQVQ4y6WT2W7bMBBF9f9f1reiT0EdJF5EUpRFUaS4aLGbmxl6aYsisIE+XFCiRod3FlaHwwHWDjifz1iWBfM8/5cqay2klFBKwhiDaZqQUkKM8SklMjFsXuC2b5hPJwL2PQ5CYy9aaK0JrAo4hIBxHB+L4wYLT8pkpjoai1pIbHc77Pf7AuXASIHPQgM5DTEg54xKGwchFaUtirMSECJ65+nZl/Qfif/pensBjt6jaRq0bQtPz+U0a9BvNwgUMFMa0wNxJk1rkBjorsC6rsvKheZD4s8fGFsFH1N5/yrdYoKAShtEclvxhhCi1O9Ww54632hq0vdv8KZDSBmhlCJ8KcUOKa4A2RmPDrvkMWIduw5LipjeXzDndJkzSu/PmZuu75m+K939Bt7GhaEMc87BEPD08YHFWyytwHr+hZVmbl3Xv8QXgld97C/A0iH6uW11ccpwhnLHiwsWFfvfZlyceTegp1lmE7xfbkrZGNx9+sOTM+gIJkWNHdX+DlSNxOvbBrIRyHO+1+UpXUtwoit32/sEToziAE4EBxsAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-082a3.png" srcset="/static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-59f9a.png 163w, /static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-00530.png 325w, /static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-082a3.png 650w, /static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-dba21.png 975w, /static/dsl_build_step-f00c22dcb4271052d9854102d9937f03-ac8eb.png 990w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Finally save the job. Once you do it the Jenkins server will start polling GitHub and create jobs defined in the scripts placed in the repository.</p> <p>After a few minutes, you should a see a new job called <code class="language-text">vlad-task-5</code> appearing on the Jenkins main screen. Running this job will give you solution to the Task-5, but for my personal set of input. Let’s examine this job in details and see how to customize it for different sets of inputs.</p> <h2>Brute force ID cracking job</h2> <p>We will use the following method to find the IP addresses by brute force</p> <ul> <li> <p>We will add a few routines to the model that will use the CID routine to generate series of CIDs for the given range of IP addresses and OTP values. Also, we will add functions to see if these newly generated CIDs match any of the known CIDs. Finally, we will add functions that generate individual IP addresses and OTP values given the range.</p> </li> <li> <p>We will create a cracking program that given the IP subrange will try all possible addresses and OTP values in that subrange to see if any CIDs that are generated using these match CIDs known by us.</p> </li> <li> <p>We will put this program into a Docker container</p> </li> <li> <p>We will use the Jenkins server to the container against every possible subrange within the range of IP addresses given to us. We will use <a href="http://bit.ly/2D9nY6F">Matrix Project plugin</a> for that.</p> </li> <li> <p>Jenkins server will create a number of temporary EC2 instances necessary to run the cracking program. Jenkins will take care of spinning up the instances when there are jobs to run and will shut them down when they are no longer needed. For that we will use <a href="http://bit.ly/2MeeoCI">Amazon EC2 plugin</a>.</p> </li> <li> <p>That cracking program will be set up in such a way that it will indicate a failure when it finds matching CID. If it doesn’t find any matching CIDs in the given range it will finish successfully. Doing it this way makes it easier to spot the runs we are interested in.</p> </li> </ul> <p><a href="http://bit.ly/2M8GOha">Here</a> is the modified model with all functions, tests, and an instance of cracking program</p> <p>Since cracking program takes some time to run and go over all possible OTP values and networking addresses we need to divide our search space into smaller manageable chunks. From <code class="language-text">network_information.txt</code> we see that we need to cover /16 size network. Which means that first two octets of the IP address always remain the same and two others vary between 0 to 255. We will break down our runs to probe a single value of 3rd octet and 16 possible values in the 4th octet. This way we’ll need to have about 4000 runs of our program or more precisely 16 * 256</p> <p>Let’s test it using the IP address that we already know, being the one we found in <a href="../codebreaker2018_task0">Task 0</a> 10.47.114.22. This address can be found in the search segment 114 1. First number is just a third octet of IP address (114) and second number is the second 16 address region of the fourth address. First region is 0-15, second is 16-31, etc.</p> <p>Let’s give it a spin.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 421px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 78.38479809976246%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsSAAALEgHS3X78AAABxElEQVQ4y52U6W6CQBSFeRZXlmiCAqKiAyogIHWpoWpjYtr3f4bTe69p0zZpWvpj4kAyH2e5ozYajRDMAqhQgfeu52EwGKDb7X5ZnU5HfnVdh2EYME0TFi3eW6YF0zChd3Voj8cj4jjGer2G6zjwfV/A/X5fwPwB27blXa/XQ7PZRKvV+nFpYRRhOg1wJPBsNoNHB+MkQZZlAmQF76pYIR9qt9s/Lm21ijEeT/Dy+orNpkBZPuBwONB+g6IoBNRoND4U8KHv0M/vNdsewLIsBEEA13XEItseDofy/F3VrwqTNIVSimxPBer7Y8znczgEZKt/gXwBRpShR6qq6gkJZccRFHku+zAMYRC0JnAhRVyvV+R5JsDtdivN51QMjwc3+2eg2KNxqaqKYCtpeLfbSQwhLb2+wkhKuFwuNIspWU1lJnls+Lm2QkU5ua6L0+mENL3nxsCUylosFjI2zToKlQppDsc4n89SBEM2NH8M5BwFWEchl+I4Li7Pz2KRQWVZSobL5fI/ChVZ9qSUJImlFL4lnC0rNOsq5Ls8mUxxu92QUXZFcb9yS7Ke/MdyQH8IbHm/31N+EZUSiTq+OVEUCrDO2LwBiND2kXR2LxoAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/model_run-2baeed7e1c6688cf2cd6fe07eb3b8287-06e96.png" srcset="/static/model_run-2baeed7e1c6688cf2cd6fe07eb3b8287-24335.png 163w, /static/model_run-2baeed7e1c6688cf2cd6fe07eb3b8287-85429.png 325w, /static/model_run-2baeed7e1c6688cf2cd6fe07eb3b8287-06e96.png 421w" sizes="(max-width: 421px) 100vw, 421px" /> </span> </span> </p> <p>Great, we have found the IP address.</p> <p>As mentioned above, the Jenkins server will be launching EC2 instances that run standard distribution of Amazon Linux without anything preinstalled. The cracking program cannot run on such instances as is, because they miss necessary pre-requisites such as <em>CPPUtest</em> and <em>OpenSSL</em> libraries. Instead of messing with configuration of these ephemeral instances to install all prerequisites and dealing with potential version conflicts, we will run our cracking program using <a href="https://dockr.ly/2D8o4eL">Docker</a>.</p> <p>Docker lets us bundle everything that is needed to run the program into <em>container</em>. This container can be downloaded and run on any type of machine without installing anything except for the Docker engine.</p> <p><a href="http://bit.ly/2ANnnWW">Here</a> is the <em>Dockerfile</em> that we will use to build our container. To build the container run the following command</p> <p> <code class="language-text">docker build .</code></p> <p>You should see something like this</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 67.88766788766789%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAABWUlEQVQ4y5WT6ZKCMBCEeRZADkXkFpYbFN7/iWanpwzl7kZ0f3QlpMhX09MTYxgG6tqW0jQV5XkuKoqCkiQhx3HocDj8kG3bf86UjGmeaV1XKstSIOfzmU6nEx2PR/J9fwM8aw9qTNNEy7JQlmWUPioyTVMuWJalvbhfIQNRYV3XFMexVBcEwe6lPW3Avu+paRq6XC4iQF9V87sFzzKmcaTlft+AsK6AYRiKsEcrsHqeJ/3FOf7Dt8e9Vv8LcGDYyGkDimCgjBO/Xq+iqqqo5UnAHpd0yW+WARnZNqzPnDi+sSJtpIyeqlXtAZRW6CzPDLozABVidFABYEhYp3ejY/RdR19sCbbQP1XF8wzqrL2cw46BbdtJj2AbweAMAnyz9+nYoF+4jPV2u4ltPEFUKAmy3r0OLRAw7FFhztajKBKY67ofwwQ48tggWdgdhvExHoU8QwBh+z/AbyUXqaTGXSX8AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/docker-build-f6016a5befcbe235e1c57de6d2d88c8a-082a3.png" srcset="/static/docker-build-f6016a5befcbe235e1c57de6d2d88c8a-59f9a.png 163w, /static/docker-build-f6016a5befcbe235e1c57de6d2d88c8a-00530.png 325w, /static/docker-build-f6016a5befcbe235e1c57de6d2d88c8a-082a3.png 650w, /static/docker-build-f6016a5befcbe235e1c57de6d2d88c8a-727ff.png 819w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>We’ll use a two stage docker file. In the first stage we’ll download all the prerequisites necessary to build the cracking program. In the second stage we’ll copy the built cracking program and it’s runtime dependencies to a much smaller barebones container. This approach keeps the container sizes smaller. You need to keep your containers small to avoid long download and setting up times. This is especially true for the cloud environments like AWS where we are billed for every minute of running time.</p> <p>Once build is complete, you will see something like this.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 595px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 41.1764705882353%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABdklEQVQoz4WPSWvCUBSF81NUnDUOCGKhERxw6UJM7CImMYOZ2yiicWg3LXTdX3z67rMW3LSLj3PugXfufUKv94DRaIThcIjJZIJGo4F6vY5KpYxyucy0wiFPlEolPpPm83kUCgVOLpdDq9WC0O12MRgMeOl4POZl7XYbzWaTl5PeZlG8LiNfrVZ/y4hiscgXCJ1OB9KjBEmS0O/3+XZRFFGr1bgnpRLKbhdTRj6TyfDLstksh7ygqioc24bjOPA8D/J8DkVZQJZlzJknVQhF4fMtI2azGabT6R3CZrPB+XzG5XLBK8P3PURRhDAMEAYB/ChGwIjDkGVXAsp9H67rwrKsO4QkSZAeDkjTFKfTCb7nI2KP3CCEyfyzbeDdkBGvNFjrNTxWYpomlsslNE2Drut3CLvdDoefwuPxyP3heMJbEuLDXOBzrSJxbRgrEwZ7YBjGnwjb7Rb7/Z4XEnHMvvuS4CvQkepP0B12ke2w7RqW7CLtH74Bh5U1uWnOG/UAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/build_finished-7b8bae28d91f9757ba88ddc47b7614b8-1450f.png" srcset="/static/build_finished-7b8bae28d91f9757ba88ddc47b7614b8-2fd86.png 163w, /static/build_finished-7b8bae28d91f9757ba88ddc47b7614b8-6e46a.png 325w, /static/build_finished-7b8bae28d91f9757ba88ddc47b7614b8-1450f.png 595w" sizes="(max-width: 595px) 100vw, 595px" /> </span> </span> </p> <p>Pay attention to the last line, indicated by an arrow. The hex number there is the image ID, which you’ll need to run our image.</p> <h3>Detour. Creating dockerhub repository</h3> <p>To run the docker container of our cracking program EC2 instances created by Jenkins need to download it from somewhere. The easiest place to host public docker containers is <a href="https://dockr.ly/2RMA25Z">Dockerhub</a></p> <p>Follow the link above and sign up for the free account if you don’t already have one. Once you logged in to dockerhub with your account, create a new repository by clicking <em>Create repository</em> button.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 32.1285140562249%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABGUlEQVQY05XPu0rEQBQG4LyJ2lgIspZiJ7K+l4uXQtCNirgoFmqhlY2lKF5XsBNE8AWSuGwyibnOJPN7zsyKoJWBL/+ZcDhz4rRPBlgknO1jWy9Qzh8NMHf4gXHXNybImOthcsfHTC8w2doLMLVr62mqZ/d9OJv9GN2R73rjQRjr9wJL19GPqxAdytU727P9JOA+CnTJVl9g+SaCo4oMTOY2mZalAaZGGmnVFZDGuHxPcPqS4Pw1wRnlxVti+pxhKDCMYtgUCEWMNCuQ5VbK6Jzy98BHFnj49D0cPAus3ArzR2u0MW/JfY7WGr81TfNHnSaoyxIVqTVoW8UvQCu7NRSKgjbEPx6eU0llLigriYYul0ohp0GcPPAL2K2rLs3l/0YAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/create_dh_repo-7689af796db842cc68d6623db60b31cc-082a3.png" srcset="/static/create_dh_repo-7689af796db842cc68d6623db60b31cc-59f9a.png 163w, /static/create_dh_repo-7689af796db842cc68d6623db60b31cc-00530.png 325w, /static/create_dh_repo-7689af796db842cc68d6623db60b31cc-082a3.png 650w, /static/create_dh_repo-7689af796db842cc68d6623db60b31cc-98691.png 747w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Enter repository name and make sure it has public access.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 61.96236559139785%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAABOklEQVQoz5WTi26DMAxF+//fN03bNG2aeHaaCs0LkgB3tmkoQ1XpLF0hEnyc+JrDNE3gCCHAGIOu7+G6Tp7jOOLRYA7rkIDu3CJ7eYIyFp5g6SOGcrGmaeCck3VeS4CkYRhgrb0Cx3FA8J6S480EXksn3u6ttQBTFVYC3EvcBcYYYelK6X3TIa74P6BzHar6KIb0dHU2pSf5OKCP88d7UI4/PewY1nuBGuvEBO0HnD3vTw85fQFO0AGoTxpZnkNpIy3w5K4Xo7wkGJqA+viNrCihydF0Ez4ATwLWQE8GttqiKEvklFBUFZTSArd2HpdARbg1muaVpbSGpv32rAQqV2bY1elRTsWJrHUk1+8F/xirHtLYrP6MeXRI06xlHm/pUoyvvwBPTYv3j088v77hKy/xQ+97J9o4Io9fwI2xETXQLgEAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/create_repo-9c00fbda56393abe0af3ebf692609eab-082a3.png" srcset="/static/create_repo-9c00fbda56393abe0af3ebf692609eab-59f9a.png 163w, /static/create_repo-9c00fbda56393abe0af3ebf692609eab-00530.png 325w, /static/create_repo-9c00fbda56393abe0af3ebf692609eab-082a3.png 650w, /static/create_repo-9c00fbda56393abe0af3ebf692609eab-08791.png 744w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <h3>Continue solving the problems</h3> <p>Login to docker from your terminal using the following command</p> <p> <code class="language-text">docker login</code></p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 5.523255813953488%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAYAAADeko4lAAAACXBIWXMAAAsSAAALEgHS3X78AAAAMElEQVQI12NwcnL6b21t/d/I2Pi/lpbWfx0dHTjW1dX9r62tjYJB4gg+VA1UDCQHANPTHqijreIRAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/docker-login-c78b2d046deb96af9f429e4ce5d592af-082a3.png" srcset="/static/docker-login-c78b2d046deb96af9f429e4ce5d592af-59f9a.png 163w, /static/docker-login-c78b2d046deb96af9f429e4ce5d592af-00530.png 325w, /static/docker-login-c78b2d046deb96af9f429e4ce5d592af-082a3.png 650w, /static/docker-login-c78b2d046deb96af9f429e4ce5d592af-dba21.png 975w, /static/docker-login-c78b2d046deb96af9f429e4ce5d592af-31023.png 1032w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Tag the image we just built for uploading using the following command</p> <p><code class="language-text">docker tag IMAGE_ID DOCKER_ACCOUNT/REPO_NAME:VERSION</code></p> <p>Substitute the <code class="language-text">IMAGE_ID</code> with the ID you got at the end of the built, use your docker account name for <code class="language-text">DOCKER_ACCOUNT</code>. For <code class="language-text">REPO_NAME</code> use the name of the created repository. For version number use any number, if you ever need to upload a new version of the container make sure to increment this number.</p> <p>For example, my command looks like this:</p> <p> <code class="language-text">docker tag b13142962697 vladistan/cb2018t5:0.1</code></p> <p>Once you have tagged your image use the following command to push the container image to the docker hub.</p> <p> <code class="language-text">docker push DOCKER_ACCOUNT/REPO_NAME:VERSION</code></p> <p>the output should look like this:</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 18.87072808320951%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAwElEQVQY012QyQ6DMBBD+RT2RdxArClLEgjbmf7/n7iZkVq1PVhWLPmNFUcqhXmW6PseUiqsy4pFL5imGWVZoq5rFEWBqqrQNA3yPEccx0jTFIn1MAwRRdFHzrZtMMZYwARl4UI8MI2jhUubb5wlScKALMu49A/5AT7vG9d5cvnYd15rzAo6dJ4XtFZwXRe+78PzPPYgCNi/RRnJea/TWvNSEsH248BuD1AuhIDoBbquY7Vti3EYMQwDd+lN30J6AaoqgiN0XWJTAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/docker_push-bf8d49e7130049562583e664be752861-082a3.png" srcset="/static/docker_push-bf8d49e7130049562583e664be752861-59f9a.png 163w, /static/docker_push-bf8d49e7130049562583e664be752861-00530.png 325w, /static/docker_push-bf8d49e7130049562583e664be752861-082a3.png 650w, /static/docker_push-bf8d49e7130049562583e664be752861-39f3f.png 673w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Now, that we pushed the image, let’s look at it on the Dockerhub.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 39.0547263681592%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABAUlEQVQoz31RXU/DMAzM//8bvDHBEGwgGKv4mHjZCz8DkNjaLm3SxulhuwS1G5ula+qLfTo7pnYe35st8qLEx+eX/kt0XfeHlMdIiESSYT/kXrSMfESs3FlsiwJ17Q7Kk2j2tsbZ5RznswUm80dcL15ws3zFLFshL3domhYmBIL3XtG07YG7qM6i8qv1Oya3S1yx0PThGdP7J1zcZcpt8pL7A4yo9s29EFEExQE4F8GWi0+F6OjI1lawVQXnHBy7TOPtB/HubOUY9b8QMecbGCkUqIsQdMThyIHvAvNypqZjUIciNN7X4Iw9Lw+VGk6hd/i7p9HuaMypS3V6HPKgIvoDnxhqi0Lwlb4AAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-082a3.png" srcset="/static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-59f9a.png 163w, /static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-00530.png 325w, /static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-082a3.png 650w, /static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-dba21.png 975w, /static/dockerhub_image-f4749137cab4d211c1cc9b0362394002-27989.png 1206w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Yes, it’s there</p> <p>Now let’s repeat the test run using Docker</p> <p> <code class="language-text">docker run vladistan/cb2018t5:0.1 /p/find_ips 114 1</code></p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 511px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 65.75342465753425%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABSklEQVQ4y52Ty3KCQBBF+RbFx8bCCIrIYwEzgKC8JLry/z/jprsrUjFllQmLW71g5nC7b4/Rtg3u9ztOZYmqqtA0jeiz73G73XC5XFAWBeq6Rtu2qM5nqYfDAZPJBPP5HLPZbJCRphppmiEKQ2w2G/i+D9u2YVkWVqsV1us1FouFXGZNp9OhMsA0zScZQRCgIAdd1xE4FSdFUQqID/z8+2+9+m442y32+z3iOAbDoyiSapPbh4t/AeMkGUCe50nL7G65XD5deOd2AIYEOh6PEkCe5zLwMw3edV2Z1V8gT0BOSymFqq6QkNssy6C1hkPBvGv5NZBaVImSlWEgB8PVcZxxDr2Hw28gt68Jao916FMg3OIDyC2zdrvdOIchLbTWKXp6GQxmhwx0xwIDAvIiX69XguWSdJbl41Nmh0ppAfEO8j6yPmgXx8zwCy59lpGpcPqIAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/docker_run-6245ccf5641b020b436277e238dd68ea-a1e15.png" srcset="/static/docker_run-6245ccf5641b020b436277e238dd68ea-b7252.png 163w, /static/docker_run-6245ccf5641b020b436277e238dd68ea-b07bf.png 325w, /static/docker_run-6245ccf5641b020b436277e238dd68ea-a1e15.png 511w" sizes="(max-width: 511px) 100vw, 511px" /> </span> </span> </p> <p>Looks good.</p> <p>Now, let’s have a massive run. <a href="http://bit.ly/2TOSqIG">Here</a> is our test Jenkins job definition. And this is how it looks in Jenkins.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 540px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 54.074074074074076%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsSAAALEgHS3X78AAABNUlEQVQoz5VSa0+DMBTl//8hTTQaHJ+WOAT3ENQobEOgBcpr5X1cm5lMPyz1JCenzW1PTu+t1vc9pmmC0GEYpI7jKCn2oibwo39xXhfnNcMwILharbBYLDCbzaTqug7LslBVlbKhoNa2Leq6lsnEumkaqZxzdF0nk55fuGQqoEERygkJIaCUIk1TxCRGzko0vAM/tDjU/Mj22Jv+ouk5NNu2Zf8cx8Fyucbm1UREPWxDB0H0AS9Yo2v/YZhlGcqyBMsZDlUHN3iAR+dww1vs0ydsgmtMozAb1QzjOEaSJKAJBUsruDsDW2riLdQRJM9wvu4wDpeH8sswiiLZP0oJWFbjxb+HR+ZwghvsEhOb/dXJUDEhYwxFUSDPc1Qlhx/ZCDMXPjERs3d8ksfTkxUTKn4a5aF8A2cZValeOLj+AAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/jenkins_matrix_img-a548b2691799d5316021bfc06702ee45-77d1c.png" srcset="/static/jenkins_matrix_img-a548b2691799d5316021bfc06702ee45-9291c.png 163w, /static/jenkins_matrix_img-a548b2691799d5316021bfc06702ee45-4028c.png 325w, /static/jenkins_matrix_img-a548b2691799d5316021bfc06702ee45-77d1c.png 540w" sizes="(max-width: 540px) 100vw, 540px" /> </span> </span> </p> <p> Each green bubble represents a single run of the job. Clicking on a bubble will take you to the details of the particular run represented by that bubble.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 51.64369034994698%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAABTUlEQVQoz32S6Y6DIBSFff83mteYX5N0VRSRxa2o4HYGmLSxtp2bnGi4l89zwCgmJyRZgsP5gCxPEJMLLskJ5+vBvccQQkEoBlnyhxinHxWVuoLuJ0zLin2NkPihX0gJA6UZCEmR5zn+q4ikBEV5gx0nrOsatCxLaOqhwpl+o64alGWJuq7QtC16M7r5EcYYGGuxtRIdL0dQ3iDjNcZpDose6svaCZKXkFKAFQKtHmDGGbfe/kGth1rM84xpmoKiRsrgUNUdusE+Afu+R5ZlYIyFqDGhuCaZO9MKlEkIqdA2TXA6DEN4RoqmYEqHr99hd6Af4pwHsNYanVPfdRhD3ME5NI/ZR2QzGzcwP8XdOvTulHI3LQQa52YP2O7xivaN7dNHkO5IPKwoClRV9QLY7gnAT41tZA/0Tv1N72defpt3i3ugd0cpDdG3/Xf1C/wfBudYUlLAAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/jenkins_run_details-8d312f0df107378a9857da0146442c03-082a3.png" srcset="/static/jenkins_run_details-8d312f0df107378a9857da0146442c03-59f9a.png 163w, /static/jenkins_run_details-8d312f0df107378a9857da0146442c03-00530.png 325w, /static/jenkins_run_details-8d312f0df107378a9857da0146442c03-082a3.png 650w, /static/jenkins_run_details-8d312f0df107378a9857da0146442c03-0ce48.png 943w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Now that we see everything is working we’ll need to bump things up a little bit. Cloud providers like AWS charge per compute hour. This means that it will cost us the same amount of money to run 100 cores for one hour, or one core for 100 hours. But it will take 100 times longer to do the later. What we need is a few really big machines.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 39.18322295805739%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABOElEQVQoz02S6baCQAyDff+3VHYYNtmGzdx+I3juD0+nbZqmwUfXdUqSRFmWq65rVVWlLM3Uv986/aJtXbUfh87z1GFxtfy48n3f5S2/a5/PR49hGFQURSh6I5inSYv3GttGW+vUtJ3GcQzDk/VSW0Ykp05elqWWZfkS0kQVgG3bjNRb3DUXqQ6rcQEYFDHEciKKwDpnS5smCAqEbImj6CLaNBl4qSsNrtJhAGfLuALCeZ6VxEmIEEIcx7HyvAjzP0I8ZAOEo3k3u1KD1RnC1/F6Q5Rl2Y8QkjzPw8neXwpp3h5wNjlASFDFObwBU/8O+9AjVpaDQUwg7PteURSH5mo//IKcM1mAv29TzbttWz2fz+AjBGBer5d9mDQI+Sl0lQsDnAHw/nsAYOj2h2V8BIhRCAZL/iv8A112aYkh3k3IAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/machine_types-ce7e1ce8d55161f809a3df4f0c583484-082a3.png" srcset="/static/machine_types-ce7e1ce8d55161f809a3df4f0c583484-59f9a.png 163w, /static/machine_types-ce7e1ce8d55161f809a3df4f0c583484-00530.png 325w, /static/machine_types-ce7e1ce8d55161f809a3df4f0c583484-082a3.png 650w, /static/machine_types-ce7e1ce8d55161f809a3df4f0c583484-85bfd.png 906w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> 36 cores looks like a nice option for the task.</p> <p> Also, we don’t want to pay the full price if it’s possible. Let’s check the spot market.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 50.63694267515923%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAABGElEQVQoz5WSi26DMAxF+f8/7KSyTiCg5VkISSiQu1zzkFg3iVk6wjG2iS8O2rZFXddI0xRVVUEphaZpxH88Huj7fo+RsiwxjiOcc5imSZ6b0Q+6rpPC+/0u0M+yTHw+8zw/vCdFUUhjkiQJXq+XIA3pxHGMKIqkkEksOANzw2uI2+0mE9GkoTEGwzDIVzjOGTgupeAUlI1n1ktDHuAWDXZmh3mej7GVJQ5Yo/D1efX6Z3JDTikNmbDKir/N7bg1T3n9Py4XaUYJwjBEwFG1MjC9fYfxTq/n4Yi2vm5A73O2n6K1RkD92lpBPXt0zYISfKzuBIk/9YHWx6wZ3uYIfu7Sf+w3jQNr/TjayHXPwEW3xu6bsS30Zt9DOgd4bVUVhgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/spot_price-1a2b307313779d1b72a8e66ceb2c8001-082a3.png" srcset="/static/spot_price-1a2b307313779d1b72a8e66ceb2c8001-59f9a.png 163w, /static/spot_price-1a2b307313779d1b72a8e66ceb2c8001-00530.png 325w, /static/spot_price-1a2b307313779d1b72a8e66ceb2c8001-082a3.png 650w, /static/spot_price-1a2b307313779d1b72a8e66ceb2c8001-8896e.png 942w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Looks like the real price for that machine is $0.58/hr which is better than the full price of $1.53/hr.</p> <p> So, let’s enter these parameters <em>machine_type</em> and <em>spot_price</em> into the Jenkins Ec2 plugin configuration. We’ll bid $0.63 cents so that we don’t get shutdown during the run. A spot price depends on how much and how many people are willing to pay and the number of available machines is limited. There is always a chance that someone will come in a middle of our run and will offer a higher price for the machine. When this happens our machine will get shut down and be given to the highest bidder.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 49.63041182682154%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAABQ0lEQVQoz31SB27EMAzL/595XbmMJh7xjlkqA0jTQw0Qsi2JpiU1uKxa62ZzzpjnGTFGeO/RDwOiNUhuIRwS71MpSIwTKKXwfD5hrUXzitAtCx6PNzgmF0lMCWvwKHpGMfNut71CoW/LI9Z1fU3oY8ZIVdZo+BCgjUGRBPoEhapKiqgEWX7lN1ei3Va4RFC+7b6Q1EQ1E1aqqYIYUA8C5zy6vkdPdF2HwMebK/sZKNINCb1WCFYjH0oqlYkq8Uu8lKY/CAf+aFLmr8KaAjJV6fYD6vMd88Dg8XtL+J4mjNxLs6RxUt8t56hhyuVGKC97dpINMHqv37pWKkwbiTRHcJKJPSFn6+5fPogDk8dxZFDeOi0jJL47yR0+xFdN2edwYX32wu+EcpaZFKVS/Dvkfta3ObySnkuCpYNt20KzDP+pFN8PG54PBQo7x0EAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ec2_config-b7bdb259ddc8b91d2e5de140ffae8083-082a3.png" srcset="/static/ec2_config-b7bdb259ddc8b91d2e5de140ffae8083-59f9a.png 163w, /static/ec2_config-b7bdb259ddc8b91d2e5de140ffae8083-00530.png 325w, /static/ec2_config-b7bdb259ddc8b91d2e5de140ffae8083-082a3.png 650w, /static/ec2_config-b7bdb259ddc8b91d2e5de140ffae8083-3a26d.png 947w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> We have a 36 core machine, which means we can run 36 independent containers at the same time. Our jobs are CPU bound, each container will always take 100% of the CPU core during the run. But we shouldn’t use entire the CPU, we need to leave some capacity to Jenkins and Docker so that they can orchestrate the runs, collect the logs and shuffle them to the master node, etc. Let’s allocate 32 out of 36 cores to our jobs and leave 4 cores to Jenkins and Docker.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 57.67045454545454%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAABZ0lEQVQoz31SCW6DMBDk/++skJo0HL7v6a6xiUPSWloBZj2eYyf0VUp7FFxXafs5538q1d6JG8sL2HFQSAmlDVKixhQRrIExBiF4eO/hnKtPrhAClLEIMV0AG6McI5bbN/TPDWFfkcSG7F29iHv5En5PKZ/vPsT6PT0VEzAdKkogyQ3L/IXlfocipnxzzgWSWSv1IjVRsV3KOFgfG0PeZFACRG0q2OgwA7AcXsyEv621b/6xNm38AGhUZVa0BMij5CycVvX23OwIJGmeZ0Sy49Pq1k1nipRSIRbFURAELu+Hh/Ui2otkPsvlEK6JM4KxFFRnOI5HlUd7j2WBEuKww1skSjm2AJjlWDwy7KEjFdNIt4OzX+u6Yt02CCHJHw2hyfTAKecPHqL+1zY8Ux6H+gSk4tnro5La2IzVAbVtoXwC5KZ93ysgJ3scpvQvUkfJUtvDw78YLuThRpL72HR57wyPJ88qD/YvNLiwbro1a4oAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-082a3.png" srcset="/static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-59f9a.png 163w, /static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-00530.png 325w, /static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-082a3.png 650w, /static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-dba21.png 975w, /static/core_config-efa556e3063e599f8c8f3bc764fdcbc3-72902.png 1056w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Bill Gates said 640 is enough for everybody. We’ll settle for half of it.</p> <p> Now let’s <a href="http://bit.ly/2D9eDvV">change</a> the job to run over the entire space. </p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 27.173913043478258%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAAAyElEQVQY022Q62rDMAxG8/5PNxgUMiiMslKWzE7kOL7k4jN5bVl/xHD8gZDFkZtCoR4rI9YMiPOkvBDTPymv5GU7YGVZN0LMdD9WezMN3Ed++8zNJSRkXFyY9cETnzfihlIOgLAWptqj2fz5Fb1lBqeozdQbpLe4SmdALWtdlR75yktNjZs6by87V3vm0rdqaLl2F07nlo/Plvf2jZv9UuuBMZhDpOZsmKLowHJf2uDod8GXxJg9gyLLjEmC7IGAfgP5kPDIqD2/x7uEHdZFBWgAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/whole_job-e50a65664b58525c4284ac71b6eaa886-082a3.png" srcset="/static/whole_job-e50a65664b58525c4284ac71b6eaa886-59f9a.png 163w, /static/whole_job-e50a65664b58525c4284ac71b6eaa886-00530.png 325w, /static/whole_job-e50a65664b58525c4284ac71b6eaa886-082a3.png 650w, /static/whole_job-e50a65664b58525c4284ac71b6eaa886-dba21.png 975w, /static/whole_job-e50a65664b58525c4284ac71b6eaa886-5a29a.png 1104w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> This is how it looks like in Jenkins</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 58.995137763371154%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAABX0lEQVQoz5WS626DMAyFef9326ZpD9Cu0AQIl1AgSQlwFqczQh39sUiRDcQfxydOvkWBbnDYr3Vd4ZyDtRZ+8vB+/t0ek58ecZoOdyIygVobDMZhtPcAA+Z5RpqmSC8ZTvIdF/WGc/6BPJe4Xq8h5pDykVPMsgxCiLiTuqiCGo8lkOZljQqXZUFd1+h0h5P4CrDPGGX+KCYIFXNOYHqmPGm1hlIVjDGxzUb3MKHVSqkIlSJHkasQCxRFEQspkkrOCUTPlCej6TGO4wa01sVYVRWapoGQYmuxLMsNwqA/wFqlGEYT1RCIFplOxW3bbj6xd9zm/h2foTzpmxZ936MOLXY65AOptRuQDWcQXdazh3wmejjRCNwdhtsNt66D7oIFAahUGVvmv3Orz7fMXm4KcbBobKg4eij+6SEN8X6zh/SRWmbgs8L9u5cKGUgTTx/3Hh5dyuEcHgH3Cl8BXw32D+bYirt69wOsAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/big_job-6b00adac266ad63b4329ab984e831995-082a3.png" srcset="/static/big_job-6b00adac266ad63b4329ab984e831995-59f9a.png 163w, /static/big_job-6b00adac266ad63b4329ab984e831995-00530.png 325w, /static/big_job-6b00adac266ad63b4329ab984e831995-082a3.png 650w, /static/big_job-6b00adac266ad63b4329ab984e831995-dba21.png 975w, /static/big_job-6b00adac266ad63b4329ab984e831995-5255b.png 1234w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Now we press the run button, and we got close to 3000 jobs on the queue.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 67.12643678160919%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAABmUlEQVQ4y52T65KjIBCFef/Xm3/JVjZmvYIgAoI3PNNoMpPKbu1WtqssReyP06dbVpQFuLTw44wU27Zhu99TuK6HqDmkUpBSIs9zOOcwDAOapsH5fIYQAp7W1lqwqqwguEavHeIav6Hb8exuPxB4AUMJ3g0QVYtlWfZvEpRzDqUNlnVFjBHsF50opYGzHsu8fKl7ACv9AekutB/gvYdsFMZxQqT9cRyhdQ9jB8yUGwnKOMmtmw5KGUxhusO275KDRO+6HbJSwkAHz9NhT1IaxpSDr8pYITS0HbHE+9uXWMmGQP4+DnjE8/pZBGtbiSzLcL1mu7mGjDXG7KU48uwV8qz+dZ2CZXmNindo2n6/KlJcUpOcH7GSZ3+C/C3YJUtjY9CZANlTF5VDqwfyJ2Ij0/8F+A2YlRLXXOBWNAT0qFtzn8mNFIaj6+8Af95qKrHbVUpSxpXdoYE6+V8KU8mN7KFInejcDkzgeaFBDeF94K1SuBZHyWaYCG4xzesxMgR8N9gpE/g45ThdCpTC4JK31OFp35zp3303PgHGNPXDosKJ+gAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/queue-2896a4b1836e8d7cd8cde81b7ec1ee5a-082a3.png" srcset="/static/queue-2896a4b1836e8d7cd8cde81b7ec1ee5a-59f9a.png 163w, /static/queue-2896a4b1836e8d7cd8cde81b7ec1ee5a-00530.png 325w, /static/queue-2896a4b1836e8d7cd8cde81b7ec1ee5a-082a3.png 650w, /static/queue-2896a4b1836e8d7cd8cde81b7ec1ee5a-d79ad.png 870w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Jenkins spun up 7 instances and started to run the jobs. We got 224 cores chugging. (7*32)</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 41.53225806451613%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABa0lEQVQoz42SW0/CQBCF+zsU0AdogcRSaHd72XZ3Cy3eYhQIIGJA0ETR//98nFaNPhj04WQmmem3PTNj9Lo9iDBCGASIhYBSEszz4HMO5npQUpY1x3HAGYPbc8uaiCJwioHvw6O+VGuKLoxICQgdI5ICvvDBImoICUbqsh7kQCM7z9G/yHE1HVE+RDrsI5QRguRTcQih4vIbY7lbY7KdY/q0wPJtjcVuhdvXByxfVrgjLZ7vMd7MMHmclxptprh5mGJUaPOt8XaGy8U1jFRqtMwmCus6G5Bt+ls/RBzFSCjnHsNx7QjVgwpqh1XUKvtUg5EPc3ScDnjgk51T6H4KRfNQWiEtcqXQbDVhmiZM6w9Rj5HnOWzbLoGDs+EHRKoSVAxa0lIsy0K9Xkej0fhVX7UiGlmWwT6xwXxOw86g0xRJkpRATUBBm7fo9X8DAzqJdrsNu0O2Q9oyZ/DobFw6AU45o1MprOwD/oS+A9ZYBeX0RtSgAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/cores_chug-c1df90c5f35dd742b0909553b146c238-082a3.png" srcset="/static/cores_chug-c1df90c5f35dd742b0909553b146c238-59f9a.png 163w, /static/cores_chug-c1df90c5f35dd742b0909553b146c238-00530.png 325w, /static/cores_chug-c1df90c5f35dd742b0909553b146c238-082a3.png 650w, /static/cores_chug-c1df90c5f35dd742b0909553b146c238-dba21.png 975w, /static/cores_chug-c1df90c5f35dd742b0909553b146c238-e5f8a.png 1240w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> After 14 minutes the jobs are done, and we see that some of them have failed.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 42.40549828178695%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABIUlEQVQoz3WS227CMBBE8/9fxkvVJ1ClthRBQorvuZG7Tx0KKKR0pZHXK3t2Zu2oi2NkkqC0RkqJDqsQgjRNKcuSKbz3LGOq3ep9U6ONparORG2RUwV0XUfbtlc01OFQ3/dPCS9k0zqhzPA6pa4biqohquwRkWwpyoZx5KmS/2p+6C+E83pk1InksEfqb0x2xGYnXKFRds8w9A/25uTL/LaPXJZhgn+TxYh8g3YfWLdFFu/cBPvFxSWY5ZFzFqV0IDqQ2BeEWmPiV8RhxWgl1BU+zNT3Hc/ibv+uMBBqZZB2x16v0MUXpjwgzJoxkPiqwOfmF5nGO4U/l/guNLkOfW4/MsZcFEq3Q+ZvnNwGlW9RxSejHx8tT48w4XxtMvz9BT/aEm62tydqfgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/jobs_done-3028b166e1b46c900eceef659afeaff8-082a3.png" srcset="/static/jobs_done-3028b166e1b46c900eceef659afeaff8-59f9a.png 163w, /static/jobs_done-3028b166e1b46c900eceef659afeaff8-00530.png 325w, /static/jobs_done-3028b166e1b46c900eceef659afeaff8-082a3.png 650w, /static/jobs_done-3028b166e1b46c900eceef659afeaff8-dba21.png 975w, /static/jobs_done-3028b166e1b46c900eceef659afeaff8-1823f.png 1300w, /static/jobs_done-3028b166e1b46c900eceef659afeaff8-1b0e0.png 1455w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Let’s click on the red balls to see why they have failed.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 68.21994408201306%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAABnUlEQVQ4y4WT2W6DMBBF/f//VlVKX/qSKmVfDcSYHd/OECAEaDvSyAjbZ7ZrEaUB7rJE13ZgM8bA8EffQ18ucCwLlm3DdRzYtB7NPO7MLoIggNYtk1Yg20jA7HqFlBJJmiLLMhR5jrqs0TUtmqZBTT4fX03crBs8N4UfSIzjc3ccR/hxDN/3yT0U9xK6alGWFe6qQqkrKKUIPMPrenIROy6cWCEtNIZhfAF6noeYoJxlEMawHR9hlCAgD6MYRVFQZ/oXF+8fbyjKboq+LZk3GTiVSheVulOfW9ofX87tTbipjTDRaDZDYRuGAVEUgXvsuu6U6TqGTb/3Ljji/sAWGIbh1EcGHkDbWc974izqAmQYZ8ilM3wPMkMPU0gYas9yV2zTPQMu0G3J1EwYSQEiB1D58x4DDzLdATk7FnSSSgxaofMt8m90lFnfD+hJaqyINcPfgHyI5ZKRSxK0+vpEbV+hc4mKtFeR9rTW5OUU/F8gH+Iyl8GoPMNfdhjKGfDxSvxJNvz8+B/rc1nP+v9vySmBeG2pxOWJLet+kGw/4VFDDOsCWIYAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-082a3.png" srcset="/static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-59f9a.png 163w, /static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-00530.png 325w, /static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-082a3.png 650w, /static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-dba21.png 975w, /static/addr_found-70bc7f0b6b70ebc39c5894094fb42adb-d9fef.png 1073w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p> Great, we have found the victim IP address. Let’s look at the other jobs and collect the client IDs and IP addresses.</p> <div class="gatsby-highlight" data-language="text"><pre class="language-text"><code class="language-text">ea1e03022cc3a0378ef9056b5346befdf735f56d56509dcb3d1ea03191803815 FOUND: 10.47.4.142 472d7834f4dd0ab70b631f58a923af3c8db18913491e03a6679bbe4ff8e658eb FOUND: 10.47.32.49 b784c8325a15d7b7d62d4ded79b86b08fd0cbc8ed0099fee200b55ef8791eae6 FOUND: 10.47.114.22</code></pre></div> <p> And then let’s submit those to the challenge.</p> <p> We have brute-forced the whole thing under 20 minutes of running time, using 10 machines paying $0.63/hr for each one. The total cost to solve this problem is about $2.00. Not bad at all.</p> <p> Note, my actual costs were a bit higher. I am still learning how to write programs that run correctly first time I run them. Because of this it took more than one attempt to solve the problem. My actual costs were about $10.00.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 12.101910828025478%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAdElEQVQI1y2L2w6CMBAF+f8/A0lE4y2xUi6tC7HQEm6+HZeVh8mZhznR8O3xmd9wS8MQO4m3o4HxBVPChnL3AnWv0U5Wmn+7f1ZCEwgRTRVe/gYdHtD+jpzZ/OkuOFYxsjrB2aY4mYP4huqu0kgrsAdep/ADBACS/hDO080AAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="Solved" title="" src="/static/task5-solved-ce6e5b9fef34d8fcd23ddf0ae372fdcc-082a3.png" srcset="/static/task5-solved-ce6e5b9fef34d8fcd23ddf0ae372fdcc-59f9a.png 163w, /static/task5-solved-ce6e5b9fef34d8fcd23ddf0ae372fdcc-00530.png 325w, /static/task5-solved-ce6e5b9fef34d8fcd23ddf0ae372fdcc-082a3.png 650w, /static/task5-solved-ce6e5b9fef34d8fcd23ddf0ae372fdcc-8896e.png 942w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <h2>Additional reading material</h2> <ol> <li> <p>We used the Jenkins server to help us orchestrate the efforts and organize the results. To read more about it, I suggest to have a look at <a href="https://amzn.to/2C4ViKn">Jenkins: The Definitive Guide</a> by John Ferguson Smart</p> </li> <li> <p>To configure jobs we have used Jenkins Job DSL language. It’s based on Groovy and to read more about Groovy consider this book <a href="https://amzn.to/2VyxYxp">Programming Groovy 2: Dynamic Productivity for the Java Developer</a> by Venkat Subramaniam</p> </li> </ol> <p>Now on to <a href="../codebreaker2018_task6">Task 6 Loophole</a>.</p><![CDATA[CodeBreaker2018 walkthrough, Task 4 Victims]]>https://blog.v-lad.org/codebreaker2018_task4/https://blog.v-lad.org/codebreaker2018_task4/Tue, 08 Jan 2019 00:00:00 GMT<p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 19.616204690831555%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAy0lEQVQY022L3QoBURSF55ZSblygvJCUUuRNTEnk+YRQ8jNj/M4gas45M43Bss85M3d2fa219t7LKDb7KDUHqLSHKLe05utdZKodZKumQvqUf7tCo0fdPnI1E8Z8e4BkYR015GfEaGljst5jvNopnUo2e0xWDu3kzVF5TFn2bPcBy3vCcM8neMTNcxXe5ZzoCVfyKrsX3JP7436F4AyC+QhJo1AgCgTerwhyDM45NELBEs8Yh8+YVp/pHyEUQfQGD0LEcYx0vsTn88UPYO8F2TrjHkYAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-3ba03cffc005ef62e388ea333e7b25b2-082a3.png" srcset="/static/assignment-3ba03cffc005ef62e388ea333e7b25b2-59f9a.png 163w, /static/assignment-3ba03cffc005ef62e388ea333e7b25b2-00530.png 325w, /static/assignment-3ba03cffc005ef62e388ea333e7b25b2-082a3.png 650w, /static/assignment-3ba03cffc005ef62e388ea333e7b25b2-80371.png 938w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Now we need to find out who the the other victims are. To solve this task, we need to have some understanding of how blockchain works.</p> <p>Before starting this challenge, I had absolutely zero knowledge about the blockchain. It took me about two weeks to learn the tools and gain proficiency. It’s not that hard, but some basic understanding of cryptography is helpful.</p> <p>The best resource that I found is Will Button’s course <a href="http://bit.ly/2FvKb0j">Learning Blockchain Application Development</a>. This course is about 3.5 hours of video lectures and takes about a day to finish if you follow the course step by step and do all the projects together with him. </p> <p>Another good resource is Jan-Erik Sandberg <a href="http://bit.ly/2CnLJ9M">Blockchain Fundamentals</a> on PluralSight. </p> <p>Once you cover these introductory materials, read the following articles</p> <ul> <li> <p><a href="http://bit.ly/2Fxivbl">Getting Deep Into Ethereum: How Data Is Stored In Ethereum?</a> - it is very detailed and technical. You can just skim it, no need for complete grokking of the material. However, at least surface level understanding of the material is essential for solving this task.</p> </li> <li> <p><a href="http://bit.ly/2CnxzFh">How to read Ethereum contract storage</a> - less technical than above.</p> </li> </ul> <p>I developed a <a href="http://bit.ly/2CkZKF6">Jupyter notebook</a> that lets you poke around different pieces of the blockchain. You can download the notebook from above link and run it on your own computer. Or you can use <a href="http://bit.ly/2D12FnY">this version</a> to run it on Google Collaboratory platform without downloading or installing anything.</p> <p>Let’s start solving the problem.</p> <p>Open the exploratory notebook, and find in the <em>Settings</em> section find the cell that looks like this.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 16.049382716049383%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAZ0lEQVQI16WOuw6AIAxF+f+/Y9SZBdGB0FqrhivgIw5u3uSkJ70dalDCzLDWout7ZPyLmWVDjAnOOYQCTxPID43qPI4nITzQUHvfaLvS3272PWNdN6gqVARzSljKx0LU5hdy9e+b2w9LbOf0gXQmtwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/bchain_url-f702eb264211d4d7e5e8da38f1cdd288-082a3.png" srcset="/static/bchain_url-f702eb264211d4d7e5e8da38f1cdd288-59f9a.png 163w, /static/bchain_url-f702eb264211d4d7e5e8da38f1cdd288-00530.png 325w, /static/bchain_url-f702eb264211d4d7e5e8da38f1cdd288-082a3.png 650w, /static/bchain_url-f702eb264211d4d7e5e8da38f1cdd288-25544.png 810w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Replace the value of URL with the one given to you in the file called <code class="language-text">blockchain_information.txt</code>.</p> <p>Then execute next cell to verify that everything is configured properly and you can connect to the blockchain.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 13.757396449704142%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAeElEQVQI162LSw7DIAxEuf8RWfGRIBRBqQAnnUVcx2fo4mk+mjGtNTjnEGOEtVYJIWh+yDmj1qqblBK896il4CP+fRTU0PA6KugkEBFM751lzHJkGStjDN5781pLVYY851Q/pXvyJf4SpXVqBsD4go2cbiluZv4LP8Vh5WQAZDUFAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/verify_connection-a749023757e61f62672db01b2c59df1d-082a3.png" srcset="/static/verify_connection-a749023757e61f62672db01b2c59df1d-59f9a.png 163w, /static/verify_connection-a749023757e61f62672db01b2c59df1d-00530.png 325w, /static/verify_connection-a749023757e61f62672db01b2c59df1d-082a3.png 650w, /static/verify_connection-a749023757e61f62672db01b2c59df1d-041bb.png 676w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Keep executing the cells, until you get to the section called <em>Constants</em></p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 41.65413533834587%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABYklEQVQoz5WR2Y7CMAxF+/+fxRtMh0FsZWtLN6BNAoVmKyDuOEUg5nEiHd3YjhPb8ZIkQb/fx2AwQK/XgxAC/12Px+ONJ6VEFEUIwxAhaZHn4IyBEUe6nHOOsixREYfDobOdCsFpz1DXpz+Xe+6AS7y1Fq1V0MagkQpSaShtSJ2tIV8o8xFzSnnXO3Hr8Hzfh+9/YTGbYPOzxOkoIdsbGnN9Iz94+3WLxt47vSj7xiuKAm6Oq/UKWRChTnKcdwXqLMM5z1CnKc505gnFaCQNjcNWO5h0DaMkDHVljO7wMkqMww02wRjxdIhqtUXDBcFxoUSnnS2eXBiHpLnp7RJq/g3FS2jbQmvd4eX0ovuQ4WiEZB6AjSZg0xkxBRuPwSYTcPJ3BBSfzVFTNzZeQGcRzOUM27awVKW11HJKLblfdpXWVIFIE/DtFpzG4GBxDEbxDnqYO/vlWy5QkVbkL9driP0ev6etWXG1nzUdAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/constants-50a25cd9c63a99de98aae49cfc96dd9f-082a3.png" srcset="/static/constants-50a25cd9c63a99de98aae49cfc96dd9f-59f9a.png 163w, /static/constants-50a25cd9c63a99de98aae49cfc96dd9f-00530.png 325w, /static/constants-50a25cd9c63a99de98aae49cfc96dd9f-082a3.png 650w, /static/constants-50a25cd9c63a99de98aae49cfc96dd9f-482cf.png 665w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>In this section, change the values of victim, escrow, ransom and victim<em>id with the values given to you in the files `ransom</em>note.txt<code class="language-text">and</code>blockchain_information.txt`</p> <p>In the <code class="language-text">blockchain_information.txt</code> you find the value for the address of your victim account. Put it into the <code class="language-text">accounts</code> section</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 546px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 25.274725274725274%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAAA8klEQVQY002PWY6DMBBEOcngIMxiggEvmMUBhJQZia+5/2Vq3M4oyseT7a52V3XS9z2qqoKUEkII1HUdKcvyfSdIi4R7JZrA6900DUSAeu73O5LrurDvO6y1MEbDORcxxoDMuq6LvHQDOSj8eofTGYyhRr2kaaWinpzniXVdMU0T5nmORaU0Hg8f3Sl510mkaYqUMcj8hqVguASD4gxf7IYsy94kNMzaEeuyYAls2xaHeu9BZsdxxPP7+cQcen9mi9MvmIL5OFoMw4A8z8E5jyQuJDP/62itQzqFtm1jsiGsR+vSJ6rXdYWMF+BFgeKDz4F/LNScQOTYMxAAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/blockchain_info-33461884e54fb73962c2b268313c2478-d9709.png" srcset="/static/blockchain_info-33461884e54fb73962c2b268313c2478-9fcba.png 163w, /static/blockchain_info-33461884e54fb73962c2b268313c2478-598f3.png 325w, /static/blockchain_info-33461884e54fb73962c2b268313c2478-d9709.png 546w" sizes="(max-width: 546px) 100vw, 546px" /> </span> </span> </p> <p>In the <code class="language-text">ransom_note.txt</code> you will find the rest of the values</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 26.724137931034488%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAAAzklEQVQY01WQWZKDMAxEfRcSAra8Y/b8c/8L9UiqMJn5eCXkklrdmFoLcs4opaDWinmelZQSQgj/iDGCiPDqe3SPB3qGnh267os5zxPHcWDfdxValkX7v6LOOXjvFRG01sJyrYFwlAjPM4mPyayRxeu6sG0bVhZb11W/W2vqSNzfSApNMk1onKxxzXXSZLlUPWakkWVxJkI3IiwOb1GpgrwNwwAaB+x+hOUa7IhGI579C+b9PnX5HhYkmtgncnr129Mvjomf/1pSRMtJo/8AU2CcV8I7sikAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ransom_note-19a6911890b87ccef8e9d4abae69da5c-082a3.png" srcset="/static/ransom_note-19a6911890b87ccef8e9d4abae69da5c-59f9a.png 163w, /static/ransom_note-19a6911890b87ccef8e9d4abae69da5c-00530.png 325w, /static/ransom_note-19a6911890b87ccef8e9d4abae69da5c-082a3.png 650w, /static/ransom_note-19a6911890b87ccef8e9d4abae69da5c-6c202.png 812w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Do not touch the variables that are assigned value of <code class="language-text">None</code>. We will get these values through the blockchain examination.</p> <h3>Now on to the solution.</h3> <p>If you have read all the material above, you’ll understand that all the storage variable of Ethereum smart contract are stored on the blockchain and are publicly available for reading by anyone. The <code class="language-text">private</code> modified used by Solidity language is just a syntactic sugar.</p> <p>Let’s take a look at some simple variables of the escrow.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 86.94444444444443%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAACXklEQVQ4y42UeW/aQBDF/f2/Fv9F6iEl0AZIxRHja32t1zfmdd4QUxolVZF+mt3EfszxBq9pGkRRpCRJojGOYyUMQwRhBFs5TBf818cbxxFZliEIAhhjNFIoTVNYV6FKQ9RFgiaP0DUOwzCg7/tP8fgABQ+HA4qiUCHe8zxHaUvYIkOZyz1N4CqLruv+iUdVHqqqUhEKzpHCxqRIJcbSDj5zuVwEgB24nv/mluHz87P2jWLsZVZIzFK4wsDlsZQeaPmlCa4kPtj/92iGZVlit9vB930dCvtY1/VbvzoM8szMOJBB/tfjfD5jHMl4QwXbtlUoQlga73xhmiZM4yAi3R1X4aFrcBaRszzDZ4mWzKk+PDxgsVhguVxiv9/j6ekJm+0Wu1/CZoU0PEqZJxSx/1Z2iDzcoyoL1FLqnIzHDCqZXhgGOmUnVrmmP2iJHFgvX3oWI9KLkzR+ksN8v8+O2Xr0XhTFaFrp1TDKyyO6ftA76diSWbht0HetxPbPWem034P001utlvjy9Rt+rLd4XP7E90cp+fUEP4xx9AMEsYGfiHWMTD4+IUsiieEVE8tdSpdYlBa2Fh+y7lL6YMXEc6kXKeP6udx8N71DS71nLpmCHMp6vVa70DrcmuPhiEAsZKKTDiQNDjCnPRJ/p7DftFup8e0s6JR5eHl5UWNba9XcxIp9mDknSZycu6ZWPt3l2YcU5cYQbgqhqJHecXBGVpFZ0RUfrdxt9dg3vrDZbFRs/vlK5G85PSarx18bRpdFKONX1M5KEt1tIe7Rkp1z+u2zOe/RHWWcaeoPd3jmN7B6GUhNArXzAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/escrow_simple_var-c2d827fbae8c68ebf6745bddd9d65191-082a3.png" srcset="/static/escrow_simple_var-c2d827fbae8c68ebf6745bddd9d65191-59f9a.png 163w, /static/escrow_simple_var-c2d827fbae8c68ebf6745bddd9d65191-00530.png 325w, /static/escrow_simple_var-c2d827fbae8c68ebf6745bddd9d65191-082a3.png 650w, /static/escrow_simple_var-c2d827fbae8c68ebf6745bddd9d65191-e1c06.png 720w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Now, let’s take a look at the Ransom contracts that Escrow knows about</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 44.71299093655589%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABQklEQVQoz4WSW2+CQBCF+f+/zAdjAl64Se2DFBHKxQUWgXi6Z1pijLUlOQy7O/PNzA5W3/coigJFWULlOeo0RVlX6LoObdtA9xrTNInPOI6iYRxEo9E0/ewNA67XKywGOo6DxWKB9yiCvVzCWa+x3W7hexHCIEL8ESM1ic6fObIsQ3muUOYlsqRGHOdI8zOUUlKEpbUWp8PhANU0uJiDuq5FSpn15YLSVF9VlVgG6k6LulajaUwnXQty2K1USOcgCOB5Hvb7PXa7nVToeS6it0j2XNeVTnJzLX89Fl8EEuL7voAZTHHNJLRMsNlspHU+t9vtSU9ABhM02zAMBUYQz1lhkiQvgZQAeU8MZtC93Tt8rpLg0+n0AHzZMp0p27axNlOeRehc4Wq1wvF4/B/If4hVcoIUv5nke9LqwXKIM+g34Bed86XSQry9+gAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/known_ransoms-44282faf9c6b8db3619f50132ebb0582-082a3.png" srcset="/static/known_ransoms-44282faf9c6b8db3619f50132ebb0582-59f9a.png 163w, /static/known_ransoms-44282faf9c6b8db3619f50132ebb0582-00530.png 325w, /static/known_ransoms-44282faf9c6b8db3619f50132ebb0582-082a3.png 650w, /static/known_ransoms-44282faf9c6b8db3619f50132ebb0582-cd06d.png 662w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>We have almost got a solution to the task. We know the ransom contract address for each victim, but the assignment asks for <code class="language-text">victim_id</code> not the contract address. So let’s look them up in the <code class="language-text">ransom_map</code> mapping.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 52%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAABR0lEQVQoz31Qi26CQBD0/z/OBw+PytNKjMFoA8iB0mR6s3UpbUxJBvZm52aHXdy6Gy7VBVmS43Q84ViWuJ7P6K1F59D3vcC62j7P8/ovFrZ3F1uLIi3g+yFis8VuucShPDjD7tu46zAMw2T2yujH0AnGzxGlS+YHAd73e7xFBl4YIIlThGGIzWaDpm0Fmu4VxJAvJsjSDNutS7fbYekSGhMhMimC55DKreHyccXwTzqaimHTNKiqCnVdiznB5q1rpb7f79Oled8+16E1dQt1ZrooigTGGPlVz/OF9zxPkvq+L1+CGkI5/pkkhHsej4dcookKuTeCtfZ0n2rKsxpyMNNOhmpAkaahERPrIHKr1Wqq2Z8P+5WQAgo5iYbr9Vq4Oa9pOER1mo6aKeE4jkiSBHmeI8syFEUhiONYOOWpIdI0FZCb80z4Bdpk4JkxX6QIAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/victim_ids-3a2c338b972ed985f160e83c646271bb-082a3.png" srcset="/static/victim_ids-3a2c338b972ed985f160e83c646271bb-59f9a.png 163w, /static/victim_ids-3a2c338b972ed985f160e83c646271bb-00530.png 325w, /static/victim_ids-3a2c338b972ed985f160e83c646271bb-082a3.png 650w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Great, we have found all the victim <code class="language-text">ids</code>. All that’s left is to identify which victims have already paid the ransom and which have not. Let’s look those up in <code class="language-text">vicToPayer</code> map.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 20.988805970149254%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAp0lEQVQY05WP3QqDMAyF+/4vN3QDkdW/qhUFW8XVWkXOGi/KtrtdfCQnIckJMy8D/syQ3B9oyhJKaxhjsK7r31hrwfbdoREtoluMOIqRJCl4xqGnCdu2fUEDv7VPaCkjN1JKcJ5B1DW6rkPt4zAM0N6tUiqwLAvmeQ56HMeQT96Acw7sOA70fY9WthBCoPRv00KCNFFV1QUdoONFUVw6z/PQJyPneeINADwtxshHXAQAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/who_paid-69502ba54846c784b80ccdb1bac49ed8-082a3.png" srcset="/static/who_paid-69502ba54846c784b80ccdb1bac49ed8-59f9a.png 163w, /static/who_paid-69502ba54846c784b80ccdb1bac49ed8-00530.png 325w, /static/who_paid-69502ba54846c784b80ccdb1bac49ed8-082a3.png 650w, /static/who_paid-69502ba54846c784b80ccdb1bac49ed8-dba21.png 975w, /static/who_paid-69502ba54846c784b80ccdb1bac49ed8-c232b.png 1072w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Now we have gathered all the answers.</p> <p>Let’s submit the IDs victim of the victims who have paid and of the ones who have not.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 648px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 9.722222222222221%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAYklEQVQI102LRwqAMBREc/9juRJijSaxBF1YsKFHGP9XAlk8hmliuC0849PA7gWqJYGaJamE2XLUa/plHu7MVnz78M8IDv/iV3dptEdFKHRnDb1miF2EcpLoyTeUM7wLf54XQv2PYWEWfVgAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="Solved" title="" src="/static/task4-solved-b3f8534a497e69f7e4b9e6c6fa63dd73-b7dfc.png" srcset="/static/task4-solved-b3f8534a497e69f7e4b9e6c6fa63dd73-256b6.png 163w, /static/task4-solved-b3f8534a497e69f7e4b9e6c6fa63dd73-37be2.png 325w, /static/task4-solved-b3f8534a497e69f7e4b9e6c6fa63dd73-b7dfc.png 648w" sizes="(max-width: 648px) 100vw, 648px" /> </span> </span> </p> <p>And now on <a href="../codebreaker2018_task5">Task 5 Containment</a></p><![CDATA[CodeBreaker2018 walkthrough, Task 3 Connections]]>https://blog.v-lad.org/codebreaker2018_task3/https://blog.v-lad.org/codebreaker2018_task3/Mon, 07 Jan 2019 00:00:00 GMT<p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 15.800636267232237%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAApUlEQVQI1z2KSQ6CQBREOZLDBTAajZdRlw6ol1B3Inoy6Ek6ESSBxhWWvzvI4uX9ql+ev7nCMg0i+GvyPsLscHeeBDfMjw93u771cHVBb3FGf2l9woA83oUYbUN4rywDFwpcSgipkHBBWSJhHIxuZyEQJwwxY+4naSdpz+mvlIKgzm5N/YH3znM8qdRaQ6cpiqJAbQyMpaocXSbqlrIsu/z3t2nwA8jAxPoEBsHeAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-56d341ca4dff7a766ebb26ef53196b72-082a3.png" srcset="/static/assignment-56d341ca4dff7a766ebb26ef53196b72-59f9a.png 163w, /static/assignment-56d341ca4dff7a766ebb26ef53196b72-00530.png 325w, /static/assignment-56d341ca4dff7a766ebb26ef53196b72-082a3.png 650w, /static/assignment-56d341ca4dff7a766ebb26ef53196b72-0ce48.png 943w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>While solving <a href="../codebreaker2018_task1">Task 1</a>, we didn’t reverse engineer the CID function. This time we will. Again, we” be using Radare.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 24.643874643874643%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAAA/UlEQVQY002Q6W6DMBCE8yq0PjBHqcAQiUDASQqEFDUHad//SaZr07T9Mdq1V/NpdldRHGM8jZjvVyilUNcVpumEKIpQrNc49B3qZgutM6RZCsk5QsERkBTpVXJon0PQP2MMq5CMx3HAPC/AbV0T8N31RVHA7HdoTYswDCB8H7EUqCIfuRLICZQQUBGMP4A24XDscbtdHKSqNjh/TEiSF0qlceje0JjGJbamZzI9Mf4j5t5WFmbnLqFd+fPr7oCmbdB3nRu6lQlY0hmEEOAP47/KXTr2lzCl2wxDj8v1vCQsS1SbEp7nQeca7c4goyqkhCRZsK1BELie/UIXfQPWlJ1glrVxYgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/use_epochtime-f80d4b8a16fddd1321a4792bbdd3febc-082a3.png" srcset="/static/use_epochtime-f80d4b8a16fddd1321a4792bbdd3febc-59f9a.png 163w, /static/use_epochtime-f80d4b8a16fddd1321a4792bbdd3febc-00530.png 325w, /static/use_epochtime-f80d4b8a16fddd1321a4792bbdd3febc-082a3.png 650w, /static/use_epochtime-f80d4b8a16fddd1321a4792bbdd3febc-bc8ae.png 702w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Looks like it uses <code class="language-text">epochtime</code>, and then calls unnamed function. Most likely that’s the OTP calculation.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 31.048951048951047%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABGElEQVQY002Q2VaDQBBE8y0yCySEIWbRbAwwDISI+mCC+v8fUjadxTzUaQ50F7dqlBgDM5vh57dH2zZQSuPzvUNTlZhMJnDOoXAlbFmgqT1skYNvkgQpzZh2tFIQQkBKiVFiEpg0Rf99gvcVv+y6NxR0OI1j5LklE4vVywrzxRwL2h/LgPcCMUiw7obTq+G5/4KvL4YfZOi9gyGCzW7LmlGKMAzxrAWWoWStbookIiXZ9E547k+oG8/4vnIUXUHrENYS3foVY4omBxr64RNNRVM/aABhw2nyT1i6gj8cjy322w13mJHhdr9DRtGXFFkEASIi1aRL1IvRQ4fmTuio/IHQZhmXHVOH9eGANZmntDNEvh2yHp+vhH9zC73G2tp+KwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/use_hmac-8fb89be195a59a9f7cc864bb74a9f018-082a3.png" srcset="/static/use_hmac-8fb89be195a59a9f7cc864bb74a9f018-59f9a.png 163w, /static/use_hmac-8fb89be195a59a9f7cc864bb74a9f018-00530.png 325w, /static/use_hmac-8fb89be195a59a9f7cc864bb74a9f018-082a3.png 650w, /static/use_hmac-8fb89be195a59a9f7cc864bb74a9f018-4c15d.png 715w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Aha, looks like it is a SHA256 HMAC signature calculation. It uses the same secret key that we recovered in <a href="../codebreaker2018_task2">Task 2</a></p> <p><code class="language-text">cid = HMAC( &#39;IP_ADDR | OTP&#39;)</code></p> <p>The full implementation of the function with the tests is <a href="http://bit.ly/2H8TrtR">here</a>. Note that in our test cases we have used the IP address and the OTP values that we have recovered in <a href="../codebreaker2018_task0">Task 0</a> and <a href="../codebreaker2018_task1">Task 1</a>.</p> <p>All we need now is too look at the <code class="language-text">victim_information</code> file to get the new values for <code class="language-text">IP address</code> and <code class="language-text">OTP</code>.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 414px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 27.294685990338163%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAABJklEQVQY0yWQTU7DMBCFcwqEhIDWjluHkkLj2E7qNnEa5adUQkJs2VCx4A7cA3HbxzhdjGZGHn1+70VlWSLLNpAygbEWWmsYY6bSeQ5rDZxzqOsaG9q9K3EuHvC1YUhEDB4LLKgLqpjmKI5jPK5WcFuHorBQSiFN1zQX9ImkQwG5XOCWcQzJDH/uHjvJcMfFBFvS+9uaT9AJyBgjFRbjOOJ0esGRelAdqm1btIcDur5HvveoC4PWZFjLBSSBAnRMBc4Zxw27wKP5fE6WFYZhhPcefddhS7ADwRraNSk97rf4HZ/xXST41BKvKYfgHFczjh/L8PHEcD27qIyCrWBzGAZUVYWmabCjzMIeyhLclxbvmYQ3CppuM2OR5wqKMq2snnIPLkM8//YroVyT/02rAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/victim_info-6f78392b173a24ee3d092e0ef146376e-487d9.png" srcset="/static/victim_info-6f78392b173a24ee3d092e0ef146376e-e4426.png 163w, /static/victim_info-6f78392b173a24ee3d092e0ef146376e-923b6.png 325w, /static/victim_info-6f78392b173a24ee3d092e0ef146376e-487d9.png 414w" sizes="(max-width: 414px) 100vw, 414px" /> </span> </span> </p> <p>Then enter them as the input of the test case. <a href="http://bit.ly/2D5FJUp">Here</a> is the example.</p> <p>Let’s run the model again with the new values.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 16.203143893591292%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAi0lEQVQI12WNXQ6DIBCEuQsYQSEKQcTIn/c/1LS7bfrShy/DzLKzwnuPUsqP1hrGGOi9M+Sf5+Gs1cb+PE8452CtxbZtsO/3vu9Y1xVCSokQAlJK/PG6Ltz3jZwz0nHwjHytFTFG9lQyTROUUn+I4ANfI+gCqdEGxnxYloVzrTUrZfM88zKVcvFXiRedl12369tU5gAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/test_real_val-cc95f800efa5c0d0f3a6dd49b632e2b0-082a3.png" srcset="/static/test_real_val-cc95f800efa5c0d0f3a6dd49b632e2b0-59f9a.png 163w, /static/test_real_val-cc95f800efa5c0d0f3a6dd49b632e2b0-00530.png 325w, /static/test_real_val-cc95f800efa5c0d0f3a6dd49b632e2b0-082a3.png 650w, /static/test_real_val-cc95f800efa5c0d0f3a6dd49b632e2b0-5844a.png 827w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>The test case is failing, but we do now have the new CID value for the other victim. We can submit it now.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 10.337552742616033%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAZ0lEQVQI11XK2QqAIBRF0f7/6yqKBhtMK00hbXw9idD0sOBezg6opJgODrGxh9w4uG1QqxyV0+jC3/ff29Y3b88wrh3mUyOoRgK2EHTGsR+mRKkSZCJELmMvExGITv32ax1qCqh9wAWH35KrFd0YhgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="Solved" title="" src="/static/task3-solved-6944668b4124b15a107e25333a29f80f-082a3.png" srcset="/static/task3-solved-6944668b4124b15a107e25333a29f80f-59f9a.png 163w, /static/task3-solved-6944668b4124b15a107e25333a29f80f-00530.png 325w, /static/task3-solved-6944668b4124b15a107e25333a29f80f-082a3.png 650w, /static/task3-solved-6944668b4124b15a107e25333a29f80f-a668a.png 948w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Let’s got to <a href="../codebreaker2018_task4">Task 4</a></p><![CDATA[CodeBreaker2018 walkthrough, Task 1 It begins]]>https://blog.v-lad.org/codebreaker2018_task1/https://blog.v-lad.org/codebreaker2018_task1/Sat, 05 Jan 2019 00:00:00 GMT<p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 22.45989304812834%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAxklEQVQY002OS3LCMBBEfZrAngKKAnKdhB3/cIyYDU5izgbYGsmSDCzsfTMah8/i1WuNWjWKurMEvXmC0TrFYPnL/sOQGX+l4pGQ4n2zR2e6w9vHN1qfMXN3jPZki/6C365+EOnC4pQTMkXiZ1biTGkcs1wyaQPD/eBcKSjSbILi8+GUw/ozouvlAlsUcExwYYzYaC05WBM9sszDvWmy+Z8TL6jrClFZlryJpEQUyhbeezjnZeacE6y1LzjpBZp7D82/rOoaN5Z+CxkalZxQAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-92669f32c0be5722dda3f6aeda3d6343-082a3.png" srcset="/static/assignment-92669f32c0be5722dda3f6aeda3d6343-59f9a.png 163w, /static/assignment-92669f32c0be5722dda3f6aeda3d6343-00530.png 325w, /static/assignment-92669f32c0be5722dda3f6aeda3d6343-082a3.png 650w, /static/assignment-92669f32c0be5722dda3f6aeda3d6343-2ea92.png 935w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>In this task we are asked to examine the binary pieces left by ransomware and captured network traffic to extract the following information:</p> <ul> <li>Victim Identifier</li> <li>Encrypted Ransom Key</li> <li>One-Time Passcode (OTP) used to authenticate the client to the ransomware LP</li> <li>Escrow contract address</li> </ul> <p>There are two ways to do this:</p> <ul> <li>we can just extract this information from the dump using some guesswork and a bit of luck, or;</li> <li>we can go the full reverse engineering route.</li> </ul> <p>The second option is a fast one, but we will then run into problems during the following tasks, so we have to reverse engineer everything anyway.</p> <p>Let’s do it the right way the first time.</p> <p>We are given two binary shared libraries that are pieces of a larger program. The challenge states that the rest of the ransomware has been removed by the attackers after the infection.</p> <p>We will solve the problem by building the model that incorporates the reverse engineered code from the libraries, the unit tests that exercise the code under different conditions and some mock up code to simulate the attackers’ infrastructure.</p> <p>The mock-up code is very important for several reasons. Firstly, the ransomware is a client-server type of system for which we have only the client. We don’t have any control over the server part, nor should we communicate with the attackers while trying to develop countermeasures against them. Secondly, even if we had access to a ransomware server, we still would use the mocks because the distributed network development is very hard. It’s much easier to work on something that is self-contained within a single process that we have complete control over.</p> <p>We will use a standard mock pattern by following these steps:</p> <ol> <li>Prepare canned responses to the ransomware code</li> <li>Reset the mock to initial state</li> <li> <p>Call ransomware function under tests</p> <ul> <li>Mocks check that they were called with the expected parameters and return the canned response back.</li> </ul> </li> <li>We’ll assert that mocks we called correct number of times in correct sequence with correct parameters</li> <li>We’ll also assert that function under test returned expected result</li> </ol> <p>You can read more about mocking <a href="http://bit.ly/2FsnvOv">here</a>. We will use a <a href="http://bit.ly/2M7S0dP">cpputest</a> library which includes both great unit testing and mocking package.</p> <h2>Let’s begin.</h2> <p>First we setup our <a href="http://bit.ly/2smEg60">initial model</a>. This model is just a skeleton framework with some rudimentary tests, and then we will expand it later in the process.</p> <p>Then we’ll use wireshark to dump the conversation between the ransomware and command post into the form of C arrays. This is very handy to use in our model code.</p> <ol> <li> <p>Open provided traffic capture with <a href="http://bit.ly/2FpNNBc">wireshark</a></p> </li> <li> <p>Right click (on mac CMD-Click) the first packet and select “Follow TCP Stream” <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 65.49520766773162%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsSAAALEgHS3X78AAACI0lEQVQ4y5XRi1LaQBSA4bz/Y3Ta6VSttlKQouUiJJAQIaAIoRAIFyGAQCAoF+Hvgk47Y3Vsd+abc/Zkz+4mkZRsCr0qk2zkyXULpO0MuRsDvaWg2nH0hoZSltFradSqitEyKPaLwvWLpLiqkMyohOUIRyfHBKMhTiIhZD2F7zSAlk9jlAwuCheUG2USukwg/J1A5A9/OIj/R5BvgmRbc24aa/JZB79fJ601kRMVKqZHWm1iZExy2SzVnxZ9pyfmVWLRslAiEa8QjRQ5j5UFkx9nV0it5gqnA8XikHC0QC7XRb9oYdfnGIaDadaxqmVGw1uW8xmW5ZBM2ajaIy1tk1Lrv3NJThRIJUsEAgrv3vs49sX5fBjm/DzPl68x4koWzShwKTZ2xjOS2hX7B6ccHJ6ydxBibz/Eh48BPom4J+qS44zo9ca0231xeptm08G2O3Q6Q9oth2i2wZHW5TgzwJdziWUs9LRO1rjkulihXu9g1dq7nlr9Bok3Rr/fo2yaON0OrjtmKF59W7u9HbBYzP9aL63Xa1612eB5HoPBQGw0YjQas1wud40b8Wzrec+bN/zfIc28Cd7EZToZ446GTN0Rk/FQEFHk2/qdNxUmzKYu93ceq8U9y1dIat4iqFwTShY5SVwRSpXwiz8clAs7Z6pJIt8gWeigCJrZx6hNBPdF0vIB5qsNixVs88WTXb56ytePxLJdXDy87tk33DzhWfx3vwAehrm96XFvlgAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/followstream-909d1649e6501c9cacf8df038c78e088-082a3.png" srcset="/static/followstream-909d1649e6501c9cacf8df038c78e088-59f9a.png 163w, /static/followstream-909d1649e6501c9cacf8df038c78e088-00530.png 325w, /static/followstream-909d1649e6501c9cacf8df038c78e088-082a3.png 650w, /static/followstream-909d1649e6501c9cacf8df038c78e088-dba21.png 975w, /static/followstream-909d1649e6501c9cacf8df038c78e088-8744b.png 1252w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> </li> <li> <p>Once you see the conversation dump, select show as C arrays and save the file into the model code. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 93.91752577319589%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAAsSAAALEgHS3X78AAADRUlEQVQ4y62U6XLiOBSFef9H6NeYqv7T1Z0QliSdDDDNaiwvsmWDV/CSBALk9LEIPcn8Hld9de49UsmWrnVbxqiP0WwIx7IhTBOO48Als+lUYywWmM9mWMznOp6MJ5hMJhBCwOT8pWHAIJZlYTgcobUyTMh2B263C69/C0mVvb6O1c+f715P49/dwb+9hdfr0e9rz725gX19DZ+e+GeK1no2gfz+Dd71Fbyr7/DbV1A3bagO6d7Q+0HvWtPM8emF93eI/n7E+vFBx6rfQ/RwD2s8Q0vZIZZDF+KXC3NoYzlyIMYezJFL34E98Tgm6UmEIkTs58iTp09kcY0i3/EYPH5h/AQZHOAFrxqpGvaM9589qh8etC/9ncZr5qkmf4EKj1gYPlqhu4YzDSCNFTwzeieGL2IoK6EmOr+MRV6KNMiRqIykf7TxQn+FVmIJxIMB0vEY2+WSGFoLVrAQZ7bmv35pGqisJSpBbWJBj3FNYk+iVUYxnnyFWgWoG/2I+uAzfmKcWAproRCJs8ZW8J4HCKRiUbwMxizFcp5Q47MSc3H2Gp1PYtgmt6Qq2FYJQaxGBdU+qxAVpIz4H64ruN5OH+wFT+3gBx9QTQHoc8ynquBMEO5YjEu8RxCkaEUyhJraCGZk7mJlSGS2xEb6yF0PuUNcnzm3HWd4SvLPpDlq6nO6QRyyKEUYorYtVI6N2nU0lW3r/L/Urvtnzhnm0uWYg2dq4LgsSpLiJYrwzOJceIkvJJrn+DIWYb/d4rUssS9KrZf4WFdYhTzDl90O/9ez2W7QqvmGw+sr9vsD2eNwOOB4PL7rAW8n6umE0zsAeTuS8/iR8w6HI05vb0jTjFcvCHS7slkIYQpWKsCW29psNsjyDQRvwHoVQnoefDLjfZ06EYZ2hlWUIEtTxNEKaRToeS3FHzbi2aRpQlJkWYaqqkiJsqwQphXynItyTpZE+DFw8eXrHF8HK26xQF0WGNkp/hrmmNhrXr0k1l+TZznfFOtFdc5FmrjcnuOiKPQLEn6NdCw8V1u9k7LYwo8L/HK3sD0u+MAm2ul0cMNGec1G2W630WWz7LLRNl4z1tDkDY+Pj7B5RHN278bvsdHe3/Zx12tjNBzgN3accvXjbX3dAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/showascarrays-90f8f7659c3c4d1448af355201948a8e-082a3.png" srcset="/static/showascarrays-90f8f7659c3c4d1448af355201948a8e-59f9a.png 163w, /static/showascarrays-90f8f7659c3c4d1448af355201948a8e-00530.png 325w, /static/showascarrays-90f8f7659c3c4d1448af355201948a8e-082a3.png 650w, /static/showascarrays-90f8f7659c3c4d1448af355201948a8e-ebbd0.png 970w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> </li> <li> <p>Include saved file <a href="http://bit.ly/2D4iEld">into the model</a></p> </li> </ol> <p>Now that we have test data, let’s take a crack at lib_comm.so. We will use a combination of <a href="http://bit.ly/2Fpufwz">Dissasembler.io</a> and <a href="http://bit.ly/2sgwURE">Radare</a>. If you haven’t done <a href="../codebreaker2018_task2/">Task 2</a> yet, I strongly recommend completing that task first, before doing this one.</p> <p>We start by having a look at the code with Dissasembler.io. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 76.70286278381046%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsSAAALEgHS3X78AAACRUlEQVQ4y32Ui27iMBBF+f8vAlr6BSvtCsQ7DSVNnPcDSOIkjnt3xrTQVCqWRjF2fDN3zpgRaERRhPF4jP1+zz+hdY++7+G6LoTw8ddyYfsJsryAUr155+PjYxA8lFIYfQk+PT1hsVjg9fUVWZqi7XpsjwkWxxR+ekZ5qeFFBZpW4bfBwkYwjmNMJhNsNpuvLfRa490L4QQp1v4JQVGbDGTToZbDqGRLe3ooyJZXqxXatoWUdJgtixDCj/DmCIgwgQgSyrAzB7UexnVN3y1Pp1PM53M4joNTUZBlTZZTLJwc4tSibhSKS2Ms80HVa6rzNXiuTS1/CB4Oh1s9+FCSpIiSDFuRw0svaJr2avlnkG0WHVhmKOv1mqgKFEVOGSpsbYGl7cN68xBGKWwnhCTLvw1jmQvNmT0/PxvBLMsok8Z80XYJiJvjmLc4SwLS9ijrliAQCPO8Bq911E4mw7qujRALWpZlvsQ9yMHZBkGAufUOy40Qk/3uQR92XYeRlNK0y2w2w3K5xPl8Bq9xHx5FgYOXoywlLhRBcjb1YhAsrD6D51fa+i7INbRte1CPIAipdgnWXgbXQGkMFNmoz+d9foPyPUN+lmWJqioNlMN7aEAc3QA+QXkj27z+EAqrcu9xhtvt9rbZkwUvyCCiHFGpkFUdWdMERl1h1O0NzAAKH/Y8z/ThbrczMKqqMtdM+AFdP4KyO1I9I7h+jOxUgRn8hMJrt5vC/yovLy/mpvA8jiOUlcSfpYt/G4/snpDkpWkjx88fWv4PlK93VR7OIVIAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/first_look_dis_io-3aec6225cef95806adff83b769956760-082a3.png" srcset="/static/first_look_dis_io-3aec6225cef95806adff83b769956760-59f9a.png 163w, /static/first_look_dis_io-3aec6225cef95806adff83b769956760-00530.png 325w, /static/first_look_dis_io-3aec6225cef95806adff83b769956760-082a3.png 650w, /static/first_look_dis_io-3aec6225cef95806adff83b769956760-dba21.png 975w, /static/first_look_dis_io-3aec6225cef95806adff83b769956760-fc031.png 1013w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Most functions in the library are just shims that glue dynamic libraries together. Except for the three at the bottom that seem to do something useful. Unfortunately, disassembler.io doesn’t do a very good job at resolving external references. This makes it quite hard to understand what is going on. Perhaps Radare will be more effective.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 58.253461128860486%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAAB4ElEQVQoz31T23KiQBT0W0QBuQiISMJNYCAihYn7BzFKrNTW/v9j7zmjGCvJ7sNUM1Sdnu7pnlGWJdjtW6xWAbI0Rb5eI4ljeJ6Hpb+AZZlQVZW+fcznc9pbsG1bfruuC8dxYBoGJpMJptMpRmmW4vefDwRLH/vnZzyEIfI8h6grIo5gmSYURYGu6ZKYhwbUNA26fvl/IyyFwOl0lGp+vewJl0jokG3XwiEFJhEuPBeuM7+iA5tUsmJGPmwgYxzVmyec+gthWRTSEh9SVgIGkc1mM2ikgNUMixXpV2Si+zVakz1WGEcR8ixDSJabTYM4SaBeCVjFeDy+qblfg7KbZR7s+5O8u65tIcoSQlSoqhoRHWLZliS1LVviMDisr/tRRqm+Hl4RUspdu4Ug2xVZrusaaRJTKIa8+GKdy3RZ5X8Ji7LA+eMMf+HhZbeTITyyfVHApMqw1WFQ+WL33vInoSjxfu6xCpbYdZ1UEZEyUYubIg6Gw7pXov5L4VOzQf/ew6eUt00DhwqbUjglETquQ3sbHiFXhl1wbVzHlbUxqNDDFXz2kOpxPB7w+BCiyAsqeIB22yKnu9T0S3EV5bvVnyzLHvLg29uBQlnJZxcEAcpSULkz+bxU7XvXfgqFkVvwF+WkeixUNazdAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/radare_first_dump-584687744561e9d614c53b5ccd5e351a-082a3.png" srcset="/static/radare_first_dump-584687744561e9d614c53b5ccd5e351a-59f9a.png 163w, /static/radare_first_dump-584687744561e9d614c53b5ccd5e351a-00530.png 325w, /static/radare_first_dump-584687744561e9d614c53b5ccd5e351a-082a3.png 650w, /static/radare_first_dump-584687744561e9d614c53b5ccd5e351a-98cd3.png 939w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> .</p> <p>Yes, this looks much better. Now we do see the actual mentioning of external names. The function at <em>0xa30</em> is just a standard DLL shutdown / clean-up function, and can be ignored for now.</p> <p>Let’s look at the one at <em>0xb30</em> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 69.54377311960542%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsSAAALEgHS3X78AAACdklEQVQ4y3WT63KiQBBGfZLsltyZAQEVxIgCAioxcRMvUeNGk33/Z/i2Z5JYMZX86BpL8XC6+5sGYwzNZhOLuzus12tkWYZsNASzbcS9GOlohCAIEPoeIktHznSYmgpV1aDRqWmaLFVVYRgGGrbNoCgKXv+9YLffwjRNTKoSURRhcJ1gelOjHYW49RkygjFDh64TRL2EfZwNYagoKo4vRzw+bqTZerlEmqYEHKCaTjHKRujHMRzHAfN8cKrf1NVXmDgbQtNmNg5/D9htt/Dp4fvFAhkBsyxHXd8gH+fokvFD18WE60i5gZZBEO2ybQlUiCwsD4cn7HZbBL6P3WZDsBR5niGl8gMfJpl7DkfH5fAIFhqKtJJQcX42DLodnF5PWK2XsGiGm9UKs9kU/es+6vkNUoJ36ZkoDMGpbY+6aPkBGOdn0NkwaLdR386xIoho06U/9KIehoMBwm6INv2u67qcrU1lWDZc/23rrm1B+QoUb2y1Wng+PmOzWUvg6uEB/X6MQZIgL8cI6bMAdQiS+A7+xB3M2y4cXT0Dzy07rktLYRK43T6CMy5b1ihnMW12Nq9RVAWSFsMtUxCZKmxVkVFrqpexeTPkDlxheHrG09OeDF2URUEh1TEcDjFb3GEStXHvmTLUKZXYsKJq38dGDNa0LBxPR+z3O7nxqizA6fsszVFMKvmgTmVScQq18cXqYobipgigCPWOWu7QEiZlJS2LokSSDGmzHGI0IiLKp4h8B5U3RafoCEORQ4f+3O/18OvqCuNxiaqe0QtNKO83Q3sP84+GFtmJAe9pfsvVUl6vshijR1Bhl9AcXbLzKPAaxecn0Ef9B9NSvxazE+3kAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/radare_dump_of_transmit-5706f902739ed6aeb89bb98d800f3064-082a3.png" srcset="/static/radare_dump_of_transmit-5706f902739ed6aeb89bb98d800f3064-59f9a.png 163w, /static/radare_dump_of_transmit-5706f902739ed6aeb89bb98d800f3064-00530.png 325w, /static/radare_dump_of_transmit-5706f902739ed6aeb89bb98d800f3064-082a3.png 650w, /static/radare_dump_of_transmit-5706f902739ed6aeb89bb98d800f3064-c1577.png 811w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Although disassembler.io was not that helpful with the external names, it is very effective when much better with analyzing the structure of the code.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 639px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 109.38967136150235%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAYAAADAQbwGAAAACXBIWXMAAAsSAAALEgHS3X78AAACMklEQVQ4y51V2Y7aQBDc//+U7EP2jTxEGwklRAsSguXG3Ate4gWDjRnP6crMQIIxZzJSyyOrXa6q7ul5QGolSZLa69g/L+WcWw/ZxCRRNnZwykaSSEgpUjnJ/YCcUYxHDRQKX9Hr1dDvNxCGUwi+Auf8kHsB9AjQBOcCjXoNj4+fUC5XUCyVMRyOEG4iCCmPcs8xPmWoWby7Lmq1Gt6mU4zHE0wmU0RhCCXECaOs/DMeHv5MJQUX3LKmhCDwPDDG9DsBIcR1hllQUxMmGUhMsFgs8D6fw51/wPM+4Pu+9lUzVuq25DRDA8gEs2yUklj4Gwti4ibDS4CEEjjdDvL5PJrNNkbDsWa5wHZLrjM8AsVOMlccMY3Rc7r49vyM/mCIarUOx+mDEHK/5D+JhBFQzhCtfSyXHqiWTzlFYmXL+yQbsOVyibpum0azhYFm1e12EUVbxCyGUOLf22Y2m+Hp6TPy33+g2eqg+lpHGGwsIJf8xOubklerFZyeg9FojIXuvaEuRLAOrVzj67XzfBZQ7o+Y0s9ovbZ78860UJrhXYDGQ9ed4Usuh8LPF7TaXd3EG9t3poXSDO8uiuf9QqlUtH3nunMEQWAlG0CRiP8/y2b5kcQ2ZruzrT3cxtu/Ftx9ltN7yrieiQMUi0W02x0MdaHimNohIfbT5wgw+5fsrJP6o57jIKc9rVReMRq/aQtCbDLz8Yhh1ofdQD54uhsOClLJXbU1OxNnJV+7J25dSOdyfgM4MbYef8gzFwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/dis_io_transmit_struct-7e5b0451aa25641f99b2ba9be71fbf99-e6698.png" srcset="/static/dis_io_transmit_struct-7e5b0451aa25641f99b2ba9be71fbf99-e2022.png 163w, /static/dis_io_transmit_struct-7e5b0451aa25641f99b2ba9be71fbf99-7c7c2.png 325w, /static/dis_io_transmit_struct-7e5b0451aa25641f99b2ba9be71fbf99-e6698.png 639w" sizes="(max-width: 639px) 100vw, 639px" /> </span> </span> </p> <p>Looks like a function that tries to send a fixed size buffer while handling the case of partial transmissions due to full buffers on the local host.</p> <p>What else can we learn from it?</p> <ol> <li>We confirm that our block size is 0x300</li> <li>We also see that they are trying to be Object Oriented and pass around an object of 0x790 bytes long, that includes 0x300 size buffer.</li> <li>Also we see that the buffer starts at position 0x320</li> </ol> <p>Let’s copy these facts to our model. <a href="http://bit.ly/2Foc4Zb">Here</a> is our reverse engineered transmit function.</p> <h2>Now let’s take a look at at the next function.</h2> <p>Again the structure dump from disassembler.io comes in handy</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 489px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 177.50511247443762%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAkCAYAAACJ8xqgAAAACXBIWXMAAAsSAAALEgHS3X78AAACs0lEQVRIx51WibLjIAzr///pzu5rX5qLm5UMpqRJz2QYkgBCtmWTU0op8wohZGdNTrm8f3opzqkBep/neZIeozIhxfiyeecaGPsGGCMYBpcDe2cx0eYI1tJiaSnF8qzfaJUxsM4/AgQITDaYRMDcseSzXVcBqatL41pstDOZgBaAYmrnx6Tm456uA0CX9i53egLoKmCbkG6g/MbLw8fnv38awHsMa+tZKqDzLg/nH35Vi78HZMB89HldlmzhZ/XlS8B+wsaPleUCwGUaN5t9BSgsUyhMYfoyjt+b3PuRPds8XpFdtkb7S0DpY9Higswafy/HqffKZGXVxnEzoyawlCyqATrJTnDwukzZRfeYoZrVhFw2cNBlaNmTFXDOK0BF2DHWvE0tvfjMRQGSIbCypYSsu+VyYSibFr9Yb8rkWFqrKphIf7EaCSsUEQrceQswV+buyhd2Md5sGKj2OGOeZ4kqn8k0aHVKYeOiBkgmFjuyANAvkb6KbEmeLeoetdfrjqC3jQ8A6ZNf5CkD1EuhB+lV8BQwCqADE5stxFoYRhEume1k8w5D+kQ1poFhsaUb1LcfMER+1iNAJIEgjQhCIPCBsFU2TwEVjCAzEt/aVaW9qeRtTQqvAL3IgOyuw0WiHqtpImIIn2P8bqS5jdk7HyrLAhDyikXDcs3TOqHNeTAQt1nzgvN7tEuemSUxbNJ1A5hT2h3ew+WMKNtdwcgSpLA5k3cM+yKgPavJTTbFPC0QGpS+xO0A+0HxrRzqUXKZwCmnh4CHDPvB3kRnnRTTUIurHlpvA27MF+3Bnz//yh9FlcxHgPc9b/6KaMX5juEdoHc+T8PQ3t8G3P37dYtXsDTLjGB5qaHPAWPcsOubANaCQbPld6/m9DGg/ro9ANRxit+ApUXGpAN/n+7l8e6v76Nv/wHtiSPSMtgiHQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/startclient_dump-0887dfbb43d13f7c85b3fce156c4e181-deb34.png" srcset="/static/startclient_dump-0887dfbb43d13f7c85b3fce156c4e181-afa81.png 163w, /static/startclient_dump-0887dfbb43d13f7c85b3fce156c4e181-b30cd.png 325w, /static/startclient_dump-0887dfbb43d13f7c85b3fce156c4e181-deb34.png 489w" sizes="(max-width: 489px) 100vw, 489px" /> </span> </span> </p> <p>as well as the analysis done by the Radare2. </p> <p>An ugly set of parameters</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 28.407460545193686%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAAAn0lEQVQY06XOSwrDIBSFYbeSlxMDsVpJTTpqnNiqee1/LadpAykJBIQOPpAr/PcS0xlYa/EwHZRSkFJCCLHDOUfJylW5Yoxt783yT3TTwvkefh5R8QpZloFSiqIodj7zGGsw9HBjj4sUSNP0G8jzfOe44AxplqAPA9w0gItf8Cg2SrRu8HJhuXCAVNfTYPSFdX2DfTr4aYS+t0iS5K/gG3mWtP4qLahrAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/scli_params-dc6a23665885a247b1e5938a29cb04e1-082a3.png" srcset="/static/scli_params-dc6a23665885a247b1e5938a29cb04e1-59f9a.png 163w, /static/scli_params-dc6a23665885a247b1e5938a29cb04e1-00530.png 325w, /static/scli_params-dc6a23665885a247b1e5938a29cb04e1-082a3.png 650w, /static/scli_params-dc6a23665885a247b1e5938a29cb04e1-dba21.png 975w, /static/scli_params-dc6a23665885a247b1e5938a29cb04e1-1823f.png 1300w, /static/scli_params-dc6a23665885a247b1e5938a29cb04e1-24cda.png 1394w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>However, it doesn’t look that bad</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 53.789004457652304%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsSAAALEgHS3X78AAAB/ElEQVQoz3WSWW/aQBSF+S0sXsBgG5utgBkvY/BWiy0PgJs0eUqCIjVUatI/f3o9FYimysPV2JJ95jvn3IrruXj7/Y44XqCpqiiKb1hv1ujZNubzOaIsAZs5aDabqNVqqFarsHt9mKaJer2ORqMhzvNzZTwe4/H5kX4OoSoyNqsV7oodPNclIYYgCOD7HFm+BGMuZKkBvaPDNAzIsixEzlOKVpjLBGGaxkLw9nDA96JAEkfgYYgky7BIEiziBJv1BrZtod1uY9jvY0BjWxZaRH8RnEwmRPgEzgMSVHCz3aLX60El+zO6zA18TBwHum6go+tQVAWSJBGpJM5yzmLCMmMMv97fBGH50cPdHdJoISgSosqyrzQ55osIDn2rGx2R5Tm36/z+Ek4neDo+Iww5FCIsbc05R7fbJWqONEvFhFSQ53mUm3QR+DhCcMZmOP08UfCuaHJLlkejkQic+T54FGL4ZfQP1cdmr6cydaY4vhyFoEIi+90Ot8WeLGtwiSigbC3LRpfGJGqZivuMUAg6tGM/Tq9kzyfLKg77A1JqWJEVshkipmw9IvVpfcqyNLromvLa7kXwlSyXGbZaGlm+wXAwgGGY4JRbkmeIkhhj2oZuuSKa9qnYpZT7h3u4tCJlKavlEnmek00LDq0LJ8pOuyOEytVpaa3/BK/f/wAwhGwm9+RQVQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/sclient_not_bad-c1c73a8cef1c39d454d60d91a76aedc7-082a3.png" srcset="/static/sclient_not_bad-c1c73a8cef1c39d454d60d91a76aedc7-59f9a.png 163w, /static/sclient_not_bad-c1c73a8cef1c39d454d60d91a76aedc7-00530.png 325w, /static/sclient_not_bad-c1c73a8cef1c39d454d60d91a76aedc7-082a3.png 650w, /static/sclient_not_bad-c1c73a8cef1c39d454d60d91a76aedc7-39f3f.png 673w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Mostly just a bunch of data shuffling back and forth</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 72.64150943396226%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsSAAALEgHS3X78AAACkklEQVQ4y32U6XKiUBSEfZUsmrgCAhl3RBAExA2XGEtF8/7P0NP3zCRlJqn5cUsr4X509+ljwbQtzOZznE9HtFu/kEQRZtMETcOA644QJTGCYAyn30P5+RnFYgmGpuHx8ZHfi99OoWlZ2Oy2uFzOqFTKCIMAx8MBzmCAXr+PCYHj8Rjd3gCtVkuglXL5P0DTFOD7e45arSoKD/s3eJ5HhS6SNIU7GiFJpvD4WSqV8PDw8An4FyzAbLPB5foHOI1jrFZLuegOXaSzGdKEETSbqGsNVKtVuXh/f/8Ju4XSsok5M8zPJ7wwz3gSYUFIm/Z8z0e2yuD7HizbllOmXZ0Zao0Gnmn/m0LrxUa2znDJz7AJDMMJ8tMZMa0r21m2JsiCQYUNgpSyWq2GRr3+M1ApXGUZzucjDF0Xy9FkIhf8sY+YEx+6Q77MJtSAYegwzabAPrL8YrnDOuz2r8jzE/OpYELLPpUpFQ5B6+0a7U4L9UZd/qaOpv1sV4Cqh4vlEtdLLj2Mqe6w32M+SzEaecx3IXVpt1uS3d3dnSj7aSAC1GgzW69FoZryJAw/8+yzi17gs9i+/O/p6UmUmczzFvTFsslib3c7AapiK8sJa6Lq4Xrs32yKMTelzkzVQIq8rMBK6YfaW2jBps3t6w7Xvz2Molg2pdftwXEcxGmCgeug3e3AtGzodGRTRKfVRr/bleHdQguapmPNYue0qYaiJnxhnqrIyrIfBqxQKIrLlYoMxWPhFXDA1VR9vN2cgm40ZcpKobI856od395gUYVavYj2Q6oO+KJOryvFHvJF6ljcMo2D+mJZlTVJp9iwHurhse9jw16KrU4HI1ZoxI3xgxADZ8Ae8leIUQR8LuV+Z4ulPPuh8jcN0fF0crgqQQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/bunch_of_data_shuffle-b62c86c89a476e9f4e465c22a02a803f-082a3.png" srcset="/static/bunch_of_data_shuffle-b62c86c89a476e9f4e465c22a02a803f-59f9a.png 163w, /static/bunch_of_data_shuffle-b62c86c89a476e9f4e465c22a02a803f-00530.png 325w, /static/bunch_of_data_shuffle-b62c86c89a476e9f4e465c22a02a803f-082a3.png 650w, /static/bunch_of_data_shuffle-b62c86c89a476e9f4e465c22a02a803f-3e50c.png 742w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Let’s rewrite those back in C. We see lots of calls being made to <em>libclient_crypt.so</em> routines. For now, we’ll just hardcode their responses using the information we got from the wireshark dump.</p> <p>But, we’ll make one exception with regard to the above. Let’s look at what the BCVH function might be doing. Looks like it just converts binary values to hex strings. We can just write one like this without resorting to reverse engineering tricks.</p> <p><a href="http://bit.ly/2FrI2Tm">Here</a> is the result of our efforts so far.</p> <p>These are all the functions that seem interesting in the <em>libclient_comm.so</em></p> <h2>Let’s look at the crypto library</h2> <p>First let’s take a look at the functions. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 404px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 87.62376237623764%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsSAAALEgHS3X78AAACPklEQVQ4y4VUibKiMBD0/z9QfeoKiCiIHCEHEI7emajsw5I1VV1QJHSmZ3pmJYRAXddo29ahblpUuoFQNXJpUNJTmgbW2kUMw4Dtdov1eo3Vz24PKSU626HrOqimQ5AqhJnGOhLYEKLcABjpxxHjOAeT8dpsNjifz1jtdjvkeQFjDEGjpKhON4GAsDnn+IkKnNIKbdOg+QBW1/f9P0LP8yCqCrWp3abUtSO45opIK3iJcO+cjuaZlt9gUo5yItzvD+6gbS1JtjC2xz6W+HNTiMsawV3jlBm81ojPayL0fR+3243yqGC0dsU4xgJHiowj9WKOUOKSSdyFpiI8olqMMDidEMcxNJExYaUM9pfCSQ2fhDERenHpnrb9ksMkSVyEfFtPVX5J9qjSUWFwSJSTPUl+0zw+P0yE0eWCNE1dhHVtnOfCu8SZEJHMUyqRktSWcsyXvnuQv80k+0GA6/XqvGi0wr3UOJDkICmdfbZknbtQTirL+4Q32/guh2zqgTY0GZtNfSYzby8VdnE1Vfnd1C/MJDNZnueP9qMkm8ZSVTXyyiCrHu0nqBX5wk9g2Uw6ER6PR0RRBCEqKCVRVNpJ7W3rZDLaZlkud9hMchiGyIti8pbtByQlFae2pHFATwkfvmBeZYquLIXrFA6/oSFxIclMONJhvv0bZoQbGjshvfAYk9TTinrZJxNzZduGJC1IXZTs+4ErCm8491OEcUG+oycfXCrGb8yK4lEvZ1lGXfKUQDPvSkOhG5bGwP+Hw1/dN2Xo1aF4pQAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/libcrypto_funcs-5896bd52a365468d0e550a602e4ef712-afc13.png" srcset="/static/libcrypto_funcs-5896bd52a365468d0e550a602e4ef712-f232a.png 163w, /static/libcrypto_funcs-5896bd52a365468d0e550a602e4ef712-4a906.png 325w, /static/libcrypto_funcs-5896bd52a365468d0e550a602e4ef712-afc13.png 404w" sizes="(max-width: 404px) 100vw, 404px" /> </span> </span> </p> <p>Some of those like base32 decode/encode we can just write ourselves, this is faster than digging through reverse engineering. The V_hh function looks like some kind of authentication function. Since we know that this is a successful exchange between ransomware and the server we’ll just stub it. It doesn’t look relevant to our task anyway.</p> <p>We’ll use <a href="http://bit.ly/2SLbYOd">RFC-4648</a> for the spec of base32 encoding.</p> <p>So <a href="http://bit.ly/2THikhC">here</a> is what we got so far.</p> <p>Now we’ve got all basic functions. Let’s see if we can compute the packet signatures that we have had hardcoded.</p> <p>Let’s see what Radare shows.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 626px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 83.86581469648563%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAADAElEQVQ4y11UV5LbRhTkUXaJOMiByIEASYAqay3tyirLlsP9b9HqNwC3VPp4xSFINDo9HO7rirfXz2i7BlEU4XK7YpzOiJMEylNQyoXveXqSOEYYBIijEJ5SsEwTlmW9j8nvh2EY8O3rFzR1Bd8PsH6443K9YJgmrOuCZbkiyzOEYcSHpPB8HwHPrvJgEEDmyDF38EPftfj48TcEfLJHFhPZDeOAuq5xOuWoqhKW4yK0DHSugdIxUXES20RgW3pCjkMwAT7M5xGvnz/BdR0NOowjyqZGnCZwbBuu48AwDEp0EXBc3qgIkDoWSsVxt6l4bjiHiYDrssBxbMoKcb3dCFghLwpa4JO10oAOgU2CydncpT7v82Rssm2RLN4Nfaf/JAxHMiwoM8lS+GGAkEFJWD5/y7KM5xgWmRu7Z8JYZEfONgylxws9FGnCaGYgHa9JMEVZoqCc0XfQeDY6frb8bJSt5dVqkyr/OXFydw+l1gn7SNMMr29MnIwdemqTiVTD1nLMrSb7WX/Xddnki+wnCaVpGp3y/b4gYRDSw+ty0w+ItNwQGa+LvyI5z3N9DmnH5qWlAWPK9Sn9MLIin35/QVUW9DBEz162ZFiTuTwsTVMcj8ctIJb50TcBkiBCArV72uKnTvn739/QESBgsYVdy7Ncly1Raks55ebItjwR3OCNG5CtPVR7B7dN6Xv8+fUPtM22KdM848xyC8tTcdIbFFBeQJkJ2Sa+QmkfUdgGgba6GD+t4EEq88ZiF1wv2ZSH5LJteO715pwk7STGS1fjQ3VCladI6aXNZjz2+X31LvOE/77/hb6ttYcLSy6VGXl9vl3wsl7x5TriVqQYyfbEwnddpz2XFjyAHsD65bDSt0BM5yz3FQtfCtNlZg8L1IGH1HMpbUtTbjTo4/Pz8zuY+bPkfg8goelRHOlSD+cBGV8Msh2KD5FtkUAk8YhelmRZV9W2jr+8wg4zPfr/339wo0zp2Hy5MJgJZzKU6XoWn0zzLMeddvSUO3BiPuRXdjI/AJFxFOyAEr1ZAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/crypto_funcs-edfdfc0f80faa719eb281667df5ee210-9a02e.png" srcset="/static/crypto_funcs-edfdfc0f80faa719eb281667df5ee210-fe66b.png 163w, /static/crypto_funcs-edfdfc0f80faa719eb281667df5ee210-3e67e.png 325w, /static/crypto_funcs-edfdfc0f80faa719eb281667df5ee210-9a02e.png 626w" sizes="(max-width: 626px) 100vw, 626px" /> </span> </span> </p> <p>Looks like c_hh is just straightforward HMAC setup using SHA256 follow with the call to BCVH for which we already have a source code. Let’s code it up and see if it works.</p> <p><a href="http://bit.ly/2smRfEH">Here</a> is the implementation of the real checksum function and the rest of the protocol.</p> <p>Now we understand completely what the protocol is between client and the server. It looks like this <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 623px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 113.96468699839485%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAYAAAALHW+jAAAACXBIWXMAAAsSAAALEgHS3X78AAABWElEQVQ4y9VU2Y6DMAzk/z+yK7ECcQkI9+1lvHU2hdDS42UjzUNsPPbYJk5VVQQopWgcR5qmyYoj3zzPHAuOMAzJoevpuo6WZaFXDmJxQOoISVmWVNc1tW2r0TQNf4wKPM+joii03fwmSRLmgF8TwgFZkLAF7Mg+WPyIh29H+I5kVLojhGSQopphGBjmIPq+54pOE6Zpyj1EIIhNNKs9CAKWJn0T4I4ePy0ZLvi3kP7vCJHp3bW5IRQ56B1kC3CHPYljDtz6gSzLmAPS9WKjfxKwBexxFOmEJkCY57mW7oA1WrPLLr1y6uvQLpcvcsqq5JKVKng90ILt4qIKJLT5f1euoHgtynXdP8lYG+yibS0gyXW/D9cGw9CSPzFl62LfI4Rd5Mr94R7Ka4OJmi8O7vUq1ff9VfLef+q1kYfzDGTKH/lTzFgroWS0/bNHuPsvm4TPVPi/CH8A16MSJfS94V4AAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/cli_ser_proto-cd66f57d77a1346b2165549f5c9b494f-4d6ae.png" srcset="/static/cli_ser_proto-cd66f57d77a1346b2165549f5c9b494f-62dee.png 163w, /static/cli_ser_proto-cd66f57d77a1346b2165549f5c9b494f-53f06.png 325w, /static/cli_ser_proto-cd66f57d77a1346b2165549f5c9b494f-4d6ae.png 623w" sizes="(max-width: 623px) 100vw, 623px" /> </span> </span> </p> <p>Here is our assumption of the meaning of each message:</p> <ul> <li><code class="language-text">HELLO</code> - initial message to the server, include victim IP address, victim ID, OTP and Encrypted Ransom Key. The message is signed with Ransomware secret key using HMAC/SHA256 protocol</li> <li><code class="language-text">ACK</code> - server responds with an ACK of some sort</li> <li><code class="language-text">PING</code> - Ransomware again sends a message to the server, this time it’s just a signed victim<em>ip and victim</em>id signed using the same method</li> <li><code class="language-text">PONG</code> - server responds with an ACK of some sort</li> <li><code class="language-text">BYE</code> - finally ransomware sends the final message which is just a signature of the last ACK received from the server</li> </ul> <p><em>NOTE</em> The names of these messages are made up by me. As typical in reverse engineering scenarios we don’t know the actual names of the variables and constants used by original programmers. This could be viewed as both a good and a bad thing. Having looked at a considerable amount of bad source code, sometimes bad source code is worse than not having a source code at all. The combination of modern optimizing compilers that clean up and remove redundancies, and streamline code and modern reverse engineering tools that show graphs of basic blogs like the ones shown above, give a lot of insight into the internal functioning of the software. </p> <p>The protocol looks pretty naive and convoluted, probably the attackers are trying to guard against replay attacks and substituted malware code.</p> <p>Now that we have a complete reverse engineered model of the ransomware <a href="http://bit.ly/2AGXTu1">code</a> we can take a look at the code that prepares the HELLO packet. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 13.066666666666668%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAm0lEQVQI122OSRKCUAwFuf/1XFggoigUMvwJRD5jG9Gli67XL8kigR8M46DxL4WXnLxhGi3r0gFPof/PJrut+yY/xIMoDjmfDlyTI3kWc79FO2ka4kyOrVMeRUKrM/ryQiVeCkZ65wqsznevq6s8pAhq1aKURmuHcx1W+GTdaPq2Z9CWqmrkxmKVwRiHktk4LSzrxjyvO5N0qbwB51nlB8lo9yAAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/hello_prep-9033ef451fbaeeef5569766591b80a02-082a3.png" srcset="/static/hello_prep-9033ef451fbaeeef5569766591b80a02-59f9a.png 163w, /static/hello_prep-9033ef451fbaeeef5569766591b80a02-00530.png 325w, /static/hello_prep-9033ef451fbaeeef5569766591b80a02-082a3.png 650w, /static/hello_prep-9033ef451fbaeeef5569766591b80a02-39c10.png 750w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>the structure of client <code class="language-text">HELLO</code> packet</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 538px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 41.635687732342%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAAsSAAALEgHS3X78AAABGklEQVQoz4VRW3KDMAzM/W/Vv14gP7ThmUyweRtsbGzYCtNJ08C0mllWZjTSrnRS2iFlGsrM+CuWZXnKf7+f46SURnblKMoGTduh7Qhti45YKom6bgit/7ehWVs+hrzitH6M0dBKYSwr9FWNggnwnHAXvlmSZuC8AONnBJ9vJOCdBubfSufXhoC1Fs5Z7yWJY2TZDYyViKIEJQ1wzvniebZUawiacndseS2cpsk3XSMIPnAJI9zznJRcSV1KfEPTDYd73Vm2bkY/TlCapruF9ijQigGDHGmfPXpiORrChMnO/2JT6C1vFi5hiDTLSCFDnCTgRUn7EuiH0Z/iSNXuKKtdY4y3vl5XCAEpJamUPi+rCqJXj+v+8D6+AMWdbj9hHv+WAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/cli_hello_pkt-bec7db08dbcd62bc72f31669454639ea-c979e.png" srcset="/static/cli_hello_pkt-bec7db08dbcd62bc72f31669454639ea-5e9d1.png 163w, /static/cli_hello_pkt-bec7db08dbcd62bc72f31669454639ea-f0516.png 325w, /static/cli_hello_pkt-bec7db08dbcd62bc72f31669454639ea-c979e.png 538w" sizes="(max-width: 538px) 100vw, 538px" /> </span> </span> </p> <p>and these unit tests</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 505px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 46.93069306930693%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABS0lEQVQoz42SW3ODIBCF8///Xp+atLloo4aICsodPF1Ik5l08pCd2VkYlsP5VjcxJPS9wseuxVfNsT0w7CuG7ZHhWLeoqwpN21EPx7IsYNcewzCAc45JGnT9gpQicqzrik2IvmziCvh4q+XwVqg5wXtfMoRQqjUW1jnaRzi6lIUegs5GqIUajEIMDs4aaLWUzI6ywDtxF914l3BlCyF2qNqBMBlOPxfCvtC6wfncgA8jpJyhtaYqoY0HGw25809ixWFMgTBXTCpCqgBBqemR2STCIvdKYRIC8zyX9V2QC0vuw5PgzSHNwLt8kP4mR3WNJe/Dfgf1IejIyaWT+Nz/oGp6wuywP52xO5zxfawLshCS5qlgrYUxBjNRKO0egk8OYwzlS7HJgUuHfrKE7jHOHouyJCYwjGNBzdh5lrlPzPq1YP4V/tt+N17d+wXn4Lzq5oKL9QAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/cli_hello_unit-f22840989f7558d5974a17acecbc6180-229d3.png" srcset="/static/cli_hello_unit-f22840989f7558d5974a17acecbc6180-29cd4.png 163w, /static/cli_hello_unit-f22840989f7558d5974a17acecbc6180-a3a07.png 325w, /static/cli_hello_unit-f22840989f7558d5974a17acecbc6180-229d3.png 505w" sizes="(max-width: 505px) 100vw, 505px" /> </span> </span> </p> <p>as well as the ransom note</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 21.283783783783782%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAy0lEQVQY0zWQy5KEIAxF/RaVTTcFyCugtKAuZtH//z13AjWzOEUVIZeTTIkSYozIKTMJ5Sg4jgPWWiilEDY9TmMMXu83lJjxvGaIZcHMLH+s6zqYWmscUHCeJypTSkFrF4L3kNrg6yROqyCVhtEa3jn8kEWhCGIJioQY4hDoYpPnxvu+ObDiuq7B8zwgIvTaZ9+xs3lics4I3Gych/OB62G82bYNQojBVMpnjFhrHbTaRnjhuz4mpb4SgmOz3iylhOYV9JBON/vH8Ue/4qeBACYs5ZkAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/ransom_note-de4e0a2dfc69ae2cda6c3c351f18dfc8-082a3.png" srcset="/static/ransom_note-de4e0a2dfc69ae2cda6c3c351f18dfc8-59f9a.png 163w, /static/ransom_note-de4e0a2dfc69ae2cda6c3c351f18dfc8-00530.png 325w, /static/ransom_note-de4e0a2dfc69ae2cda6c3c351f18dfc8-082a3.png 650w, /static/ransom_note-de4e0a2dfc69ae2cda6c3c351f18dfc8-75055.png 888w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>and a dump of the hello packet</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 13.398692810457517%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAAsSAAALEgHS3X78AAAAwElEQVQI1x2OTU/CQBRF+///jaEfzEw7gBqkoNMPE4U0LS0spOPKhbg8vnZxcpPz8m5u4LIFzkaUT4p29czw+MJlv+c6cThwzXOG7ZZeuOx2cssp1wlvNqRYx/Ib4lYRr+ZhdsFHvOAzCTnphGap6LShNYYuTRk2GzqjabXmbC29cLYZx2XEScUyIKNJFY1RHGPpSCICX5b4smIsCm7O4d9rfF0zip8RP+XkfFVJVvz0A3fv+fPf3EcvjPx+3Wb+AZrMzVdwSxLGAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/hellopktdump-321bb45dc9cddb6697acfb84c2066969-082a3.png" srcset="/static/hellopktdump-321bb45dc9cddb6697acfb84c2066969-59f9a.png 163w, /static/hellopktdump-321bb45dc9cddb6697acfb84c2066969-00530.png 325w, /static/hellopktdump-321bb45dc9cddb6697acfb84c2066969-082a3.png 650w, /static/hellopktdump-321bb45dc9cddb6697acfb84c2066969-75b78.png 918w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>and we have all the information we need</p> <ul> <li>Escrow contract address - has been given to us in the ransom note left by the attacker</li> <li>Victim Identifier - has been given in the ransom note, we can also see it in the dump of the hello packet</li> <li>One-Time Passcode (OTP) - in the dump of the hello packet, the 6 symbols that immediately follow the victim identifier</li> <li>Encrypted Ransom Key - again in the dump of the hello packet. It’s the rest of the data after OTP</li> </ul> <p>Note on the encoding. The encoding of the messages is little bit weird. Looks like they convert all binary values to their hex representation, except for the OTP which is converted to decimal. Not clear what the attackers trying to accomplish here. Perhaps the command server is written in the language that is not very friendly to binary encoding. (Javascript?)</p> <p>Now that we have all the data, we can submit it to the challenge.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 17.526881720430108%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAApElEQVQY03WOzQ6CMBCE+/5PhcQAmhAPUoiUFpB/pGhAvI4FDBGihy+ZnZ3ZLCn7BCueCZK7QNQwhIpY8kVf21mnj3DKbbtFF4OI1gNv3QWhYI0DJ7dxYDqMiwbT38FS+sj3cIvTtBdfnbnngUkHZDboijEcSAo7MmH4GqxAnxhnLunnGN2gHpFnEPmq0AzlT+o+R9VlKLtUkaHqM/zLj/5tKPAGDJ8kEcjsNVgAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/task1_done-4cb17774cbcec6913b0c991548d5c38f-082a3.png" srcset="/static/task1_done-4cb17774cbcec6913b0c991548d5c38f-59f9a.png 163w, /static/task1_done-4cb17774cbcec6913b0c991548d5c38f-00530.png 325w, /static/task1_done-4cb17774cbcec6913b0c991548d5c38f-082a3.png 650w, /static/task1_done-4cb17774cbcec6913b0c991548d5c38f-341ba.png 930w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <h2>Additional reading materials</h2> <ol> <li> <p>We have relied a lot on test driven development (TDD) techniques. It was not a pure TDD, because that we already had a code. But a lot of practices came from the TDD approach. Kent Becks’ <a href="https://amzn.to/2M7RSuS">Test Driven Development</a> and Roy Osherove <a href="https://amzn.to/2SPqHYx">The Art of Unit Testing</a> are great introductions to these techniques</p> </li> <li> <p>To learn more about Mocks, read Martin Fowler’s article <a href="http://bit.ly/2FsnvOv">Mocks Arent’ Stubs</a></p> </li> <li> <p>Most of the TDD material out there usually talks about projects written in languages like Java / Python / Ruby / Javascript. The James Grenning’s <a href="https://amzn.to/2RFiBV7">Test Driven Development for Embedded C</a> describes a lot of techniques we have used to solve this task</p> </li> <li> <p>The best way to learn TDD is to by practicing. And the best way to practice it is with the group of people. Checkout these meetups if in your neighborhood:</p> <ul> <li><a href="http://bit.ly/2Rm5RDj">New York</a></li> <li><a href="http://bit.ly/2VNQh1L">Baltimore</a></li> <li><a href="http://bit.ly/2FpYZOW">Austin</a></li> <li><a href="http://bit.ly/2soL5nI">Boston</a></li> <li><a href="http://bit.ly/2QGDOZX">Washington,DC</a></li> <li><a href="http://bit.ly/2slH1oa">Global Day of Code Retreat</a> — annual event happens around November.</li> </ul> </li> </ol> <p>Let’s continue to <a href="../codebreaker2018_task3">Task 3</a></p><![CDATA[CodeBreaker2018 walkthrough, Task 2 Secrets]]>https://blog.v-lad.org/codebreaker2018_task2/https://blog.v-lad.org/codebreaker2018_task2/Fri, 04 Jan 2019 00:00:00 GMT<p>Let’s look at Task 2 before doing Task 1. It is a much quicker and easier task, and it is a good warm-up practice in reverse engineering before we dive into the much more complicated Task 1.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 17.508055853920514%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAAAv0lEQVQY022Myw4BQRBF284CC1/Dgo0E8SMks5GZ+B6PhPgHBHuP8RNMvwZDgtVV3T0ZG4uTW3Xqplih6aPY8lFqB1mWOwPkG32was+Sq3vZ/JdKF6zmodQKwGabI2brA+bbkDilGWJKbrzcW4aLHUbEZGX2nSOdrSNMmj9M8zNifsFNcVxFhKuklBF05PxdCSRauptw+z3t3qhrOokWeMQSMd2ZkApSGfQPcsZzITNE6iy0m57z0vaTxxOv9wdfIMn3sUNwx80AAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-4ca84b98aae2a5e90fca26e300b949a8-082a3.png" srcset="/static/assignment-4ca84b98aae2a5e90fca26e300b949a8-59f9a.png 163w, /static/assignment-4ca84b98aae2a5e90fca26e300b949a8-00530.png 325w, /static/assignment-4ca84b98aae2a5e90fca26e300b949a8-082a3.png 650w, /static/assignment-4ca84b98aae2a5e90fca26e300b949a8-f658c.png 931w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>In this task we are asked to extract a secret key from the binaries left over by the ransomware. To solve this we need to use some reverse engineering tools.</p> <p>The organizers of recommend <a href="http://bit.ly/2ST8vgN">IDAPro</a> or <a href="http://bit.ly/2FgVYAk">Binary Ninja</a>. IDAPro is indeed an excellent tool, but unfortunately in order to get the full functionality you have to buy the complete version which is quite pricey. I have never used the Binary Ninja, looks like a good tool, but also expensive.</p> <p>To keep this accessible to everyone I have opted for the free tools <a href="http://bit.ly/2Fpufwz">Dissasembler.io</a> and <a href="http://bit.ly/2sgwURE">Radare</a></p> <p>The first one is a web application, you don’t need anything to install. The second one is an open source tool which is a package with many distributions. For example, on Mac you can use the excellent <a href="http://bit.ly/2D2iVFf">Homebrew</a> package manager to install it.</p> <div class="gatsby-highlight" data-language="text"><pre class="language-text"><code class="language-text">brew install radare2</code></pre></div> <p>Radare will come in handy for Task 1. In this task we’ll stick with <a href="http://bit.ly/2Fpufwz">Dissasembler.io</a>. </p> <p>Let’s start.</p> <ol> <li>Download libclient_crypt.so</li> <li>Open <a href="http://bit.ly/2Fpufwz">Dissasembler.io</a> in your browser</li> <li>Click on the start disassembling button that looks like this. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 252px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 21.825396825396826%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsSAAALEgHS3X78AAABBElEQVQY003Pz0oCURTH8XmH/pAUrYIyiwqCshHFsVLaCUGLXiFo06Z3sTQiKht1VPpnEoQ1TjW28g/kzLN8O9dcuPjwO4d7z7lc7bT1SLr2TqLqEK82iVhN9BFbJTHMzaLDRsEhPJIx65Oo9cV+rcGxXUdLPzcYz3SZOGszd9nDKPnEih5RoZsecelVnbB8toXq9UIfQ+pIwWMm12XyvMN0rs3h6xva3sMHY5keU9k281c9GfDkskfY/B1Iln12yh6pij+od4U6T1bUQ31mLzoEZDaQ7XBQl4Un7hOGfHXddFm7c1m6/SYkloeCN/8WlGvFJShULorVfIuV/A+pe5sj+4U/gPPY5NxGxrsAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="button" title="" src="/static/startdisbutton-d4ea610872b980cefa8ab3c018a02611-f670d.png" srcset="/static/startdisbutton-d4ea610872b980cefa8ab3c018a02611-6a8c1.png 163w, /static/startdisbutton-d4ea610872b980cefa8ab3c018a02611-f670d.png 252w" sizes="(max-width: 252px) 100vw, 252px" /> </span> </span> </li> <li>Once the app loads, upload your <em>libclient_crypt.so</em> file.</li> <li>After a short time your file will be disassembled and you’ll see the screen like this, <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 50.50215208034433%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsSAAALEgHS3X78AAACQElEQVQozzWRW08TYRCG+1dRLFCCNdZwz7/Q6K033pAQlNCSGKLRGIklHFostYdtt6c9dE/d8+7jbIFJJvnm+76888w7pXfvP7C795Lyi00qlR22tsqUd/aoVGvsVvcp7+3zrPKGje3XPNupsfGU2zW5r/F8c5NX1SqHR4ccfDyg9OmszfVVk8vrFn8k79ot2r0Zp22bt988vnbgYgS/x/BzAL+Gj7VkU4VOd0ir1eLmpkXr6o5Ss6MRrFz0VYqyDHmK8Vyl2W0TxRq+O+L68ju22ZMXnTxZYNhjNHdKktlkuUOS2sSZRckyFljLJQvbR9Fd4jiSTFiaOtboH5lvM1L6HH8+ZjafkZPhrjz6I5XOaMZE0/GkzvKENI0pGaaJbVnobsjYXJFEoXRL0XWD2WBIGoao/R6N4yPmqsyYZThewN+eyp2iMV7Y2G5AGKcEUUrJfBQ0CsGlT+I5IuJTNJovFtI5ZzKd0qifMh8rpIHPKohQJrrYYjLTLRH0pU8uhJkQGgbLpSl+hAx0jyQRdM/G0LQHQSGybZsvJydour721w+EeqYxEDrd8YmiWLxOCaOEki6fDENnbgd0F+6DoKQ57LPo3pPJ2fM8zhoN+v0+rutgWi7NtsL9YLomVabmWiyXadYjF0spPBwaBWEs6CmmkM9k1MJPx3Go1+vc3raIwgBTFnh6MRTPffmb4/nx2poiHjy0xUPvcSkFYSEo9+pkShDGrGSL5+fna8JIlmZYK360p6jGSsjkPYjXdEX8B4OH0uDmDgnVAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-082a3.png" srcset="/static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-59f9a.png 163w, /static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-00530.png 325w, /static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-082a3.png 650w, /static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-dba21.png 975w, /static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-1823f.png 1300w, /static/initial_window-d8658ddfadb83d8fd6d2ac066c5ae26e-24cda.png 1394w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> with the symbols pane on the left and the code pane on the right. </li> <li>Scroll all the way down on the symbols pane. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 390px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 84.1025641025641%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAAAsSAAALEgHS3X78AAACNklEQVQ4y42UCXOjMAyF+///X7ckabIhnOY2GDAG8iqZwuRqdz2jMedDn57EW5okcJwdhBBo2xZKKTRtB1dU8FOJDy+3sQ8KKLqudY++v4+u6zCOIxLSeiuKAq7rIs8Le4NFu36AKBWivME5kSRcw88a9FpjGIan0HR9nudvwTzHznFQ1zV9ZYKhB6b5is+oxj6sEVc9LmmLQ9RgGGe8Wtfr1e5pmuKtqkp4nmeROcOOMuz1YLPyKGLK0hUSCWWcy9bu+rcMsyzF8XjC2b1ANVS/pkHb9ThFFQ5hiQsh87Fg/LjCMSipbtqKrMF1nKZpESyphkEQII6FvTlQmGmGmzQ4xg2CvIWbKpwEIZvJonE2jLkGn2/ItZQWN02z7YuDMQjIhDBXyGRH+CysbCnYTWNGu69h6HkWthmmicB+fyBkFw0ZY6PtsfML/CVEbp/PYEE3w4J3i/uEvJoShpH9ErusKYOoaKl12F0Jj7I9U5aGuoDx+GXe1+BzXlawrqWtIWMPg7GuMRKLJVVLYgoxHfuEbAiPX34Mxt4EExEvyOcz4Ta2H1eXWXweqW6GetMMT6gvkaWsCDekk3S7yQ3O2VVK04OLCWa8N+LRlC1DWdHM+r51mZFZdOImLRdBmoO7er2KuxoKQn5//0PIrm1qdll/TwrPM5vU/4D6IzKbwk25/j0YQRQKUjG+sX1pfgmu9daHGQk5Hw68i0dTshSeV0Dutnrchv9fsU3K7YXHv8cV/7duBb8AT78fBGCwIYoAAAAASUVORK5CYII='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/symbols-a6c38dc1fa81e584a4df7c855753fcb8-f7585.png" srcset="/static/symbols-a6c38dc1fa81e584a4df7c855753fcb8-af2e7.png 163w, /static/symbols-a6c38dc1fa81e584a4df7c855753fcb8-aac0d.png 325w, /static/symbols-a6c38dc1fa81e584a4df7c855753fcb8-f7585.png 390w" sizes="(max-width: 390px) 100vw, 390px" /> </span> </span> </li> <li>Most functions names are self-explanatory, except for the one that is called <em>func_00001930</em>, this looks suspicious. Click on it’s name to see the code. <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 99.08256880733944%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAACbklEQVQ4y42U6XKqQBBG8/4PlURlMd5EQRBQAXGLuIBxV1y+dA+aSJWpy1TNH2VOne5vep5OpxN4xXGMcvkNxWIJ681G/Ha5XGgDQdCDaZow/RAvZojBdIXdPqHvdrS3mf10A86mM0iSjOfnF+x2O9yvMBxhNOwjGE5RsQYYR0sc9tlvbusHGEUxZFlBoVDEYECHxhNsyHS9XmMwmsINPtHtf2KzTmH8X1pBdv8azmaQyZChTaeJTqeDxWKB+fwLljeAXHVQtTpYrrNmDPnDMIJUkqiHRTiOA6fZxGq1Egdsb4iXDw91f3LX28sP7B6aASqKSoYyOn4HrusJ6+PpDL8/QdXpw+5OhOH5fHlolwHy4TSUZ4zCEMvlUhzgknXDht8dYhp9YbHaPjR7GIpC/eOS2U7TdWy3WxySI6qmRz1soVCxRPm5gDdDLtn3fOgE5CST4wkahVHW2wRsoO50cc5nGAng62uBeuhD0zRheAO+6a4wNFq9/EBFVlGipH26MoZhXIFHAazUPUjvDoxmTiCXXLpeG9d1Rck3w1rDR1lro0iGdQLm6mF8DYXL5kvdaDR+gLqdlqxUm3ingBIKKl8oZMhAz/Ng27aYaT5cJUMGqrUWmbawPyT5Q5EkSQDvDUXKVDIbVijt/SGHYTSLxBwrikLPVQDLsjKhsGGZDFNgkhnBP0qOrqGURCi/wN9Q1FpqyL/lmxSaZUVVRcltgh7Jjiel7gSokeWH6eJfvY34a5XDkB7YUjE15P4xkBeHotkBFCrXaPPjusB2t/8/cB7Poapl0Ue+NuNwTLCELE/weiHejIBem+mf7+BtfQPzj+HqreiPbwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="code" title="" src="/static/getsecretkey-3e8d106756efc28727b9ac9e720f2e63-082a3.png" srcset="/static/getsecretkey-3e8d106756efc28727b9ac9e720f2e63-59f9a.png 163w, /static/getsecretkey-3e8d106756efc28727b9ac9e720f2e63-00530.png 325w, /static/getsecretkey-3e8d106756efc28727b9ac9e720f2e63-082a3.png 650w, /static/getsecretkey-3e8d106756efc28727b9ac9e720f2e63-39825.png 872w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </li> <li>These <em>MOVB</em> instructions look interesting. Seems like this function is writing a sequence of byte values to a memory location.</li> <li>So, what’s can we say about these bytes? We see that these values range between 0x30 and 0x59, which covers digits 0 and uppercase letters.</li> <li>Let’s refresh our memory about Base32 encoding <a href="http://bit.ly/2TF6sN3">here</a> and <a href="http://bit.ly/2SQ5Fcc">here</a>.</li> <li>We see that the most common form of Base32 encoding uses uppercase letters A-Z and numbers 0-9.</li> <li>Most likely this is what we want.</li> <li>Let’s convert these hex values to their ASCII representation to get the string <em>CAYPFE6MG2DJT4EB5RIZLIAYFJAUGL3L</em></li> <li>Let’s submit it to the challenge</li> <li>Voila! <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 575px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 10.956521739130435%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAaUlEQVQI102NSQ6AIBRDuf+5TFARnOK0EHGKK9EbVD4OcdG8/qbpZ9o2GI4WRONYbQrZFCGbY6SO+SxQrgmKJfFZ4TzlagxdN4U5O/w32Hv0e418EZCG+zKJvBz5k90kxTrwfB/2tv4GL9FIjUf+eiDiAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="yay" title="" src="/static/task2-solved-1b8f2356a9ca015745911402dc9e8a2b-7abe3.png" srcset="/static/task2-solved-1b8f2356a9ca015745911402dc9e8a2b-ad948.png 163w, /static/task2-solved-1b8f2356a9ca015745911402dc9e8a2b-e36f9.png 325w, /static/task2-solved-1b8f2356a9ca015745911402dc9e8a2b-7abe3.png 575w" sizes="(max-width: 575px) 100vw, 575px" /> </span> </span> </li> </ol> <h2>Additional reading materials</h2> <p>If you want to find out more about the way we identified our suspect function so quickly, check out these reading materials.</p> <ul> <li>Very comprehensive series of posts about linkers and shared libraries <a href="http://bit.ly/2D3nLBS">https://www.airs.com/blog/page/4?s=linkers</a></li> <li><a href="https://amzn.to/2VHxBkq">Linkers and loader</a> by John R. Levin — very comprehensive overview of linkers, loaders and shared libraries. Somewhat dated, but things haven’t changed that much since 2000</li> </ul> <p>Let’s move on to <a href="../codebreaker2018_task1">Task 1</a></p><![CDATA[CodeBreaker2018 walkthrough, Task 0 Warm up]]>https://blog.v-lad.org/codebreaker2018_task0/https://blog.v-lad.org/codebreaker2018_task0/Thu, 03 Jan 2019 00:00:00 GMT<p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 23.850267379679142%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsSAAALEgHS3X78AAAAx0lEQVQY053Myw7BUBAG4LOjtjZuiQfCSoLEi2AhUfFwiKiFO0Fio1Sl9xbnN1UaCxsm+fLPmZMZlqqISJYDmUobaZKtdhAvNhHJ1SDkG6SOKBG+8OexQgOJUov2RTBpscNoucNwsQ1TIoPZBt3xGr3JmnKF/nRDgrff+/lpON9itpfBLucT1NMRylGGIh+evaVrcC3zxYBDro4dzpx3mkY4sw0dfjH1QsveDe414JF/6845mGY6MGzvSbc8aJZLR+/0zcH57x7nq1cSVQQjGAAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="screen" title="" src="/static/assignment-5760404e32f3cb827b0feb5e58c3899c-082a3.png" srcset="/static/assignment-5760404e32f3cb827b0feb5e58c3899c-59f9a.png 163w, /static/assignment-5760404e32f3cb827b0feb5e58c3899c-00530.png 325w, /static/assignment-5760404e32f3cb827b0feb5e58c3899c-082a3.png 650w, /static/assignment-5760404e32f3cb827b0feb5e58c3899c-2ea92.png 935w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>This task is really simple, all you need to do is download the given capture file and analyze it with a tool such as <a href="https://www.tcpdump.org/">tcpdump</a> or <a href="https://www.wireshark.org/">WireShark</a></p> <p>Let’s use tcpdump. </p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 29.801324503311257%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsSAAALEgHS3X78AAABI0lEQVQY0z2Ry47CMAxF+z8gBigLaIECSdNHkqZt0KAiNsz//8Md20UsrhT5cXwdJ9Y6hNCjqmpSBe87mNIgz3Ic8yO00ijOBa6XK9I0xc9qhRVpu02xS3dYLBbYbDZYr9dYLpdIGDAMI97vP6ibgnMOnhTHKENCCAhdwOP3gaZpUWoNpRSstejJCA/nfBzvMMbMwL4f8Jyen0I3F1NM6xJt28K2FjHGL5BdN00jgJq2qmlw21gBf4HTNIlDBrrPN2hqZhjH7vE+Q8pS6jjvnEfF0LoRcV/S+SArv14vccQDvPcYKcYOPDWxeGUGM7Ak9cMg39NRvWxh53diTCWr8EH2+wOKohDdyEWWZXIQlqI1T6czssOBlEk+z/O5nvLnz+H+AX6323e0Co7UAAAAAElFTkSuQmCC'); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="TrafficDump" title="" src="/static/tcpdump-9ef06765cac359796c06ff972b5eaa01-082a3.png" srcset="/static/tcpdump-9ef06765cac359796c06ff972b5eaa01-59f9a.png 163w, /static/tcpdump-9ef06765cac359796c06ff972b5eaa01-00530.png 325w, /static/tcpdump-9ef06765cac359796c06ff972b5eaa01-082a3.png 650w, /static/tcpdump-9ef06765cac359796c06ff972b5eaa01-16aed.png 755w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>The provided PCAP file contains a dump of a single conversation between two hosts; first one with IP address 10.47.114.22 and the second one with IP address 172.17.39.217. We also see that host 10.47.114.22 sends out the first packet and it has a higher port number than host 172.17.39.217. So we can assume that this is a typical client server design where Ransomware reaches out to the control host first. We therefore assume that the address of command server is <em>172.17.39.217</em></p> <p>Let’s try.</p> <p> <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 650px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 10.790598290598291%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAYAAABYBvyLAAAACXBIWXMAAAsSAAALEgHS3X78AAAAZElEQVQI12XMywqAIBQE0P7/43pAmWWRFqkZPUhoO5n0gFqcxeXOTDDYDnwpIFbmlBcGNmbIZAQiY+Q6AVGxl/ah/7WffLNQaLcVzLuBssIfrxZ8YqgN/akcPlVP7u7ITeDcOgAibZKGbq2vwwAAAABJRU5ErkJggg=='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="Solved" title="" src="/static/task0-solved-188f6d2eba38141aaa3be79ab70ec225-082a3.png" srcset="/static/task0-solved-188f6d2eba38141aaa3be79ab70ec225-59f9a.png 163w, /static/task0-solved-188f6d2eba38141aaa3be79ab70ec225-00530.png 325w, /static/task0-solved-188f6d2eba38141aaa3be79ab70ec225-082a3.png 650w, /static/task0-solved-188f6d2eba38141aaa3be79ab70ec225-8c54c.png 936w" sizes="(max-width: 650px) 100vw, 650px" /> </span> </span> </p> <p>Yes, our assumption was correct.</p> <p>Let’s continue to <a href="../codebreaker2018_task2/">Task 2</a></p><![CDATA[CodeBreaker 2018, complete walkthrough]]>https://blog.v-lad.org/codebreaker2018_intro/https://blog.v-lad.org/codebreaker2018_intro/Wed, 02 Jan 2019 00:00:00 GMT<p>Every year publishes a <a href="https://codebreaker.ltsnet.net/challenge">challenge</a> to reverse engineer and exploit something. Past challenges involved disarming simulation of IED (improvised explosive device), making sense of encrypted SSL traffic and so on.</p> <p>This year the challenge was to analyze blockchain based ransomware, retrieve the decryption keys without paying and ultimately refund all the victims who already paid.</p> <p>This year is the first time I managed to solve the entire thing with the other 19 finalists. Only 1.3% of the participants solved all 7 problems.</p> <p>I will be posting a complete walkthrough on this blog, stay tuned.</p> <p>Use the links below for the complete walkthrough of each task.</p> <ul> <li><a href="../codebreaker2018_task0/">Task 0 Warmup</a></li> <li><a href="../codebreaker2018_task2/">Task 2 Secrets</a></li> <li><a href="../codebreaker2018_task1">Task 1 It Begins</a></li> <li><a href="../codebreaker2018_task3">Task 3 Connections</a></li> <li><a href="../codebreaker2018_task4">Task 4 Victims</a></li> <li><a href="../codebreaker2018_task5">Task 5 Containment</a></li> <li><a href="../codebreaker2018_task6">Task 6 Loophole</a></li> <li><a href="../codebreaker2018_task7">Task 7 Refunds</a></li> <li><a href="../codebreaker2018_final-remarks">Final remarks</a></li> </ul><![CDATA[Welcome to the new home!]]>https://blog.v-lad.org/welcome-to-the-blog/https://blog.v-lad.org/welcome-to-the-blog/Tue, 01 Jan 2019 00:00:00 GMT<p>I haven’t been posting regularly here for a very long time. We’ll try to resume this blog. Let’s see how long it’s going to last this time.</p><![CDATA[Simple script to convert opml to markdown]]>https://blog.v-lad.org/opml-to-markdown/https://blog.v-lad.org/opml-to-markdown/Wed, 23 Apr 2014 00:00:00 GMT<p>I just put a quick transform script to convert outlines generated by <a href="http://www.omnigroup.com/omnioutliner">OmniOutliner</a> to MarkDown slide deck. The markdown is specific to <a href="https://github.com/vladistan/wiki2beamer">Wiki2Beamer</a> flavor.</p> <p>Here the script code is here.</p> <p>It is not the best of the XQuery code, but it does the job.</p><![CDATA[New version 0.5 of AWS4C has been released]]>https://blog.v-lad.org/aws4c-update3/https://blog.v-lad.org/aws4c-update3/Tue, 28 Jun 2011 00:00:00 GMT<p>Just released new version of AWS4C library.</p> <p>The new release includes support for S3 delete operation. Check the <a href="https://code.google.com/archive/p/aws4c/wikis/APIRef.wiki#S3_Interface_Functions">API Reference</a> and example code in s3_delete.c for details.</p> <p>The library could be downloaded from here: <a href="https://github.com/vladistan/aws4c">https://github.com/vladistan/aws4c</a></p> <p>Have any questions or suggestions write to me ‘tutorials@v-lad.org’ or post your comment here.</p> <p>This release was made possible thanks to the anonymous contributors, who submitted these fixes.</p><![CDATA[Port of RXTX library to Android platform]]>https://blog.v-lad.org/android-gnu-io/https://blog.v-lad.org/android-gnu-io/Tue, 01 Mar 2011 00:00:00 GMT<p>Just ported the RXTX library to the Android platform. </p> <p>Check out the picture below, it shows the Motorola Droid phone talking to the FreeNAS device over the serial port.</p> <p>Reference-style: <span class="gatsby-resp-image-wrapper" style="position: relative; display: block; margin: 15px -30px !important max-width: 600px; margin-left: auto; margin-right: auto;" > <span class="gatsby-resp-image-background-image" style="padding-bottom: 68.16666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAMEBf/EABQBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAY3Z6RuM4T//xAAaEAACAgMAAAAAAAAAAAAAAAABAgARAwQQ/9oACAEBAAEFAtZbQrkhDyqh5//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAEDAQE/AYf/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAdEAAABQUAAAAAAAAAAAAAAAAAAQIDoSAiMjNy/9oACAEBAAY/AjtQfQ1MwMGoo//EABwQAQABBAMAAAAAAAAAAAAAAAEAESFB8GFxof/aAAgBAQABPyFWiqzgau4N2ey1UbckEZ//2gAMAwEAAgADAAAAEKTf/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8QY//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/EBn/xAAcEAEAAwACAwAAAAAAAAAAAAABABEhMUFhcZH/2gAIAQEAAT8QIxh0szq2A4XuVLRfC4XRVOGlGRF1Pkwz/9k='); background-size: cover; display: block;" > <img class="gatsby-resp-image-image" style="width: 100%; height: 100%; margin: 0; vertical-align: middle; position: absolute; top: 0; left: 0; box-shadow: inset 0px 0px 0px 400px white;" alt="AndroidSerialS1" title="" src="/static/AndroidSerialS1-e82a141cf6853ddbd2cf97c764252328-716cc.jpg" srcset="/static/AndroidSerialS1-e82a141cf6853ddbd2cf97c764252328-09f93.jpg 163w, /static/AndroidSerialS1-e82a141cf6853ddbd2cf97c764252328-4bd8f.jpg 325w, /static/AndroidSerialS1-e82a141cf6853ddbd2cf97c764252328-716cc.jpg 600w" sizes="(max-width: 600px) 100vw, 600px" /> </span> </span> </p> <p>Testing android with serial</p> <p>More information and binaries are here <a href="http://v-lad.org/projects/gnu.io.android/">http://v-lad.org/projects/gnu.io.android/</a>. The source code of port is here <a href="https://github.com/vladistan/gnu.io.android/">https://github.com/vladistan/gnu.io.android/</a> .</p> <p>If you have any questions, comments or support request post them below.</p><![CDATA[New version of AWS4C has been released]]>https://blog.v-lad.org/aws4c-update2/https://blog.v-lad.org/aws4c-update2/Sun, 03 Oct 2010 00:00:00 GMT<p>Just released new version of AWS4C library.</p> <p>The new release includes support for Reduced Redundancy Storage and some bug fixes related to memory and socket leaks during extended operations.</p> <p>The library could be downloaded from here: <a href="https://github.com/vladistan/aws4c">https://github.com/vladistan/aws4c</a></p> <p>Have any questions or suggestions write to me ‘tutorials@v-lad.org’ or post your comment here.</p> <p>This release was made possible thanks to the anonymous contributors, who submitted these fixes.</p><![CDATA[Compiling native programs for Android]]>https://blog.v-lad.org/android-code-cruft/https://blog.v-lad.org/android-code-cruft/Wed, 18 Aug 2010 00:00:00 GMT<p>There is an excellent tutorial by <a href="https://plus.google.com/+Nirnimesh">Nirnimesh</a> on how to compile native programs for Android here <a href="http://android-tricks.blogspot.com/2009/02/hello-world-c-program-on-using-android.html">http://android-tricks.blogspot.com/2009/02/hello-world-c-program-on-using-android.html</a></p> <p>Unfortunately things have changed a bit since last year when this post was written. Andy’s agcc script doesn’t work with the most recent Google NDK release 4B.</p> <p>I have changed the script a little bit to address new path changes. The new script is available here <a href="http://android-cruft.googlecode.com/files/agcc-0.2.tgz">http://android-cruft.googlecode.com/files/agcc-0.2.tgz</a>.</p> <p>Make sure to add this to your path</p> <p>$HOME/AndroidNDK/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/</p> <p><em>Where AndroidNDK is your NDK installation directory.</em></p> <p>Hope this works for you.</p><![CDATA[AWS4C has been updated]]>https://blog.v-lad.org/aws4c-update1/https://blog.v-lad.org/aws4c-update1/Wed, 18 Nov 2009 00:00:00 GMT<p>Thanks to Henry N. for sending patches to the AWS4C library. I applied and tested them, hence the new release of the library.</p> <p>Here is the list of changes:</p> <p>The code quality has been improved. Some memory leaks fixed. Also addressed some warnings given by GCC 4.1.2</p> <ul> <li>Addressed a bug with having wrong file length after get</li> <li>When debug is not set, don’t print verbose output to stdout</li> <li>Fixed up EU and virtual host URLS</li> <li>Now can set the mime-type for the items</li> <li>Now can attach canned ACL to the items</li> </ul> <p>The library is available at <a href="https://github.com/vladistan/aws4c">https://github.com/vladistan/aws4c</a></p> <p>Have any questions or suggestions write to me ‘tutorials@v-lad.org’ or post your comment here.</p><![CDATA[AWS4C a C library that lets you work with AWS]]>https://blog.v-lad.org/aws4c/https://blog.v-lad.org/aws4c/Sat, 15 Aug 2009 00:00:00 GMT<p>Believe it or not some people need to write programs to access Amazon Web Services in C. This project grew out of the conversion of my old HPC project to run on the amazon EC2.</p> <p>I needed a C library to access the code. Unfortunately I couldn’t find any, so I wrote my own.</p> <p>The code quality sucks, I wrote the whole thing pretty much in one day. And I wouldn’t use it for anything more then a proof of concept projects unless it is heavily reworked to be more robust. But nevertheless it gets the job done.</p> <p>The library includes bindings for SQS and S3.</p> <p>It depends on <a href="https://curl.haxx.se/libcurl/">libcurl</a> for its network operations and <a href="https://www.openssl.org/">openssl</a> for the crypto.</p> <p>There is also <a href="http://aws.28msec.com/">libAWS</a> but it is heavily C++ dependent so it wouldn’t work for all types of C projects.</p> <p>The library is available at <a href="https://github.com/vladistan/aws4c">https://github.com/vladistan/aws4c</a></p> <p>Have any questions or suggestions write to me ‘tutorials@v-lad.org’ or post your comment here.</p><![CDATA[Hadoop tutorial for Windows and Eclipse]]>https://blog.v-lad.org/hadoop-tutorial/https://blog.v-lad.org/hadoop-tutorial/Fri, 20 Mar 2009 00:00:00 GMT<p>Hadoop tutorial for Windows and <a href="https://www.eclipse.org/">Eclipse</a>.</p> <p>Just posted a tutorial on how to configure Hadoop environment for Windows using <a href="http://www.cygwin.com/">CYGWIN</a>.</p> <p>The tutorial explains how to set-up a Hadoop cluster in the pseudo distributed mode and how to get it working with the Eclipse.</p> <p>If you have any questions / comments / suggestions about this tutorial post them here.</p> <p><a href="http://v-lad.org/Tutorials/Hadoop/00%20-%20Intro.html">The tutorial is located here</a>.</p> <h1>NOTE</h1> <p>This tutorial is 10 years old, and probably nothing there applies to modern data processing. It’s here only for historical reasons</p>