watobo 0.9.9.pre3 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.yardopts +24 -0
  2. data/CHANGELOG +17 -7
  3. data/README +4 -60
  4. data/bin/nfq_server.rb +191 -0
  5. data/config/interceptor.yml +2 -6
  6. data/lib/watobo/adapters/data_store.rb +1 -1
  7. data/lib/watobo/adapters/file/file_store.rb +50 -33
  8. data/lib/watobo/ca.rb +22 -0
  9. data/lib/watobo/config.rb +6 -0
  10. data/lib/watobo/core/ca.rb +411 -0
  11. data/lib/watobo/core/cert_store.rb +56 -0
  12. data/lib/watobo/core/forwarding_proxy.rb +38 -0
  13. data/lib/watobo/core/http_socket.rb +18 -0
  14. data/lib/watobo/core/intercept_carver.rb +179 -0
  15. data/lib/watobo/core/intercept_filter.rb +257 -0
  16. data/lib/watobo/core/interceptor.rb +342 -79
  17. data/lib/watobo/core/netfilter_queue.rb +191 -0
  18. data/lib/watobo/core/project.rb +84 -138
  19. data/lib/watobo/core/proxy.rb +61 -0
  20. data/lib/watobo/core/request.rb +40 -0
  21. data/lib/watobo/core/response.rb +30 -0
  22. data/lib/watobo/core/scanner.rb +64 -58
  23. data/lib/watobo/core/session.rb +70 -77
  24. data/lib/watobo/core.rb +1 -1
  25. data/lib/watobo/framework/create_project.rb +25 -10
  26. data/lib/watobo/framework/init.rb +13 -0
  27. data/lib/watobo/gui/browser_preview.rb +5 -4
  28. data/lib/watobo/gui/checks_policy_frame.rb +1 -0
  29. data/lib/watobo/gui/client_cert_dialog.rb +11 -6
  30. data/lib/watobo/gui/conversation_table.rb +7 -4
  31. data/lib/watobo/gui/fuzzer_gui.rb +9 -11
  32. data/lib/watobo/gui/intercept_filter_dialog.rb +210 -0
  33. data/lib/watobo/gui/interceptor_gui.rb +59 -21
  34. data/lib/watobo/gui/interceptor_settings_dialog.rb +39 -5
  35. data/lib/watobo/gui/list_box.rb +2 -1
  36. data/lib/watobo/gui/log_viewer.rb +79 -5
  37. data/lib/watobo/gui/main_window.rb +159 -113
  38. data/lib/watobo/gui/manual_request_editor.rb +11 -5
  39. data/lib/watobo/gui/mixins/subscriber.rb +47 -0
  40. data/lib/watobo/gui/project_wizzard.rb +3 -3
  41. data/lib/watobo/gui/proxy_dialog.rb +17 -18
  42. data/lib/watobo/gui/request_editor.rb +1 -1
  43. data/lib/watobo/gui/rewrite_filters_dialog.rb +416 -0
  44. data/lib/watobo/gui/rewrite_rules_dialog.rb +394 -0
  45. data/lib/watobo/gui/scanner_settings_dialog.rb +9 -6
  46. data/lib/watobo/gui/session_management_dialog.rb +33 -23
  47. data/lib/watobo/gui/sites_tree.rb +5 -6
  48. data/lib/watobo/gui/status_bar.rb +101 -49
  49. data/lib/watobo/gui/table_editor.rb +1 -1
  50. data/lib/watobo/gui/templates/plugin2.rb +23 -27
  51. data/lib/watobo/gui/utils/save_default_settings.rb +9 -9
  52. data/lib/watobo/gui/utils/save_proxy_settings.rb +25 -9
  53. data/lib/watobo/gui/utils/save_scanner_settings.rb +10 -7
  54. data/lib/watobo/gui/utils/session_history.rb +1 -1
  55. data/lib/watobo/gui/www_auth_dialog.rb +25 -21
  56. data/lib/watobo/gui.rb +3 -1
  57. data/lib/watobo/mixins/httpparser.rb +47 -40
  58. data/lib/watobo/mixins/request_parser.rb +126 -41
  59. data/lib/watobo/mixins/shapers.rb +124 -15
  60. data/lib/watobo/utils/hexprint.rb +31 -0
  61. data/lib/watobo/utils/load_chat.rb +2 -0
  62. data/lib/watobo/utils/response_builder.rb +111 -0
  63. data/lib/watobo.rb +4 -1
  64. data/modules/active/discovery/http_methods.rb +6 -4
  65. data/modules/active/fileinclusion/lfi_simple.rb +3 -3
  66. data/modules/active/sqlinjection/sqli_timing.rb +6 -6
  67. data/modules/passive/redirectionz.rb +5 -6
  68. data/plugins/catalog/catalog.rb +240 -56
  69. data/plugins/catalog/db_tests +1 -6483
  70. data/plugins/catalog/db_variables +2 -29
  71. data/plugins/crawler/gui/auth_frame.rb +15 -3
  72. data/plugins/crawler/gui/crawler_gui.rb +24 -0
  73. data/plugins/crawler/gui/hooks_frame.rb +7 -2
  74. data/plugins/crawler/gui/settings_tabbook.rb +4 -0
  75. data/plugins/crawler/gui.rb +3 -3
  76. data/plugins/crawler/lib/engine.rb +1 -1
  77. data/plugins/filefinder/filefinder.rb +21 -17
  78. data/plugins/sqlmap/bin/test.rb +100 -0
  79. data/plugins/sqlmap/gui/main.rb +227 -0
  80. data/plugins/sqlmap/gui/options_frame.rb +119 -0
  81. data/plugins/sqlmap/gui.rb +27 -0
  82. data/plugins/sqlmap/icons/sqlmap.ico +0 -0
  83. data/plugins/sqlmap/lib/sqlmap_ctrl.rb +116 -0
  84. data/plugins/sqlmap/sqlmap.rb +26 -0
  85. data/plugins/sslchecker/gui/gui.rb +45 -30
  86. metadata +32 -9
  87. data/certificates/cert.pem +0 -19
  88. data/certificates/privkey.pem +0 -15
  89. data/certificates/watobo_dh.key +0 -5
  90. data/lib/watobo/core/simple_ca.rb +0 -393
@@ -1,393 +0,0 @@
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