首页 文章 精选 留言 我的

精选列表

搜索[java脚本],共10000篇文章
优秀的个人博客,低调大师

Python pyclamad病毒扫描与目录病毒扫描脚本(转载)

Clam AntiVirus(Clam AV)是一个免费而且开放源码的防毒软件,软件与病毒库的更新由开源社区免费发布,目前ClamdAV主要为Linux、Uinux系统提供病毒扫描查杀pyClamad是一个python的第三方模块,可让python直接使用ClamAV病毒扫描守护进程clamd来实现一个高效的病毒检测功能。 一、实现集中式的病毒扫描 1、客户端(病毒扫描源)安装clamavp clamd 服务的相关程序包 yum install clamav clamd clamav-update -y chkconfig clamd on 更新病毒库 /usr/bin/freshclam 更改配置文件修改监听地址到所有网络,启动服务 sed -i -e '/^TCPAddr/{ s/127.0.0.1/0.0.0.0/;}' /etc/clamd.conf /etc/init.d/clamd start 2、主控端安装pyClamd模块 参考:http://xael.org/pages/pyclamd-en.html pip install pyclamd 验证安装结果: <pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(238, 238, 221); text-decoration-style: initial; text-decoration-color: initial;">>>> import pyclamd cd = pyclamd.ClamdAgnostic() cd.ping() True</pre> 工作原理:管理服务器通过python发出多线程指令连接业务服务器的3310端口,执行病毒扫描,然后返回结果给管理服务器。 业务服务器必须安装clamd相关程序包,并启动服务监听在3310端口才能正常收到指令;可以针对不同业务环境定制相应的扫描策略,比如扫描对象、描述模式、扫描路径、调试频率等。 实现代码:simplel.py [ 复制代码 ](javascript:void(0); "复制代码") <pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> 1 #!/usr/bin/env python 2 # -- coding: utf-8 -- 3 import time 4 import pyclamd 5 from threading import Thread 6 class Scan(Thread): #继承多线程Thread类 7 def init (self,IP,scan_type,file): 8 """构造方法""" 9 Thread.init(self) 10 self.IP = IP 11 self.scan_type=scan_type 12 self.file = file 13 self.connstr="" 14 self.scanresult="" 15 def run(self): 16 """多进程run方法""" 17 try: 18 cd = pyclamd.ClamdNetworkSocket(self.IP,3310) 19 """探测连通性""" 20 if cd.ping(): 21 self.connstr=self.IP+" connection [OK]" 22 """重载clamd病毒特征库""" 23 cd.reload() 24 """判断扫描模式""" 25 if self.scan_type=="contscan_file": 26 self.scanresult="{0}\n".format(cd.contscan_file(self.file)) 27 elif self.scan_type=="multiscan_file": 28 self.scanresult="{0}\n".format(cd.multiscan_file(self.file)) 29 elif self.scan_type=="scan_file": 30 self.scanresult="{0}\n".format(cd.scan_file(self.file)) 31 time.sleep(1) 32 else: 33 self.connstr=self.IP+" ping error,exit" 34 return 35 except Exception,e: 36 self.connstr=self.IP+" "+str(e) 37 IPs=['172.16.65.201','172.16.65.202'] #扫描主机的列表 38 scantype="multiscan_file" #指定扫描模式,支持 multiscan_file、contscan_file、scan_file 39 scanfile="/usr/local/bin" #指定扫描路径 40 i=1 41 threadnum=2 #指定启动的线程数 42 scanlist = [] #存储Scan类线程对象列表 43 for ip in IPs: 44 """将数据值带入类中,实例化对象""" 45 currp = Scan(ip,scantype,scanfile) 46 scanlist.append(currp) #追加对象到列表 47 """当达到指定的线程数或IP列表数后启动线程""" 48 if i%threadnum==0 or i==len(IPs): 49 for task in scanlist: 50 task.start() #启动线程 51 for task in scanlist: 52 task.join() #等待所有子线程退出,并输出扫描结果 53 print task.connstr #打印服务器连接信息 54 print task.scanresult #打印结果信息 55 scanlist = [] 56 i+=1</pre> [ 复制代码 ](javascript:void(0); "复制代码")

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码