{"id":268,"date":"2011-12-04T02:54:09","date_gmt":"2011-12-04T01:54:09","guid":{"rendered":"http:\/\/blog.pi3.com.pl\/?p=268"},"modified":"2011-12-25T11:50:07","modified_gmt":"2011-12-25T10:50:07","slug":"gchq-canyoucrackit-virtual-machine","status":"publish","type":"post","link":"https:\/\/blog.pi3.com.pl\/?p=268","title":{"rendered":"GCHQ &#8216;canyoucrackit&#8217; Virtual Machine"},"content":{"rendered":"<p>Second level of GCHQ &#8216;canyoucrackit&#8217; challenge requires to implement own Virtual Machine(!). This VM must emulate segmented memory model with 16-byte segment size (notation seg:offset). For details please read this link:<\/p>\n<pre><a href=\"http:\/\/www.canyoucrackit.co.uk\/\/15b436de1f9107f3778aad525e5d0b20.js\" target=\"_blank\">http:\/\/www.canyoucrackit.co.uk\/15b436de1f9107f3778aad525e5d0b20.js<\/a><\/pre>\n<p>I wrote quick overview about this challenge, how to solve it and some tips. It can be found here:<\/p>\n<pre><a href=\"http:\/\/blog.pi3.com.pl\/?p=213\" target=\"_blank\">http:\/\/blog.pi3.com.pl\/?p=213<\/a><\/pre>\n<p>Anyway, I am <strong>impressed<\/strong> how many people saw this post and how fast this link was shared in community \ud83d\ude42 Of course I&#8217;m happy of that but also a bit\u00a0terrified. Anyway, in this short post I didn&#8217;t put much details about how to implement this VM, if there is any difficulties, etc. This was one of the reason I received a few emails asking some help to solve it. This is the reason why I decide finally write this second post. I want to share with my VM which i wrote in pure C (I love this language). To be honest I didn&#8217;t implement it at the beginning like it is here. I found some implementation in the <a href=\"http:\/\/pastebin.com\" target=\"_blank\">http:\/\/pastebin.com<\/a> webpage in python language. Unfortunately it has some mistakes (in fact serious mistakes). This was the reason why this machine didn&#8217;t work properly and in fact after a few instruction put exceptions and of course whole VM stops. I spend some time to fix it and I did it. After rewriting this machine, python VM starts working. This machine had a few problems like doesn&#8217;t correct\u00a0 implement the most important instructions (JMP and JMPE). Also there was mistakes in take care about MOD flag. Another bug was that CS and DS register can be used in operations like ADD via normal operand argument as register. Also operations which use addressing [seg:off] must especially take care if the arguments are inside of the SEGMENT, if not make them fix. In fact this was critical bugs.<\/p>\n<p>Anyway because of that I rewrote almost whole program so after all I decide, OK let&#8217;s do that in my way and this was the point why I implement everything again in C. Here you have got my VM in pure C:<\/p>\n<pre><a href=\"http:\/\/site.pi3.com.pl\/exp\/pi3_VM.c\" target=\"_blank\">http:\/\/site.pi3.com.pl\/exp\/pi3_VM.c<\/a><\/pre>\n<p>&nbsp;<\/p>\n<p>Btw. In fact this challenge is NOT finished yet&#8230; Maybe it was mistake to publish solution BEFORE end of it? I feel a bit guilty.<\/p>\n<p>&nbsp;<\/p>\n<p>Best regards,<\/p>\n<p>Adam Zabrocki<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Second level of GCHQ &#8216;canyoucrackit&#8217; challenge requires to implement own Virtual Machine(!). This VM must emulate segmented memory model with 16-byte segment size (notation seg:offset). For details please read this link: http:\/\/www.canyoucrackit.co.uk\/15b436de1f9107f3778aad525e5d0b20.js I wrote quick overview about this challenge, how to solve it and some tips. It can be found here: http:\/\/blog.pi3.com.pl\/?p=213 Anyway, I am [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,5,6],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","hentry","category-bughunt","category-exploiting","category-ideas"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268"}],"version-history":[{"count":5,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/posts\/268\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=\/wp\/v2\/posts\/268\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pi3.com.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}