{"id":1727,"date":"2024-08-15T13:30:40","date_gmt":"2024-08-15T17:30:40","guid":{"rendered":"https:\/\/www.peteonsoftware.com\/?p=1727"},"modified":"2024-08-15T13:30:40","modified_gmt":"2024-08-15T17:30:40","slug":"core-tools-to-know-cyberchef","status":"publish","type":"post","link":"https:\/\/www.peteonsoftware.com\/index.php\/2024\/08\/15\/core-tools-to-know-cyberchef\/","title":{"rendered":"Core Tools to Know: CyberChef"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/peteonsoftware.com\/images\/202408\/cybercheflogo.jpg\" alt=\"CyberChef Logo\" title=\"CyberChef Logo\" style=\"float:left;margin:.5rem;\">Last month, I started a series about tools and utilities that are good to know with a <a href=\"https:\/\/www.peteonsoftware.com\/index.php\/2024\/07\/12\/core-tools-to-know-curl\/\">post about curl<\/a>.  In my <a href=\"https:\/\/www.peteonsoftware.com\/index.php\/2024\/07\/22\/vulnhub-walkthrough-the-planets-earth\/\">most recent CTF post<\/a>, I had to use <a href=\"https:\/\/gchq.github.io\/CyberChef\/\">CyberChef<\/a> to help me with one of my steps.  That post was already going to be very long, so I didn&#8217;t have a lot of time to explain what CyberChef was or how it worked if a reader was unfamiliar.  It <strong><em>did<\/em><\/strong>, however, seem like a good topic for my next &#8220;Core Tools to Know&#8221; post, so here we are.<\/p>\n<p>As some background, CyberChef was created by an anonymous worker at GCHQ (Government Communications Headquarters) in England.  GCHQ is an intelligence agency and is the current version of the organization (then called GC&#038;CS) that was at Bletchley Park and broke the Enigma Codes.  So.. smart folks.  Like a lot of high-tech places, GCHQ gives their employees 10% &#8220;Innovation Time&#8221; and this worker created this tool during that time.  They shared it with their colleagues and eventually decided to open source it on GitHub for the world to benefit.  So what is it?  Let&#8217;s take a look.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchefui.jpg\" alt=\"The CyberChef UI\" title=\"The CyberChef UI\"><\/p>\n<p>There is a lot going on here, but think of it like a factory or assembly line.  In the upper right is where you put the input to the process.  In the bottom right is the output.  The center column is where you drag the &#8220;recipes&#8221;, which are the operations that you are going to conduct on the input.  The left side shows all of the available recipes\/operations that you can choose from.  In the upper left is a search box to help you easily find what you were looking for.  Let&#8217;s say you came across this string: <strong>UGV0ZSBvbiBTb2Z0d2FyZQ%3D%3D<\/strong>.  If you recognize the end as looking to be URL encoded, let&#8217;s set up CyberChef to try to handle it.  First, I put <strong>UGV0ZSBvbiBTb2Z0d2FyZQ%3D%3D<\/strong> in the input.  It will immediately appear &#8211; unchanged &#8211; in the output because &#8220;Auto Bake&#8221; is selected at the bottom of the center column.  If it isn&#8217;t, either check it or click Bake! to see something in the output.  Next, let&#8217;s search for <em>URL Decode<\/em> in the search box and drag <em>URL Decode<\/em> to the <em>Recipe<\/em> column.  After baking, you see that the output now says <strong>UGV0ZSBvbiBTb2Z0d2FyZQ==<\/strong> because each <strong>%3D<\/strong> was converted to an <strong>=<\/strong>.  We now see that this looks like a base64 string.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_urldecodeinput.jpg\" alt=\"Our input with the URL Decode Recipe Only\" title=\"Our input with the URL Decode Recipe Only\"><\/p>\n<p>What is interesting is that CyberChef figured that out, too!  You&#8217;ll notice that a magic wand appeared by the Output header and if you hover on it, it tells you that this is a Base64 string and what the decoding is.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_outputmagic.jpg\" alt=\"Output Magic Suggestion\" title=\"Output Magic Suggestion\"><\/p>\n<p>If you click it, it adds <em>From Base64<\/em> to the recipe and our output now shows <strong>Pete on Software<\/strong>.  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_peteonsoftwaredecoded.jpg\" alt=\"Our decoded string\" title=\"Our decoded string\"><\/p>\n<p>It is important to note that order matters.  You can drag the recipe steps up and down to perform them in a different order.  If I <em>From Base64<\/em> first and <em>URL Decode<\/em> second, we don&#8217;t get the exact right answer.  If this was a more complicated recipe, small errors get compounded and might make this fail entirely.  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_ordermatters.jpg\" alt=\"Recipe Order Matters\" title=\"Recipe Order Matters\"><\/p>\n<p>As we move forward, it is important to note that you can remove a recipe step by either clicking and dragging it to the trash can in the upper right portion of the Recipe column, or by clicking the &osol; on the operation.  That will disable it.  Clicking that symbol again will re-enable it.<\/p>\n<p>By now, you can imagine all of the things you can do to text.  CyberChef has encryption, hashing, encoding, and much, much more.  However, you aren&#8217;t limited to text.  You can perform network operations and even operate on Files.  If you don&#8217;t enter text in the <em>Input<\/em> section, you have other options for input.  If you hover on each of the icons, you can see that you can also open a Folder or a File as input.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_inputoptions.jpg\" alt=\"CyberChef Input Options\" title=\"CyberChef Input Options\"><\/p>\n<p>I&#8217;m going to use CyberChef to remove EXIF data from an image of a moped.  To start, here is the EXIF data that is on the image.<\/p>\n<pre>\r\n$ exif moped.jpg\r\nEXIF tags in 'moped.jpg' ('Motorola' byte order):\r\n--------------------+----------------------------------------------------------\r\nTag                 |Value\r\n--------------------+----------------------------------------------------------\r\nX-Resolution        |72\r\nY-Resolution        |72\r\nResolution Unit     |Inch\r\nDate and Time (Origi|2018:11:08 19:49:33\r\nUser Comment        |Screenshot\r\nPixel X Dimension   |640\r\nPixel Y Dimension   |641\r\nExif Version        |Exif Version 2.1\r\nFlashPixVersion     |FlashPix Version 1.0\r\nColor Space         |Internal error (unknown value 65535)\r\n--------------------+----------------------------------------------------------\r\n<\/pre>\n<p>I selected my file as input, added the <em>Remove EXIF<\/em> operation to the <em>Recipe<\/em>, made sure it Baked and I have file data in the output.  If you click the Floppy Disk icon, you can save that output to a file.  (Note: CyberChef didn&#8217;t blur the image.  I did for privacy reasons)<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.peteonsoftware.com\/images\/202408\/cyberchef_savefile.jpg\" alt=\"CyberChef Remove EXIF Save File\" title=\"CyberChef Remove EXIF Save File\"><\/p>\n<pre>\r\n$ exif moped_cyberchef.jpg\r\nCorrupt data\r\nThe data provided does not follow the specification.\r\nExifLoader: The data supplied does not seem to contain EXIF data.\r\n<\/pre>\n<p>I will note that I was using a Linux utility to read that EXIF data, but CyberChef could have read the data in the first place.  There is an <em>Extract EXIF<\/em> operation that you can add to the recipe.<\/p>\n<p>As we wrap up, there are some things to consider.  First, CyberChef is a client-side application.  When you enter input (text, file, folder, etc), your data does not leave the browser.  All of the recipes are written in JavaScript and are executed on the client.  You don&#8217;t have to worry that some agency is getting your encryption keys, pictures, or other sensitive data.  As a reminder, <a href=\"https:\/\/github.com\/gchq\/CyberChef\">the code is open source<\/a> and can be viewed and reviewed.  Also, you don&#8217;t have to be online to use CyberChef.  There is a download link at the top left that will let you download a ZIP file of the application to run locally.  When you click the link, you get a popup that provides this message.  It is important to note that this isn&#8217;t an installed application and there is no provision for keeping it updated unless you create those means.<\/p>\n<pre>\r\nCyberChef runs entirely within your browser with no server-side component, meaning that your Input data and Recipe configuration are not sent anywhere, whether you use the live, official version of CyberChef or a downloaded, standalone version (assuming it is unmodified).\r\n\r\nThere are three operations that make calls to external services, those being the 'Show on map' operation which downloads map tiles from wikimedia.org, the 'DNS over HTTPS' operation which resolves DNS requests using either Google or Cloudflare services, and the 'HTTP request' operation that calls out to the configured URL you enter. You can confirm what network requests are made using your browser's developer console (F12) and viewing the Network tab.\r\n\r\nIf you would like to download your own standalone copy of CyberChef to run in a segregated network or where there is limited or no Internet connectivity, you can get a ZIP file containing the whole web app below. This can be run locally or hosted on a web server with no configuration required.\r\n\r\nBe aware that the standalone version will never update itself, meaning it will not receive bug fixes or new features until you re-download newer versions manually.\r\n<\/pre>\n<p>That&#8217;s it!  I hope you got a good introduction to CyberChef and keep it in mind when you have little needs to manipulate data.  If there is anything that you have found very handy to use it for or any good tips and tricks, I&#8217;d love to hear about it in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last month, I started a series about tools and utilities that are good to know with a post about curl. In my most recent CTF post, I had to use CyberChef to help me with &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76],"tags":[151,154,130],"class_list":["post-1727","post","type-post","status-publish","format-standard","hentry","category-general-tips","tag-core-tools-to-know","tag-cyberchef","tag-general-tips"],"_links":{"self":[{"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/posts\/1727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/comments?post=1727"}],"version-history":[{"count":0,"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/posts\/1727\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/media?parent=1727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/categories?post=1727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.peteonsoftware.com\/index.php\/wp-json\/wp\/v2\/tags?post=1727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}