-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example_2.5 standalone.py
62 lines (53 loc) · 1.9 KB
/
Example_2.5 standalone.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
import os
import docx
import re
validInstances = 0
#Opens Document
def openDoc():
desiredDoc = input("Enter desired document: ")
Doc = docx.Document(str(desiredDoc))
return Doc
#Grabs Material
def DocumentMaterial(Doc):
Material = []
for para in Doc.paragraphs:
Material.append(para.text)
#print(Material)
return '\n'.join(Material)
#Searches current page for IPs
def findIPs(document):
global validInstances
testableDoc = document
#print("Test Flag 1")
for i in range(0,len(testableDoc)-14):
print("Testing...")
for a in range(192,193):
for b in range(0,20):
#print(validInstances)
#print("Testing IPs in range of: " + str(a) +"." + str(b) + ".###.###")
for c in range(0,20):
for d in range(0,120):
for k in range(7,15):
#print("Pass " + str(k-6) + "/9 completed.")
#print("Testing for: " + str(a) + "." + str(b) + "." + str(c) + "."+ str(d))
if testableDoc[i:i+k] == str(str(a) + "." + str(b) + "." + str(c) + "." + str(d)):
#print("Instance found!")
validInstances+=1 #print(pdf[i:i+15])
print('Instance found!')
print(validInstances)
def findIPs2(document):
global validInstances
testableDoc = document
DesiredIP = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
for i in range(0,len(testableDoc)-6):
if DesiredIP.match(testableDoc[i:i+):
validInstances+=1
#print("Instance found!")
#Main Program
X = openDoc()
Y = DocumentMaterial(X)
#findIPs(Y)
findIPs2(Y)
print(validInstances)
#print()
#print("There are " + str(validInstances) + " instances of IPs found.")