ctf之AWD(6)_服务器
文件监控
#用linux python环境
pip install pyinotify
pip show pyinotify
#将pyinotify.py 和下面的 py_mon.py 复制到同一个文件夹下
#使用 python py_mon.py 默认监控目录: /var/www/html
#python -m pyinotify 监控目录
py_mon.py
##### py_mon.py #####
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
from pyinotify import WatchManager, Notifier, ProcessEvent
from pyinotify import IN_DELETE, IN_CREATE, IN_MOVED_TO, IN_ATTRIB
class EventHandler(ProcessEvent):
"""事件处理"""
# 创建
def process_IN_CREATE(self, event):
print("[!] Create : " + event.pathname)
DeleteFileOrDir(event.pathname)
# 删除