@OJ this is already implemented in metasploit (just see my comment below) ;)