{"id":7772,"date":"2021-05-02T13:53:11","date_gmt":"2021-05-02T13:53:11","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=7772"},"modified":"2021-05-02T13:54:47","modified_gmt":"2021-05-02T13:54:47","slug":"curo-bin","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2021\/05\/02\/curo-bin\/","title":{"rendered":"Cur\\o\/bin"},"content":{"rendered":"\n<p>This post wraps up another <a href=\"https:\/\/twitter.com\/Hexacorn\/status\/1387832956656488460?s=20\">Twitter thread<\/a> I started a few days ago:<\/p>\n\n\n\n<p>If you ever get bored using &#8220;copy&#8221; to copy files you can always use \u2026 curl:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl file:\/\/c:\\test\\foo -o bar<\/pre>\n\n\n\n<p>Same way, you can use it instead of &#8220;type&#8221; or &#8220;cat&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl file:\/\/c:\\test\\foo<\/pre>\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\/curl-copy.gif\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl-copy.gif\" alt=\"\" class=\"wp-image-7773\" width=\"500\"\/><\/a><\/figure><\/div>\n\n\n\n<p>You can also copy file by\u2026 uploading it locally<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -T bar file:\/\/c:\\test\\<\/pre>\n\n\n\n<p>this will copy &#8220;bar&#8221; file to &#8220;c:\\test\\bar&#8221;.<\/p>\n\n\n\n<p>And during copying, you can stat copying at a given offset:<\/p>\n\n\n\n<p>and even cooler, you can extract any part of the file using range<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl file:\/\/c:\\test\\foo -C 1<\/pre>\n\n\n\n<p>dynamic payload building anyone?<\/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\/curl-copy-partial.gif\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl-copy-partial.gif\" alt=\"\" class=\"wp-image-7774\" width=\"500\"\/><\/a><\/figure><\/div>\n\n\n\n<p>and even cooler, you can extract any part of the file using range<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl file:\/\/c:\\test\\foo -r2-10<\/pre>\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\/curl-copy-partial2.gif\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl-copy-partial2.gif\" alt=\"\" class=\"wp-image-7775\" width=\"500\"\/><\/a><\/figure><\/div>\n\n\n\n<p>offering a chance to build dynamic payloads.<\/p>\n\n\n\n<p>The operation is surgical and using Procmon we can confirm it reads only these two specific bytes:<\/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\/curl_procmon.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl_procmon.png\" alt=\"\" class=\"wp-image-7776\" width=\"500\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl_procmon.png 676w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/05\/curl_procmon-300x98.png 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/a><\/figure><\/div>\n\n\n\n<p><a href=\"https:\/\/twitter.com\/nf3xn\">@nf3xn<\/a> <a href=\"https:\/\/twitter.com\/nf3xn\/status\/1388098269620973568?s=20\">added<\/a> one more interesting option:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl --remote-time file:\/\/c:\\test\\foo -o bar<\/pre>\n\n\n\n<p>to preserve file timestamps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post wraps up another Twitter thread I started a few days ago: If you ever get bored using &#8220;copy&#8221; to copy files you can always use \u2026 curl: curl file:\/\/c:\\test\\foo -o bar Same way, you can use it instead &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2021\/05\/02\/curo-bin\/\">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\/7772"}],"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=7772"}],"version-history":[{"count":1,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7772\/revisions"}],"predecessor-version":[{"id":7777,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7772\/revisions\/7777"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=7772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=7772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=7772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}