-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_write_listfile.py
More file actions
72 lines (63 loc) · 1.68 KB
/
load_write_listfile.py
File metadata and controls
72 lines (63 loc) · 1.68 KB
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
# !/usr/bin/env python
# -*- coding:utf-8 -*-
"""
test file
"""
import os
import commands
readfilepath = '/tmp/readfile.txt'
xssfilepath = '/tmp/xss.txt'
sqlfilepath = '/tmp/sqli.txt'
filelist = [readfilepath, xssfilepath, sqlfilepath]
def checkfile():
count = 0
filecount = len(filelist)
for i in range(len(filelist)):
result = os.path.exists(filelist[i])
if result is False:
commands.getstatusoutput('touch %s' % filelist[i])
result = os.path.exists(filelist[i])
if result is True:
count += 1
elif result is True:
count += 1
if count == filecount:
return loadlist(filelist)
def loadlist(filelist):
readfilelist = []
xsslist = []
sqlilist = []
# print filelist
for i in range(len(filelist)):
file1 = open(filelist[i])
content = file1.readlines()
if len(content) != 0:
tmp = content[0]
urllist = eval(tmp)
if i == 0:
readfilelist = urllist
elif i == 1:
xsslist = urllist
elif i == 2:
sqlilist = urllist
else:
pass
return readfilelist, xsslist, sqlilist
def writelist(readfilelist, xsslist, sqlilist):
"""
write the new list to file!
"""
for i in range(len(filelist)):
file1 = open(filelist[i], 'w')
if i == 0:
file1.write(str(readfilelist))
elif i == 1:
file1.write(str(xsslist))
elif i == 2:
file1.write(str(sqlilist))
else:
pass
# print content
if __name__ == '__main__':
checkfile()
# print __name__