This repository was archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathread_configuration.py
More file actions
192 lines (167 loc) · 4.5 KB
/
read_configuration.py
File metadata and controls
192 lines (167 loc) · 4.5 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
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
from plugins_loader import *
import ConfigParser
import sys
class BaseConfiguration:
"""
Permet de lire la section [Base] du fichier de configuration de l'exploit
"""
def __init__(self, file_configuration, printing):
"""
Creer une instance de ConfigParser et charge toutes les informations de la section [Base]
"""
try:
self.config = ConfigParser.SafeConfigParser()
self.config.readfp(open(file_configuration))
self.read_title()
self.read_description()
self.read_version()
self.read_author()
self.read_date()
self.read_type()
self.read_CVE()
self.read_EDB()
if(printing == True):
self.print_base_configuration()
except:
print "Error in loading exploit module %s !" % file_configuration
sys.exit(1)
def read_title(self):
"""
Recupere le titre
"""
self.title = self.config.get('Base', 'title')
return self.title
def read_description(self):
"""
Recupere la description
"""
self.description = self.config.get('Base', 'description')
return self.description
def read_version(self):
"""
Recupere la version
"""
self.version = self.config.get('Base', 'version')
return self.version
def read_author(self):
"""
Recupere l'auteur
"""
self.author = self.config.get('Base', 'author')
return self.author
def read_date(self):
"""
Recupere la date
"""
self.date = self.config.get('Base', 'date')
return self.date
def read_type(self):
"""
Recupere le type d'exploit
"""
self.type = self.config.get('Base', 'type')
return self.type
def read_CVE(self):
"""
Recupere le CVE s'il existe
"""
try:
self.cve = self.config.get('Identifiers', 'CVE')
except:
self.cve = 'Not defined!'
return self.cve
def read_EDB(self):
"""
Recupere le EDB s'il existe
"""
try:
self.edb = self.config.get('Identifiers', 'EDB')
except:
self.edb = 'Not defined!'
return self.edb
def print_base_configuration(self):
print '\nExploit Configuration:'
print " Title:", self.title
print " Description:", self.description
print " Version:", self.version
print " Author:", self.author
print " Date:", self.date
print " Exploit type:", self.type
print " CVE ID:", self.cve
print " EDB ID:", self.edb
class ExploitationConfiguration:
"""
Permet de lire la section [Exploitation] et [Parameters] du fichier de configuration de l'exploit
"""
def __init__(self, file_configuration):
self.config = ConfigParser.SafeConfigParser()
self.config.readfp(open(file_configuration))
self.read_method()
self.read_url()
self.read_parameters()
def read_method(self):
self.method = self.config.get('Exploitation', 'method')
return self.method
def read_url(self):
self.url = self.config.get('Exploitation', 'url')
return self.url
def read_parameters(self):
self.tab = {}
self.parameters = self.config.options('Parameters')
for i in range(len(self.parameters)):
self.tab[self.parameters[i]] = self.config.get('Parameters', self.parameters[i])
return self.tab
class PayloadConfiguration:
"""
Charge le payload
"""
def __init__(self, file_payload, printing, list_plugins):
"""
Creer une instance de ConfigParser et charge toutes les informations de la section [Payload]
"""
self.list_plugins = list_plugins
self.config = ConfigParser.SafeConfigParser()
self.config.readfp(open(file_payload))
self.read_title()
self.read_description()
self.read_payload()
self.read_type()
self.read_method()
if(printing == True):
self.print_payload_configuration()
def read_title(self):
"""
Recupere le titre
"""
self.title = self.config.get('Payload', 'title')
return self.title
def read_description(self):
"""
Recupere la description
"""
self.description = self.config.get('Payload', 'description')
return self.description
def read_payload(self):
"""
Recupere le payload
"""
self.payload = self.config.get('Payload', 'payload')
return self.payload
def read_type(self):
"""
Recupere le type
"""
self.type = self.config.get('Payload', 'type')
return self.type
def read_method(self):
"""
Recupere la method
"""
if self.type.lower() == "csrf":
self.method = self.config.get('Payload', 'method')
return self.method
def print_payload_configuration(self):
print '\nPayload:'
print ' Title:', self.title
print ' Description:', self.description
print ' Type:', self.type