{"id":9021,"date":"2023-12-31T10:21:41","date_gmt":"2023-12-31T10:21:41","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=9021"},"modified":"2024-12-25T23:19:26","modified_gmt":"2024-12-25T23:19:26","slug":"1-little-known-secret-of-forfiles-exe","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2023\/12\/31\/1-little-known-secret-of-forfiles-exe\/","title":{"rendered":"1 little known secret of forfiles.exe"},"content":{"rendered":"\n<p>The <em>forfiles.exe<\/em> program is a well-known lolbin. Its power comes from the <em>\/c<\/em> command line argument that helps to specify a command that we want to execute for each item found by the program when it enumerates directories.<\/p>\n\n\n\n<p>The less known fact about <em>forfiles.exe<\/em> is that executing the program itself, without any option, leads to <em>cmd.exe<\/em> being spawn for every item enumerated. This is because its default command is <em>cmd \/c echo @file<\/em>.<\/p>\n\n\n\n<p>As such, one can copy <em>forfiles.exe<\/em> to a different directory, and place malicious <em>cmd.exe<\/em> there. Running <em>forfiles.exe<\/em> without any command line argument (or a combination without <em>\/c<\/em> argument) will still launch malicious <em>cmd.exe<\/em>!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/forfiles.png\"><img decoding=\"async\" loading=\"lazy\" width=\"317\" height=\"265\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/forfiles.png\" alt=\"\" class=\"wp-image-9023\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/forfiles.png 317w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/forfiles-300x251.png 300w\" sizes=\"(max-width: 317px) 100vw, 317px\" \/><\/a><\/figure><\/div>","protected":false},"excerpt":{"rendered":"<p>The forfiles.exe program is a well-known lolbin. Its power comes from the \/c command line argument that helps to specify a command that we want to execute for each item found by the program when it enumerates directories. The less &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2023\/12\/31\/1-little-known-secret-of-forfiles-exe\/\">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":[126,56,64],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9021"}],"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=9021"}],"version-history":[{"count":2,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9021\/revisions"}],"predecessor-version":[{"id":9024,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9021\/revisions\/9024"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=9021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=9021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=9021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}