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,393 @@
1
+ # .
2
+ # simple_ca.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
+ require 'openssl'
23
+ require 'digest/md5'
24
+
25
+ module Watobo
26
+
27
+ # SimpleCA is based on QuickCert
28
+ # http://segment7.net/projects/ruby/QuickCert/index.html
29
+
30
+ class SimpleCA
31
+
32
+ def initialize(ca_config)
33
+ @ca_config = ca_config
34
+ create_ca()
35
+ end
36
+
37
+ def create_cert(cert_config)
38
+ puts " ... keypair ..."
39
+ cert_keypair = create_key(cert_config)
40
+ puts "... csr ..."
41
+ cert_csr = create_csr(cert_config, cert_keypair)
42
+ puts "... signing ..."
43
+ sign_cert(cert_config, cert_keypair, cert_csr)
44
+ end
45
+
46
+
47
+ def create_ca
48
+ if not File.exists? @ca_config[:CA_dir] then
49
+ Dir.mkdir(@ca_config[:CA_dir])
50
+ Dir.mkdir File.join(@ca_config[:CA_dir], 'private') #, 0700
51
+ Dir.mkdir File.join(@ca_config[:CA_dir], 'newcerts')
52
+ Dir.mkdir File.join(@ca_config[:CA_dir], 'crl')
53
+ end
54
+
55
+ File.open @ca_config[:serial_file], 'w' do |f| f << '1' end
56
+
57
+ print "Generating CA keypair ..." if $DEBUG
58
+ puts " - rsa_key_length: " + @ca_config[:ca_rsa_key_length].to_s
59
+ keypair = OpenSSL::PKey::RSA.new(@ca_config[:ca_rsa_key_length])
60
+ puts "done!"
61
+
62
+ print "Create Certificate ..."
63
+ cert = OpenSSL::X509::Certificate.new
64
+ puts "done!"
65
+ name = @ca_config[:name].dup << ['CN', 'CA']
66
+ cert.subject = cert.issuer = OpenSSL::X509::Name.new(name)
67
+ cert.not_before = Time.now
68
+ cert.not_after = Time.now + @ca_config[:ca_cert_days] * 24 * 60 * 60
69
+ cert.public_key = keypair.public_key
70
+ cert.serial = 0x0
71
+ cert.version = 2 # X509v3
72
+
73
+ ef = OpenSSL::X509::ExtensionFactory.new
74
+ ef.subject_certificate = cert
75
+ ef.issuer_certificate = cert
76
+ cert.extensions = [
77
+ ef.create_extension("basicConstraints","CA:TRUE", true),
78
+ ef.create_extension("nsComment","Ruby/OpenSSL Generated Certificate"),
79
+ ef.create_extension("subjectKeyIdentifier", "hash"),
80
+ ef.create_extension("keyUsage", "cRLSign,keyCertSign", true),
81
+ ]
82
+ cert.add_extension ef.create_extension("authorityKeyIdentifier",
83
+ "keyid:always,issuer:always")
84
+ cert.sign keypair, OpenSSL::Digest::SHA1.new
85
+
86
+ cb = proc do @ca_config[:password] end
87
+ keypair_export = keypair.export OpenSSL::Cipher::DES.new(:EDE3, :CBC),
88
+ &cb
89
+
90
+ puts "Writing keypair to #{@ca_config[:keypair_file]}" if $DEBUG
91
+ begin
92
+ fh = File.open(@ca_config[:keypair_file], "w+")
93
+
94
+ fh.puts keypair_export
95
+ fh.close
96
+ rescue => bang
97
+ puts "! Could not write keypair"
98
+ puts bang
99
+ end
100
+
101
+
102
+ puts "Writing cert to #{@ca_config[:cert_file]}" if $DEBUG
103
+ File.open @ca_config[:cert_file], "w", 0644 do |f|
104
+ f << cert.to_pem
105
+ end
106
+
107
+ puts "Done generating certificate for #{cert.subject}" if $DEBUG
108
+ end
109
+
110
+ ##
111
+ # Creates a new RSA key from +cert_config+.
112
+
113
+ def create_key(cert_config)
114
+ passwd_cb = nil
115
+ target = cert_config[:hostname] || cert_config[:user]
116
+ dest = @ca_config[:CA_dir]
117
+ keypair_file = File.join(dest, (target + "_keypair.pem"))
118
+
119
+ puts "create_key: #{keypair_file}"
120
+ begin
121
+ Dir.mkdir dest #, 0700
122
+ rescue Errno::EEXIST
123
+ puts "directory exists"
124
+ end
125
+
126
+ if not File.exists?(keypair_file) then
127
+ puts "Generating RSA keypair" if $DEBUG
128
+ keypair = OpenSSL::PKey::RSA.new 1024
129
+ puts keypair.to_pem.class
130
+
131
+ if cert_config[:password].nil? then
132
+ puts "no password for cert"
133
+ puts "Writing keypair to #{keypair_file}" if $DEBUG
134
+ begin
135
+ dummy = keypair.to_pem.split("\n")
136
+ dummy.each do |line|
137
+ line.strip!
138
+ end
139
+ fh = File.open( keypair_file, "wb" )
140
+ fh.write dummy.join("\n")
141
+ fh.close
142
+ rescue => bang
143
+ puts "! Could not write keypair"
144
+ end
145
+ else
146
+ passwd_cb = proc do cert_config[:password] end
147
+ keypair_export = keypair.export OpenSSL::Cipher::DES.new(:EDE3, :CBC),
148
+ cert_config[:password]
149
+
150
+ puts "Writing keypair to #{keypair_file}" if $DEBUG
151
+ #File.open keypair_file, "w" do |f|
152
+ # f << keypair_export
153
+ #end
154
+ begin
155
+ fh = File.open( keypair_file, "w" )
156
+ fh.puts keypair_export
157
+ fh.close
158
+ rescue => bang
159
+ puts "! Could not write keypair"
160
+ end
161
+
162
+ end
163
+ end
164
+ return keypair_file
165
+ end
166
+
167
+ ##
168
+ # Creates a new Certificate Signing Request for the keypair in
169
+ # +keypair_file+, generating and saving new keypair if nil.
170
+
171
+ def create_csr(cert_config, keypair_file = nil)
172
+ keypair = nil
173
+ target = cert_config[:hostname] || cert_config[:user]
174
+ dest = @ca_config[:CA_dir]
175
+ csr_file = File.join dest, "csr_#{target}.pem"
176
+
177
+ name = @ca_config[:name].dup
178
+ case cert_config[:type]
179
+ when 'server' then
180
+ name << ['OU', 'CA']
181
+ name << ['CN', cert_config[:hostname]]
182
+ when 'client' then
183
+ name << ['CN', cert_config[:user]]
184
+ name << ['emailAddress', cert_config[:email]]
185
+ end
186
+ puts "Create Certificate Signing Request ..."
187
+ puts "Keypair File: " + keypair_file
188
+ # puts name
189
+ name = OpenSSL::X509::Name.new(name)
190
+ puts "- - -"
191
+
192
+ if File.exists? keypair_file then
193
+ puts "Get Keypair from file #{keypair_file}"
194
+ keypair = OpenSSL::PKey::RSA.new(File.read(keypair_file), cert_config[:password])
195
+ else
196
+ puts "Create Certificate KeyPair ..."
197
+ keypair = create_key(cert_config)
198
+ end
199
+
200
+ puts "Generating CSR for #{name}" if $DEBUG
201
+
202
+ req = OpenSSL::X509::Request.new
203
+ req.version = 0
204
+ req.subject = name
205
+ req.public_key = keypair.public_key
206
+ req.sign keypair, OpenSSL::Digest::MD5.new
207
+
208
+ puts "Writing CSR to #{csr_file}" if $DEBUG
209
+ File.open csr_file, "w" do |f|
210
+ f << req.to_pem
211
+ end
212
+
213
+ return csr_file
214
+ end
215
+
216
+ ##
217
+ # Signs the certificate described in +cert_config+ and
218
+ # +csr_file+, saving it to +cert_file+.
219
+
220
+ def sign_cert(cert_config, cert_file, csr_file)
221
+ csr = OpenSSL::X509::Request.new File.read(csr_file)
222
+
223
+ raise "CSR sign verification failed." unless csr.verify csr.public_key
224
+
225
+ if csr.public_key.n.num_bits < @ca_config[:cert_key_length_min] then
226
+ raise "Key length too short"
227
+ end
228
+
229
+ if csr.public_key.n.num_bits > @ca_config[:cert_key_length_max] then
230
+ raise "Key length too long"
231
+ end
232
+
233
+ if csr.subject.to_a[0, @ca_config[:name].size] != @ca_config[:name] then
234
+ raise "DN does not match"
235
+ end
236
+
237
+ # Only checks signature here. You must verify CSR according to your
238
+ # CP/CPS.
239
+
240
+ # CA setup
241
+
242
+ puts "Reading CA cert from #{@ca_config[:cert_file]}" if $DEBUG
243
+ ca = OpenSSL::X509::Certificate.new File.read(@ca_config[:cert_file])
244
+
245
+ puts "Reading CA keypair from #{@ca_config[:keypair_file]}" if $DEBUG
246
+ ca_keypair = OpenSSL::PKey::RSA.new File.read(@ca_config[:keypair_file]),
247
+ @ca_config[:password]
248
+
249
+ serial = File.read(@ca_config[:serial_file]).chomp.hex
250
+ File.open @ca_config[:serial_file], "w" do |f|
251
+ f << "%04X" % (serial + 1)
252
+ end
253
+
254
+ puts "Generating cert" if $DEBUG
255
+
256
+ cert = OpenSSL::X509::Certificate.new
257
+ from = Time.now
258
+ cert.subject = csr.subject
259
+ cert.issuer = ca.subject
260
+ cert.not_before = from
261
+ cert.not_after = from + @ca_config[:cert_days] * 24 * 60 * 60
262
+ cert.public_key = csr.public_key
263
+ cert.serial = serial
264
+ cert.version = 2 # X509v3
265
+
266
+ basic_constraint = nil
267
+ key_usage = []
268
+ ext_key_usage = []
269
+
270
+ case cert_config[:type]
271
+ when "ca" then
272
+ basic_constraint = "CA:TRUE"
273
+ key_usage << "cRLSign" << "keyCertSign"
274
+ when "terminalsubca" then
275
+ basic_constraint = "CA:TRUE,pathlen:0"
276
+ key_usage << "cRLSign" << "keyCertSign"
277
+ when "server" then
278
+ basic_constraint = "CA:FALSE"
279
+ key_usage << "digitalSignature" << "keyEncipherment"
280
+ ext_key_usage << "serverAuth"
281
+ when "ocsp" then
282
+ basic_constraint = "CA:FALSE"
283
+ key_usage << "nonRepudiation" << "digitalSignature"
284
+ ext_key_usage << "serverAuth" << "OCSPSigning"
285
+ when "client" then
286
+ basic_constraint = "CA:FALSE"
287
+ key_usage << "nonRepudiation" << "digitalSignature" << "keyEncipherment"
288
+ ext_key_usage << "clientAuth" << "emailProtection"
289
+ else
290
+ raise "unknonw cert type \"#{cert_config[:type]}\""
291
+ end
292
+
293
+ ef = OpenSSL::X509::ExtensionFactory.new
294
+ ef.subject_certificate = cert
295
+ ef.issuer_certificate = ca
296
+ ex = []
297
+ ex << ef.create_extension("basicConstraints", basic_constraint, true)
298
+ ex << ef.create_extension("nsComment",
299
+ "Ruby/OpenSSL Generated Certificate")
300
+ ex << ef.create_extension("subjectKeyIdentifier", "hash")
301
+ #ex << ef.create_extension("nsCertType", "client,email")
302
+ unless key_usage.empty? then
303
+ ex << ef.create_extension("keyUsage", key_usage.join(","))
304
+ end
305
+ #ex << ef.create_extension("authorityKeyIdentifier",
306
+ # "keyid:always,issuer:always")
307
+ #ex << ef.create_extension("authorityKeyIdentifier", "keyid:always")
308
+ unless ext_key_usage.empty? then
309
+ ex << ef.create_extension("extendedKeyUsage", ext_key_usage.join(","))
310
+ end
311
+
312
+ if @ca_config[:cdp_location] then
313
+ ex << ef.create_extension("crlDistributionPoints",
314
+ @ca_config[:cdp_location])
315
+ end
316
+
317
+ if @ca_config[:ocsp_location] then
318
+ ex << ef.create_extension("authorityInfoAccess",
319
+ "OCSP;" << @ca_config[:ocsp_location])
320
+ end
321
+ cert.extensions = ex
322
+ cert.sign ca_keypair, OpenSSL::Digest::SHA1.new
323
+
324
+ backup_cert_file = @ca_config[:new_certs_dir] + "/cert_#{cert.serial}.pem"
325
+ puts "Writing backup cert to #{backup_cert_file}" if $DEBUG
326
+ File.open backup_cert_file, "w", 0644 do |f|
327
+ f << cert.to_pem
328
+ end
329
+
330
+ # Write cert
331
+ target = cert_config[:hostname] || cert_config[:user]
332
+ dest = @ca_config[:CA_dir]
333
+ cert_file = File.join dest, "cert_#{target}.pem"
334
+ puts "Writing cert to #{cert_file}"
335
+ File.open cert_file, "w", 0644 do |f|
336
+ f << cert.to_pem
337
+ end
338
+
339
+ return cert_file
340
+ end
341
+
342
+ end # class QuickCert
343
+
344
+ end
345
+
346
+ if __FILE__ == $0 then
347
+
348
+
349
+ cadir = File.join(Dir.pwd, "CA")
350
+ crl_dir= File.join(cadir, "crl")
351
+ hostname = "watobo"
352
+ domainname = "watobo.local"
353
+ ca = {
354
+ :CA_dir => cadir,
355
+ :password => '1234',
356
+
357
+ :keypair_file => File.join(cadir, "private/cakeypair.pem"),
358
+ :cert_file => File.join(cadir, "cacert.pem"),
359
+ :serial_file => File.join(cadir, "serial"),
360
+ :new_certs_dir => File.join(cadir, "newcerts"),
361
+ :new_keypair_dir => File.join(cadir, "private/keypair_backup"),
362
+
363
+
364
+ :ca_cert_days => 5 * 365, # five years
365
+ :ca_rsa_key_length => 2048,
366
+
367
+ :cert_days => 365, # one year
368
+ :cert_key_length_min => 1024,
369
+ :cert_key_length_max => 2048,
370
+
371
+ :crl_file => File.join(crl_dir, "#{hostname}.crl"),
372
+ :crl_pem_file => File.join(crl_dir, "#{hostname}.pem"),
373
+ :crl_days => 14,
374
+ :name => [
375
+ ['C', 'DE', OpenSSL::ASN1::PRINTABLESTRING],
376
+ ['O', domainname, OpenSSL::ASN1::UTF8STRING],
377
+ ['OU',hostname, OpenSSL::ASN1::UTF8STRING],
378
+ ]
379
+ }
380
+
381
+
382
+
383
+
384
+ cert = {
385
+ :type => 'server',
386
+ :user => 'watobo',
387
+ :email => 'a.schmidt@siberas.de',
388
+ }
389
+
390
+ qc = QuickCert.new(ca)
391
+ qc.create_cert(cert)
392
+
393
+ end
@@ -0,0 +1,34 @@
1
+ # .
2
+ # core.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
+ lib_folder = "core"
24
+ path = File.expand_path(File.join(File.dirname(__FILE__), lib_folder))
25
+ puts "* loading #{lib_folder}"
26
+ Dir.glob("#{path}/*.rb").each do |cf|
27
+ puts "+ #{cf}" if $DEBUG
28
+ require cf
29
+
30
+ end
31
+ =end
32
+ %w( project scanner session fuzz_gen http_socket interceptor passive_check active_check simple_ca cookie).each do |lib|
33
+ require File.join( "watobo", "core", lib)
34
+ end
@@ -0,0 +1,40 @@
1
+ # .
2
+ # defaults.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
+ def self.load_defaults
24
+ config_path = File.expand_path(File.join(File.dirname(__FILE__),"..","..", "config"))
25
+ puts "* loading defaults from #{config_path}"
26
+ Dir.glob("#{config_path}/*.yml").each do |cf|
27
+ dummy = File.basename(cf).gsub!(/.yml/,'')
28
+ cc = dummy.strip.gsub(/[^[a-zA-Z\-_]]/,"").gsub( "-" , "_").split("_").map{ |s| s.downcase.capitalize }.join
29
+
30
+ print " - #{cc} ... "
31
+ settings = YAML.load_file(cf)
32
+ Watobo::Conf.add(cc, settings )
33
+ print "OK\n"
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ puts "=== loading defaults ==="
40
+ Watobo.load_defaults
@@ -0,0 +1,42 @@
1
+ # .
2
+ # array.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
+ #! /usr/env/bin ruby
23
+ #--
24
+ # Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
25
+ # adapted from:
26
+ # Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
27
+ # Smalltalk by Mario I. Wolczko <mario@wolczko.com>
28
+ # implements McIlroy-Hunt diff algorithm
29
+ #
30
+ # This program is free software. It may be redistributed and/or modified under
31
+ # the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
32
+ # Ruby licence.
33
+ #
34
+ # $Id: array.rb,v 1.3 2004/08/08 20:33:09 austin Exp $
35
+ #++
36
+ # Includes Diff::LCS into the Array built-in class.
37
+
38
+ require 'diff/lcs'
39
+
40
+ class Array
41
+ include Diff::LCS
42
+ end
@@ -0,0 +1,72 @@
1
+ # .
2
+ # block.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
+ #! /usr/env/bin ruby
23
+ #--
24
+ # Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
25
+ # adapted from:
26
+ # Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
27
+ # Smalltalk by Mario I. Wolczko <mario@wolczko.com>
28
+ # implements McIlroy-Hunt diff algorithm
29
+ #
30
+ # This program is free software. It may be redistributed and/or modified under
31
+ # the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
32
+ # Ruby licence.
33
+ #
34
+ # $Id: block.rb,v 1.3 2004/08/08 20:33:09 austin Exp $
35
+ #++
36
+ # Contains Diff::LCS::Block for bin/ldiff.
37
+
38
+ # A block is an operation removing, adding, or changing a group of items.
39
+ # Basically, this is just a list of changes, where each change adds or
40
+ # deletes a single item. Used by bin/ldiff.
41
+ class Diff::LCS::Block
42
+ attr_reader :changes, :insert, :remove
43
+
44
+ def initialize(chunk)
45
+ @changes = []
46
+ @insert = []
47
+ @remove = []
48
+
49
+ chunk.each do |item|
50
+ @changes << item
51
+ @remove << item if item.deleting?
52
+ @insert << item if item.adding?
53
+ end
54
+ end
55
+
56
+ def diff_size
57
+ @insert.size - @remove.size
58
+ end
59
+
60
+ def op
61
+ case [@remove.empty?, @insert.empty?]
62
+ when [false, false]
63
+ '!'
64
+ when [false, true]
65
+ '-'
66
+ when [true, false]
67
+ '+'
68
+ else # [true, true]
69
+ '^'
70
+ end
71
+ end
72
+ end