@@ -52,7 +52,7 @@ def execute_file
52
52
end
53
53
54
54
#
55
- # Executes the supplied script or Post module with arguments +args+
55
+ # Executes the supplied script, Post module, or local exploit with arguments +args+
56
56
#
57
57
# Will search the script path.
58
58
#
@@ -61,13 +61,12 @@ def execute_script(script_name, *args)
61
61
if mod
62
62
# Don't report module run events here as it will be taken care of
63
63
# in +Post.run_simple+
64
- # meterpreter scripts don't need SESSION, but it's not gonna hurt
65
64
opts = { 'SESSION' => self . sid }
66
65
args . each do |arg |
67
66
k , v = arg . split ( "=" , 2 )
68
67
opts [ k ] = v
69
68
end
70
- if mod . type == "post"
69
+ if mod . type == "post"
71
70
mod . run_simple (
72
71
# Run with whatever the default stance is for now. At some
73
72
# point in the future, we'll probably want a way to force a
@@ -77,17 +76,15 @@ def execute_script(script_name, *args)
77
76
'LocalOutput' => self . user_output ,
78
77
'Options' => opts
79
78
)
80
- elsif mod . type == "exploit"
79
+ elsif mod . type == "exploit"
81
80
# well it must be a local, we're not currently supporting anything else
82
81
if mod . exploit_type == "local"
83
82
# get a copy of the session exploit's datastore if we can
84
83
original_exploit_datastore = self . exploit . datastore || { }
85
- copy_of_orig_exploit_datastore = original_exploit_datastore . clone
84
+ copy_of_orig_exploit_datastore = original_exploit_datastore . dup
86
85
# we don't want to inherit a couple things, like AutoRunScript's
87
- to_neuter = [ 'AutoRunScript' , 'InitialAutoRunScript' ]
86
+ to_neuter = [ 'AutoRunScript' , 'InitialAutoRunScript' , 'LPORT' ]
88
87
to_neuter . each { |setting | copy_of_orig_exploit_datastore . delete ( setting ) }
89
- # @TODO: if opts are the same, we don't need another handler, set
90
- # DisablePayloadHandler => true in that case?
91
88
92
89
# merge in any opts that were passed in, defaulting to the
93
90
# copy of the datastore (of the exploit) that spawned the session
@@ -96,8 +93,8 @@ def execute_script(script_name, *args)
96
93
# try to run this local exploit, which is likely to be exception prone
97
94
begin
98
95
new_session = mod . exploit_simple (
99
- 'PAYLOAD ' => local_exploit_opts [ 'PAYLOAD' ] ,
100
- 'TARGET' => local_exploit_opts [ 'TARGET' ] ,
96
+ 'Payload ' => local_exploit_opts [ 'PAYLOAD' ] ,
97
+ 'Target' => local_exploit_opts [ 'TARGET' ] ,
101
98
'LocalInput' => self . user_input ,
102
99
'LocalOutput' => self . user_output ,
103
100
'Options' => local_exploit_opts
@@ -118,7 +115,7 @@ def execute_script(script_name, *args)
118
115
end # end if local
119
116
end # end if exploit
120
117
121
- else # else no mod
118
+ else
122
119
full_path = self . class . find_script_path ( script_name )
123
120
124
121
# No path found? Weak.
@@ -128,10 +125,9 @@ def execute_script(script_name, *args)
128
125
end
129
126
framework . events . on_session_script_run ( self , full_path )
130
127
execute_file ( full_path , args )
131
- end # end if mod
128
+ end
132
129
end
133
130
134
131
end
135
132
136
133
end
137
-
0 commit comments