监控通知工具 之前渗透一个网站,在拿下一台c段服务器后,发现在登陆的时候需要手机短信验证码(几分钟有效),于是写了个关于文本监控方面的工具。 主要功能是为了对嗅探数据进行监控,当匹配到指定的信息的时候,通过邮件的方式通知,并实现模拟登陆等操作。 工具模拟实现效果如下: 如下是一段不停向一个文件里面写东西的代码:
# coding=utf-8import logging
import time
import sys
def write_tofile(content):
try:
with open('test.txt', 'a+') as fl:
fl.write('{}\n'.format(content))
ltime = time.localtime(time.time())
print time.strftime("%Y-%m-%d %H:%M:%S", ltime), ': save'except Exception,e:
print e
sys.exit(1)
def run(runt):
i = 1
if runt != 0:
while True:
write_tofile('This is the {} message'.format(i))
time.sleep(1)
i += 1
runt -=1
if runt < 0 or runt==0: breakif __name__ == '__main__':
try:
run(10)
except KeyboardInterrupt:
logging.info("Ctrl C - Stopping Client")
sys.exit(1)
工具的配置代码config.conf:
[email]
# 邮箱设置
host = smtp.qq.com
port = 465
user = ****@qq.com
pwd = *****
# 接受方设置
receiver = ****@qq.com
# 发送标题
title = just for test
[file]
# 附件保存
outname = result.txt
# 是否删除发送附件
isdelete = True
# 是否发送邮件附件
isSendFile = True
[re]
# 邮件抓取内容正则设置findall
re_c = (.*?10.*?)
# 附件保存内容正则
re_e = (.*)
运行监控文件 运行写入文件 结果
当初的后续的执行代码没有发出来,不太方便。 后台执行的话,目前知道的有三种方法。 1. python在linux后面加& 2. 在windows下用.pyc 3. 打包成exe的话用如下一段vbs set wscriptObj = CreateObject("Wscript.Shell") wscriptObj.run "monitorf.exe",0
|