forked from forced-request/wXf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwXfgui
executable file
·355 lines (281 loc) · 8.14 KB
/
wXfgui
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/usr/bin/env ruby
case RUBY_PLATFORM
when 'java'
else
print("\e[1;31m[wXf error]\e[0m Please start this application using JRuby\n")
exit
end
wXfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
WXFDIR = File.join(File.expand_path(File.dirname(wXfbase)))
$:.unshift(File.join(File.expand_path(File.dirname(wXfbase)), 'jlib'))
#System level requirements
require 'java'
require 'rubygems'
# Gem requirements
begin
require 'jdbc/sqlite3'
require 'buby'
rescue LoadError => le
print("\e[1;31m[wXf error]\e[0m Please ensure you have the following gems installed:\n")
print("1) buby\n")
print("2) jdbc-sqlite3\n")
exit
end
#wXf gui elements
require 'wXfgui/base'
require 'wXfgui/analysis'
require 'wXfgui/buby'
require 'wXfgui/console'
require 'wXfgui/sca'
require 'wXfgui/database'
require 'wXfgui/decision_tree'
require 'wXfgui/main'
require 'wXfgui/modules_factory'
require 'wXfgui/workspace'
require 'wXfgui/xmlrpc'
# Time to require native wXf stuff
require 'wXf/wXfassists'
require 'wXf/wXfconductors'
require 'wXf/wXfdb'
require 'wXf/wXfconstants'
require 'wXf/wXflog'
require 'wXf/wXfmod_factory'
require 'wXf/wXfui'
require 'wXf/wXfwebserver'
# Necessary libs, well, most of them......
import java.util.LinkedList
import java.util.Properties
import javax.swing.JTree
import javax.swing.tree.DefaultMutableTreeNode
import javax.swing.tree.TreeModel
import java.awt.Dimension
import java.awt.Color
import java.awt.Font
import javax.swing.BorderFactory
import javax.swing.SwingConstants
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.JTextArea
import javax.swing.JComponent
import javax.swing.JList
import javax.swing.JPanel
import javax.swing.JMenuBar
import javax.swing.JScrollPane
import javax.swing.JTabbedPane
import javax.swing.GroupLayout
import java.awt.event.MouseListener
import java.awt.event.FocusListener
import java.awt.event.MouseEvent
import java.awt.event.WindowEvent
module WxfGui
class WxfGuiTabbedPane < JTabbedPane
attr_accessor :wXf_main_panel, :wXf_analysis_panel, :wXf_buby_panel, :wXf_console_pane, :wXf_sca_panel
def initialize(wXfgui)
@wXfgui = wXfgui
super(JTabbedPane::TOP, JTabbedPane::SCROLL_TAB_LAYOUT)
self.wXf_main_panel = WxfMainPanel.new
self.wXf_analysis_panel = WxfAnalysisPanel.new(@wXfgui)
self.wXf_buby_panel = WxfBubyPanel.new
self.wXf_console_pane = WxfConsolePanel.new
self.wXf_sca_panel = WxfScaPanel.new
add("Main", wXf_main_panel)
add("Analysis", wXf_analysis_panel)
add("Buby", wXf_buby_panel)
add("SCA", wXf_sca_panel)
add("Console", wXf_console_pane)
listener
end
def add(*vals)
name, obj = vals
self.add_tab(name, obj)
end
def listener(*params)
self.add_change_listener do |event|
#=begin
#THIS IS ALL STUBBED CODE, USING IT AS AN EXAMPLE.
end
#=end
end
def restore
self.wXf_main_panel.restore
self.wXf_sca_panel.restore
end
def send_log_text(*params)
self.wXf_main_panel.send_log_text(*params)
end
end
class WxfMainPanel < JPanel
include MouseListener
attr_accessor :decision_panel
def initialize
super()
init
end
def init
@main_tabs = MainTabs.new
#
# SCROLL PANE
#
treeModel = ModulesTree.new(ModulesLoader.new)
tree_1 = JTree.new(treeModel)
tree_1.shows_root_handles = true
tree_1.addMouseListener(ModulesPopUpClickListener.new(tree_1, self))
t_scroll_pane_1 = JScrollPane.new(tree_1)
self.decision_panel = DecisionPanel.new
#
# SPLIT PANES
#
split_pane1 = JSplitPane.new JSplitPane::VERTICAL_SPLIT
split_pane1.setDividerLocation 390
split_pane1.add self.decision_panel
split_pane1.add @main_tabs
split_pane2 = JSplitPane.new JSplitPane::HORIZONTAL_SPLIT
split_pane2.setDividerLocation 300
split_pane2.add t_scroll_pane_1
split_pane2.add split_pane1
#
# GROUP LAYOUT OPTIONS
#
layout = GroupLayout.new self
# Add Group Layout to the frame
self.setLayout layout
# Create sensible gaps in components (like buttons)
layout.setAutoCreateGaps true
layout.setAutoCreateContainerGaps true
sh1 = layout.createSequentialGroup
sv1 = layout.createSequentialGroup
p1 = layout.createParallelGroup
p2 = layout.createParallelGroup
layout.setHorizontalGroup sh1
layout.setVerticalGroup sv1
sh1.addComponent split_pane2
sh1.addGroup p1
p2.addComponent split_pane2
sv1.addGroup p2
end
def restore
@main_tabs.restore
end
def selected_list
return decision_panel.selected_list
end
def gray_out
decision_panel.gray_out
end
def undo_gray_out
decision_panel.undo_gray_out
end
def send_log_text(*params)
@main_tabs.send_log_text(*params)
end
end
#
# MAIN FRAME
#
class Wxfgui < JFrame
attr_accessor :wXf_gui_tabbed_pane, :base
def initialize(base)
self.base = base
super "The Web Exploitation Framework"
init_classes
check_workspace
end
def init_classes
self.wXf_gui_tabbed_pane = WxfGuiTabbedPane.new(self)
end
def initUI
self.base.initialized = true
self.add self.wXf_gui_tabbed_pane
#
# Menu Bar Items
#
@jmenubar = JMenuBar.new
@wxfmenu = WxfMenu.new(self)
@xmlrpc_menu = XmlRpcMenu.new(self)
@bubymenu = BubyMenu.new
@aboutmenu = AboutMenu.new
menuBar = @jmenubar
menuBar.add @wxfmenu
menuBar.add @xmlrpc_menu
menuBar.add @bubymenu
menuBar.add @aboutmenu
#
# FRAME OPTIONS
#
self.addWindowListener do |e|
if e.kind_of?(WindowEvent)
ps = e.paramString.split(',')[0] == "WINDOW_CLOSING" ? true : false
if (ps)
close_it
end
end
end
# Set the overall side of the frame
self.setJMenuBar menuBar
self.setPreferredSize Dimension.new(1300, 900)
self.pack
self.setDefaultCloseOperation JFrame::DO_NOTHING_ON_CLOSE
self.setLocationRelativeTo nil
self.setVisible true
end
def restore
self.wXf_gui_tabbed_pane.restore
end
def send_log_text(*params)
self.wXf_gui_tabbed_pane.send_log_text(*params)
end
def check_workspace
pwd = Dir.pwd
db_exists = false
Dir.foreach(WXf::WXF_HOME_DIR) do |f|
if File.extname(f) == ".db"
db_exists = true
next
end
end
if db_exists == true
WorkspaceChooser.new(self)
else
WorkspaceCreator.new(self)
end
end
def close_it
jo = JOptionPane.showConfirmDialog(nil,
"Are you sure that you'd like to exit wXf?",
"Confirmation",
javax.swing.JOptionPane::YES_NO_OPTION,
javax.swing.JOptionPane::QUESTION_MESSAGE)
if jo == JOptionPane::YES_OPTION
java.lang.System.exit 0
end
end
def stop_dt
base.remove_all_selected_dt
wXf_gui_tabbed_pane.wXf_analysis_panel.unload_dt_tree
# Undo gray out selected items
wXf_gui_tabbed_pane.wXf_main_panel.undo_gray_out
# Undo gray out start decision tree
@wxfmenu.enable("start decision tree")
@wxfmenu.disable("stop decision tree")
self.repaint()
end
def start_dt
# Gotta find a better abstraction, in the meantime...
dt_sel = wXf_gui_tabbed_pane.wXf_main_panel.selected_list
if not dt_sel.empty?
base.add_all_selected_dt(dt_sel)
# Add something to the top of the activity stack
mod = base.hash_value_at(0, dt_sel)
base.add_decision_tree_activity(mod)
# Gray out selected items
wXf_gui_tabbed_pane.wXf_analysis_panel.load_dt_tree
wXf_gui_tabbed_pane.wXf_main_panel.gray_out
# Gray out start decision tree
@wxfmenu.disable("start decision tree")
@wxfmenu.enable("stop decision tree")
self.repaint()
end
end
end
end
WxfGui::Base.new