- Mastering Metasploit
- Nipun Jaswal
- 234字
- 2021-06-25 21:35:57
Libraries and functions
Let's see some important functions from the libraries that are used in this module, as follows:
We define the run_host method, which serves as the main method. The connect function will be responsible for initializing a connection to the host. However, we supply two parameters to the connect function, which are true and false. The true parameter defines the use of global parameters, whereas false turns off the verbose capabilities of the module. The beauty of the connect function lies in its operation of connecting to the target and recording the banner of the FTP service in the parameter named banner automatically, as shown in the following screenshot:
Now, we know that the result is stored in the banner attribute. Therefore, we just print out the banner at the end. Next, we use the report_service function so that the scan data gets saved to the database for later use or advanced reporting. The method is located in the report.rb file in the auxiliary library section. The code for report_service looks similar to the following screenshot:
We can see that the provided parameters to the report_service method are passed to the database using another method called framework.db.report_service from /lib/msf/core/db_manager/service.rb. After performing all the necessary operations, we just disconnect the connection with the target.
This was an easy module, and I recommend that you try building simple scanners and other modules like these.