watobo 0.9.19 → 0.9.20
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +104 -0
- data/bin/nfq_server.rb +8 -20
- data/bin/watobo_gui.rb +8 -20
- data/config/forwarding_proxy.yml +2 -2
- data/lib/watobo.rb +12 -22
- data/lib/watobo/adapters.rb +12 -24
- data/lib/watobo/adapters/data_store.rb +76 -66
- data/lib/watobo/adapters/file/file_store.rb +295 -307
- data/lib/watobo/adapters/session_store.rb +13 -25
- data/lib/watobo/ca.rb +9 -21
- data/lib/watobo/config.rb +205 -217
- data/lib/watobo/constants.rb +8 -20
- data/lib/watobo/core.rb +11 -23
- data/lib/watobo/core/active_check.rb +11 -21
- data/lib/watobo/core/active_checks.rb +57 -69
- data/lib/watobo/core/ca.rb +388 -398
- data/lib/watobo/core/cert_store.rb +42 -54
- data/lib/watobo/core/chat.rb +100 -112
- data/lib/watobo/core/chats.rb +271 -275
- data/lib/watobo/core/client_cert_store.rb +33 -45
- data/lib/watobo/core/conversation.rb +56 -68
- data/lib/watobo/core/cookie.rb +31 -43
- data/lib/watobo/core/finding.rb +74 -86
- data/lib/watobo/core/findings.rb +113 -125
- data/lib/watobo/core/forwarding_proxy.rb +44 -35
- data/lib/watobo/core/fuzz_gen.rb +8 -20
- data/lib/watobo/core/intercept_carver.rb +176 -188
- data/lib/watobo/core/intercept_filter.rb +243 -255
- data/lib/watobo/core/interceptor.rb +106 -118
- data/lib/watobo/core/min_class.rb +12 -24
- data/lib/watobo/core/netfilter_queue.rb +178 -190
- data/lib/watobo/core/ott_cache.rb +152 -148
- data/lib/watobo/core/parameter.rb +53 -58
- data/lib/watobo/core/passive_check.rb +8 -20
- data/lib/watobo/core/passive_checks.rb +56 -68
- data/lib/watobo/core/passive_scanner.rb +54 -66
- data/lib/watobo/core/plugin.rb +19 -31
- data/lib/watobo/core/project.rb +8 -20
- data/lib/watobo/core/proxy.rb +51 -63
- data/lib/watobo/core/request.rb +128 -120
- data/lib/watobo/core/response.rb +59 -61
- data/lib/watobo/core/scanner.rb +8 -20
- data/lib/watobo/core/scanner3.rb +413 -425
- data/lib/watobo/core/scope.rb +91 -103
- data/lib/watobo/core/session.rb +109 -87
- data/lib/watobo/core/sid_cache.rb +106 -118
- data/lib/watobo/core/subscriber.rb +33 -45
- data/lib/watobo/defaults.rb +29 -41
- data/lib/watobo/external/diff/lcs.rb +8 -20
- data/lib/watobo/external/diff/lcs/array.rb +8 -20
- data/lib/watobo/external/diff/lcs/block.rb +8 -20
- data/lib/watobo/external/diff/lcs/callbacks.rb +8 -20
- data/lib/watobo/external/diff/lcs/change.rb +8 -20
- data/lib/watobo/external/diff/lcs/hunk.rb +8 -20
- data/lib/watobo/external/diff/lcs/ldiff.rb +8 -20
- data/lib/watobo/external/diff/lcs/string.rb +8 -20
- data/lib/watobo/externals.rb +14 -26
- data/lib/watobo/framework.rb +12 -24
- data/lib/watobo/framework/create_project.rb +68 -80
- data/lib/watobo/framework/init.rb +8 -20
- data/lib/watobo/framework/init_modules.rb +8 -20
- data/lib/watobo/framework/license_text.rb +36 -48
- data/lib/watobo/framework/load_chat.rb +21 -33
- data/lib/watobo/gui.rb +121 -133
- data/lib/watobo/gui/about_watobo.rb +8 -20
- data/lib/watobo/gui/browser_preview.rb +8 -20
- data/lib/watobo/gui/certificate_dialog.rb +8 -20
- data/lib/watobo/gui/chat_diff.rb +11 -21
- data/lib/watobo/gui/chatviewer_frame.rb +10 -22
- data/lib/watobo/gui/checkboxtree.rb +8 -20
- data/lib/watobo/gui/checks_policy_frame.rb +8 -20
- data/lib/watobo/gui/client_cert_dialog.rb +10 -21
- data/lib/watobo/gui/confirm_scan_dialog.rb +8 -20
- data/lib/watobo/gui/conversation_table.rb +54 -44
- data/lib/watobo/gui/conversation_table_ctrl.rb +215 -227
- data/lib/watobo/gui/conversation_table_ctrl2.rb +385 -393
- data/lib/watobo/gui/csrf_token_dialog.rb +11 -25
- data/lib/watobo/gui/custom_viewer.rb +357 -369
- data/lib/watobo/gui/dashboard.rb +8 -20
- data/lib/watobo/gui/define_scope_frame.rb +8 -20
- data/lib/watobo/gui/differ_frame.rb +223 -235
- data/lib/watobo/gui/edit_comment.rb +8 -20
- data/lib/watobo/gui/edit_scope_dialog.rb +8 -20
- data/lib/watobo/gui/export_dialog.rb +114 -0
- data/lib/watobo/gui/finding_info.rb +9 -21
- data/lib/watobo/gui/findings_tree.rb +8 -20
- data/lib/watobo/gui/full_scan_dialog.rb +8 -20
- data/lib/watobo/gui/fuzzer_gui.rb +8 -20
- data/lib/watobo/gui/goto_url_dialog.rb +78 -90
- data/lib/watobo/gui/hex_viewer.rb +25 -27
- data/lib/watobo/gui/html_viewer.rb +295 -307
- data/lib/watobo/gui/intercept_filter_dialog.rb +196 -208
- data/lib/watobo/gui/interceptor_gui.rb +1046 -1041
- data/lib/watobo/gui/interceptor_settings_dialog.rb +8 -20
- data/lib/watobo/gui/list_box.rb +109 -121
- data/lib/watobo/gui/log_file_viewer.rb +40 -52
- data/lib/watobo/gui/log_viewer.rb +87 -99
- data/lib/watobo/gui/login_wizzard.rb +8 -20
- data/lib/watobo/gui/main_window.rb +34 -33
- data/lib/watobo/gui/manual_request_editor.rb +25 -35
- data/lib/watobo/gui/master_pw_dialog.rb +8 -20
- data/lib/watobo/gui/mixins/gui_settings.rb +37 -49
- data/lib/watobo/gui/page_tree.rb +225 -237
- data/lib/watobo/gui/password_policy_dialog.rb +8 -20
- data/lib/watobo/gui/plugin_board.rb +8 -20
- data/lib/watobo/gui/preferences_dialog.rb +8 -20
- data/lib/watobo/gui/progress_window.rb +8 -20
- data/lib/watobo/gui/project_wizzard.rb +8 -20
- data/lib/watobo/gui/proxy_dialog.rb +117 -85
- data/lib/watobo/gui/quick_scan_dialog.rb +8 -20
- data/lib/watobo/gui/request_builder_frame.rb +125 -122
- data/lib/watobo/gui/request_editor.rb +53 -28
- data/lib/watobo/gui/rewrite_filters_dialog.rb +402 -414
- data/lib/watobo/gui/rewrite_rules_dialog.rb +380 -392
- data/lib/watobo/gui/save_chat_dialog.rb +148 -160
- data/lib/watobo/gui/scanner_settings_dialog.rb +8 -20
- data/lib/watobo/gui/select_chat_dialog.rb +8 -20
- data/lib/watobo/gui/session_management_dialog.rb +8 -20
- data/lib/watobo/gui/sites_tree.rb +118 -22
- data/lib/watobo/gui/status_bar.rb +8 -20
- data/lib/watobo/gui/table_editor.rb +76 -53
- data/lib/watobo/gui/tagless_viewer.rb +10 -21
- data/lib/watobo/gui/templates/plugin.rb +8 -20
- data/lib/watobo/gui/templates/plugin2.rb +99 -111
- data/lib/watobo/gui/templates/plugin_base.rb +152 -164
- data/lib/watobo/gui/text_viewer.rb +8 -20
- data/lib/watobo/gui/transcoder_window.rb +15 -22
- data/lib/watobo/gui/utils/gui_utils.rb +8 -20
- data/lib/watobo/gui/utils/init_icons.rb +94 -106
- data/lib/watobo/gui/utils/load_icons.rb +41 -53
- data/lib/watobo/gui/utils/load_plugins.rb +118 -130
- data/lib/watobo/gui/utils/master_password.rb +76 -88
- data/lib/watobo/gui/utils/save_default_settings.rb +121 -133
- data/lib/watobo/gui/utils/save_project_settings.rb +8 -20
- data/lib/watobo/gui/utils/save_proxy_settings.rb +53 -21
- data/lib/watobo/gui/utils/save_scanner_settings.rb +26 -38
- data/lib/watobo/gui/utils/session_history.rb +120 -132
- data/lib/watobo/gui/workspace_dialog.rb +8 -20
- data/lib/watobo/gui/www_auth_dialog.rb +8 -20
- data/lib/watobo/gui/xml_viewer_frame.rb +8 -20
- data/lib/watobo/http.rb +12 -23
- data/lib/watobo/http/cookies/cookies.rb +63 -70
- data/lib/watobo/http/data/data.rb +56 -64
- data/lib/watobo/http/data/json.rb +51 -0
- data/lib/watobo/http/url/url.rb +46 -58
- data/lib/watobo/http/xml/xml.rb +129 -141
- data/lib/watobo/interceptor.rb +11 -23
- data/lib/watobo/interceptor/proxy.rb +624 -625
- data/lib/watobo/interceptor/transparent.rb +22 -34
- data/lib/watobo/mixins.rb +18 -30
- data/lib/watobo/mixins/check_info.rb +35 -47
- data/lib/watobo/mixins/httpparser.rb +42 -35
- data/lib/watobo/mixins/request_parser.rb +8 -20
- data/lib/watobo/mixins/shapers.rb +484 -477
- data/lib/watobo/mixins/transcoders.rb +8 -20
- data/lib/watobo/parser.rb +9 -21
- data/lib/watobo/parser/html.rb +91 -103
- data/lib/watobo/sockets.rb +11 -23
- data/lib/watobo/sockets/agent.rb +836 -848
- data/lib/watobo/sockets/client_socket.rb +283 -277
- data/lib/watobo/sockets/connection.rb +409 -421
- data/lib/watobo/sockets/http_socket.rb +16 -23
- data/lib/watobo/sockets/ntlm_auth.rb +137 -149
- data/lib/watobo/utils.rb +18 -30
- data/lib/watobo/utils/check_regex.rb +8 -20
- data/lib/watobo/utils/copy_object.rb +8 -20
- data/lib/watobo/utils/crypto.rb +8 -20
- data/lib/watobo/utils/expand_range.rb +31 -43
- data/lib/watobo/utils/export_xml.rb +108 -0
- data/lib/watobo/utils/file_management.rb +8 -20
- data/lib/watobo/utils/hexprint.rb +17 -29
- data/lib/watobo/utils/load_chat.rb +8 -20
- data/lib/watobo/utils/load_icon.rb +8 -20
- data/lib/watobo/{external/ntlm → utils}/ntlm.rb +874 -796
- data/lib/watobo/utils/print_debug.rb +20 -32
- data/lib/watobo/utils/response_builder.rb +98 -110
- data/lib/watobo/utils/response_hash.rb +9 -20
- data/lib/watobo/utils/secure_eval.rb +10 -22
- data/lib/watobo/utils/strings.rb +18 -30
- data/lib/watobo/utils/text2request.rb +12 -20
- data/lib/watobo/utils/url.rb +31 -43
- data/lib/watobo/utils/utf16.rb +22 -0
- data/modules/active/Apache/mod_status.rb +9 -0
- data/modules/active/Apache/multiview.rb +161 -0
- data/modules/active/Flash/crossdomain.rb +9 -0
- data/modules/active/directories/dirwalker.rb +8 -20
- data/modules/active/discovery/fileextensions.rb +10 -22
- data/modules/active/discovery/http_methods.rb +8 -20
- data/modules/active/domino/domino_db.rb +8 -20
- data/modules/active/dotNET/custom_errors.rb +110 -122
- data/modules/active/dotNET/dotnet_files.rb +98 -110
- data/modules/active/fileinclusion/lfi_simple.rb +8 -20
- data/modules/active/jboss/jboss_basic.rb +8 -20
- data/modules/active/sap/business_objects.rb +63 -0
- data/modules/active/sap/its_commands.rb +8 -20
- data/modules/active/sap/its_service_parameter.rb +8 -20
- data/modules/active/sap/its_services.rb +8 -20
- data/modules/active/sap/its_xss.rb +8 -20
- data/modules/active/shell_shock/shell_shock.rb +149 -0
- data/modules/active/siebel/siebel_apps.rb +168 -180
- data/modules/active/sqlinjection/sql_boolean.rb +9 -21
- data/modules/active/sqlinjection/sqli_error.rb +10 -22
- data/modules/active/sqlinjection/sqli_timing.rb +228 -240
- data/modules/active/struts2/default_handler_ognl.rb +114 -126
- data/modules/active/struts2/include_params_ognl.rb +113 -125
- data/modules/active/xml/xml_xxe.rb +122 -127
- data/modules/active/xss/xss_ng.rb +223 -234
- data/modules/active/xss/xss_simple.rb +8 -20
- data/modules/passive/ajax.rb +76 -84
- data/modules/passive/autocomplete.rb +64 -76
- data/modules/passive/cookie_options.rb +8 -20
- data/modules/passive/cookie_xss.rb +9 -21
- data/modules/passive/detect_code.rb +9 -21
- data/modules/passive/detect_fileupload.rb +11 -22
- data/modules/passive/detect_infrastructure.rb +23 -35
- data/modules/passive/detect_one_time_tokens.rb +8 -20
- data/modules/passive/dirindexing.rb +9 -21
- data/modules/passive/disclosure_domino.rb +66 -79
- data/modules/passive/disclosure_emails.rb +9 -21
- data/modules/passive/disclosure_ipaddr.rb +15 -23
- data/modules/passive/filename_as_parameter.rb +8 -20
- data/modules/passive/form_spotter.rb +15 -21
- data/modules/passive/hidden_fields.rb +64 -70
- data/modules/passive/hotspots.rb +13 -22
- data/modules/passive/in_script_parameter.rb +15 -24
- data/modules/passive/multiple_server_headers.rb +8 -20
- data/modules/passive/possible_login.rb +12 -23
- data/modules/passive/redirect_url.rb +10 -22
- data/modules/passive/redirectionz.rb +9 -21
- data/modules/passive/sap-headers.rb +64 -76
- data/modules/passive/xss_dom.rb +10 -21
- data/plugins/catalog/catalog.rb +17 -23
- data/plugins/crawler/crawler.rb +12 -24
- data/plugins/crawler/gui.rb +13 -25
- data/plugins/crawler/gui/auth_frame.rb +278 -290
- data/plugins/crawler/gui/crawler_gui.rb +302 -320
- data/plugins/crawler/gui/general_settings_frame.rb +104 -116
- data/plugins/crawler/gui/hooks_frame.rb +88 -100
- data/plugins/crawler/gui/scope_frame.rb +58 -70
- data/plugins/crawler/gui/settings_tabbook.rb +46 -58
- data/plugins/crawler/gui/status_frame.rb +67 -78
- data/plugins/crawler/lib/bags.rb +26 -38
- data/plugins/crawler/lib/constants.rb +19 -31
- data/plugins/crawler/lib/engine.rb +505 -508
- data/plugins/crawler/lib/grabber.rb +77 -87
- data/plugins/crawler/lib/status.rb +82 -0
- data/plugins/crawler/lib/uri_mp.rb +20 -32
- data/plugins/filefinder/dbs/siebel_paths.txt +1118 -0
- data/plugins/filefinder/dbs/subs-big.lst +31986 -0
- data/plugins/filefinder/filefinder.rb +13 -23
- data/plugins/sqlmap/bin/test.rb +86 -98
- data/plugins/sqlmap/gui.rb +12 -24
- data/plugins/sqlmap/gui/main.rb +226 -238
- data/plugins/sqlmap/gui/options_frame.rb +105 -117
- data/plugins/sqlmap/lib/sqlmap_ctrl.rb +103 -115
- data/plugins/sqlmap/sqlmap.rb +10 -22
- data/plugins/sslchecker/cli/sslchecker_cli.rb +8 -20
- data/plugins/sslchecker/gui/cipher_table.rb +252 -264
- data/plugins/sslchecker/gui/gui.rb +267 -276
- data/plugins/sslchecker/gui/sslchecker.rb +12 -24
- data/plugins/sslchecker/lib/check.rb +172 -80
- data/plugins/wshell/gui/main.rb +115 -127
- data/plugins/wshell/lib/core.rb +85 -97
- data/plugins/wshell/wshell.rb +19 -31
- metadata +14 -6
- data/.yardopts +0 -24
@@ -1,37 +1,25 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# transparent.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
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
|
-
# .
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
9
|
+
|
22
10
|
# @private
|
23
|
-
module Watobo#:nodoc: all
|
24
|
-
module Interceptor
|
25
|
-
module Transparent
|
26
|
-
@nfq_drb = nil
|
27
|
-
def self.start
|
28
|
-
DRb.start_service
|
29
|
-
@nfq_drb = DRbObject.new nil, "druby://127.0.0.1:9090"
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.info(data)
|
33
|
-
@nfq_drb.info(data)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
11
|
+
module Watobo#:nodoc: all
|
12
|
+
module Interceptor
|
13
|
+
module Transparent
|
14
|
+
@nfq_drb = nil
|
15
|
+
def self.start
|
16
|
+
DRb.start_service
|
17
|
+
@nfq_drb = DRbObject.new nil, "druby://127.0.0.1:9090"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.info(data)
|
21
|
+
@nfq_drb.info(data)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
37
25
|
end
|
data/lib/watobo/mixins.rb
CHANGED
@@ -1,33 +1,21 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# mixins.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
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
|
-
# @private
|
23
|
-
module Watobo#:nodoc: all
|
24
|
-
module Mixins
|
25
|
-
mixins_path = File.expand_path(File.join(File.dirname(__FILE__), "mixins"))
|
26
|
-
# puts "* loading mixins #{mixins_path}"
|
27
|
-
Dir.glob("#{mixins_path}/*.rb").each do |cf|
|
28
|
-
puts "+ #{File.basename(cf)}" if $DEBUG
|
29
|
-
require File.join("watobo","mixins", File.basename(cf))
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30
9
|
|
31
|
-
|
32
|
-
|
10
|
+
# @private
|
11
|
+
module Watobo#:nodoc: all
|
12
|
+
module Mixins
|
13
|
+
mixins_path = File.expand_path(File.join(File.dirname(__FILE__), "mixins"))
|
14
|
+
# puts "* loading mixins #{mixins_path}"
|
15
|
+
Dir.glob("#{mixins_path}/*.rb").each do |cf|
|
16
|
+
puts "+ #{File.basename(cf)}" if $DEBUG
|
17
|
+
require File.join("watobo","mixins", File.basename(cf))
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
33
21
|
end
|
@@ -1,50 +1,38 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# check_info.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
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
|
-
# @private
|
23
|
-
module Watobo#:nodoc: all
|
24
|
-
module CheckInfoMixin
|
25
|
-
module InfoMethods
|
26
|
-
def check_name
|
27
|
-
|
28
|
-
#puts self.methods.sort
|
29
|
-
info = instance_variable_get("@info")
|
30
|
-
return nil if info.nil?
|
31
|
-
return info[:check_name]
|
32
|
-
end
|
33
|
-
|
34
|
-
def check_group
|
35
|
-
info = instance_variable_get("@info")
|
36
|
-
return nil if info.nil?
|
37
|
-
return info[:check_group]
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
extend InfoMethods
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
43
9
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
10
|
+
# @private
|
11
|
+
module Watobo#:nodoc: all
|
12
|
+
module CheckInfoMixin
|
13
|
+
module InfoMethods
|
14
|
+
def check_name
|
15
|
+
|
16
|
+
#puts self.methods.sort
|
17
|
+
info = instance_variable_get("@info")
|
18
|
+
return nil if info.nil?
|
19
|
+
return info[:check_name]
|
20
|
+
end
|
21
|
+
|
22
|
+
def check_group
|
23
|
+
info = instance_variable_get("@info")
|
24
|
+
return nil if info.nil?
|
25
|
+
return info[:check_group]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
extend InfoMethods
|
31
|
+
|
32
|
+
def self.included( other )
|
33
|
+
other.extend InfoMethods
|
34
|
+
end
|
35
|
+
#:name => "#{check.info[:check_group]}|#{check.info[:check_name]}",
|
36
|
+
|
37
|
+
end
|
50
38
|
end
|
@@ -1,24 +1,12 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# httpparser.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
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
|
-
# .
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
9
|
+
|
22
10
|
# http://www.ietf.org/rfc/rfc2396.txt
|
23
11
|
# http://en.wikipedia.org/wiki/URI_scheme
|
24
12
|
|
@@ -98,7 +86,7 @@ module Watobo#:nodoc: all
|
|
98
86
|
end
|
99
87
|
|
100
88
|
def method
|
101
|
-
if self.first =~ /(^[^[:space:]]{1,})
|
89
|
+
if self.first =~ /(^[^[:space:]]{1,}) /i then
|
102
90
|
return $1
|
103
91
|
else
|
104
92
|
return nil
|
@@ -373,6 +361,8 @@ module Watobo#:nodoc: all
|
|
373
361
|
begin
|
374
362
|
if self.last =~ /\=.*\&?/i
|
375
363
|
parmlist = self.last.split(/\&/)
|
364
|
+
parmlist.map!{|p| x = p.strip.empty? ? nil : p }
|
365
|
+
parmlist.compact!
|
376
366
|
end
|
377
367
|
rescue => bang
|
378
368
|
# puts self.last.unpack("C*").pack("C*").gsub(/[^[:print:]]/,".")
|
@@ -449,7 +439,7 @@ module Watobo#:nodoc: all
|
|
449
439
|
ct = default_ct
|
450
440
|
self.each do |line|
|
451
441
|
break if line.strip.empty?
|
452
|
-
if line =~ /^Content-Type:
|
442
|
+
if line =~ /^Content-Type:([^;]*);?/i then
|
453
443
|
ct = $1
|
454
444
|
break
|
455
445
|
end
|
@@ -461,7 +451,7 @@ module Watobo#:nodoc: all
|
|
461
451
|
ct = default_ct
|
462
452
|
self.each do |line|
|
463
453
|
break if line.strip.empty?
|
464
|
-
if line =~ /^Content-Type:
|
454
|
+
if line =~ /^Content-Type:(.*)/i then
|
465
455
|
ct = $1.strip
|
466
456
|
break
|
467
457
|
end
|
@@ -475,8 +465,8 @@ module Watobo#:nodoc: all
|
|
475
465
|
ct = -1
|
476
466
|
self.each do |line|
|
477
467
|
break if line.strip.empty?
|
478
|
-
if line =~ /^Content-Length:
|
479
|
-
ct = $1.to_i
|
468
|
+
if line =~ /^Content-Length:(.*)/i then
|
469
|
+
ct = $1.strip.to_i
|
480
470
|
break
|
481
471
|
end
|
482
472
|
end
|
@@ -487,9 +477,9 @@ def content_encoding
|
|
487
477
|
te = TE_NONE
|
488
478
|
self.each do |line|
|
489
479
|
break if line.strip.empty?
|
490
|
-
if line =~ /^Content-Encoding:
|
480
|
+
if line =~ /^Content-Encoding:(.*)/i then
|
491
481
|
dummy = $1.strip
|
492
|
-
|
482
|
+
# puts "Content-Encoding => #{dummy}"
|
493
483
|
te = case dummy
|
494
484
|
when /chunked/i
|
495
485
|
TE_CHUNKED
|
@@ -514,7 +504,7 @@ def content_encoding
|
|
514
504
|
te = TE_NONE
|
515
505
|
self.each do |line|
|
516
506
|
break if line.strip.empty?
|
517
|
-
if line =~ /^Transfer-Encoding:
|
507
|
+
if line =~ /^Transfer-Encoding:(.*)/i then
|
518
508
|
dummy = $1.strip
|
519
509
|
# puts dummy
|
520
510
|
te = case dummy
|
@@ -603,7 +593,7 @@ def content_encoding
|
|
603
593
|
def body
|
604
594
|
begin
|
605
595
|
return nil if self.nil? or self.length < 3
|
606
|
-
return self.last if self[-2].strip.empty?
|
596
|
+
return "#{self.last}" if self[-2].strip.empty?
|
607
597
|
rescue
|
608
598
|
return nil
|
609
599
|
end
|
@@ -627,24 +617,41 @@ def content_encoding
|
|
627
617
|
return false
|
628
618
|
end
|
629
619
|
|
620
|
+
def is_json?
|
621
|
+
ct = self.content_type
|
622
|
+
return true if ct =~ /\/json/i
|
623
|
+
return false
|
624
|
+
end
|
625
|
+
|
630
626
|
def is_xml?
|
631
627
|
ct = self.content_type
|
632
628
|
return true if ct =~ /xml/i
|
633
629
|
return false
|
634
630
|
end
|
635
631
|
|
632
|
+
def is_multipart?
|
633
|
+
ct = self.content_type
|
634
|
+
return true if ct =~ /^multipart/i
|
635
|
+
return false
|
636
|
+
end
|
637
|
+
|
636
638
|
def body_encoded
|
637
639
|
b = self.body
|
638
|
-
cs = self.charset
|
639
640
|
return nil if b.nil?
|
641
|
+
|
642
|
+
cs = self.charset
|
640
643
|
return b.unpack("C*").pack("C*") if cs.nil?
|
644
|
+
|
641
645
|
begin
|
642
|
-
|
646
|
+
# not sure if this is a good idea???
|
647
|
+
#return b.encode(cs, :invalid => :replace, :undef => :replace, :replace => '').unpack("C*").pack("C*")
|
643
648
|
rescue => bang
|
644
|
-
|
645
|
-
|
646
|
-
|
649
|
+
if $DEBUG
|
650
|
+
puts bang
|
651
|
+
puts bang.backtrace
|
652
|
+
end
|
647
653
|
end
|
654
|
+
return b.unpack("C*").pack("C*")
|
648
655
|
end
|
649
656
|
|
650
657
|
def responseCode
|
@@ -692,7 +699,7 @@ end
|
|
692
699
|
self.each do |line|
|
693
700
|
break if line.strip.empty?
|
694
701
|
if line =~ /^Content-Type: .*charset=([^;]*)/i then
|
695
|
-
cs = $1
|
702
|
+
cs = $1.strip
|
696
703
|
break
|
697
704
|
end
|
698
705
|
end
|
@@ -1,24 +1,12 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# request_parser.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
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
|
-
# .
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
9
|
+
|
22
10
|
# @private
|
23
11
|
module Watobo#:nodoc: all
|
24
12
|
module Mixins
|
@@ -1,478 +1,485 @@
|
|
1
|
-
|
1
|
+
#.
|
2
2
|
# shapers.rb
|
3
|
-
|
4
|
-
# Copyright
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
self.first.gsub!(/(
|
64
|
-
end
|
65
|
-
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
self.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
line
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
self
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
self
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
#
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
self.
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
end
|
255
|
-
|
256
|
-
def
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
self.
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
self.
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
self.
|
408
|
-
new_r
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
if self.content_encoding == TE_GZIP or self.transfer_encoding == TE_GZIP
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
end
|
3
|
+
#.
|
4
|
+
# Copyright 2014 by siberas, http://www.siberas.de
|
5
|
+
# This file is part of WATOBO (Web Application Tool Box) http://watobo.sourceforge.com
|
6
|
+
# WATOBO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.
|
7
|
+
# WATOBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
8
|
+
# You should have received a copy of the GNU General Public License along with WATOBO; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
9
|
+
|
10
|
+
# @private
|
11
|
+
module Watobo#:nodoc: all
|
12
|
+
module Mixin
|
13
|
+
module Shaper
|
14
|
+
module Web10
|
15
|
+
include Watobo::Constants
|
16
|
+
def replace_post_parm(parm,value)
|
17
|
+
parm_quoted = Regexp.quote(parm)
|
18
|
+
self.last.gsub!(/([?&]{1}|^)#{parm_quoted}=([^&]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
|
19
|
+
end
|
20
|
+
|
21
|
+
def replace_get_parm(parm,value)
|
22
|
+
parm_quoted = Regexp.quote(parm)
|
23
|
+
self.first.gsub!(/([?&]{1})#{parm_quoted}=([^ &]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
|
24
|
+
end
|
25
|
+
|
26
|
+
def replaceMethod(new_method)
|
27
|
+
self.first.gsub!(/^[^[:space:]]{1,}/i, "#{new_method}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def replaceFileExt(new_file)
|
31
|
+
begin
|
32
|
+
file = new_file.strip
|
33
|
+
file.gsub!(/^\//, "")
|
34
|
+
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1#{file} \\3")
|
35
|
+
rescue => bang
|
36
|
+
puts bang
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def replaceElement(new_element)
|
41
|
+
new_element.gsub!(/^\//, "")
|
42
|
+
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1#{new_element} \\3")
|
43
|
+
end
|
44
|
+
|
45
|
+
def replaceURL(new_url)
|
46
|
+
self.first.gsub!(/(^[^[:space:]]{1,})(.*) (HTTP.*)/i,"\\1 #{new_url} \\3")
|
47
|
+
end
|
48
|
+
|
49
|
+
def replaceQuery(new_query)
|
50
|
+
new_query.gsub!(/^\//, "")
|
51
|
+
self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_query} \\3")
|
52
|
+
end
|
53
|
+
|
54
|
+
def strip_path()
|
55
|
+
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1# \\3")
|
56
|
+
end
|
57
|
+
|
58
|
+
def setDir(dir)
|
59
|
+
dir.strip!
|
60
|
+
dir.gsub!(/^\/+/,"")
|
61
|
+
dir.gsub!(/\/+$/,"")
|
62
|
+
dir += "/" unless dir == ''
|
63
|
+
self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)(.*)( HTTP\/.*)/, "\\1#{dir}\\3")
|
64
|
+
end
|
65
|
+
|
66
|
+
def appendDir(dir)
|
67
|
+
dir.strip!
|
68
|
+
dir.gsub!(/^\//,"")
|
69
|
+
dir << "/" unless dir =~ /\/$/
|
70
|
+
self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*\/).*( HTTP\/.*)/, "\\1#{dir}\\2")
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_post_parm(parm,value)
|
75
|
+
line = self.last
|
76
|
+
return false if line !~ /=/
|
77
|
+
line += "&#{parm}=#{value}"
|
78
|
+
self.pop
|
79
|
+
self.push line
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_get_parm(parm,value)
|
83
|
+
line = self.shift
|
84
|
+
new_p = "&"
|
85
|
+
new_p = "?" if not self.element =~ /\?/
|
86
|
+
new_p += parm
|
87
|
+
line.gsub!(/( HTTP\/.*)/, "#{new_p}=#{value}\\1")
|
88
|
+
self.unshift(line)
|
89
|
+
end
|
90
|
+
|
91
|
+
def addHeader(header, value)
|
92
|
+
self_copy = []
|
93
|
+
self_copy.concat(self.headers)
|
94
|
+
self_copy.push "#{header}: #{value}\r\n"
|
95
|
+
|
96
|
+
unless self.body.nil?
|
97
|
+
self_copy.push "\r\n"
|
98
|
+
#self_copy.concat(self.body)
|
99
|
+
self_copy.push self.body
|
100
|
+
end
|
101
|
+
|
102
|
+
self.replace(self_copy)
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
alias_method :add_header, :addHeader
|
107
|
+
|
108
|
+
def removeURI
|
109
|
+
if self.first =~ /(^[^[:space:]]{1,}) (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/ then
|
110
|
+
uri = $2
|
111
|
+
self.first.gsub!(/(^[^[:space:]]{1,}) (#{Regexp.quote(uri)})/,"\\1 /")
|
112
|
+
# puts "* Removed URI: #{uri}"
|
113
|
+
# puts self.first
|
114
|
+
return uri
|
115
|
+
else
|
116
|
+
return nil
|
117
|
+
end
|
118
|
+
#self.first.gsub!(/^(.*)(https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/,"\\1/")
|
119
|
+
end
|
120
|
+
|
121
|
+
def removeBody
|
122
|
+
self.pop if self[-2].strip.empty?
|
123
|
+
end
|
124
|
+
|
125
|
+
def set_header_UNUSED(header, value)
|
126
|
+
self.each do |h|
|
127
|
+
break if h.strip.empty?
|
128
|
+
if h =~ /^#{header}:/
|
129
|
+
h.replace "#{header}: #{value}\r\n"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_body(content)
|
135
|
+
if self[-2].strip.empty?
|
136
|
+
self.pop
|
137
|
+
else
|
138
|
+
self << "\r\n"
|
139
|
+
end
|
140
|
+
self << content
|
141
|
+
end
|
142
|
+
|
143
|
+
def rewrite_body(pattern, content)
|
144
|
+
if self[-2].strip.empty?
|
145
|
+
puts "rewrite_body ... #{pattern} - #{content}"
|
146
|
+
b = self.pop
|
147
|
+
b.gsub!(/#{pattern}/i, content)
|
148
|
+
self << b
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def restoreURI(uri)
|
153
|
+
if self.first =~ /(^[^[:space:]]{1,}) \/(.*) (HTTP\/.*)/ then
|
154
|
+
method = $1
|
155
|
+
rest = $2
|
156
|
+
http = $3.strip
|
157
|
+
#self.first.gsub!(/^\w*/, "#{method} #{uri}#{rest}")
|
158
|
+
self.shift
|
159
|
+
self.unshift "#{method} #{uri}#{rest} #{http}\r\n"
|
160
|
+
return self.first
|
161
|
+
else
|
162
|
+
return nil
|
163
|
+
end
|
164
|
+
#self.first.gsub!(/^(.*)(https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/,"\\1/")
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# R E M O V E _ H E A D E R
|
169
|
+
#
|
170
|
+
|
171
|
+
def removeHeader(header)
|
172
|
+
begin
|
173
|
+
|
174
|
+
while i = headers.index{|h| h =~ /#{header}/i }
|
175
|
+
self.delete_at i
|
176
|
+
end
|
177
|
+
|
178
|
+
rescue => bang
|
179
|
+
puts bang
|
180
|
+
puts bang.backtrace if $DEBUG
|
181
|
+
puts self
|
182
|
+
puts "====="
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
alias_method :remove_header, :removeHeader
|
187
|
+
|
188
|
+
# removeUrlParms
|
189
|
+
# Function: Remove all parameter within the URL
|
190
|
+
#
|
191
|
+
def removeUrlParms
|
192
|
+
line = self.shift
|
193
|
+
new_line = "#{line}"
|
194
|
+
# get end-of-path-index
|
195
|
+
eop_index = line.rindex(/[^ HTTP]\//)
|
196
|
+
# get start of parms
|
197
|
+
sop_index = line.index(/(\?|&)/, eop_index)
|
198
|
+
# find end-of-url
|
199
|
+
eou_index = line.index(/ HTTP/)
|
200
|
+
|
201
|
+
unless sop_index.nil?
|
202
|
+
new_line = line[0..sop_index-1]
|
203
|
+
new_line += line[eou_index..-1]
|
204
|
+
end
|
205
|
+
|
206
|
+
self.unshift new_line
|
207
|
+
end
|
208
|
+
|
209
|
+
def removeHeader_OLD(header)
|
210
|
+
# p "REMOVE HEADER: #{header}"
|
211
|
+
begin
|
212
|
+
self_copy = []
|
213
|
+
eoh = false
|
214
|
+
self.each do |line|
|
215
|
+
puts self if line.nil?
|
216
|
+
if not eoh == true then
|
217
|
+
if not line =~ /#{header}/i
|
218
|
+
self_copy.push line unless line.nil?
|
219
|
+
end
|
220
|
+
else
|
221
|
+
self_copy.push line unless line.nil?
|
222
|
+
end
|
223
|
+
|
224
|
+
if line and line.strip.empty? then
|
225
|
+
eoh = true
|
226
|
+
end
|
227
|
+
end
|
228
|
+
self.replace(self_copy)
|
229
|
+
|
230
|
+
rescue => bang
|
231
|
+
puts bang
|
232
|
+
puts bang.backtrace if $DEBUG
|
233
|
+
puts self
|
234
|
+
puts "====="
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def replace_header(header, value)
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
def fix_session(pattern,value)
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
def fix_content_length
|
247
|
+
return false if self.body.nil?
|
248
|
+
#TODO: had trouble with length calculation of binary data in multipart request
|
249
|
+
# Workaround: toHex and then calculate length ... very time consuming :(
|
250
|
+
#
|
251
|
+
#blen = self.body.unpack("H*")[0].length / 2
|
252
|
+
blen = self.body.force_encoding("ASCII-8BIT").length
|
253
|
+
set_header("Content-Length" , blen)
|
254
|
+
end
|
255
|
+
|
256
|
+
def fixupContentLength_UNUSED
|
257
|
+
te = self.transferEncoding
|
258
|
+
if te == TE_CHUNKED then
|
259
|
+
# puts "Transfer-Encoding = TE_CHUNKED"
|
260
|
+
# puts self.body
|
261
|
+
self.removeHeader("Transfer-Encoding")
|
262
|
+
self.addHeader("Content-Length", "0")
|
263
|
+
new_r = []
|
264
|
+
new_r.concat self.headers
|
265
|
+
new_r.push "\r\n"
|
266
|
+
|
267
|
+
bytes_to_read = 0
|
268
|
+
body = []
|
269
|
+
is_new_chunk = false
|
270
|
+
|
271
|
+
off = 0
|
272
|
+
new_body = ''
|
273
|
+
|
274
|
+
body_orig = self.body
|
275
|
+
puts body_orig.class
|
276
|
+
while body_orig[off..-1] =~ /^([0-9a-fA-F]{1,6})\r\n/
|
277
|
+
len_raw = "#{$1}"
|
278
|
+
|
279
|
+
len = len_raw.hex
|
280
|
+
|
281
|
+
chunk_start = off + len_raw.length + 2
|
282
|
+
chunk_end = chunk_start + len
|
283
|
+
|
284
|
+
break if len == 0
|
285
|
+
|
286
|
+
new_body.chomp!
|
287
|
+
new_body += "#{body_orig[chunk_start..chunk_end]}"
|
288
|
+
|
289
|
+
off = chunk_end + 2
|
290
|
+
end
|
291
|
+
|
292
|
+
new_r.push new_body
|
293
|
+
self.replace(new_r)
|
294
|
+
self.fix_content_length
|
295
|
+
# puts "= FIXED ="
|
296
|
+
# puts self.headers
|
297
|
+
elsif te == TE_NONE then
|
298
|
+
self.fix_content_length
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|
302
|
+
|
303
|
+
def fixupContentLength
|
304
|
+
self.unchunk
|
305
|
+
self.fix_content_length
|
306
|
+
end
|
307
|
+
|
308
|
+
def setRawQueryParms(parm_string)
|
309
|
+
return nil if parm_string.nil?
|
310
|
+
return nil if parm_string == ''
|
311
|
+
new_r = ""
|
312
|
+
path = Regexp.quote(self.path)
|
313
|
+
#puts path
|
314
|
+
if self.first =~ /(.*#{path})/ then
|
315
|
+
new_r = $1 << "?" << parm_string
|
316
|
+
end
|
317
|
+
self.first.gsub!(/(.*) (HTTP\/.*)/, "#{new_r} \\2")
|
318
|
+
end
|
319
|
+
|
320
|
+
def appendQueryParms(parms)
|
321
|
+
return if parms.nil?
|
322
|
+
return if parms == ''
|
323
|
+
|
324
|
+
puts self.first
|
325
|
+
puts self.file_ext
|
326
|
+
|
327
|
+
pref = (self.file_ext =~ /\?/) ? '&' : '?'
|
328
|
+
puts "append query parms"
|
329
|
+
self.first.gsub!(/(.*) (HTTP\/.*)/, "\\1#{pref}#{parms} \\2")
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
def set_content_length(length)
|
334
|
+
set_header("Content-Length", length)
|
335
|
+
end
|
336
|
+
|
337
|
+
def set_content_type(ctype)
|
338
|
+
set_header("Content-Type", ctype)
|
339
|
+
end
|
340
|
+
|
341
|
+
def set_header(header, value)
|
342
|
+
begin
|
343
|
+
new_header = "#{header}: #{value}\r\n"
|
344
|
+
self.each_with_index do |h, i|
|
345
|
+
if h =~ /^#{Regexp.quote(header)}:/i
|
346
|
+
self[i] = new_header
|
347
|
+
return true
|
348
|
+
end
|
349
|
+
|
350
|
+
if h.strip.empty? or i == self.length-1
|
351
|
+
self.insert(i, new_header)
|
352
|
+
return true
|
353
|
+
end
|
354
|
+
end
|
355
|
+
rescue => bang
|
356
|
+
puts bang
|
357
|
+
end
|
358
|
+
return false
|
359
|
+
end
|
360
|
+
alias :setHeader :set_header
|
361
|
+
|
362
|
+
# sets post data
|
363
|
+
def setData(data)
|
364
|
+
return if data.nil?
|
365
|
+
if self.has_body?
|
366
|
+
self.pop
|
367
|
+
self.push data
|
368
|
+
else
|
369
|
+
self.push("\r\n")
|
370
|
+
self.push data
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def setMethod(method)
|
375
|
+
m = method.is_a?(Symbol) ? method.to_s.upcase : method
|
376
|
+
self.first.gsub!(/(^[^[:space:]]{1,}) /, "#{m} ")
|
377
|
+
end
|
378
|
+
|
379
|
+
alias_method :set_method, :setMethod
|
380
|
+
alias :method= :setMethod
|
381
|
+
|
382
|
+
def setHTTPVersion(version)
|
383
|
+
self.first.gsub!(/HTTP\/(.*)$/, "HTTP\/#{version}")
|
384
|
+
# puts "HTTPVersion fixed: #{self.first}"
|
385
|
+
end
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
module HttpResponse
|
390
|
+
include Watobo::Constants
|
391
|
+
def unchunk!
|
392
|
+
return false unless self.has_body?
|
393
|
+
|
394
|
+
unchunked = self.unchunk
|
395
|
+
self.replace(unchunked)
|
396
|
+
self.fix_content_length
|
397
|
+
|
398
|
+
end
|
399
|
+
|
400
|
+
def unchunk
|
401
|
+
return Response.new(self) unless self.has_body?
|
402
|
+
|
403
|
+
if self.transfer_encoding == TE_CHUNKED then
|
404
|
+
self.removeHeader("Transfer-Encoding")
|
405
|
+
self.addHeader("Content-Length", "0")
|
406
|
+
new_r = []
|
407
|
+
new_r.concat self.headers
|
408
|
+
new_r.push "\r\n"
|
409
|
+
|
410
|
+
bytes_to_read = 20
|
411
|
+
body = []
|
412
|
+
is_new_chunk = false
|
413
|
+
|
414
|
+
off = 0
|
415
|
+
new_body = ''
|
416
|
+
|
417
|
+
body_orig = self.body
|
418
|
+
pattern = '[0-9a-fA-F]+\r?\n'
|
419
|
+
while off >= 0 and off < body_orig.length
|
420
|
+
chunk_pos = body_orig.index(/(#{pattern})/, off)
|
421
|
+
len_raw = $1
|
422
|
+
unless chunk_pos.nil?
|
423
|
+
len = len_raw.strip.hex
|
424
|
+
|
425
|
+
chunk_start = chunk_pos + len_raw.length
|
426
|
+
chunk_end = chunk_start + len
|
427
|
+
|
428
|
+
break if len == 0
|
429
|
+
chunk = "#{body_orig[chunk_start..chunk_end]}"
|
430
|
+
new_body += chunk.chomp
|
431
|
+
off = chunk_end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
new_r.push new_body
|
435
|
+
return Watobo::Response.new new_r
|
436
|
+
|
437
|
+
end
|
438
|
+
return Response.new(self)
|
439
|
+
end
|
440
|
+
|
441
|
+
def unzip!
|
442
|
+
if self.content_encoding == TE_GZIP or self.transfer_encoding == TE_GZIP
|
443
|
+
if self.has_body?
|
444
|
+
unziped = self.unzip_body
|
445
|
+
|
446
|
+
self[-1] = unziped
|
447
|
+
self.removeHeader("Transfer-Encoding") if self.transfer_encoding == TE_GZIP
|
448
|
+
self.removeHeader("Content-Encoding") if self.content_encoding == TE_GZIP
|
449
|
+
self.fix_content_length
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
def unzip
|
456
|
+
if self.content_encoding == TE_GZIP or self.transfer_encoding == TE_GZIP
|
457
|
+
if self.has_body?
|
458
|
+
unzipped = Response.new(self)
|
459
|
+
unzipped.unzip!
|
460
|
+
return unzipped
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
return Response.new(self)
|
465
|
+
end
|
466
|
+
|
467
|
+
def unzip_body
|
468
|
+
begin
|
469
|
+
if self.has_body?
|
470
|
+
gziped = self.last
|
471
|
+
gz = Zlib::GzipReader.new( StringIO.new( gziped ) )
|
472
|
+
data = gz.read
|
473
|
+
return data
|
474
|
+
end
|
475
|
+
|
476
|
+
rescue => bang
|
477
|
+
puts bang
|
478
|
+
end
|
479
|
+
|
480
|
+
end
|
481
|
+
|
482
|
+
end
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|