watobo 0.9.8.724 → 0.9.9.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGELOG +17 -0
  2. data/bin/watobo +1 -1
  3. data/lib/watobo/adapters/file/file_store.rb +93 -52
  4. data/lib/watobo/config.rb +90 -12
  5. data/lib/watobo/core/active_check.rb +8 -4
  6. data/lib/watobo/core/http_socket.rb +5 -5
  7. data/lib/watobo/core/interceptor.rb +9 -5
  8. data/lib/watobo/core/project.rb +16 -1
  9. data/lib/watobo/defaults.rb +2 -1
  10. data/lib/watobo/externals.rb +1 -1
  11. data/lib/watobo/framework/create_project.rb +10 -2
  12. data/lib/watobo/gui/certificate_dialog.rb +1 -1
  13. data/lib/watobo/gui/chat_diff.rb +19 -2
  14. data/lib/watobo/gui/client_cert_dialog.rb +1 -1
  15. data/lib/watobo/gui/conversation_table.rb +57 -37
  16. data/lib/watobo/gui/conversation_table_ctrl.rb +48 -26
  17. data/lib/watobo/gui/finding_info.rb +1 -0
  18. data/lib/watobo/gui/findings_tree.rb +91 -11
  19. data/lib/watobo/gui/list_box.rb +122 -0
  20. data/lib/watobo/gui/log_viewer.rb +36 -28
  21. data/lib/watobo/gui/main_window.rb +119 -91
  22. data/lib/watobo/gui/manual_request_editor.rb +7 -3
  23. data/lib/watobo/gui/page_tree.rb +231 -0
  24. data/lib/watobo/gui/plugin/base.rb +1 -1
  25. data/lib/watobo/gui/preferences_dialog.rb +1 -1
  26. data/lib/watobo/gui/quick_scan_dialog.rb +1 -3
  27. data/lib/watobo/gui/sites_tree.rb +6 -4
  28. data/lib/watobo/gui/templates/plugin2.rb +40 -14
  29. data/lib/watobo/gui/utils/load_icons.rb +1 -0
  30. data/lib/watobo/gui/utils/load_plugins.rb +59 -36
  31. data/lib/watobo/gui/utils/save_default_settings.rb +34 -5
  32. data/lib/watobo/gui/utils/save_proxy_settings.rb +10 -8
  33. data/lib/watobo/gui/utils/save_scanner_settings.rb +37 -0
  34. data/lib/watobo/gui.rb +1 -1
  35. data/lib/watobo/utils/file_management.rb +4 -9
  36. data/lib/watobo/utils/load_chat.rb +2 -2
  37. data/lib/watobo/utils/strings.rb +32 -0
  38. data/lib/watobo.rb +4 -1
  39. data/modules/active/fileinclusion/lfi_simple.rb +2 -2
  40. data/modules/active/sqlinjection/sql_boolean.rb +2 -2
  41. data/modules/active/sqlinjection/{sqli_simple.rb → sqli_error.rb} +7 -7
  42. data/modules/active/sqlinjection/sqli_timing.rb +241 -0
  43. data/modules/active/xss/xss_rated.rb +204 -0
  44. data/modules/active/xss/xss_simple.rb +2 -2
  45. data/modules/passive/in_script_parameter.rb +1 -1
  46. data/plugins/crawler/crawler.rb +79 -0
  47. data/plugins/crawler/gui/auth_frame.rb +270 -0
  48. data/plugins/crawler/gui/crawler_gui.rb +252 -0
  49. data/plugins/crawler/gui/general_settings_frame.rb +118 -0
  50. data/plugins/crawler/gui/hooks_frame.rb +97 -0
  51. data/plugins/crawler/gui/scope_frame.rb +72 -0
  52. data/plugins/crawler/gui/settings_tabbook.rb +56 -0
  53. data/plugins/crawler/gui/status_frame.rb +81 -0
  54. data/plugins/crawler/gui.rb +114 -0
  55. data/plugins/crawler/icons/crawler.ico +0 -0
  56. data/plugins/crawler/lib/bags.rb +40 -0
  57. data/{lib/watobo/gui/utils/save_session_settings.rb → plugins/crawler/lib/constants.rb} +9 -5
  58. data/plugins/crawler/lib/engine.rb +486 -0
  59. data/plugins/crawler/lib/grabber.rb +85 -0
  60. data/plugins/crawler/lib/uri_mp.rb +33 -0
  61. data/plugins/sslchecker/gui/gui.rb +2 -2
  62. metadata +51 -11
@@ -0,0 +1,79 @@
1
+ # .
2
+ # crawler.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ begin
23
+ require 'mechanize'
24
+ rescue LoadError
25
+ puts "To use the crawler plugin you must install the 'mechanize' gem."
26
+ puts "Simply enter the command 'gem install mechanize'"
27
+ end
28
+
29
+
30
+
31
+
32
+ path = File.expand_path(File.dirname(__FILE__))
33
+
34
+ %w( constants bags grabber engine uri_mp).each do |l|
35
+ require File.join(path, "lib", l)
36
+ end
37
+
38
+ if $0 == __FILE__
39
+ module Watobo
40
+ module Conf
41
+ class Interceptor
42
+ def self.port
43
+ # 8081
44
+ nil
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ require 'yaml'
51
+ if ARGV.length > 0
52
+ url = ARGV[0]
53
+ end
54
+
55
+ hook = lambda{ |agent, request|
56
+ begin
57
+ puts request.class
58
+ puts request.method
59
+ puts request.methods.sort
60
+
61
+ exit
62
+ clean_jar = Mechanize::CookieJar.new
63
+ agent.cookie_jar.each{|cookie|
64
+ puts "Cookie: #{cookie.name}"
65
+ clean_jar.add! cookie unless cookie.name =~ /^box/i
66
+ }
67
+ exit unless agent.cookie_jar.empty?(request.url)
68
+ agent.cookie_jar = clean_jar
69
+ rescue => bang
70
+ puts bang
71
+ puts bang.backtrace
72
+ end
73
+
74
+ }
75
+ hook = nil
76
+
77
+ crawler = Watobo::Crawler::Engine.new
78
+ crawler.run(url, :pre_connect_hook => hook, :num_grabbers => 1 )
79
+ end
@@ -0,0 +1,270 @@
1
+ # .
2
+ # auth_frame.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Plugin
24
+ module Crawler
25
+ class Gui
26
+ class FormFieldsTable < FXTable
27
+ def subscribe(event, &callback)
28
+ (@event_dispatcher_listeners[event] ||= []) << callback
29
+ end
30
+
31
+ def clearEvents(event)
32
+ @event_dispatcher_listener[event].clear
33
+ end
34
+
35
+ def update_fields
36
+ self.getNumRows.times do |i|
37
+ self.getItemData(i,0).value = self.getItemText(i,1)
38
+ end
39
+ end
40
+
41
+ def clear_fields
42
+ initTable
43
+ end
44
+
45
+ def initialize(owner, opts={})
46
+ super(owner, opts)
47
+
48
+ @event_dispatcher_listeners = Hash.new
49
+ initTable()
50
+
51
+ self.connect(SEL_COMMAND, method(:onTableClick))
52
+
53
+ self.columnHeader.connect(SEL_COMMAND) do |sender, sel, index|
54
+ # self.fitColumnsToContents(index)
55
+ end
56
+ end
57
+
58
+ def add_field(field)
59
+ lastRowIndex = self.getNumRows
60
+ self.appendRows(1)
61
+ self.setItemData(lastRowIndex, 0, field)
62
+ self.setItemText(lastRowIndex, 0, field.name)
63
+ self.getItem(lastRowIndex, 0).justify = FXTableItem::LEFT
64
+ self.setItemText(lastRowIndex, 1, field.value)
65
+ self.getItem(lastRowIndex, 1).justify = FXTableItem::LEFT
66
+
67
+ end
68
+ private
69
+
70
+ def onTableClick(sender, sel, item)
71
+ begin
72
+ row = item.row
73
+ self.selectRow(row, false)
74
+ self.startInput(row,1)
75
+ rescue => bang
76
+ puts bang
77
+ end
78
+ end
79
+
80
+ def notify(event, *args)
81
+ if @event_dispatcher_listeners[event]
82
+ @event_dispatcher_listeners[event].each do |m|
83
+ m.call(*args) if m.respond_to? :call
84
+ end
85
+ end
86
+ end
87
+
88
+ def initTable
89
+ self.clearItems()
90
+ self.setTableSize(0, 2)
91
+
92
+ self.setColumnText( 0, "Field" )
93
+ self.setColumnText( 1, "Value" )
94
+
95
+ self.rowHeader.width = 0
96
+ self.setColumnWidth(0, 100)
97
+ self.setColumnWidth(1, 100)
98
+ end
99
+ end
100
+
101
+ class AuthFrame < FXVerticalFrame
102
+ attr_accessor :crawler
103
+ def subscribe(event, &callback)
104
+ (@event_dispatcher_listeners[event] ||= []) << callback
105
+ end
106
+
107
+ def clearEvents(event)
108
+ @event_dispatcher_listener[event].clear
109
+ end
110
+
111
+ def to_h
112
+ a = case @auth_type_dt.value
113
+ when 0
114
+ {
115
+ :auth_type => :none
116
+ }
117
+ when 1
118
+ {
119
+ :auth_type => :basic,
120
+ :username => @basic_auth_user_txt.text,
121
+ :password => @basic_auth_passwd_txt.text
122
+ # :uri => URI.parse
123
+ }
124
+ when 2
125
+ @form_fields_table.update_fields
126
+
127
+ {
128
+ :auth_type => :form,
129
+ :form => @auth_form,
130
+ :cookie_jar => @agent.respond_to?(:cookie_jar) ? @agent.cookie_jar : nil
131
+ }
132
+ end
133
+ a
134
+
135
+ end
136
+
137
+ def set(settings)
138
+ @form_auth_url_txt.text = settings[:form_auth_url].to_s if settings.has_key? :form_auth_url
139
+ update_form
140
+ end
141
+
142
+ def update_form
143
+ [ @form_auth_url_txt ].each do |e|
144
+ e.handle(self, FXSEL(SEL_UPDATE, 0), nil)
145
+ end
146
+ end
147
+
148
+ def initialize(owner, opts={})
149
+ super(owner, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_THICK|FRAME_RAISED, :padding => 0)
150
+ frame = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
151
+ #left_frm = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_Y|FRAME_NONE)
152
+ @event_dispatcher_listeners = Hash.new
153
+ @crawler = opts[:crawler] if opts.has_key? :crawler
154
+ @start_url = ""
155
+
156
+ auth_gb= FXGroupBox.new(frame, "Authentication", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
157
+ auth_frm = FXVerticalFrame.new(auth_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE)
158
+ @auth_form = nil
159
+ @auth_type_dt = FXDataTarget.new(0)
160
+
161
+ @no_auth_rb = FXRadioButton.new(auth_frm, "None", @auth_type_dt, FXDataTarget::ID_OPTION)
162
+
163
+ @basic_auth_rb = FXRadioButton.new(auth_frm, "Basic", @auth_type_dt, FXDataTarget::ID_OPTION + 1)
164
+
165
+ @form_auth_rb = FXRadioButton.new(auth_frm, "Form", @auth_type_dt, FXDataTarget::ID_OPTION + 2)
166
+
167
+ # group_box = FXGroupBox.new(self, "Collection",LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
168
+ # frame = FXVerticalFrame.new(group_box, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_GROOVE)
169
+ # @collectionList = FXList.new(frame, :opts => LIST_EXTENDEDSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
170
+
171
+ @switcher = FXSwitcher.new(auth_frm,LAYOUT_FILL_X|LAYOUT_FILL_Y)
172
+ frame = FXHorizontalFrame.new(@switcher, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE)
173
+ FXLabel.new(frame, "No Authentication Selected", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
174
+ frame = FXHorizontalFrame.new(@switcher, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE)
175
+ FXLabel.new(frame, "Username:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
176
+ @basic_auth_user_txt = FXTextField.new(frame, 10, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
177
+ FXLabel.new(frame, "Password:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
178
+ @basic_auth_passwd_txt = FXTextField.new(frame, 10, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
179
+ FXLabel.new(frame, "Retype:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
180
+ @basic_auth_retype_txt = FXTextField.new(frame, 10, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
181
+
182
+ form_auth_frame = FXVerticalFrame.new(@switcher, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE)
183
+ frame = FXHorizontalFrame.new(form_auth_frame, :opts => LAYOUT_FILL_X|FRAME_NONE)
184
+ FXLabel.new(frame, "URL of LoginForm, leave empty to use Start URL:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
185
+ @form_auth_url_txt = FXTextField.new(frame, 10, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_X)
186
+ @fetch_button = FXButton.new(frame, "load page", :opts => BUTTON_DEFAULT|BUTTON_NORMAL )
187
+
188
+ form_frame = FXHorizontalFrame.new(form_auth_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE)
189
+ frame = FXHorizontalFrame.new(form_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
190
+ @page_tree = Watobo::Gui::PageTree.new(frame)
191
+ frame = FXHorizontalFrame.new(form_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_THICK)
192
+ @form_fields_table = FormFieldsTable.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
193
+
194
+ @auth_type_dt.connect(SEL_COMMAND) {
195
+ @basic_auth_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil)
196
+ @form_auth_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil)
197
+ @no_auth_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil)
198
+ @switcher.current = @auth_type_dt.value
199
+ }
200
+
201
+ @fetch_button.connect(SEL_COMMAND){
202
+ begin
203
+ @form_fields_table.clear_fields
204
+ @page_tree.clearItems
205
+
206
+ page = nil
207
+ url = nil
208
+ unless Watobo::Plugin::Crawler.start_url.nil?
209
+ uri = Watobo::Plugin::Crawler.start_url
210
+ else
211
+ url = @form_auth_url_txt.text unless @form_auth_url_txt.text.empty?
212
+ uri = URI.parse(url)
213
+ end
214
+
215
+ notify(:log, "GET PAGE << #{url}")
216
+ @agent, page = @crawler.get_page(uri)
217
+ notify(:log, "PAGE LOADED")
218
+ @page_tree.page = page
219
+ rescue => bang
220
+ notify(:log, "could not get page #{url}")
221
+ puts "Could not get page for #{url}"
222
+ puts url.class
223
+ puts bang
224
+ puts bang.backtrace
225
+ end
226
+ true
227
+ }
228
+ @switcher.current = @auth_type_dt.value
229
+
230
+ @page_tree.subscribe(:form_selected){|form|
231
+ @auth_form = form
232
+ @form_fields_table.clear_fields
233
+ form.fields.each do |field|
234
+ @form_fields_table.add_field field
235
+ end
236
+ }
237
+
238
+ end
239
+
240
+ private
241
+
242
+ def notify(event, *args)
243
+ if @event_dispatcher_listeners[event]
244
+ @event_dispatcher_listeners[event].each do |m|
245
+ m.call(*args) if m.respond_to? :call
246
+ end
247
+ end
248
+ end
249
+
250
+ def enable_basic_auth
251
+
252
+ end
253
+
254
+ def disable_basic_auth
255
+
256
+ end
257
+
258
+ def enable_form_auth
259
+
260
+ end
261
+
262
+ def disable_form_auth
263
+
264
+ end
265
+
266
+ end
267
+ end
268
+ end
269
+ end
270
+ end
@@ -0,0 +1,252 @@
1
+ # .
2
+ # crawler_gui.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Plugin
24
+ module Crawler
25
+ def self.start_url
26
+ @start_url
27
+ end
28
+
29
+ def self.start_url=(url)
30
+ @start_url ||= ""
31
+ host = nil
32
+ begin
33
+ host = URI.parse(url).host
34
+ rescue => bang
35
+ host = nil
36
+ end
37
+ @start_url = url unless host.nil?
38
+ @start_url
39
+ end
40
+
41
+ class Gui < Watobo::Plugin2
42
+ icon_file "crawler.ico"
43
+
44
+ include Watobo::Constants
45
+ include Watobo::Plugin::Crawler::Constants
46
+ def updateView
47
+
48
+ end
49
+
50
+ def start_url
51
+ url = url_valid? ? URI.parse(@url_txt.text) : nil
52
+ return url
53
+ end
54
+
55
+ def settings
56
+ @settings_tabbook
57
+ end
58
+
59
+ def set_tab_index(index)
60
+ @settings_tabbook.setCurrent index
61
+ end
62
+
63
+ def initialize(owner, project=nil)
64
+ super(owner, "Crawler", project, :opts => DECOR_ALL, :width=>800, :height=>600)
65
+ @plugin_name = "Crawler"
66
+ @project = project
67
+ @status_lock = Mutex.new
68
+ @crawl_status = {
69
+ :engine_status => CRAWL_NONE,
70
+ :page_size => 0,
71
+ :link_size => 0,
72
+ :skipped_domains => 0
73
+ }
74
+
75
+ main = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
76
+ FXLabel.new(main, "Start URL, e.g. http://my.target.to/scan/:")
77
+ frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
78
+ # FXLabel.new(frame, "http://")
79
+ @url_txt = FXTextField.new(frame, 60, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT|LAYOUT_FILL_X)
80
+
81
+ @start_button = FXButton.new(frame, "start", :opts => BUTTON_DEFAULT|BUTTON_NORMAL )
82
+ @start_button.disable
83
+
84
+ @url_txt.connect(SEL_COMMAND){ |sender, sel, item|
85
+ @start_button.setFocus() if url_valid?
86
+ }
87
+
88
+ @url_txt.connect(SEL_CHANGED){
89
+ if url_valid?
90
+ Watobo::Plugin::Crawler.start_url = start_url
91
+ @start_button.enable
92
+ else
93
+ @start_button.disable
94
+ Watobo::Plugin::Crawler.start_url = nil
95
+ end
96
+ }
97
+
98
+ @start_button.connect(SEL_COMMAND){ |sender, sel, item|
99
+ case sender.text
100
+ when /start/i
101
+ start
102
+ when /cancel/i
103
+ cancel
104
+ end
105
+ }
106
+
107
+ @crawler = Watobo::Crawler::Engine.new
108
+
109
+ @settings_tabbook = SettingsTabBook.new(main)
110
+ @settings_tabbook.general.set @crawler.settings
111
+ @settings_tabbook.auth.crawler = @crawler
112
+ @settings_tabbook.scope.set @crawler.settings
113
+
114
+ @log_viewer = @settings_tabbook.log_viewer
115
+
116
+ @status_frame = StatusFrame.new(main)
117
+
118
+ @crawler.subscribe( :update_status ){ |status|
119
+ @status_lock.synchronize do
120
+ @crawl_status.update status
121
+ end
122
+ }
123
+
124
+ stbk = @settings_tabbook
125
+ [ @crawler, stbk.auth].each do |i|
126
+ i.subscribe( :log ){ |msg|
127
+ @log_viewer.log(LOG_INFO, msg)
128
+ }
129
+ end
130
+
131
+ end
132
+
133
+ private
134
+
135
+ def remove_update_timer
136
+ app = FXApp.instance
137
+ if app.hasTimeout? @update_timer
138
+ app.removeTimeout @update_timer
139
+ end
140
+ end
141
+
142
+ def add_update_timer(ms=50)
143
+ @update_timer = FXApp.instance.addTimeout( ms, :repeat => true) {
144
+ update_status
145
+ }
146
+
147
+ end
148
+
149
+ def update_status
150
+ @status_lock.synchronize do
151
+
152
+ @status_frame.update_status @crawl_status
153
+
154
+ if @crawl_status.has_key? :engine_status
155
+ case @crawl_status[:engine_status]
156
+ when CRAWL_NONE
157
+ @start_button.text = "start"
158
+ when CRAWL_RUNNING
159
+ @start_button.text = "cancel"
160
+
161
+ when CRAWL_PAUSED
162
+ @start_button.text = "start"
163
+ end
164
+ end
165
+
166
+ end
167
+ end
168
+
169
+ def cancel
170
+ remove_update_timer()
171
+ @crawler.cancel
172
+ @start_button.text = "start"
173
+ update_status
174
+ end
175
+
176
+ def auth_settings()
177
+ puts "= Authentication Settings ="
178
+ auth = @settings_tabbook.auth.to_h
179
+ # puts auth.to_yaml
180
+ case auth[:auth_type]
181
+ when :form
182
+ if auth.has_key? :form
183
+ #puts ""
184
+ #@crawler.send_form(form)
185
+ if auth[:form].respond_to? :submit
186
+ puts "Submitting Form"
187
+ p = auth[:form].submit()
188
+ puts p.class
189
+ end
190
+ end
191
+ end
192
+ puts "---"
193
+ auth
194
+ end
195
+
196
+ def scope_settings()
197
+ # puts "= Scope Settings ="
198
+ scope = @settings_tabbook.scope
199
+ ss = scope.to_h
200
+ ss[:root_path] = start_url.path_mp if scope.path_restricted?
201
+ ss
202
+ end
203
+
204
+ def general_settings()
205
+ # puts "= General Settings ="
206
+
207
+ gs = @settings_tabbook.general.to_h
208
+
209
+ end
210
+
211
+ def hook_settings
212
+ hs = @settings_tabbook.hooks.to_h
213
+ end
214
+
215
+ def url_valid?
216
+ begin
217
+ return false unless @url_txt.text =~ /^https?:\/\//
218
+ url = URI.parse(@url_txt.text)
219
+ # puts url.host.class
220
+ return true unless url.host.nil?
221
+ return false
222
+ rescue => bang
223
+ puts bang if $DEBUG
224
+ return false
225
+ end
226
+ end
227
+
228
+ def start
229
+ return false unless url_valid?
230
+
231
+ prefs ={}
232
+ prefs.update auth_settings
233
+ prefs.update scope_settings
234
+ prefs.update general_settings
235
+ prefs.update hook_settings
236
+
237
+ # puts prefs.to_yaml
238
+
239
+ Thread.new{
240
+ url = @url_txt.text
241
+ @crawler.run(url, prefs)
242
+ }
243
+
244
+ @start_button.text = 'Cancel'
245
+ add_update_timer()
246
+ end
247
+
248
+ end
249
+
250
+ end
251
+ end
252
+ end