@@ -12,49 +12,53 @@ class MetasploitModule < Msf::Exploit::Remote
12
12
#
13
13
14
14
def initialize ( info = { } )
15
- super ( update_info ( info ,
16
- 'Name' => 'Generic Payload Handler' ,
17
- 'Description' => %q{
18
- This module is a stub that provides all of the
19
- features of the Metasploit payload system to exploits
20
- that have been launched outside of the framework.
21
- } ,
22
- 'License' => MSF_LICENSE ,
23
- 'Author' => [ 'hdm' ] ,
24
- 'References' => [ ] ,
25
- 'Payload' =>
26
- {
27
- 'Space' => 10000000 ,
28
- 'BadChars' => '' ,
29
- 'DisableNops' => true ,
30
- } ,
31
- 'Platform' => %w{ android bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi } ,
32
- 'Arch' => ARCH_ALL ,
33
- 'Targets' => [ [ 'Wildcard Target' , { } ] ] ,
34
- 'DefaultTarget' => 0
35
- ) )
15
+ super (
16
+ update_info (
17
+ info ,
18
+ 'Name' => 'Generic Payload Handler' ,
19
+ 'Description' => %q(
20
+ This module is a stub that provides all of the
21
+ features of the Metasploit payload system to exploits
22
+ that have been launched outside of the framework.
23
+ ) ,
24
+ 'License' => MSF_LICENSE ,
25
+ 'Author' => [ 'hdm' , 'bcook-r7' ] ,
26
+ 'References' => [ ] ,
27
+ 'Payload' =>
28
+ {
29
+ 'Space' => 10000000 ,
30
+ 'BadChars' => '' ,
31
+ 'DisableNops' => true
32
+ } ,
33
+ 'Platform' => %w[ android bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi ] ,
34
+ 'Arch' => ARCH_ALL ,
35
+ 'Targets' => [ [ 'Wildcard Target' , { } ] ] ,
36
+ 'DefaultTarget' => 0 ,
37
+ 'Stance' => Msf ::Exploit ::Stance ::Passive
38
+ )
39
+ )
36
40
37
41
register_advanced_options (
38
42
[
39
- OptBool . new ( "ExitOnSession" , [ false , "Return from the exploit after a session has been created" , true ] ) ,
40
- OptInt . new ( "ListenerTimeout" , [ false , "The maximum number of seconds to wait for new sessions" , 0 ] )
41
- ] )
43
+ OptBool . new (
44
+ "ExitOnSession" ,
45
+ [ true , "Return from the exploit after a session has been created" , false ]
46
+ ) ,
47
+ OptInt . new (
48
+ "ListenerTimeout" ,
49
+ [ false , "The maximum number of seconds to wait for new sessions" , 0 ]
50
+ )
51
+ ]
52
+ )
42
53
end
43
54
44
55
def exploit
45
- if not datastore [ 'ExitOnSession' ] and not job_id
46
- fail_with ( Failure ::Unknown , "Setting ExitOnSession to false requires running as a job (exploit -j)" )
47
- end
48
-
49
56
stime = Time . now . to_f
50
- print_status "Starting the payload handler..."
51
- while ( true )
52
- break if session_created? and datastore [ 'ExitOnSession' ]
53
- break if ( datastore [ 'ListenerTimeout' ] . to_i > 0 and ( stime + datastore [ 'ListenerTimeout' ] . to_i < Time . now . to_f ) )
54
-
55
- select ( nil , nil , nil , 1 )
57
+ timeout = datastore [ 'ListenerTimeout' ] . to_i
58
+ loop do
59
+ break if session_created? && datastore [ 'ExitOnSession' ]
60
+ break if timeout . positive? && ( stime + timeout < Time . now . to_f )
61
+ sleep ( 1 )
56
62
end
57
63
end
58
-
59
-
60
64
end
0 commit comments