-
Notifications
You must be signed in to change notification settings - Fork 1
/
gxreset.py
83 lines (75 loc) · 1.53 KB
/
gxreset.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
#-*- encoding:utf-8 -*-
#Filename:gxreset.py
import os
import sys
import fnmatch
import re
reload(sys)
sys.setdefaultencoding('utf-8')
"""
捞取广西6月重置密码的数据
"""
def getFiles():
dir = '/data/logs/log_hjb/'
flist = []
regex = 'umserver.log.201306*.bz2'
for f in os.listdir(dir):
if fnmatch.fnmatch(f,regex):
#print f
flist.append(f)
for f in flist:
print '正在处理%s...' % f
fpath = os.path.join(dir,f)
cmd1 = '''bzcat %s|grep '>>>>'|grep findpassword >> gxreset.log''' % fpath
os.system(cmd1)
print 'fuck gx over....'
def regexFile():
f = '/data/logs/log_hjb/gxreset.log'
fr = open(f,'r')
num = 0
result = []
for line in fr:
str = ''
if line != None and len(line) > 0:
#phone
m = re.search(r'account=([\d]{11})',line)
if m:
phone = m.group(1)
#print phone
if phone ==None or len(phone) <= 0:
continue
str = phone
#ip
m = re.search(r'IP:([^,]*),',line)
if m:
ip = m.group(1)
#print ip
str += "|"+ ip
#imei
m = re.search(r'pub.CP_IMEI=([^,]*)',line)
if m:
imei = m.group(1)
#print imei
str += "|"+ imei
#time
index = line.index(',')
time = line[0:index]
str += "|" + time
#uuid
m = re.search(r'UUID:([^,]*),',line)
if m:
uuid = m.group(1)
str += "|"+ uuid
print str
if str != None and len(str) > 0:
result.append(str+"\n")
#print num
num += 1
fresult = open('gxreset.txt','w')
fresult.writelines(result)
fresult.close()
fr.close()
print len(result)
getFiles()
regexFile()