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,664 @@
1
+ # .
2
+ # httpparser.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
+ # http://www.ietf.org/rfc/rfc2396.txt
23
+ # http://en.wikipedia.org/wiki/URI_scheme
24
+
25
+ #
26
+ # http://www.mysite.com:80/my/path/show.php?p=aaa&debug=true
27
+ #
28
+ # proto = "http"
29
+ # host = "www.mysite.com"
30
+ # site = "www.mysite.com:80"
31
+ # dir = "my/path"
32
+ # file = "show.php"
33
+ # file_ext = "show.php?p=aaa&debug=true"
34
+ # path = "my/path/show.php"
35
+ # query = "p=aaa&debug=true"
36
+ # fext = "php"
37
+ # path_ext = "my/path/show.php?p=aaa&debug=true"
38
+
39
+ module Watobo
40
+ module Mixin
41
+ module Parser
42
+ module Url
43
+ include Watobo::Constants
44
+ def file
45
+ @file ||= nil
46
+ return @file unless @file.nil?
47
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
48
+ tmp = $1
49
+ end_of_file_index = tmp.index(/\?/)
50
+
51
+ if end_of_file_index.nil?
52
+ @file = tmp
53
+ elsif end_of_file_index == 0
54
+ @file = ""
55
+ else
56
+ @file = tmp[0..end_of_file_index-1]
57
+ end
58
+
59
+ else
60
+ @file = ""
61
+ end
62
+ end
63
+
64
+ def file_ext
65
+ @file_ext ||= nil
66
+ return @file_ext unless @file_ext.nil?
67
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
68
+ @file_ext = $1
69
+ else
70
+ @file_ext = ''
71
+ end
72
+ end
73
+
74
+ # returns a string containing all urlparms
75
+ # e.g. "parm1=first&parm2=second"
76
+ def urlparms
77
+ begin
78
+ off = self.first.index('?')
79
+ return nil if off.nil?
80
+ eop = self.first.index(' HTTP/')
81
+ return nil if eop.nil?
82
+ parms = self.first[off+1..eop-1]
83
+ return parms
84
+ rescue => bang
85
+ puts bang
86
+ puts bang.backtrace if $DEBUG
87
+ end
88
+ return nil
89
+ end
90
+
91
+ def method
92
+ if self.first =~ /(^[^[:space:]]{1,}) http/i then
93
+ return $1
94
+ else
95
+ return nil
96
+ end
97
+ end
98
+
99
+ #The path may consist of a sequence of path segments separated by a
100
+ #single slash "/" character. Within a path segment, the characters
101
+ #"/", ";", "=", and "?" are reserved. Each path segment may include a
102
+ #sequence of parameters, indicated by the semicolon ";" character.
103
+ #The parameters are not significant to the parsing of relative
104
+ #references.
105
+
106
+ #
107
+ # http://www.mysite.com:80/my/path/show.php?p=aaa&debug=true
108
+ # path = "my/path/show.php"
109
+ def path
110
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*).* HTTP/i then
111
+ return $1
112
+ else
113
+ return ""
114
+ end
115
+ end
116
+
117
+ # path_ext = "my/path/show.php?p=aaa&debug=true"
118
+ def path_ext
119
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/(.*) HTTP\//i then
120
+ return $1
121
+ else
122
+ return ""
123
+ end
124
+ end
125
+
126
+ def dir
127
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*)\/.* HTTP/i then
128
+ return $1
129
+ else
130
+ return ""
131
+ end
132
+ end
133
+
134
+ def query
135
+ begin
136
+ q = nil
137
+ if self.first =~ /^[^[:space:]]{1,} (.*) HTTP.*/ then
138
+ uri = $1
139
+ end
140
+ off = uri.index('?')
141
+ #parts.shift
142
+ # puts "HTTPParser.query: #{parts.join('?')}"
143
+ return "" if off.nil?
144
+ return uri[off+1..-1]
145
+ rescue => bang
146
+ puts "!!! Could not parse query !!!"
147
+ puts bang
148
+ puts bang.backtrace if $DEBUG
149
+ end
150
+ return ''
151
+
152
+ end
153
+
154
+ def element
155
+ cl = self.first.gsub(/\?+/,"?")
156
+ cl.gsub!(/ HTTP.*/, '')
157
+ dummy = cl.split('?').first
158
+ if dummy =~ /^[^[:space:]]{1,} (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}).*\/(.*)/i then
159
+ return $2
160
+ else
161
+ return ""
162
+ end
163
+ end
164
+
165
+ def doctype
166
+ /.*\/.*?\.(\w{2,4})(\?| )/.match(self.first)
167
+ # puts $1
168
+ return $1 unless $1.nil?
169
+ return ''
170
+ #dummy = self.first.gsub(/\?+/,"?")
171
+ #parts = dummy.split('?')
172
+ #parts[0].gsub!(/ HTTP\/(.*)/i,"")
173
+ #if parts[0] =~ /(.*\.)(\w{2,3})$/i then
174
+ # return $2
175
+ #else
176
+ # return ''
177
+ #end
178
+ end
179
+
180
+ def proto
181
+ @proto ||= nil
182
+ return @proto unless @proto.nil?
183
+ @proto = "http" if self.first =~ /^[^[:space:]]{1,} http:\/\//i
184
+ # puts dummy
185
+ @proto = "https" if self.first =~ /^[^[:space:]]{1,} https:\/\//i
186
+ @proto
187
+ end
188
+
189
+ def is_ssl?
190
+ return true if self.first =~ /^[^[:space:]]{1,} https/i
191
+ return false
192
+ end
193
+
194
+ def is_chunked?
195
+ self.each do |h|
196
+ return true if h =~ /^Transfer-Encoding.*chunked/i
197
+ break if h.strip.empty?
198
+ end
199
+ return false
200
+ end
201
+
202
+ def url
203
+ @url ||= nil
204
+ return @url unless @url.nil?
205
+ if self.first =~ /^[^[:space:]]{1,} (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*) HTTP\//i then
206
+ @url = $1
207
+ else
208
+ @url = ''
209
+ end
210
+ @url
211
+ end
212
+
213
+ def site
214
+ @site ||= nil
215
+ return @site unless @site.nil?
216
+ if self.first =~ /^[^[:space:]]{1,} (https?):\/\/([\-0-9a-zA-Z.]*)([:0-9]{0,6})/i then
217
+ host = $2
218
+ port_extension = $3
219
+ proto = $1
220
+ s = host + port_extension
221
+ if port_extension == ''
222
+ s = host + ":" + DEFAULT_PORT_HTTPS.to_s if proto =~ /^https$/i
223
+ s = host + ":" + DEFAULT_PORT_HTTP.to_s if proto =~ /^http$/i
224
+ end
225
+ @site = s
226
+ else
227
+ @site = nil
228
+ end
229
+ @site
230
+ end
231
+
232
+ def host
233
+ @host ||= nil
234
+ return @host unless @host.nil?
235
+ if self.first =~ /^[^[:space:]]{1,} https?:\/\/([\-0-9a-zA-Z.]*)[:0-9]{0,6}/i then
236
+ @host = $1
237
+ else
238
+ @host = ''
239
+ end
240
+ @host
241
+ end
242
+
243
+ # returns all subdir combinations
244
+ # www.company.com/this/is/my/path.php
245
+ # returns:
246
+ # [ "/this", "/this/is", "/this/is/my" ]
247
+ def subDirs
248
+ sub_dirs = self.dir.split(/\//)
249
+ dir = ""
250
+ sub_dirs.map! do |d| dir += "/" + d ; end
251
+ return sub_dirs
252
+ end
253
+
254
+ def port
255
+ return nil if self.first.nil?
256
+ dummy = self.first
257
+ portnum = nil
258
+ parts = dummy.split('?')
259
+
260
+ if parts[0] =~ /^[^[:space:]]{1,} https:\/\//i then
261
+ portnum = 443
262
+ elsif parts[0] =~ /^[^[:space:]]{1,} http:\/\//i
263
+ portnum = 80
264
+ end
265
+ if parts[0] =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*:([0-9]{0,6})/i then
266
+ portnum = $1
267
+ end
268
+ return portnum
269
+ end
270
+
271
+ # get_parms returns an array of parm=value
272
+ def get_parms
273
+ begin
274
+ off = self.first.index('?')
275
+ return [] if off.nil?
276
+ eop = self.first.index(' HTTP/')
277
+ return [] if eop.nil?
278
+ parms = self.first[off+1..eop-1].split('&').select {|x| x =~ /=/ }
279
+ # puts parms
280
+ return parms
281
+ rescue => bang
282
+ puts bang
283
+ puts bang.backtrace if $DEBUG
284
+ end
285
+ return []
286
+ #parmlist=[]
287
+ #if self.first =~ /^[^[:space:]]{1,} (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}).*\/.*(\?.*=.*) HTTP/i then
288
+ # dummy = $2.gsub!(/\?+/,"?").split('?')
289
+ # remove left part of ? from url
290
+ # dummy.shift
291
+
292
+ # parmlist=dummy.join.split(/\&/)
293
+ #end
294
+ #return parmlist
295
+
296
+ end
297
+
298
+ #################### doubles
299
+
300
+ def get_parm_names
301
+
302
+ parm_names=[]
303
+ parmlist=[]
304
+ parmlist.concat(get_parms)
305
+
306
+ parmlist.each do |p|
307
+ if p then
308
+ p.gsub!(/=.*/,'')
309
+ parm_names.push p
310
+ end
311
+ end
312
+
313
+ return parm_names
314
+
315
+ end
316
+
317
+ def get_parm_value(parm_name)
318
+ parm_value = ""
319
+ self.get_parms.each do |parm|
320
+ if parm =~ /^#{Regexp.quote(parm_name)}=/i then
321
+ dummy = parm.split(/=/)
322
+ if dummy.length > 1 then
323
+ # parm_value=dummy[1].gsub(/^[ ]*/,"")
324
+ parm_value=dummy[1].strip
325
+ end
326
+ end
327
+ end
328
+ return parm_value
329
+ end
330
+
331
+ def post_parm_value(parm_name)
332
+ parm_value=""
333
+ self.post_parms.each do |parm|
334
+ if parm =~ /#{Regexp.quote(parm_name)}/i then
335
+ dummy = parm.split(/=/)
336
+ if dummy.length > 1 then
337
+ parm_value = dummy[1].strip
338
+ else
339
+ # puts "Uhhhh ... need parameter value from '#{parm}''"
340
+ end
341
+ end
342
+ end
343
+ return parm_value
344
+ end
345
+
346
+ end
347
+
348
+ module Web10
349
+
350
+ def post_parms
351
+ parmlist=[]
352
+ begin
353
+ if self.last =~ /\=.*\&?/i
354
+ parmlist = self.last.split(/\&/)
355
+ end
356
+ rescue => bang
357
+ puts bang
358
+ puts self.last.unpack("C*").pack("C*").gsub(/[^[:print:]]/,".")
359
+ if $DEBUG
360
+ puts bang.backtrace
361
+
362
+ end
363
+ end
364
+ return parmlist
365
+ end
366
+
367
+ def parms
368
+ parmlist=[]
369
+ parmlist.concat(get_parms)
370
+ parmlist.concat(post_parms)
371
+
372
+ return parmlist
373
+ end
374
+
375
+ def parm_names
376
+ parm_names=[]
377
+ parmlist=[]
378
+ parmlist.concat(get_parms)
379
+ parmlist.concat(post_parms)
380
+ parmlist.each do |p|
381
+ p.gsub!(/=.*/,'')
382
+ parm_names.push p
383
+ end
384
+
385
+ return parm_names
386
+
387
+ end
388
+
389
+ def post_parm_names
390
+
391
+ parm_names=[]
392
+ parmlist=[]
393
+
394
+ parmlist.concat(post_parms)
395
+ parmlist.each do |p|
396
+ if p then
397
+ p.gsub!(/=.*/,'')
398
+ parm_names.push p
399
+ end
400
+ end
401
+
402
+ return parm_names
403
+
404
+ end
405
+
406
+ # def get_parm_names
407
+
408
+ # parm_names=[]
409
+ # parmlist=[]
410
+ # parmlist.concat(get_parms)
411
+
412
+ # parmlist.each do |p|
413
+ # if p then
414
+ # p.gsub!(/=.*/,'')
415
+ # parm_names.push p
416
+ # end
417
+ # end
418
+
419
+ # return parm_names
420
+
421
+ # end
422
+
423
+ def header_value(header_name)
424
+ header_values =[]
425
+ self.headers.each do |header|
426
+ begin
427
+ if header =~ /^#{header_name}/i then
428
+ dummy = header.split(/:/)
429
+ value=dummy[1]
430
+ value.gsub!(/^[ ]*/,"")
431
+ header_values.push value
432
+ end
433
+ rescue => bang
434
+ puts bang
435
+ puts bang.backtrace if $DEBUG
436
+ end
437
+ end
438
+ return header_values
439
+ end
440
+
441
+ def content_type
442
+ ct = "undefined"
443
+ self.each do |line|
444
+ break if line.strip.empty?
445
+ if line =~ /^Content-Type: (.*)/i then
446
+ ct = $1
447
+ break
448
+ end
449
+ end
450
+ return ct.strip
451
+ end
452
+
453
+ def content_length
454
+ # Note: Calculate Chunk-Encoded Content-Length
455
+ # this is only possible if the whole body is loaded???
456
+ ct = -1
457
+ self.each do |line|
458
+ break if line.strip.empty?
459
+ if line =~ /^Content-Length: (.*)/i then
460
+ ct = $1.to_i
461
+ break
462
+ end
463
+ end
464
+ return ct
465
+ end
466
+
467
+ def transferEncoding
468
+ te = TE_NONE
469
+ self.each do |line|
470
+ break if line.strip.empty?
471
+ if line =~ /^Transfer-Encoding: (.*)/i then
472
+ dummy = $1.strip
473
+ puts dummy
474
+ te = case dummy
475
+ when 'chunked'
476
+ Watobo::TE_CHUNKED
477
+ when 'compress'
478
+ Watobo::TE_COMPRESS
479
+ when 'zip'
480
+ Watobo::TE_GZIP
481
+ when 'deflate'
482
+ Watobo::TE_DEFLATE
483
+ when 'identity'
484
+ Watobo::TE_IDENTITY
485
+ else
486
+ Watobo::TE_NONE
487
+ end
488
+ break
489
+ end
490
+ end
491
+ return te
492
+ end
493
+
494
+ def contentMD5
495
+ b = self.body.nil? ? "" : self.body
496
+ hash = Digest::MD5.hexdigest(b)
497
+ return hash
498
+ end
499
+
500
+ # def get_parm_value(parm_name)
501
+ # parm_value = ""
502
+ # self.get_parms.each do |parm|
503
+ # if parm =~ /^#{Regexp.quote(parm_name)}=/i then
504
+ # dummy = parm.split(/=/)
505
+ # if dummy.length > 1 then
506
+ # # parm_value=dummy[1].gsub(/^[ ]*/,"")
507
+ # parm_value=dummy[1].strip
508
+ # end
509
+ # end
510
+ # end
511
+ # return parm_value
512
+ # end
513
+
514
+ def post_parm_value(parm_name)
515
+ parm_value=""
516
+ self.post_parms.each do |parm|
517
+ if parm =~ /#{Regexp.quote(parm_name)}/i then
518
+ dummy = parm.split(/=/)
519
+ if dummy.length > 1 then
520
+ parm_value = dummy[1].strip
521
+ else
522
+ # puts "Uhhhh ... need parameter value from '#{parm}''"
523
+ end
524
+ end
525
+ end
526
+ return parm_value
527
+ end
528
+
529
+ def has_body?
530
+ self.body.nil? ? false : true
531
+ end
532
+
533
+ def has_header?(name)
534
+ self.each do |l|
535
+ return false if l.strip.empty?
536
+ return true if l =~ /^#{name}:/i
537
+ end
538
+ return false
539
+ end
540
+
541
+ def body
542
+ begin
543
+ #return nil if self.nil?
544
+ return self.last if self[-2].strip.empty?
545
+ rescue
546
+ return nil
547
+ end
548
+ end
549
+
550
+ def responseCode
551
+ if self.first =~ /^HTTP\/... (\d+) /
552
+ return $1
553
+ else
554
+ return nil
555
+ end
556
+ end
557
+
558
+ # returns array of new cookies
559
+ # Set-Cookie: mycookie=b41dc9e55d6163f78321996b10c940edcec1b4e55a76464c4e9d25e160ac0ec5b769806b; Path=/
560
+ def new_cookies(&b)
561
+ nc = []
562
+ headers("Set-Cookie") do |h|
563
+ cookie = Watobo::Cookie.new(h)
564
+ yield cookie if block_given?
565
+ nc.push cookie
566
+ end
567
+ end
568
+
569
+ def status
570
+ begin
571
+ # Filter bad utf-8 chars
572
+ dummy = self.first.unpack("C*").pack("C*")
573
+
574
+ if dummy =~ /^HTTP\/1\.\d{1,2} (.*)/i then
575
+ return $1.chomp
576
+ else
577
+ return ''
578
+ end
579
+ rescue => bang
580
+ puts "! No Status Available !".upcase
581
+ puts bang
582
+ puts bang.backtrace if $DEBUG
583
+ return nil
584
+ end
585
+ end
586
+
587
+ def headers(filter=nil, &b)
588
+ begin
589
+ header_list=[]
590
+ self.each do |line|
591
+ cl = line.unpack("C*").pack("C*")
592
+ return header_list if cl.strip.empty?
593
+ unless filter.nil?
594
+ if cl =~ /#{filter}/
595
+ yield line if block_given?
596
+ header_list.push line
597
+ end
598
+ else
599
+ yield line if block_given?
600
+ header_list.push line
601
+ end
602
+ end
603
+ return header_list
604
+ rescue => bang
605
+ puts "! no headers available !".upcase
606
+ puts bang
607
+ if $DEBUG
608
+ puts bang.backtrace
609
+ puts self.to_yaml
610
+ end
611
+ return nil
612
+ end
613
+ end
614
+
615
+ def cookies
616
+ cookie_list=[]
617
+ self.headers.each do |line|
618
+ if line =~ /Cookie2?: (.*)/i then
619
+ clist = $1.split(";")
620
+ clist.each do |c|
621
+ # c.gsub!(/^[ ]+/,"")
622
+ # c.chomp!
623
+ cookie_list.push c.strip
624
+ end
625
+ end
626
+ end
627
+ return cookie_list
628
+ end
629
+
630
+ def data
631
+ return self.last.strip if self.last =~ /\=.*\&?/i
632
+ return ""
633
+ end
634
+
635
+ end
636
+
637
+ ############################################################
638
+ # R E S P O N S E P A R S E R M I X I N
639
+ ###############################################################
640
+ module ResponseParser
641
+ def status
642
+ dummy = self.first
643
+
644
+ if dummy =~ /HTTP\/1.. (.*)/i then
645
+ return $1.chomp
646
+ else
647
+ return nil
648
+ end
649
+ end
650
+
651
+
652
+ def headers(&b)
653
+ header=[]
654
+ self.each do |line|
655
+ return header if line.strip.empty?
656
+ yield line if block_given?
657
+ header.push line
658
+ end
659
+ return nil
660
+ end
661
+ end
662
+ end
663
+ end
664
+ end