Cortana Tutorial - Armitage
Cortana Tutorial - Armitage
Cortana Tutorial - Armitage
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
on exec_dir {<br />
# $3 now contains a big string representing all of the files on the system<br />
if ("*secrets*" iswm $3) {<br />
println("Session $1 may have secrets");<br />
}<br />
}<br />
This function works on Windows and Linux systems. The process is spawned from the<br />
current working directory in Meterpreter. Issue a cd command with &m_cd to change the<br />
start directory of your process if you need to.<br />
Tip: When there is a function to carry out a Meterpreter action, you should use<br />
it. These functions often work-‐around Meterpreter quirkiness in the<br />
background to spare you a great deal of pain. For example, &m_cd examines the<br />
path you provide and queues several cd commands to get meterpreter to the<br />
right directory.<br />
Example: Process Hunt and Destroy<br />
This example regularly grabs a process list from all active Windows meterpreter sessions.<br />
It looks for any processes that match a fixed wildcard. Any processes that match this string<br />
are automatically killed.<br />
The fixed wildcard in this example is *sol*. If a user opens Windows solitaire, this script<br />
will automatically kill it.<br />
global('$suppress');<br />
$suppress = "*sol*";<br />
This script sends a ps command to all open Windows meterpreter sessions every 15<br />
seconds. This script uses the -isready predicate to make sure the meterpreter session is<br />
ready for interaction.<br />
on heartbeat_15s {<br />
local('$sid');<br />
foreach $sid (session_ids()) {<br />
if (-iswinmeterpreter $sid && -isready $sid) {<br />
m_cmd($sid, "ps");<br />
}<br />
}<br />
}<br />
When a meterpreter session responds with ps output, the meterpreter_ps event is fired.<br />
This script takes advantage of the &parse_ps function to quickly parse the meterpreter<br />
output into a Sleep data structure.<br />
on meterpreter_ps {<br />
local('@processes $process $name $pid $host');<br />
@processes = parse_ps($3);<br />
The &parse_ps function returns an array containing a dictionary for each process. Each<br />
dictionary contains the keys name and pid that indicate the process name and identifier.<br />
21