Understanding the existing modules

The best way to start writing modules is to delve deeper into the existing Metasploit modules, and see how they work internally.