forked from r4stl1n/SSH-Brute-Forcer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.py
50 lines (33 loc) · 1.01 KB
/
Util.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
'''
Created on Aug 25, 2011
@author: r4stl1n
'''
def fileContentsToList(fileName):
lineList = []
try:
fileParser = open(fileName, 'r')
except IOError:
print("[!] Could not open file " + fileName)
except:
print("[!] Could not access file " + fileName)
for line in fileParser.readlines():
newLine = line.replace('\n', '')
lineList.append(newLine)
return lineList
def fileContentsToTuple(fileName):
tupleList = []
try:
fileParser = open(fileName, 'r')
except IOError:
print("[!] Could not open file " + fileName)
except:
print("[!] Could not access file " + fileName)
for line in fileParser.readlines():
newLine = line.replace('\n', '')
newTuple = (newLine[:line.find(':')], newLine[line.find(':') + 1:])
tupleList.append(newTuple)
return tupleList
def appendLineToFile(line, filename):
fileHandler = open(filename, "a+")
fileHandler.write(line + "\n")
fileHandler.close()