The best way to start writing modules is to delve deeper into the existing Metasploit modules, and see how they work internally.
Understanding the existing modules
Get Mastering Metasploit - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.