background image

M E T E R P R E T E R   S C R I P T I N G

Metasploit’s powerful scripting environment lets you 
add features or options to Meterpreter. In this chapter, 
you’ll learn the basics of Meterpreter scripting, some 
useful native calls, and learn how to run these com-
mands from within Meterpreter. We’ll cover two ways

to leverage Meterpreter scripting. The first method is somewhat outdated 
but still important, because not all scripts have been converted. The second 
method is nearly identical to the one discussed in Chapter 13, so we won’t 
cover it in detail in this chapter. (Special thanks to Carlos Perez [darkoperator] 
for his contributions to this chapter.)

Meterpreter Scripting Basics

All Meterpreter scripts are located under the Framework root under 

scripts/

meterpreter/

. To show a listing of all scripts, press the 

TAB

 key in a Meterpreter 

shell, enter 

run

, and press 

TAB

 again.

Let’s dissect a simple Meterpreter script and then build our own. We’ll 

explore the 

multi_meter_inject

 script that injects Meterpreter shells into