forked from atiger77/Dionaea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tail.py
62 lines (52 loc) · 1.67 KB
/
tail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#-*- coding:utf-8
import time
import re
import requests
import datetime
import logging
lines = []
context = []
f_user_pass = open('UserPass.log', 'a')
f_path = open('Path.log', 'a')
def tail(f):
f.seek(0.2)
while True:
line = f.readline()
if not line:
time.sleep(10)
continue
yield line
def callback(lines_):
for line in lines_:
if line not in lines:
rule = r'Username:.*'
rule1 = r'Not Found: (.*)'
lines.append(line)
honey = re.findall(rule, line)
honey1 = re.findall(rule1, line)
if honey:
f_user_pass.write(honey[0]+'\n')
content = """
type : {type}
ip : {ip}
info : {info}
time : {time}
""".format(type="port:80", ip="x.x.x.x", info=honey[0], time=str(datetime.datetime.now())[11:19])
resp = requests.post("http://dk.ttupp.com/weixin/weixin.php",
data={"key": "xxx.xxx.xxx", "msg": content})
elif honey1:
f_path.write(honey1[0]+'\n')
content = """
type : {type}
ip : {ip}
info : {info}
time : {time}
""".format(type="port:80", ip="x.x.x.x", info=honey1[0], time=str(datetime.datetime.now())[11:19])
resp = requests.post("http://dk.ttupp.com/weixin/weixin.php",
data={"key": "xxx.xxx.xxx", "msg": content})
time.sleep(10)
def main():
flog = tail(open('Dionaea.log'))
callback(flog)
if __name__ == "__main__":
main()