前段时间的一次样本,需要给出专杀,应急中遇到的是linux中比较常见的两个家族gates和xor。

首先是xor的专杀脚本,xor样本查杀的时候需要注意的是样本的主进程和子进程相互保护(详见之前的xor ddos分析http://www.cnblogs.com/goabout2/p/4888651.html),想要杀掉的话,需要先通过kill –stop挂起主进程,再删除其他的文件,但是由于xor的进程名是随机值,同时主机上还有有gates木马(gates最显著的特征就是会替换系统文件ps,lsof,ss,netstat),因此为了避嫌,脚本必须隔离系统命令。

此处通过的是遍历/proc/pid/maps文件获取所有进程对应的程序路径,通过该路径与特征值匹配出的路径对比,从而确定主进程的pid。

import os
import re
import sys
import time# property of the virus
sigin = "m4S4nAC/nA"
filepath = "/boot/dingzhi_random_10_word1;/lib/udev/udev"
delpath = "/etc/cron.hourly/cron.sh;/etc/init.d/fromdingzhi_"#read file
def readfile(path):file = open(path)try:content = file.read()finally:file.close()return content#scan the filesystem in the os with specify eigenvalue
def scanforeigen(path,word):for filename in os.listdir(path):fp = os.path.join(path,filename)if os.path.isfile(fp):print fpwith open(fp) as f:for line in f:if word in line:print "find in the file:" + fpreturn fpbreakelif os.path.isdir(fp):scanforeigen(fp,word)#check the specify dir thrugh property return the path in a lis
def check():targetlist = []bootfile = scanforeigen("/boot",sigin)if bootfile is not None and bootfile != '':bootfilename = bootfile.split("/")[-1]if len(bootfilename) == 10 and re.match('^[a-z]+$',bootfilename):targetlist.append(bootfile)libfile = scanforeigen("/lib/udev",sigin)if libfile is not None and libfile != '':libfilename = libfile.split("/")[-1]if libfilename == "udev":targetlist.append(libfile)return targetlistdef kill():itemlist = []targetlist = check()print targetlistboot = targetlist[0]print "boot is " + bootbootname = boot.split('/')[-1]for itemnum in os.listdir("/proc"):                   #throught the filename to find the pid and returnif itemnum.isdigit():print "the dir is " + itemnum path = "/proc/" + itemnum + "/maps"print pathmapscontent = readfile(path)if bootname in mapscontent:print "the pid of the " + bootname + " is " + itemnumitemlist.append(itemnum)print itemlist#stop the father processfor item in itemlist:print "item is " + item cmd = "kill -STOP " + itemos.popen(cmd)time.sleep(5)print "going sleeping"#delete the file for target in targetlist:print "del the" + targetcmd = "rm " + targetos.popen(cmd)dellist = delpath.split(';')for delfile in dellist:print "the delfile" + delfileif delfile.split('/')[-1] == "fromdingzhi_":delfile = delfile.replace("fromdingzhi_",bootname)print "del the " + delfilecmd = "rm " + delfileos.popen(cmd)#kill the processcmd = "kill -9 " + itemprint cmdos.popen(cmd)if __name__ == '__main__':
#list = check()if sys.argv[1] == "-check":list = check()elif sys.argv[1] == '-kill':kill()

对于gates木马需要注意的是,样本运行第一次的时候的文件不会删除,通过二进制分析的时候是获取不到该样本的路径的,索性该处的路径保存在/etc/init.d/DbSecuritySpt的启动文件中。

import os
import sys
import time#linux.tragon.bill.gatessigin = "88FD2FE8EF8D51263B037677FD30F25CBFEB57F759F711FB41956288A85E9655F"
initpaht = "/etc/init.d/selinux;/etc/init.d/DbSecuritySpt"
filedir = "/usr/bin;/usr/sbin;/bin;/usr/bin/bsd-port;/usr/bin/dpkgd"
filepath = "/usr/bin/.sshd;/usr/bin/bsd-port/getty"
delpath = "/usr/bin/ps;/usr/bin/ss;/usr/bin/lsof;/usr/bin/netsata;/usr/sbin/ps;/usr/sbin/ss;/usr/sbin/lsof;/usr/sbin/netsata;/bin/ps;/bin/ss;/bin/lsof;/bin/netsata;/etc/init.d/selinux;/etc/init.d/DbSecuritySpt;/tmp/moni.lod;/tmp/gates.lod;/usr/bin/bsd-port/getty.lock"
configfile = "/tmp/moni.lod;/tmp/gates.lod;/usr/bin/bsd-port/getty.lock"findlist = []#read file
def readfile(path):file = open(path)try:content = file.read()finally:file.close()return content#scan the filesystem in the os with specify eigenvalue
def scanforeigen(path,word):for filename in os.listdir(path):fp = os.path.join(path,filename)if os.path.isfile(fp):print fpwith open(fp) as f:for line in f:if word in line:print "find in the file:" + fpfindlist.append(fp)return fpelif os.path.isdir(fp):scanforeigen(fp,word)#check the specify dir thrugh property return the path in a lis
def check():targetlist = []dirlist = filedir.split(";")for dirpath in dirlist:checkfile = scanforeigen(dirpath,sigin)'''print "the checkfile is :"print checkfiletargetlist.append(checkfile)'''
#start kill
def kill():piddic = {}check()print findlist#get pidif findlist is not None:conflist = configfile.split(";")for confpath in conflist:content = readfile(confpath)print "the path " + confpath + "content is " + content piddic[confpath] = contentprint piddic#get the filepath restart by DbSecuritySptspecialpath = readfile("/etc/init.d/DbSecuritySpt")specialpath = specialpath[12:]print "dd" + specialpath#stop the process in the pidlistfor key in piddic:cmd = "kill -STOP " + piddic[key]os.popen(cmd)#start to delete the filedelfile = delpath.split(";")for delfielpath in delfile:cmd = "rm " + delfielpathos.popen(cmd)cmd = "rm " + specialpathos.popen(cmd)cmd = "cp /usr/bin/dpkgd/ps /bin"os.popen(cmd)cmd = "cp /usr/bin/dpkgd/ss /bin"os.popen(cmd)cmd = "cp /usr/bin/dpkgd/lsof /bin"os.popen(cmd)cmd = "cp /usr/bin/dpkgd/netstat /bin"os.popen(cmd)for key in piddic:cmd = "kill -9 " + piddic[key]os.popen(cmd)if __name__ == '__main__':
#list = check()if sys.argv[1] == "-check":list = check()elif sys.argv[1] == '-kill':kill()

转载于:https://www.cnblogs.com/goabout2/p/5149037.html

xor和gates的专杀脚本相关推荐

  1. 创建 jun.exe病毒专杀程序(BETA1.1)

    昨天在网吧下载几本书,回去习惯的右键打开U盘,可是出现了两个中文菜单:"打开(O)","资源管理器(X)",我的系统是英文的,感到很奇怪~我当时也没在意就右键打 ...

  2. 360网站卫士 PHP-DOS攻击脚本专杀工具使用笔记

    0x00 背景 该工具用于查杀网站上可能存在的DDOS恶意脚本.用户只需将该脚本上传并解压到网站根目录,即可通过浏览器访问轻松查杀恶意文件. 0x01 下载与安装 1.下载链接:http://wang ...

  3. 网络安全学习第4篇-使用特征码和MD5对勒索病毒进行专杀,并对加密文件进行解密

    请使用IDA或其它分析工具分析本次的样本文件,写一个简要的行为分析报告,并编写一个针对于这次样本的专杀(恢复)程序. 要求: 1.样本分析只要说明主要行为即可.提示:sub_401320主要用于文件加 ...

  4. 网络安全入门实验04:病毒专杀工具的制作

    目录 0.实验要求 1.病毒行为分析 1.1  火绒剑监控 1.1.1 对docx进行的操作 1.1.2 创建了readme.txt 1.1.3  创建了自删除脚本.执行并删除 1.1.4 补充 1. ...

  5. 肢解“文件夹图标”病毒,制作专杀工具——“郑大扫帚”

    肢解"文件夹图标"病毒,制作专杀工具--"郑大扫帚" 回想2009年7-8月份,学校机房被"文件夹图标病毒"变成了病毒"集散地&q ...

  6. 一台电脑中招,整网均被感染---9166.biz / 5y5.us Arp木马病毒专杀360独家发布

    原文:http://x.360safe.com/index.php/1/action_viewspace_itemid_27395.html 近日,360安全中心接到大量用户的举报,称全局域网的电脑中 ...

  7. 文件夹快捷方式VBS病毒清除专杀

    文件夹快捷方式病毒清除专用附件包含下面几部分. 1.自动化清除脚本 2.NTFS系统盘专用清理工具清理工具和FAT32系统盘专用清理工具 3.恢复文件夹属性工具 首先使用"自动化清除脚本程序 ...

  8. lockbit勒索病毒专杀工具,.lockbit勒索病毒数据恢复,lockbit勒索病毒解密处理,数据库恢复

    lockbit勒索病毒专杀工具,.lockbit勒索病毒数据恢复,lockbit勒索病毒解密处理,数据库恢复 目录: lockbit勒索病毒简述 计算机感染lockbit勒索病毒后的表现 lockbi ...

  9. eking勒索病毒文件恢复|eking勒索病毒解密工具|eking勒索病毒解密专杀怎么办数据库恢复

    eking勒索病毒文件恢复|eking勒索病毒解密工具|eking勒索病毒解密专杀怎么办数据库恢复 目录: eking勒索病毒介绍 感染eking勒索病毒后的表现 eking勒索病毒的感染形式 eki ...

最新文章

  1. ubuntu18.04.4 录制麦克风音频
  2. Python学习记录day3
  3. Visual Studio 2008 环境变量的配置(参考设置VS2010)
  4. 网站等保测评针对服务器,互联互通测评知识分享之信息安全建设要点
  5. java反射 获取方法_java反射之获取类的信息方法(推荐)
  6. ORACLE备份中的压缩
  7. Linux-sed command
  8. matlab矩阵除法
  9. Ubuntu20.04 美化
  10. MySQL笔记: B站宋红康最新教程 (持续更新中)
  11. Git更新本地分支信息
  12. 什么是web services?它有什么作用,以及它如何实现?
  13. 台式机通过网线连接笔记本上网
  14. ppi 各代iphone_从iPhone 6到iPhone X:居然隐藏了这么多秘密
  15. python有哪些细节描写_什么是细节描写?它又包括哪些方面?
  16. 双碳时代,数据中心供配电的“智”与“能”
  17. Java中实例化对象是什么意思
  18. 使用飞信api接口实现短信发送(只能发送好友)
  19. 云波社区 l Mecha Morphing(变形机甲)游戏介绍
  20. bios设置raid启动模式Linux,华硕主板BIOS里哪项是开启RAID方式?

热门文章

  1. JavaScript DOM 编程艺术 公用方法
  2. iOS 自定义layer的两种方式
  3. MediaPlayer控件的初探
  4. la是什么牌子_La Prairie
  5. (90)FPGA面试题-使用Verilog实现可预置初值的7进制循环计数器
  6. (16)Verilog HDL常量:数值表示
  7. hive使用适用场景_Hive 中 Map Join 的适用场景:非等值连接
  8. C++ 关于复制、移动构造函数和移动、复制 赋值运算符的重载问题;
  9. c语言考博真题,中国科学院2015年考博英语真题及答案
  10. 数据结构与算法分析(十)——母牛的故事