watobo 0.9.8.677

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. data/bin/watobo_gui.rb +39 -0
  2. data/certificates/cert.pem +19 -0
  3. data/certificates/privkey.pem +15 -0
  4. data/certificates/watobo_dh.key +5 -0
  5. data/config/datastore.yml +5 -0
  6. data/config/forwarding_proxy.yml +12 -0
  7. data/config/general.yml +4 -0
  8. data/config/gui.yml +23 -0
  9. data/config/interceptor.yml +16 -0
  10. data/config/scan_policy.yml +13 -0
  11. data/config/scanner.yml +34 -0
  12. data/icons/Add.ico +0 -0
  13. data/icons/Add_24x24.ico +0 -0
  14. data/icons/Bandwidth.ico +0 -0
  15. data/icons/Bandwidth_24x24.ico +0 -0
  16. data/icons/Mr. Bomb.ico +0 -0
  17. data/icons/Mr. Bomb_16x16.ico +0 -0
  18. data/icons/Mr. Bomb_24x24.ico +0 -0
  19. data/icons/Orange Ball.ico +0 -0
  20. data/icons/Orange Ball_16x16.ico +0 -0
  21. data/icons/Orange Ball_24x24.ico +0 -0
  22. data/icons/Pause.ico +0 -0
  23. data/icons/Play.ico +0 -0
  24. data/icons/Play_24x24.ico +0 -0
  25. data/icons/Red Ball.ico +0 -0
  26. data/icons/Red Ball_16x16.ico +0 -0
  27. data/icons/Red Ball_24x24.ico +0 -0
  28. data/icons/Run.ico +0 -0
  29. data/icons/Stop.ico +0 -0
  30. data/icons/Stop_24x24.ico +0 -0
  31. data/icons/Terminal.ico +0 -0
  32. data/icons/Transfer.ico +0 -0
  33. data/icons/Transfer_16x16.ico +0 -0
  34. data/icons/User.ico +0 -0
  35. data/icons/User_16x16.ico +0 -0
  36. data/icons/User_24x24.ico +0 -0
  37. data/icons/Web Browser.ico +0 -0
  38. data/icons/Web Browser_16x16.ico +0 -0
  39. data/icons/Write Document.ico +0 -0
  40. data/icons/Yellow Ball.ico +0 -0
  41. data/icons/Yellow Ball_16x16.ico +0 -0
  42. data/icons/Yellow Ball_24x24.ico +0 -0
  43. data/icons/advanced.ico +0 -0
  44. data/icons/advanced_16x16.ico +0 -0
  45. data/icons/advanced_24x24.ico +0 -0
  46. data/icons/applications.ico +0 -0
  47. data/icons/applications_16x16.ico +0 -0
  48. data/icons/applications_24x24.ico +0 -0
  49. data/icons/browser_16x16.ico +0 -0
  50. data/icons/browser_24x24.ico +0 -0
  51. data/icons/burn.ico +0 -0
  52. data/icons/burn_16x16.ico +0 -0
  53. data/icons/burn_24x24.ico +0 -0
  54. data/icons/calculator.ico +0 -0
  55. data/icons/calculator_24x24.ico +0 -0
  56. data/icons/cb_checked.ico +0 -0
  57. data/icons/cb_checked_orange.ico +0 -0
  58. data/icons/cb_unchecked.ico +0 -0
  59. data/icons/coin_24x24.ico +0 -0
  60. data/icons/conversation.ico +0 -0
  61. data/icons/conversation_24x24.ico +0 -0
  62. data/icons/engine.ico +0 -0
  63. data/icons/filter.ico +0 -0
  64. data/icons/folder.ico +0 -0
  65. data/icons/folder_16x16.ico +0 -0
  66. data/icons/fuzzer_16x16.ico +0 -0
  67. data/icons/fuzzer_24x24.ico +0 -0
  68. data/icons/go-down_16x16.png +0 -0
  69. data/icons/go-up_16x16.png +0 -0
  70. data/icons/help.ico +0 -0
  71. data/icons/help_16x16.ico +0 -0
  72. data/icons/help_24x24.ico +0 -0
  73. data/icons/iChat.ico +0 -0
  74. data/icons/iChat_16x16.ico +0 -0
  75. data/icons/iChat_24x24.ico +0 -0
  76. data/icons/icons.txt +3 -0
  77. data/icons/info.ico +0 -0
  78. data/icons/info_16x16.ico +0 -0
  79. data/icons/info_24x24.ico +0 -0
  80. data/icons/interceptor_24x24.ico +0 -0
  81. data/icons/lock.ico +0 -0
  82. data/icons/lock_12x12.ico +0 -0
  83. data/icons/lock_16x16.ico +0 -0
  84. data/icons/monitor.ico +0 -0
  85. data/icons/plugin.ico +0 -0
  86. data/icons/plugin_24x24.ico +0 -0
  87. data/icons/scan_16x16.png +0 -0
  88. data/icons/send.ico +0 -0
  89. data/icons/server.ico +0 -0
  90. data/icons/server_16x16.ico +0 -0
  91. data/icons/siberas_logo_x24.gif +0 -0
  92. data/icons/tag_blue_32x32.ico +0 -0
  93. data/icons/watobo-48x48.png +0 -0
  94. data/icons/watobo-logo.png +0 -0
  95. data/icons/watobo.ico +0 -0
  96. data/lib/watobo/adapters/data_store.rb +38 -0
  97. data/lib/watobo/adapters/file/file_store.rb +211 -0
  98. data/lib/watobo/adapters/session_store.rb +27 -0
  99. data/lib/watobo/adapters.rb +26 -0
  100. data/lib/watobo/config.rb +143 -0
  101. data/lib/watobo/constants.rb +92 -0
  102. data/lib/watobo/core/active_check.rb +404 -0
  103. data/lib/watobo/core/cookie.rb +69 -0
  104. data/lib/watobo/core/fuzz_gen.rb +160 -0
  105. data/lib/watobo/core/http_socket.rb +142 -0
  106. data/lib/watobo/core/interceptor.rb +729 -0
  107. data/lib/watobo/core/passive_check.rb +141 -0
  108. data/lib/watobo/core/project.rb +1058 -0
  109. data/lib/watobo/core/scanner.rb +396 -0
  110. data/lib/watobo/core/session.rb +1320 -0
  111. data/lib/watobo/core/simple_ca.rb +393 -0
  112. data/lib/watobo/core.rb +34 -0
  113. data/lib/watobo/defaults.rb +40 -0
  114. data/lib/watobo/external/diff/lcs/array.rb +42 -0
  115. data/lib/watobo/external/diff/lcs/block.rb +72 -0
  116. data/lib/watobo/external/diff/lcs/callbacks.rb +343 -0
  117. data/lib/watobo/external/diff/lcs/change.rb +190 -0
  118. data/lib/watobo/external/diff/lcs/hunk.rb +279 -0
  119. data/lib/watobo/external/diff/lcs/ldiff.rb +247 -0
  120. data/lib/watobo/external/diff/lcs/string.rb +40 -0
  121. data/lib/watobo/external/diff/lcs.rb +1124 -0
  122. data/lib/watobo/external/ntlm/ntlm.rb +797 -0
  123. data/lib/watobo/externals.rb +28 -0
  124. data/lib/watobo/framework/create_project.rb +55 -0
  125. data/lib/watobo/framework/init.rb +149 -0
  126. data/lib/watobo/framework/init_modules.rb +116 -0
  127. data/lib/watobo/framework/license_text.rb +50 -0
  128. data/lib/watobo/framework.rb +26 -0
  129. data/lib/watobo/gui/about_watobo.rb +68 -0
  130. data/lib/watobo/gui/browser_preview.rb +460 -0
  131. data/lib/watobo/gui/certificate_dialog.rb +132 -0
  132. data/lib/watobo/gui/chat_diff.rb +415 -0
  133. data/lib/watobo/gui/chatviewer_frame.rb +427 -0
  134. data/lib/watobo/gui/checkboxtree.rb +221 -0
  135. data/lib/watobo/gui/checks_policy_frame.rb +123 -0
  136. data/lib/watobo/gui/client_cert_dialog.rb +227 -0
  137. data/lib/watobo/gui/confirm_scan_dialog.rb +67 -0
  138. data/lib/watobo/gui/conversation_table.rb +386 -0
  139. data/lib/watobo/gui/conversation_table_ctrl.rb +175 -0
  140. data/lib/watobo/gui/csrf_token_dialog.rb +446 -0
  141. data/lib/watobo/gui/dashboard.rb +341 -0
  142. data/lib/watobo/gui/define_scope_frame.rb +380 -0
  143. data/lib/watobo/gui/edit_comment.rb +70 -0
  144. data/lib/watobo/gui/edit_scope_dialog.rb +69 -0
  145. data/lib/watobo/gui/finding_info.rb +212 -0
  146. data/lib/watobo/gui/findings_tree.rb +459 -0
  147. data/lib/watobo/gui/full_scan_dialog.rb +269 -0
  148. data/lib/watobo/gui/fuzzer_gui.rb +1522 -0
  149. data/lib/watobo/gui/hex_viewer.rb +106 -0
  150. data/lib/watobo/gui/interceptor_gui.rb +994 -0
  151. data/lib/watobo/gui/interceptor_settings_dialog.rb +201 -0
  152. data/lib/watobo/gui/log_viewer.rb +97 -0
  153. data/lib/watobo/gui/login_wizzard.rb +301 -0
  154. data/lib/watobo/gui/main_window.rb +1815 -0
  155. data/lib/watobo/gui/manual_request_editor.rb +1105 -0
  156. data/lib/watobo/gui/master_pw_dialog.rb +142 -0
  157. data/lib/watobo/gui/password_policy_dialog.rb +98 -0
  158. data/lib/watobo/gui/plugin/base.rb +82 -0
  159. data/lib/watobo/gui/plugin_board.rb +95 -0
  160. data/lib/watobo/gui/preferences_dialog.rb +116 -0
  161. data/lib/watobo/gui/progress_window.rb +102 -0
  162. data/lib/watobo/gui/project_wizzard.rb +369 -0
  163. data/lib/watobo/gui/proxy_dialog.rb +550 -0
  164. data/lib/watobo/gui/quick_scan_dialog.rb +242 -0
  165. data/lib/watobo/gui/request_editor.rb +480 -0
  166. data/lib/watobo/gui/save_chat_dialog.rb +158 -0
  167. data/lib/watobo/gui/scanner_settings_dialog.rb +360 -0
  168. data/lib/watobo/gui/select_chat_dialog.rb +169 -0
  169. data/lib/watobo/gui/session_management_dialog.rb +688 -0
  170. data/lib/watobo/gui/sites_tree.rb +347 -0
  171. data/lib/watobo/gui/status_bar.rb +88 -0
  172. data/lib/watobo/gui/table_editor.rb +445 -0
  173. data/lib/watobo/gui/tagless_viewer.rb +62 -0
  174. data/lib/watobo/gui/templates/plugin.rb +80 -0
  175. data/lib/watobo/gui/templates/plugin2.rb +103 -0
  176. data/lib/watobo/gui/text_viewer.rb +247 -0
  177. data/lib/watobo/gui/transcoder_window.rb +215 -0
  178. data/lib/watobo/gui/utils/gui_utils.rb +129 -0
  179. data/lib/watobo/gui/utils/init_icons.rb +106 -0
  180. data/lib/watobo/gui/utils/load_icons.rb +54 -0
  181. data/lib/watobo/gui/utils/load_plugins.rb +94 -0
  182. data/lib/watobo/gui/utils/master_password.rb +90 -0
  183. data/lib/watobo/gui/utils/save_default_settings.rb +99 -0
  184. data/lib/watobo/gui/utils/save_project_settings.rb +21 -0
  185. data/lib/watobo/gui/utils/save_proxy_settings.rb +45 -0
  186. data/lib/watobo/gui/utils/save_session_settings.rb +21 -0
  187. data/lib/watobo/gui/utils/session_history.rb +134 -0
  188. data/lib/watobo/gui/workspace_dialog.rb +89 -0
  189. data/lib/watobo/gui/www_auth_dialog.rb +348 -0
  190. data/lib/watobo/gui/xml_viewer_frame.rb +114 -0
  191. data/lib/watobo/gui.rb +139 -0
  192. data/lib/watobo/mixins/httpparser.rb +664 -0
  193. data/lib/watobo/mixins/request_parser.rb +210 -0
  194. data/lib/watobo/mixins/shapers.rb +345 -0
  195. data/lib/watobo/mixins/transcoders.rb +88 -0
  196. data/lib/watobo/mixins.rb +32 -0
  197. data/lib/watobo/utils/check_regex.rb +36 -0
  198. data/lib/watobo/utils/copy_object.rb +29 -0
  199. data/lib/watobo/utils/crypto.rb +74 -0
  200. data/lib/watobo/utils/expand_range.rb +45 -0
  201. data/lib/watobo/utils/file_management.rb +73 -0
  202. data/lib/watobo/utils/load_chat.rb +219 -0
  203. data/lib/watobo/utils/load_icon.rb +47 -0
  204. data/lib/watobo/utils/print_debug.rb +34 -0
  205. data/lib/watobo/utils/response_hash.rb +143 -0
  206. data/lib/watobo/utils/secure_eval.rb +57 -0
  207. data/lib/watobo/utils/text2request.rb +96 -0
  208. data/lib/watobo/utils.rb +32 -0
  209. data/lib/watobo.rb +76 -0
  210. data/modules/active/Apache/mod_status.rb +123 -0
  211. data/modules/active/Flash/crossdomain.rb +102 -0
  212. data/modules/active/directories/dirwalker.rb +89 -0
  213. data/modules/active/discovery/fileextensions.rb +151 -0
  214. data/modules/active/discovery/http_methods.rb +135 -0
  215. data/modules/active/domino/domino_db.lst +164 -0
  216. data/modules/active/domino/domino_db.rb +128 -0
  217. data/modules/active/fileinclusion/lfi_simple.rb +134 -0
  218. data/modules/active/jboss/jboss_basic.rb +119 -0
  219. data/modules/active/sap/business_objects.rb +73 -0
  220. data/modules/active/sap/its_commands.rb +101 -0
  221. data/modules/active/sap/its_service_parameter.rb +105 -0
  222. data/modules/active/sap/its_services.rb +103 -0
  223. data/modules/active/sap/its_xss.rb +98 -0
  224. data/modules/active/sqlinjection/sql_boolean.rb +262 -0
  225. data/modules/active/sqlinjection/sqli_simple.rb +205 -0
  226. data/modules/active/xss/xss_simple.rb +179 -0
  227. data/modules/passive/cookie_options.rb +97 -0
  228. data/modules/passive/cookie_xss.rb +85 -0
  229. data/modules/passive/detect_code.rb +89 -0
  230. data/modules/passive/detect_fileupload.rb +80 -0
  231. data/modules/passive/detect_infrastructure.rb +98 -0
  232. data/modules/passive/detect_one_time_tokens.rb +86 -0
  233. data/modules/passive/dirindexing.rb +81 -0
  234. data/modules/passive/disclosure_emails.rb +82 -0
  235. data/modules/passive/disclosure_ipaddr.rb +87 -0
  236. data/modules/passive/filename_as_parameter.rb +85 -0
  237. data/modules/passive/form_spotter.rb +75 -0
  238. data/modules/passive/hotspots.rb +86 -0
  239. data/modules/passive/in_script_parameter.rb +92 -0
  240. data/modules/passive/multiple_server_headers.rb +98 -0
  241. data/modules/passive/possible_login.rb +134 -0
  242. data/modules/passive/redirect_url.rb +88 -0
  243. data/modules/passive/redirectionz.rb +96 -0
  244. data/modules/passive/xss_dom.rb +91 -0
  245. data/plugins/catalog/catalog.ico +0 -0
  246. data/plugins/catalog/catalog.rb +726 -0
  247. data/plugins/catalog/db_tests +6483 -0
  248. data/plugins/catalog/db_variables +29 -0
  249. data/plugins/filefinder/dbs/hbci.db +12 -0
  250. data/plugins/filefinder/filefinder.rb +602 -0
  251. data/plugins/sslchecker/cli/sslchecker_cli.rb +21 -0
  252. data/plugins/sslchecker/gui/cipher_table.rb +260 -0
  253. data/plugins/sslchecker/gui/gui.rb +245 -0
  254. data/plugins/sslchecker/gui/sslchecker.rb +26 -0
  255. data/plugins/sslchecker/icons/green_16x16.ico +0 -0
  256. data/plugins/sslchecker/icons/grey_16x16.ico +0 -0
  257. data/plugins/sslchecker/icons/red_16x16.ico +0 -0
  258. data/plugins/sslchecker/icons/sslchecker.ico +0 -0
  259. data/plugins/sslchecker/lib/check.rb +117 -0
  260. metadata +317 -0
@@ -0,0 +1,460 @@
1
+ # .
2
+ # browser_preview.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 Gui
24
+ class BrowserControl
25
+ def initialize()
26
+
27
+ end
28
+
29
+ def navigate(url)
30
+ raise "Navigate-Method not defined"
31
+ end
32
+
33
+ def connect()
34
+ # check if browser is controlable. If not, create new instance.
35
+ raise "Connect-Method not defined"
36
+ end
37
+
38
+ def ready?()
39
+ # running? can be controlled?
40
+ end
41
+
42
+ def busy?()
43
+ # wait until loading url has finished
44
+ end
45
+
46
+ def getDoc()
47
+ raise "GetDocument-Method not defined"
48
+ end
49
+
50
+ def close()
51
+
52
+ end
53
+
54
+ def visible=(status)
55
+
56
+ end
57
+
58
+ def watobo_enabled?()
59
+ # check if necessary plugins, etc. are installed
60
+ # e.g. jssh for Firefox
61
+ end
62
+ end
63
+
64
+ #
65
+ # Firefox Controller Class
66
+ #
67
+ class FFControl_UNUSED < BrowserControl
68
+ #@@fft = nil
69
+ def initialize()
70
+ @jssh = nil
71
+ aquireSession()
72
+ end
73
+
74
+ def ready?()
75
+ return false if @jssh == nil
76
+ begin
77
+ @jssh.cmd(""){ |s| print s }
78
+ rescue
79
+ @jssh = nil
80
+ return false
81
+ end
82
+
83
+ return true
84
+ end
85
+
86
+ def navigate(url)
87
+ # puts "* Firefox.navigate"
88
+ if aquireSession() then
89
+ res = ""
90
+ @jssh.cmd("tabBrowser.loadURI(\"#{url}\")"){ |l|
91
+ print l
92
+ res += l
93
+ }
94
+ if res.split(/\n/).first =~ /Error:/i then
95
+ @jssh.cmd("var tab = browser.addTab(\"#{url}\")"){ |s| print s }
96
+ @jssh.cmd("var tabBrowser = browser.getBrowserForTab(tab)"){ |s| print s }
97
+ end
98
+
99
+ end
100
+ end
101
+
102
+ def getDoc()
103
+ begin
104
+ aquireSession()
105
+
106
+ jssh_cmd = "var doc = tabBrowser.contentDocument;"
107
+ @jssh.cmd(jssh_cmd){ |s| print s }
108
+
109
+ jssh_cmd = "var body = doc.body;"
110
+ @jssh.cmd(jssh_cmd){ |s| print s }
111
+ @jssh.cmd("body"){ |s| print s }
112
+
113
+ jssh_cmd = "body.innerHTML;"
114
+ doc = @jssh.cmd(jssh_cmd)
115
+ puts doc
116
+ return doc
117
+
118
+ rescue => bang
119
+ puts bang
120
+ return false
121
+
122
+ end
123
+
124
+ end
125
+
126
+ def busy?()
127
+ ffcmd = "tabBrowser.webProgress.isLoadingDocument"
128
+ res = ""
129
+ begin
130
+
131
+ if ready?() then
132
+
133
+ res = ""
134
+ @jssh.cmd(ffcmd) {|s| res += s}
135
+
136
+ return true if res =~ /true/
137
+ end
138
+
139
+ return false
140
+
141
+ rescue => bang
142
+ puts bang
143
+ return false
144
+ end
145
+ end
146
+
147
+ def connect()
148
+ aquireSession()
149
+ end
150
+
151
+ def close()
152
+ if ready?
153
+ @jssh.cmd("browser.removeTab(tab)"){ |s| print s }
154
+ end
155
+ end
156
+
157
+ private
158
+
159
+ def aquireSession()
160
+
161
+ if not ready?
162
+ @jssh = nil
163
+ @jssh = ffconnect("127.0.0.1", "9997")
164
+ end
165
+
166
+ if @jssh != nil then
167
+ @jssh.cmd("var w0 = getWindows()[0]"){ |s| print s }
168
+ @jssh.cmd("var browser = w0.getBrowser()"){ |s| print s }
169
+ @jssh.cmd("browser"){ |s| print s }
170
+
171
+ #jssh.cmd("browser.loadURI(\"http://www.siberas.de\")"){ |s| print s }
172
+ else
173
+ return false
174
+ end
175
+ end
176
+
177
+ def startFireFox()
178
+ puts "startFireFox()"
179
+ path_to_firefox = ""
180
+ case RUBY_PLATFORM
181
+ when /mswin|mingw|bccwin/
182
+ puts "* firefox on this platform (#{RUBY_PLATFORM}) not supported, yet!"
183
+ when /linux|bsd|solaris|hpux/i
184
+ path_to_firefox = `which firefox`.strip
185
+ when /darwin/i
186
+ path_to_firefox = '/Applications/Firefox.app/Contents/MacOS/firefox'
187
+ else
188
+ puts "!Unknown OS???"
189
+ nil
190
+ end
191
+ if path_to_firefox != ""
192
+ puts "* trying to start firefox (#{path_to_firefox})"
193
+ Thread.new { system("#{path_to_firefox} -jssh")}
194
+ end
195
+ end
196
+
197
+ def ffconnect(host, port)
198
+ retry_count = 0
199
+
200
+ begin
201
+ puts "* connecting to firefox jssh extension"
202
+ jssh = Net::Telnet.new('Host' => host,
203
+ 'Port' => port)
204
+ jssh.sync = true
205
+
206
+ jssh.waitfor(/>/){ |s| print s }
207
+ rescue Errno::ECONNREFUSED
208
+ puts "! BrowserControl: Connection Reset"
209
+
210
+ if retry_count < 1 then
211
+ retry_count += 1
212
+ startFireFox()
213
+ retry
214
+ elsif retry_count < 3 then
215
+ retry_count += 1
216
+ # startFireFox()
217
+ sleep 1.0
218
+ retry
219
+ else
220
+ puts "!!! Seems like JSSH is not installed !!!"
221
+ puts "please check the installation instructions!"
222
+ raise "JSSH_CONNECT_ERROR"
223
+ end
224
+ rescue => bang
225
+ puts "!!! Could not create FireFoxControl !!!"
226
+ puts bang
227
+ return false
228
+ end
229
+
230
+ return jssh
231
+ end
232
+ end
233
+
234
+ #
235
+ # InternetExplorer Controller Class
236
+ #
237
+ class IEControl < BrowserControl
238
+ # include WIN32OLE::VARIANT
239
+ def initialize()
240
+ @ie = nil
241
+ createBrowser()
242
+
243
+ end
244
+
245
+ def createBrowser()
246
+ @ie = WIN32OLE.new('InternetExplorer.Application')
247
+
248
+ @ie.menubar=0
249
+ @ie.toolbar=0
250
+ @ie.statusbar=0
251
+ @ie.visible = true
252
+ end
253
+
254
+ def busy?()
255
+ @ie.busy()
256
+ end
257
+
258
+ def connect()
259
+ createBrowser()
260
+ end
261
+
262
+ def navigate(url)
263
+
264
+ @ie.navigate(url)
265
+ end
266
+
267
+ def visible=(status)
268
+ @ie.visible = status
269
+ end
270
+
271
+ def getDoc()
272
+ @ie.document.body.innerHTML.to_s
273
+ end
274
+
275
+ def close()
276
+ @ie.Quit
277
+ @ie = nil
278
+ end
279
+
280
+ def ready?()
281
+ return false if @ie.nil?
282
+ begin
283
+ @ie.visible = true
284
+ rescue => bang
285
+ puts bang
286
+ return false
287
+ end
288
+ return true
289
+ end
290
+ end
291
+
292
+ class SeleniumRC < BrowserControl
293
+ def initialize(browser_type = :firefox, prefs = {})
294
+ proxy = "127.0.0.1:8081"
295
+ @rc = nil
296
+ proxy = prefs[:proxy] if prefs.has_key? :proxy
297
+ begin
298
+ # require 'selenium-webdriver'
299
+ @rc = createBrowser(browser_type, proxy)
300
+ rescue => bang
301
+ puts "* Could not create selenium driver"
302
+ end
303
+ end
304
+
305
+ def createBrowser( browser_type = :firefox, proxy = nil )
306
+ profile = nil
307
+ unless proxy.nil?
308
+ puts "* create preview with proxy #{proxy}"
309
+ profile = Selenium::WebDriver::Firefox::Profile.new
310
+
311
+ driver_proxy = Selenium::WebDriver::Proxy.new(:http => proxy)
312
+ profile.proxy = driver_proxy
313
+
314
+ @rc = Selenium::WebDriver.for :firefox, :profile => profile
315
+
316
+ else
317
+ @rc = Selenium::WebDriver.for browser_type
318
+ end
319
+ end
320
+
321
+ def busy?()
322
+ false
323
+ end
324
+
325
+ def connect()
326
+ createBrowser()
327
+ end
328
+
329
+ def navigate(url)
330
+ @rc.navigate.to(url)
331
+ end
332
+
333
+ def visible=(status)
334
+
335
+ end
336
+
337
+ def getDoc()
338
+ @rc.page_source
339
+ end
340
+
341
+ def close()
342
+ @rc.quit
343
+
344
+ end
345
+
346
+ def ready?()
347
+
348
+ begin
349
+ return false if @rc.nil?
350
+
351
+ rescue => bang
352
+ puts bang
353
+ return false
354
+ end
355
+ return true
356
+ end
357
+ end
358
+
359
+ class BrowserPreview
360
+ attr_accessor :proxy
361
+ def show(request, response)
362
+ begin
363
+ if watoboProxy? then
364
+ hashid = @proxy.addPreview(response)
365
+ url = request.url
366
+ url += request.query != '' ? '&' : '?'
367
+ url += "WATOBOPreview=#{hashid}"
368
+ @browser.navigate(url) if hashid
369
+ return url
370
+ else
371
+ raise "WRONG_PROXY_SETTINGS"
372
+ end
373
+ rescue => bang
374
+ puts bang
375
+ # puts bang.class
376
+ # puts bang.backtrace if $DEBUG
377
+ raise bang
378
+ end
379
+ #raise "Wrong Proxy Settings"
380
+ end
381
+
382
+ def initialize(proxy)
383
+ @proxy = proxy
384
+ @browser = nil
385
+
386
+ end
387
+
388
+ private
389
+
390
+ def wait()
391
+ while @browser.busy? == true
392
+ #puts "sleep, browser sleep ..."
393
+ sleep 0.5
394
+ end
395
+ end
396
+
397
+ def watoboProxy?
398
+
399
+ aquireBrowser()
400
+
401
+ begin
402
+ #@browser.visible = false
403
+ url = "http://watobo.localhost/?WATOBOPreview=ProxyTest"
404
+ timeout(5.0) do
405
+ @browser.navigate(url)
406
+ #sleep 1
407
+ wait()
408
+ end
409
+ puts "* check proxy"
410
+ if @browser.getDoc() =~ /PROXY_OK/ then
411
+ return true
412
+ end
413
+
414
+ rescue Timeout::Error
415
+ puts "!!! Proxy Connection Timed out"
416
+ rescue => bang
417
+ puts "!!! Could not connect to proxy."
418
+ puts bang
419
+ puts bang.backtrace if $DEBUG
420
+ aquireBrowser(true)
421
+ retry
422
+ end
423
+ # @browser.close
424
+
425
+ return false
426
+
427
+ end
428
+
429
+ def aquireBrowser( force = false )
430
+ if @browser.nil? or force == true then
431
+ # TODO: initialize a global GUI function on startup to check if necessary gems are installed
432
+ case RUBY_PLATFORM
433
+ when /mswin|mingw|bccwin/
434
+ require 'win32ole'
435
+ @browser = IEControl.new()
436
+
437
+ when /linux|bsd|solaris|hpux|darwin/i
438
+ begin
439
+ require 'selenium-webdriver'
440
+ puts "* AquireBrowser (Proxy: #{@proxy.server}:#{@proxy.port})"
441
+ @browser = SeleniumRC.new(:firefox, :proxy => "#{@proxy.server}:#{@proxy.port}")
442
+ puts @browser.class
443
+ rescue LoadError
444
+ # require 'net/telnet'
445
+ # @browser = FFControl.new()
446
+ puts "! Could not load Selenium Webdriver which is necessary for BrowserPreview Feature. Please install via:\n>gem install selenium-webdriver"
447
+ end
448
+
449
+ else # cygwin|java
450
+ puts "!!! Could not aquire browser control for preview (unsupported OS) !!!"
451
+ end
452
+ elsif not @browser.ready?
453
+ puts
454
+ @browser.createBrowser
455
+ end
456
+ end
457
+
458
+ end
459
+ end
460
+ end
@@ -0,0 +1,132 @@
1
+ # .
2
+ # certificate_dialog.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 Gui
24
+ class CertificateDialog < FXDialogBox
25
+
26
+ def createCertificate(sender, sel, ptr)
27
+ @createButton.disable
28
+
29
+ cadir = File.join(File.dirname($0), "CA")
30
+ crl_dir= File.join(cadir, "crl")
31
+ hostname = "watobo"
32
+ domainname = "watobo.local"
33
+
34
+ puts "CA Directory:" + cadir
35
+
36
+ # return 0
37
+ ca_settings = {
38
+ :CA_dir => cadir,
39
+ #:password => '1234',
40
+ # some pseudo crypto ;)
41
+ :password => Digest::MD5.hexdigest(Time.now.to_s + rand(100000).to_s + __FILE__).to_s,
42
+
43
+ :keypair_file => File.join(cadir, "private/cakeypair.pem"),
44
+ :cert_file => File.join(cadir, "cacert.pem"),
45
+ :serial_file => File.join(cadir, "serial"),
46
+ :new_certs_dir => File.join(cadir, "newcerts"),
47
+ :new_keypair_dir => File.join(cadir, "private/keypair_backup"),
48
+
49
+
50
+ :ca_cert_days => 5 * 365, # five years
51
+ :ca_rsa_key_length => 2048,
52
+
53
+ :cert_days => 365, # one year
54
+ :cert_key_length_min => 1024,
55
+ :cert_key_length_max => 2048,
56
+
57
+ :crl_file => File.join(crl_dir, "#{@hostname_dt.value}.crl"),
58
+ :crl_pem_file => File.join(crl_dir, "#{@hostname_dt.value}.pem"),
59
+ :crl_days => 14,
60
+ :name => [
61
+ ['C', 'DE', OpenSSL::ASN1::PRINTABLESTRING],
62
+ ['O', @domain_dt.value, OpenSSL::ASN1::UTF8STRING],
63
+ ['OU', @hostname_dt.value, OpenSSL::ASN1::UTF8STRING],
64
+ ]
65
+ }
66
+
67
+ cert = {
68
+ :type => 'server',
69
+ # :user => @user_dt.value,
70
+ :hostname => @hostname_dt.value,
71
+ :email => @email_dt.value
72
+
73
+ }
74
+ puts "Create CA ..."
75
+ ca = Watobo::SimpleCA.new(ca_settings)
76
+ puts "Create Certificate ... "
77
+ ca.create_cert(cert)
78
+ FXMessageBox.information(self,MBOX_OK, "Certificate Created!", "Files written to #{ca_settings[:CA_dir]}\n!!! DON'T USE IT IN A PRODUCTION ENVIRONMENT !!!")
79
+
80
+ end
81
+
82
+ def initialize(owner, project)
83
+ super(owner, "Create Certificate", :opts => DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE, :width => 270, :height => 250)
84
+ @project = project
85
+
86
+ main = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
87
+
88
+ FXLabel.new(main, "CA Settings")
89
+
90
+ frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
91
+ @hostname_dt = FXDataTarget.new('WATOBO')
92
+ FXLabel.new(frame, "Hostname:")
93
+ @hostname = FXTextField.new(frame, 25, :target => @hostname_dt, :selector => FXDataTarget::ID_VALUE,
94
+ :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT)
95
+
96
+
97
+ frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
98
+ @domain_dt = FXDataTarget.new('watobo.local')
99
+ FXLabel.new(frame, "Domain:")
100
+ @domain = FXTextField.new(frame, 25, :target => @domain_dt, :selector => FXDataTarget::ID_VALUE,
101
+ :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT)
102
+
103
+ frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
104
+ @user_dt = FXDataTarget.new('watobo')
105
+ FXLabel.new(frame, "User:")
106
+ @user = FXTextField.new(frame, 25, :target => @user_dt, :selector => FXDataTarget::ID_VALUE,
107
+ :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT)
108
+
109
+ frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
110
+ @email_dt = FXDataTarget.new('watobo@siberas.de')
111
+ FXLabel.new(frame, "Email:")
112
+ @email = FXTextField.new(frame, 25, :target => @email_dt, :selector => FXDataTarget::ID_VALUE,
113
+ :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT)
114
+
115
+
116
+ buttons_frame = FXHorizontalFrame.new(main, :opts => LAYOUT_FILL_X)
117
+ @createButton = FXButton.new(buttons_frame, "Create" , nil, nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
118
+ @createButton.connect(SEL_COMMAND, method(:createCertificate))
119
+
120
+ @hostname.handle(self, FXSEL(SEL_UPDATE, 0), nil)
121
+ @domain.handle(self, FXSEL(SEL_UPDATE, 0), nil)
122
+ @user.handle(self, FXSEL(SEL_UPDATE, 0), nil)
123
+ @email.handle(self, FXSEL(SEL_UPDATE, 0), nil)
124
+
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ if __FILE__ == $0
131
+ # TODO Generated stub
132
+ end