1 Star 0 Fork 0

堆栈虫/phpox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
analysis.py 3.48 KB
一键复制 编辑 原始数据 按行查看 历史
glaslos 提交于 2015-12-31 17:41 . some cleaning and python3 stuff
# Copyright (C) 2012 Lukas Rist
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import hashlib
class Botnet(object):
""" this class contains irc bot info"""
def __init__(self, script):
self.id = ""
if '/' in script:
self.file_name = script.rsplit("/", 1)[1]
else:
self.file_name = script
self.file_md5 = hashlib.md5(open(script).read().encode('utf-8')).hexdigest()
self.first_analysis_date = ""
self.last_analysis_date = ""
self.irc_addr = ""
self.irc_server_pwd = ""
self.irc_nick = ""
self.irc_user = ""
self.irc_mode = ""
self.irc_channel = []
self.irc_nickserv = ""
self.irc_notice = []
self.irc_privmsg = []
def todict(self):
botnet_dict = {
'id': self.id,
'file_name': self.file_name,
'file_md5': self.file_md5,
'first_analysis_date': self.first_analysis_date,
'last_analysis_date': self.last_analysis_date,
'irc_addr': self.irc_addr,
'irc_server_pwd': self.irc_server_pwd,
'irc_nick': self.irc_nick,
'irc_user': self.irc_user,
'irc_mode': self.irc_mode,
'irc_channel': self.irc_channel,
'irc_nickserv': self.irc_nickserv,
'irc_notice': self.irc_notice,
'irc_privmsg': self.irc_privmsg
}
return botnet_dict
class DataAnalysis(object):
"""this class is used to extracts raw sandbox data to useful info for us"""
def __init__(self, script, debug=0):
self.botnet = Botnet(script)
self.debug_level = debug
def analyze(self, output):
output = output.decode('utf-8')
for line in output.split("\n"):
if self.debug_level > 0:
print(repr(line))
if line[:4] == "ADDR":
self.botnet.irc_addr = line[5:]
elif line[:4] == "PASS":
self.botnet.irc_server_pwd = line[5:]
elif line[:4] == "USER":
self.botnet.irc_user = line[5:]
elif line[:4] == "NICK":
self.botnet.irc_nick = line[5:]
elif line[:4] == "MODE":
try:
self.botnet.irc_mode = line[5:].split(" ", 1)[1]
except IndexError:
continue
elif line[:4] == "JOIN":
self.botnet.irc_channel.append(line[5:])
elif line[:7] == "PRIVMSG":
line_parts = line[8:].split(" ")
if line_parts[0] == "nickserv":
self.botnet.irc_nickserv = line[8:]
else:
self.botnet.irc_privmsg.append(line[8:])
elif line[:6] == "NOTICE":
self.botnet.irc_notice.append(line[7:])
return self.botnet
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stackw0rm/phpox.git
[email protected]:stackw0rm/phpox.git
stackw0rm
phpox
phpox
master

搜索帮助