xor和gates的专杀脚本
前段时间的一次样本,需要给出专杀,应急中遇到的是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 fp
with open(fp) as f:
for line in f:
if word in line:
print "find in the file:" + fp
return fp
break
elif 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 targetlist def kill():
itemlist = []
targetlist = check()
print targetlist
boot = targetlist[0]
print "boot is " + boot
bootname = boot.split('/')[-1]
for itemnum in os.listdir("/proc"): #throught the filename to find the pid and return
if itemnum.isdigit():
print "the dir is " + itemnum
path = "/proc/" + itemnum + "/maps"
print path
mapscontent = readfile(path)
if bootname in mapscontent:
print "the pid of the " + bootname + " is " + itemnum
itemlist.append(itemnum)
print itemlist #stop the father process
for item in itemlist:
print "item is " + item
cmd = "kill -STOP " + item
os.popen(cmd)
time.sleep(5)
print "going sleeping" #delete the file
for target in targetlist:
print "del the" + target
cmd = "rm " + target
os.popen(cmd) dellist = delpath.split(';')
for delfile in dellist:
print "the delfile" + delfile
if delfile.split('/')[-1] == "fromdingzhi_":
delfile = delfile.replace("fromdingzhi_",bootname) print "del the " + delfile
cmd = "rm " + delfile
os.popen(cmd) #kill the process
cmd = "kill -9 " + item
print cmd
os.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.gates sigin = "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 fp
with open(fp) as f:
for line in f:
if word in line:
print "find in the file:" + fp
findlist.append(fp)
return fp elif 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 checkfile
targetlist.append(checkfile)
'''
#start kill
def kill():
piddic = {}
check()
print findlist
#get pid
if findlist is not None:
conflist = configfile.split(";")
for confpath in conflist:
content = readfile(confpath)
print "the path " + confpath + "content is " + content
piddic[confpath] = content
print piddic #get the filepath restart by DbSecuritySpt
specialpath = readfile("/etc/init.d/DbSecuritySpt")
specialpath = specialpath[12:]
print "dd" + specialpath #stop the process in the pidlist
for key in piddic:
cmd = "kill -STOP " + piddic[key]
os.popen(cmd) #start to delete the file
delfile = delpath.split(";")
for delfielpath in delfile:
cmd = "rm " + delfielpath
os.popen(cmd) cmd = "rm " + specialpath
os.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()
xor和gates的专杀脚本的更多相关文章
- DedeCMS顽固木马后门专杀工具V2.0实现方式研究
catalog . 安装及使用方式 . 检查DEDECMS是否为最新版本 . 检查默认安装(install)目录是否存在 . 检查默认后台目录(dede)是否存在 . 检查DedeCMS会员中心是否关 ...
- 【旧文章搬运】PE感染逆向之修复(Serverx.exe专杀工具出炉手记)
原文发表于百度空间,2008-10-4看雪论坛发表地址:https://bbs.pediy.com/thread-73948.htm================================== ...
- DesktopLayer.exe专杀
这两天发现电脑卡慢. 同事电脑发现病毒,而后装上杀软后(一直在裸奔~~~),发现自己电脑也存在. DesktopLayer.exe 会有以下几个行为: 第一,会在C:\Program Files (x ...
- 病毒木马查杀实战第011篇:QQ盗号木马之专杀工具的编写
前言 由于我已经在<病毒木马查杀第004篇:熊猫烧香之专杀工具的编写>中编写了一个比较通用的专杀工具的框架,而这个框架对于本病毒来说,经过简单修改也是基本适用的,所以本文就不讨论那些重叠的 ...
- 病毒木马查杀实战第017篇:U盘病毒之专杀工具的编写
前言 经过前几次的讨论,我们对于这次的U盘病毒已经有了一定的了解,那么这次我们就依据病毒的行为特征,来编写针对于这次U盘病毒的专杀工具. 专杀工具功能说明 因为这次是一个U盘病毒,所以我打算把这次的专 ...
- r0capture安卓应用层通杀脚本-使用文档
本文所有教程及源码.软件仅为技术研究.不涉及计算机信息系统功能的删除.修改.增加.干扰,更不会影响计算机信息系统的正常运行.不得将代码用于非法用途,如侵立删! r0capture安卓应用层通杀脚本-使 ...
- [转帖] securebootthemes 挖矿病毒的说明 http://blog.netlab.360.com/msraminer-qian-fu-yi-jiu-de-wa-kuang-jiang-shi-wang-luo/ 原文为毛不给一个专杀工具呢.
MsraMiner: 潜伏已久的挖矿僵尸网络 2017 年 11 月底,我们的 DNSMon 系统监测到几个疑似 DGA 产生的恶意域名活动有异常.经过我们深入分析,确认这背后是一个从 2017 年 ...
- 数列[专杀Splay版]
时间限制: 3 Sec 内存限制: 128 MB提交: 49 解决: 7 题目描述 输入一个数列,你需要进行如下操作: 1. 把编号为I的数值改为K 2. 输出从小到大排序后第k个数 输入 输 ...
- 【转】BAT 批处理脚本 教程
第一章 批处理基础第一节 常用批处理内部命令简介批处理定义:顾名思义,批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT或者CMD.这些命令统称批处理命令.小知识:可以在 ...
随机推荐
- 平衡二叉查找树(AVL)的理解与实现
AVL树的介绍 平衡二叉树,又称AVL(Adelson-Velskii和Landis)树,是带有平衡条件的二叉查找树.这个平衡条件必须要容易保持,而且它必须保证树的深度是 O(log N).一棵AVL ...
- 山东第一届省赛1001 Phone Number(字典树)
Phone Number Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 We know that if a phone numb ...
- wpf 获取datagrid中模板中控件
//获取name为datagrid中第三列第一行模板的控件 FrameworkElement item = dataGrid.Columns[].GetCellContent(dataGrid.Ite ...
- C#内存管理与垃圾回收
垃圾回收还得从根说起,就像生儿育女一样. 根:根是一个位置,存放一个指针,该指针指向托管堆中的一个对象,或是一个空指针不指向任何对象,即为null.根存在线程栈或托管堆中,大部分的跟都在线程栈上,因为 ...
- Web编程基础--HTML、CSS、JavaScript 学习之课程作业“仿360极速浏览器新标签页”
Web编程基础--HTML.CSS.JavaScript 学习之课程作业"仿360极速浏览器新标签页" 背景: 作为一个中专网站建设出身,之前总是做静态的HTML+CSS+DIV没 ...
- 四、Shell输入、输出功能和字符颜色设置
一.Shell输入功能 1.键盘输入 方式一: [root@Salve four]# cat test.sh #!/bin/bash #-e 参数可以解析语句中的转义字符 echo -e &quo ...
- 设置arc 的默认编辑器
arc set-config editor "vim" 转自:http://udn.yyuap.com/thread-39791-1-1.html Pharicator是FB的代码 ...
- 浏览器内核控制Meta标签说明文档
浏览器内核控制Meta标签说明文档 原文链接 背景介绍 由于众所周知的情况,国内的主流浏览器都是双核浏览器:基于Webkit内核用于常用网站的高速浏览.基于IE的内核用于兼容网银.旧版网站.以360的 ...
- jvm
-Xms128m表示JVM Heap(堆内存)最小尺寸128MB,初始分配-Xmx512m表示JVM Heap(堆内存)最大允许的尺寸256MB,按需分配. 说明:如果-Xmx不指定或者指定偏小,应用 ...
- 1.从Node.js链接到MongoDB
MongoDB采用了MongoDB Node.js驱动程序作为标准. 1.安装MongoDB驱动 npm install mongoDB npm install mongoose require('m ...