-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathexploitdb.py
204 lines (144 loc) · 5.94 KB
/
exploitdb.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import csv
import os
import tempfile
class ExploitDB_Search:
"""This class allows you to search exploit db for exploits on an app specified"""
def __init__(self,search):
self.search = search
self.file = "files.csv"
self.os = os.name
self.foundList = []
self.headerList = []
def searchDB(self):
search = self.search
openFile = open(self.file, "r")
reader = csv.reader(openFile)
#Grab the headers of the csv file and add them to a list
rownum = 0
for row in reader:
if rownum == 0:
headerList = row
break
self.headerList = headerList
#search for a term
searchTerm = search
newRowNum = 0
for row in reader:
if newRowNum == 0:
newRowNum += 1
continue
else:
tempRow = row
if searchTerm in tempRow[4]:
self.foundList.append(tempRow)
newRowNum +=1
continue
else:
newRowNum += 1
continue
##
##
## print(self.foundList)
## print(len(self.foundList))
## #for each in foundList:
## #print(each[0])
##
## resultsPagesList = self.createPageLists(self.foundList)
##
## for i in range(len(resultsPagesList[0])):
## print(i + 1," - ",resultsPagesList[0][i][2])
##
## #with open(foundList[0][1],mode="w",encoding="utf-8") as myFile:
## #self.createTempFile(foundList[0][1])
openFile.close()
def createPageListing(self,resultsPagesList):
width = self.width
height = self.height
totalResults = len(self.foundList)
end = False
print("-" * width)
currentPage = 0
pageNavigation = """
________________________________________________________________
| |
| Navigation Options |
| |
| - Enter 'p' followed by page number (e.g. 'p4', 'p5') |
| - Enter 'e' followed by the exploit number (e.g. 'e3', 'e11') |
| - Enter 'exit' to return to the main menu |
|________________________________________________________________|
"""
totalNumOfPages = len(resultsPagesList)
print(pageNavigation)
input("Press [enter] to continue...")
while end == False:
print("-" * width)
print("Current page - {0}".format(currentPage + 1),end=" | ")
print("Exploits - {0}".format(totalResults),end=" | ")
print("Pages - {0}".format(totalNumOfPages),end="\n")
print()
for num in range(0,len(resultsPagesList[currentPage])):
print("{0}. {1}".format((((currentPage + 1) * 10) - 10 + (num + 1)),resultsPagesList[currentPage][num][2]))
#resultsPagesList[currentPage][num]['pagenum'] = currentPage
print()
print("-" * width)
print()
try:
choice = input("Enter option: ")
if choice == 'exit':
break
else:
pNumber = int(choice[1:])
##Navigate pages
if choice[0] == "p":
if pNumber > 0 and pNumber <= totalNumOfPages:
currentPage = int(choice[1:]) - 1
else:
print()
print("Please choose a page number in range...")
##Navigate Exploits
elif choice[0] == "e":
exploitNumber = int(choice[1:])
exploitMenu = """
_______________________________
| |
| Exploit Options |
| |
| 1. View Full Details |
| 2. View Shell Code |
| 3. Continue |
|_______________________________|
"""
print(exploitMenu)
exploitMenuChoice = 0
while exploitMenuChoice != 3:
if exploitNumber % 10 == 0:
pageOfExploit = (exploitNumber // 10) - 1
exploitNumInList = 9
else:
pageOfExploit = (exploitNumber // 10)
exploitNumInList = (exploitNumber % 10) - 1
print("-" * width)
exploitMenuChoice = int(input("Please choose an option: "))
if exploitMenuChoice == 1:
print("\nFull Details\n")
for each in self.headerList:
print(each)
elif exploitMenuChoice == 2:
try:
#Open the code of the exploit in a temp file
if exploitNumber % 10 == 0:
pageOfExploit = (exploitNumber // 10) - 1
exploitNumInList = 9
openTempFile(resultsPagesList[pageOfExploit][exploitNumInList][1])
else:
pageOfExploit = (exploitNumber // 10)
exploitNumInList = (exploitNumber % 10) - 1
self.createTempFile(resultsPagesList[pageOfExploit][exploitNumInList][1])
except KeyError:
print("Code unvailable for this exploit. Refer to online site for database provider.")
elif choice == 3:
continue
except ValueError:
print()
print("Please enter a valid option !")