@@ -17,17 +17,20 @@ class Console::CommandDispatcher::Priv::Elevate
17
17
18
18
include Console ::CommandDispatcher
19
19
20
- ELEVATE_TECHNIQUE_NONE = -1
21
- ELEVATE_TECHNIQUE_ANY = 0
22
- ELEVATE_TECHNIQUE_SERVICE_NAMEDPIPE = 1
23
- ELEVATE_TECHNIQUE_SERVICE_NAMEDPIPE2 = 2
24
- ELEVATE_TECHNIQUE_SERVICE_TOKENDUP = 3
25
-
26
- ELEVATE_TECHNIQUE_DESCRIPTION = [ "All techniques available" ,
27
- "Service - Named Pipe Impersonation (In Memory/Admin)" ,
28
- "Service - Named Pipe Impersonation (Dropper/Admin)" ,
29
- "Service - Token Duplication (In Memory/Admin)"
30
- ]
20
+ ELEVATE_TECHNIQUE_NONE = -1
21
+ ELEVATE_TECHNIQUE_ANY = 0
22
+ ELEVATE_TECHNIQUE_SERVICE_NAMEDPIPE = 1
23
+ ELEVATE_TECHNIQUE_SERVICE_NAMEDPIPE2 = 2
24
+ ELEVATE_TECHNIQUE_SERVICE_TOKENDUP = 3
25
+
26
+ ELEVATE_TECHNIQUE_DESCRIPTION =
27
+ [
28
+ "All techniques available" ,
29
+ "Named Pipe Impersonation (In Memory/Admin)" ,
30
+ "Named Pipe Impersonation (Dropper/Admin)" ,
31
+ "Token Duplication (In Memory/Admin)"
32
+ ]
33
+
31
34
#
32
35
# List of supported commands.
33
36
#
@@ -45,6 +48,25 @@ def name
45
48
end
46
49
47
50
51
+ #
52
+ # Returns the description of the technique(s)
53
+ #
54
+ def translate_technique_index ( index )
55
+ translation = ''
56
+
57
+ case index
58
+ when 0
59
+ desc = ELEVATE_TECHNIQUE_DESCRIPTION . dup
60
+ desc . shift
61
+ translation = desc
62
+ else
63
+ translation = [ ELEVATE_TECHNIQUE_DESCRIPTION [ index ] ]
64
+ end
65
+
66
+ translation
67
+ end
68
+
69
+
48
70
#
49
71
# Attempt to elevate the meterpreter to that of local system.
50
72
#
@@ -73,17 +95,29 @@ def cmd_getsystem( *args )
73
95
}
74
96
75
97
if ( technique < 0 or technique >= ELEVATE_TECHNIQUE_DESCRIPTION . length )
76
- print_error ( "Technique '#{ technique } ' is out of range." ) ;
98
+ print_error ( "Technique '#{ technique } ' is out of range." )
77
99
return false ;
78
100
end
79
101
80
- result = client . priv . getsystem ( technique )
102
+ begin
103
+ result = client . priv . getsystem ( technique )
104
+ rescue Rex ::Post ::Meterpreter ::RequestError => e
105
+ print_error ( "#{ e . message } The following was attempted:" )
106
+ translate_technique_index ( technique ) . each do |desc |
107
+ print_error ( desc )
108
+ end
109
+ elog ( "#{ e . class } #{ e . message } (Technique: #{ technique } )\n #{ e . backtrace * "\n " } " )
110
+ return
111
+ end
81
112
82
113
# got system?
83
114
if result [ 0 ]
84
- print_line ( "...got system ( via technique #{ result [ 1 ] } ). " ) ;
115
+ print_line ( "...got system via technique #{ result [ 1 ] } ( #{ translate_technique_index ( result [ 1 ] ) . first } ). " )
85
116
else
86
- print_line ( "...failed to get system." ) ;
117
+ print_line ( "...failed to get system while attempting the following:" )
118
+ translate_technique_index ( technique ) . each do |desc |
119
+ print_error ( desc )
120
+ end
87
121
end
88
122
89
123
return result
0 commit comments