forked from entropy1337/infernal-twin
/
InfernalWireless.py
203 lines (154 loc) · 7.41 KB
/
InfernalWireless.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
#~ import infernal_wireless_gui_project
import MySQLdb
import db_connect_creds
import os
import os.path
import sys
import wx
from datetime import datetime
os.system('/etc/init.d/apache2 start')
os.system('/etc/init.d/mysql start')
if not os.path.exists('dbconnect.conf'):
print "DB Config 'dbconnect.conf' file doesn't seem to exist."
print "Run db_setup.py."
sys.exit(1)
username, password = db_connect_creds.read_creds()
cxn = MySQLdb.connect('localhost', username, password)
date = datetime.now()
cxn.query('CREATE DATABASE IF NOT EXISTS InfernalWireless')
cxn.commit()
cxn.close()
#~ cxn = MySQLdb.connect(db='InfernalWireless')
cxn = MySQLdb.connect('localhost', username, password, db='InfernalWireless')
cur = cxn.cursor()
current_project_id = 0
#~ os.system("airmon-ng start wlan0")
def create_project_table():
##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
PROJECT_TITLE = '''CREATE TABLE IF NOT EXISTS Projects (ProjectId MEDIUMINT NOT NULL AUTO_INCREMENT, ProjectName TEXT, PRIMARY KEY (ProjectId), AuditorName TEXT, TargetName TEXT, date TEXT)'''
cur.execute(PROJECT_TITLE)
#~ print 'Project table is created'
#~ def create_report_table(self):
#~
#~ ##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
#~
#~
#~ report_table = '''CREATE TABLE IF NOT EXISTS Reports (findingID MEDIUMINT NOT NULL AUTO_INCREMENT, finding_name TEXT, phase TEXT, PRIMARY KEY (findingID), risk_level TEXT, risk_category TEXT, Findings_detail TEXT, Notes TEXT, Project_fk_Id MEDIUMINT, FOREIGN KEY (Project_fk_Id) REFERENCES Projects (ProjectId))'''
#~ cur.execute(report_table)
#~ print 'Report table is created'
#~
def create_report_table():
##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
report_table = '''CREATE TABLE IF NOT EXISTS Reports (findingID MEDIUMINT NOT NULL AUTO_INCREMENT, finding_name TEXT, phase TEXT, PRIMARY KEY (findingID), risk_level TEXT, risk_category TEXT, Findings_detail TEXT, Notes TEXT, Project_fk_Id MEDIUMINT, FOREIGN KEY (Project_fk_Id) REFERENCES Projects (ProjectId))'''
cur.execute(report_table)
create_project_table()
create_report_table()
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title,
size=(600, 450))
#~ self.create_project_table()
#~ self.create_report_table()
self.InitUI()
self.Centre()
self.Show()
global MultiLine
isProject = False
global projectName
#~ self.projectIDNumber = 0
def InitUI(self):
panel = wx.Panel(self)
self.quote = wx.StaticText(panel,-1, label="PROJECT DETAILS \n", pos=(10, 30))
self.quote.SetForegroundColour((255,0,0)) # set text color
start_image = wx.Image("img/logo2.png")
start_image.Rescale(450, 450)
image = wx.BitmapFromImage(start_image)
pic=wx.StaticBitmap(panel, -1, image, pos=(150, 0), style=wx.BITMAP_TYPE_PNG)
#~ prjBtn = wx.Button(panel, -1, "Create a Project",size=(150,30), pos=(10,650))
#~ prjBtn.Bind(wx.EVT_BUTTON, self.create_project)
#~ start_image = wx.Image("img/logo2.png")
#~ start_image.Rescale(180, 140)
#~ image = wx.BitmapFromImage(start_image)
#~ pic=wx.StaticBitmap(pnl, -1, image, pos=(250, 50), style=wx.BITMAP_TYPE_PNG)
panel.SetBackgroundColour('#4f5049')
#vbox = wx.BoxSizer(wx.VERTICAL)
self.projectname = wx.TextCtrl(panel, -1, "Project Name",size=(250,30), pos=(10,120))
#self.projectname.SetBackgroundColour('#ededed')
self.author = wx.TextCtrl(panel, -1, "Author's Full Name'",size=(250,30), pos=(10,160))
#self.author.SetBackgroundColour('#ededed')
self.targetname = wx.TextCtrl(panel, -1, "Target Name",size=(250,30), pos=(10,200))
#self.targetname.SetBackgroundColour('#ededed')
self.datename = wx.TextCtrl(panel, -1, "dd/mm/yy",size=(250,30), pos=(10,240))
#self.targetname.SetBackgroundColour('#ededed')
prjBtn = wx.Button(panel, -1, "Create a Project",size=(150,30), pos=(10,300))
prjBtn.Bind(wx.EVT_BUTTON, self.create_project)
prjBtn2 = wx.Button(panel, -1, "Stand alone",size=(150,30), pos=(10,350))
prjBtn2.Bind(wx.EVT_BUTTON, self.create_std)
#~ vbox.Add(self.MultiLine, -1,10)
#~ vbox.Add(prjBtn,-1, border=10)
#~ panel.SetSizer(vbox)
def create_project_table(self):
##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
PROJECT_TITLE = '''CREATE TABLE IF NOT EXISTS Projects (ProjectId MEDIUMINT NOT NULL AUTO_INCREMENT, ProjectName TEXT, PRIMARY KEY (ProjectId), AuditorName TEXT, TargetName TEXT, date TEXT)'''
cur.execute(PROJECT_TITLE)
#~ print 'Project table is created'
#~ def create_report_table(self):
#~
#~ ##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
#~
#~
#~ report_table = '''CREATE TABLE IF NOT EXISTS Reports (findingID MEDIUMINT NOT NULL AUTO_INCREMENT, finding_name TEXT, phase TEXT, PRIMARY KEY (findingID), risk_level TEXT, risk_category TEXT, Findings_detail TEXT, Notes TEXT, Project_fk_Id MEDIUMINT, FOREIGN KEY (Project_fk_Id) REFERENCES Projects (ProjectId))'''
#~ cur.execute(report_table)
#~ print 'Report table is created'
#~
def create_report_table(self):
##############3333 THIS IS GOING TO CRAETE A TABLE FOR PROJECT
report_table = '''CREATE TABLE IF NOT EXISTS Reports (findingID MEDIUMINT NOT NULL AUTO_INCREMENT, finding_name TEXT, phase TEXT, PRIMARY KEY (findingID), risk_level TEXT, risk_category TEXT, Findings_detail TEXT, Notes TEXT, Project_fk_Id MEDIUMINT, FOREIGN KEY (Project_fk_Id) REFERENCES Projects (ProjectId))'''
cur.execute(report_table)
#~ print 'Report table is created'
def project_details(self, projectname, Authors_name, TargetName, date):
PROJECT_DETAILS = 'INSERT INTO Projects (ProjectName, AuditorName, TargetName, date) VALUES ("%s","%s","%s","%s")'%(projectname, Authors_name, TargetName, date)
cur.execute(PROJECT_DETAILS)
current_project_id_tmp = cur.lastrowid
current_project_id = current_project_id_tmp
#~ cur.close()
#~ cxn.commit()
#~ cxn.close()
#~ print "report is generated"
def create_project(self, e):
isProject = True
#~ print isProject
self.projectName = self.projectname.GetValue()
#print self.projectName
dic_project = {"Project":str(self.projectName),"Authors Full Name":str(self.author.GetValue()),"Target name":str(self.targetname.GetValue()),"Date":str(self.datename.GetValue())}
os.system("mkdir %s"%str(self.projectName).replace(" ","_"))
dic_project['Filename']=str(self.projectName).replace(" ","_")
pFile = open(self.projectName.replace(" ","_")+"/Project Info.txt","wb")
pFile.write(str(dic_project))
pFile.close()
prID = self.project_details(str(self.projectName),str(self.author.GetValue()),str(self.targetname.GetValue()),str(self.datename.GetValue()))
cur.close()
cxn.commit()
cxn.close()
self.closeWindow(self)
infernal_wireless_gui_project.main()
def closeWindow(self, event):
self.Destroy()
def create_std(self, e):
isProject = False
#~ print isProject
#print self.projectName
self.closeWindow(self)
infernal_wireless_gui_project.main()
def returnproject(self):
return self.projectName
def create_new_project():
app = wx.App()
Example(None, title='Infernal Wireless - Create A project')
app.MainLoop()
if __name__ == '__main__':
import infernal_wireless_gui_project
create_new_project()
cur.close()
cxn.commit()
cxn.close()