{"id":7757,"date":"2021-05-02T13:42:11","date_gmt":"2021-05-02T13:42:11","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=7757"},"modified":"2021-05-02T13:42:52","modified_gmt":"2021-05-02T13:42:52","slug":"throwing-a-lolbin-tar-ball","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2021\/05\/02\/throwing-a-lolbin-tar-ball\/","title":{"rendered":"Throwing LOLBIN a tar ball"},"content":{"rendered":"\n<p>This post summarizes some of the findings I posted on <a href=\"https:\/\/twitter.com\/Hexacorn\/status\/1387204376368984065\">Twitter<\/a> the other day.<\/p>\n\n\n\n<p>While looking at Windows version of tar.exe I discovered that it includes lots of undocumented command line arguments; undocumented &#8211; in a sense that they are not described in program&#8217;s help (tar &#8211;help), but are obviously known to *NIX tar program users:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar_undoc.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar_undoc-583x1024.png\" alt=\"\" class=\"wp-image-7758\" width=\"500\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar_undoc-583x1024.png 583w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar_undoc-171x300.png 171w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar_undoc.png 651w\" sizes=\"(max-width: 583px) 100vw, 583px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Amongst the more interesting ones are the LOLBIN and data encoding opportunities:<\/p>\n\n\n\n<p><strong>Encoding<\/strong><\/p>\n\n\n\n<p>Windows tar can BASE64-encode and UUEncode files:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -c -f&lt;out> --b64encode &lt;in>\ntar -c -f&lt;out> --uuencode &lt;in><\/pre>\n\n\n\n<p><strong>Decoding<\/strong><\/p>\n\n\n\n<p>Using &#8220;-x&#8221; we can decode these files:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -x -f&lt;in> --b64encode\ntar -x -f&lt;in> --uuencode <\/pre>\n\n\n\n<p><strong>Running programs (lolbin #1):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -cff --use-compress-program calc f<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar.gif\"><img decoding=\"async\" loading=\"lazy\" width=\"324\" height=\"569\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/tar.gif\" alt=\"\" class=\"wp-image-7767\"\/><\/a><\/figure><\/div>\n\n\n\n<p>The <em>&#8211;use-compress-program<\/em> works with:<\/p>\n\n\n\n<ul><li>-c(create) <\/li><li>-x(extract) <\/li><li>-t(test) <\/li><\/ul>\n\n\n\n<p>options meaning that:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -x --use-compress-program calc -f &lt;in> \ntar -t --use-compress-program calc -f &lt;in><\/pre>\n\n\n\n<p>can be used to launch a program of your choice too.<\/p>\n\n\n\n<p><strong>Running Programs (lolbin #2):<\/strong><\/p>\n\n\n\n<p>When you use tar to create archives using different archive types e.g. bzip2, grzip, xz, etc. tar.exe spawns a child process (e.g. <em>bzip2.exe<\/em>). You can place a dummy <em>bzip2.exe<\/em> in your chosen directory and it will be launched when you use a command like the one below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -c -ffoo -j .<\/pre>\n\n\n\n<p>Possible child processes created (need to tinker with options) are:<\/p>\n\n\n\n<ul><li>bzip2.exe<\/li><li>grzip.exe<\/li><li>lrzip.exe<\/li><li>lz4.exe<\/li><li>lzop.exe<\/li><li>lzma.exe<\/li><li>xz.exe<\/li><li>lzip.exe<\/li><\/ul>\n\n\n\n<p>Some of them only work with &#8220;test&#8221; option e.g. xz <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tar -t -f&lt;in> -J<\/pre>\n\n\n\n<p>These are existing archive type options <\/p>\n\n\n\n<ul><li>-j, -y &#8212; bzip2.exe<\/li><li>-J = xz.exe<\/li><li>-z = (gzip &#8211; n\/a)<\/li><li>-Z = (compress &#8211; n\/a)<\/li><li>&#8211;grzip = grzip.exe<\/li><li>&#8211;lrzip = lrzip.exe<\/li><li>&#8211;lz4 = lz4.exe<\/li><li>&#8211;lzma = (lzma &#8211; n\/a)<\/li><li>&#8211;lzip = (doesn&#8217;t seem to work although should spawn lzip.exe)<\/li><li>&#8211;lzop = lzop.exe<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post summarizes some of the findings I posted on Twitter the other day. While looking at Windows version of tar.exe I discovered that it includes lots of undocumented command line arguments; undocumented &#8211; in a sense that they are &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2021\/05\/02\/throwing-a-lolbin-tar-ball\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[56,64],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7757"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=7757"}],"version-history":[{"count":4,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7757\/revisions"}],"predecessor-version":[{"id":7771,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7757\/revisions\/7771"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=7757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=7757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=7757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}