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,210 @@
1
+ # .
2
+ # request_parser.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Mixins
24
+ # This mixin can be used to parse a String or any object which supports method.to_s into a valid http request string
25
+ module RequestParser
26
+ # This method parses (eval) ruby code which is included in the string.
27
+ # Ruby code is identified by its surrounding delimiters - default: '%%'.
28
+ # For examples the string 'ABC%%"_"*10%%DEFG' will result to 'ABC__________DEFG'
29
+ #
30
+ # Possible prefs:
31
+ #
32
+ # :code_dlmtr [String] - set ruby code delimiter
33
+ def parse_code(prefs={})
34
+ cprefs = { :code_dlmtr => '%%' } # default delimiter for ruby code
35
+ cprefs.update(prefs)
36
+
37
+ pattern="(#{cprefs[:code_dlmtr]}.*?#{cprefs[:code_dlmtr]})"
38
+ request = self.to_s
39
+
40
+ begin
41
+ # puts new_request
42
+ expr = ''
43
+ new_request = ''
44
+ request.split(/\n/).each do |line|
45
+ #puts line.unpack("H*")
46
+ new_line = line
47
+ parsed_line = ''
48
+ pos = 0
49
+ off = 0
50
+ while pos >= 0 and pos < line.length
51
+ /#{pattern}/.match(line[pos..-1])
52
+ match = $1
53
+ break if match.nil?
54
+ #new_line = parsed_line
55
+ expr = match.gsub(/%%/,"")
56
+ puts "DEBUG: executing: #{expr}" if $DEBUG
57
+ result = eval(expr)
58
+ puts "DEBUG: got #{result.class}" if $DEBUG
59
+ if result.is_a? File
60
+ data = result.read
61
+ result.close
62
+
63
+ elsif result.is_a? String
64
+ data = result
65
+ elsif result.is_a? Array
66
+ data = result.join
67
+ else
68
+ log("!!!WATOBO - expression must return String or File !!!",'')
69
+ end
70
+ start = line.index(match)
71
+
72
+ parsed_line += line[off..start-1] if start > 0
73
+ parsed_line += data
74
+ pos = start + match.length
75
+ off = pos
76
+ end
77
+
78
+ unless parsed_line.empty?
79
+ parsed_line += line[off..-1]
80
+ new_request += "#{parsed_line}\n"
81
+ else
82
+ new_request += "#{new_line}\n"
83
+ end
84
+ #puts new_request
85
+ end
86
+
87
+ return new_request
88
+
89
+ rescue SyntaxError, LocalJumpError, NameError => e
90
+ raise SyntaxError, "SyntaxError in '#{expr}'"
91
+ #rescue LocalJumpError => e
92
+ # raise LocalJumpError, "(#{expr}) LocalJumpError!"
93
+ #rescue NameError => e
94
+ # raise NameError, "(#{expr}) NameError!"
95
+ #rescue => e
96
+ # puts e
97
+ # raise e, "(#{expr}) Not a valid expression!"
98
+ end
99
+
100
+ # puts new_request
101
+ return nil
102
+
103
+ end
104
+
105
+ def unchunked( opts = {} )
106
+ options = { :update_content_length => false }
107
+ options.update opts
108
+ begin
109
+ text = parse_code
110
+ eoh = self.index("\n\n")
111
+ unless eoh.nil?
112
+ raw_header = text[0..eoh-1]
113
+ raw_body = text[eoh+1..-1]
114
+ else
115
+ raw_header = text
116
+ raw_body = nil
117
+ end
118
+
119
+ unchunked = raw_header.split("\n")
120
+ unchunked.extend Watobo::Mixin::Parser::Url
121
+ unchunked.extend Watobo::Mixin::Parser::Web10
122
+ unchunked.extend Watobo::Mixin::Shaper::Web10
123
+
124
+ unless raw_body.nil?
125
+ unchunked
126
+ end
127
+
128
+ rescue => bang
129
+ end
130
+ end
131
+
132
+ def to_request(opts={})
133
+ options = { :update_content_length => false }
134
+ options.update opts
135
+ begin
136
+ text = parse_code
137
+ result = []
138
+
139
+ if text =~ /\n\n/
140
+ dummy = text.split(/\n\n/)
141
+ header = dummy.shift.split(/\n/)
142
+ body = dummy.join("\n\n")
143
+ else
144
+ header = text.split(/\n/)
145
+ body = nil
146
+ end
147
+
148
+ header.each do |h|
149
+ result.push "#{h}\r\n"
150
+ end
151
+
152
+ result.extend Watobo::Mixin::Parser::Url
153
+ result.extend Watobo::Mixin::Parser::Web10
154
+ result.extend Watobo::Mixin::Shaper::Web10
155
+
156
+ ct = result.content_type
157
+ # last line is without "\r\n" if text has a body
158
+ if ct =~ /multipart\/form/ and body then
159
+ #Content-Type: multipart/form-data; boundary=---------------------------3035221901842
160
+ if ct =~ /boundary=([\-\w]+)/
161
+ boundary = $1.strip
162
+ chunks = body.split(boundary)
163
+ e = chunks.pop # remove "--"
164
+ new_body = []
165
+ chunks.each do |c|
166
+ new_chunk = ''
167
+ c.gsub!(/[\-]+$/,'')
168
+ next if c.nil?
169
+ next if c.strip.empty?
170
+ c.strip!
171
+ if c =~ /\n\n/
172
+ ctmp = c.split(/\n\n/)
173
+ cheader = ctmp.shift.split(/\n/)
174
+ cbody = ctmp.join("\n\n")
175
+ else
176
+ cheader = c.split(/\n/)
177
+ cbody = nil
178
+ end
179
+ new_chunk = cheader.join("\r\n")
180
+ new_chunk += "\r\n\r\n"
181
+ new_chunk += cbody.strip + "\r\n" if cbody
182
+
183
+ # puts cbody
184
+ new_body.push new_chunk
185
+
186
+ end
187
+ body = "--#{boundary}\r\n"
188
+ body += new_body.join("--#{boundary}\r\n")
189
+ body += "--#{boundary}--"
190
+ end
191
+ # body.gsub!(/\n/, "\r\n") if body
192
+
193
+ end
194
+
195
+ if body then
196
+ result.push "\r\n"
197
+ result.push body.strip
198
+ end
199
+
200
+ result.fixupContentLength() if options[:update_content_length] == true
201
+ return result
202
+ rescue
203
+ raise
204
+ end
205
+ #return nil
206
+ end
207
+
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,345 @@
1
+ # .
2
+ # shapers.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Mixin
24
+ module Shaper
25
+ module Web10
26
+ def replace_post_parm(parm,value)
27
+ parm_quoted = Regexp.quote(parm)
28
+ self.last.gsub!(/([?&]{0,1})#{parm_quoted}=([0-9a-zA-Z\-\._,+<>\%!=]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
29
+ end
30
+
31
+ def replace_get_parm(parm,value)
32
+ parm_quoted = Regexp.quote(parm)
33
+ # puts "replacing parameter #{parm} with value #{value}"
34
+ # self.first.gsub!(/([?&]{0,1})#{parm}=([0-9a-zA-Z\-\._,+<>\%!=]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
35
+ self.first.gsub!(/([?&]{1})#{parm_quoted}=([^ &]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
36
+ end
37
+
38
+ def replaceMethod(new_method)
39
+ self.first.gsub!(/^[^[:space:]]{1,}/i, "#{new_method}")
40
+ end
41
+
42
+ def replaceFileExt(new_file)
43
+ # puts "replace element #{new_element}"
44
+ begin
45
+ new_file.gsub!(/^\//, "")
46
+ self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1#{new_file} \\3")
47
+ rescue => bang
48
+ puts bang
49
+ end
50
+ end
51
+
52
+ def replaceElement(new_element)
53
+ # puts "replace element #{new_element}"
54
+ new_element.gsub!(/^\//, "")
55
+ self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_element} \\3")
56
+ end
57
+
58
+ def replaceURL(new_url)
59
+ self.first.gsub!(/(^[^[:space:]]{1,})(.*) (HTTP.*)/i,"\\1 #{new_url} \\3")
60
+ end
61
+
62
+ def replaceQuery(new_query)
63
+ new_query.gsub!(/^\//, "")
64
+ self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_query} \\3")
65
+ end
66
+
67
+ def strip_path()
68
+ if self.first =~ /(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/).* (HTTP.*)/i then
69
+ new_line = "#{$1} #{$2}"
70
+ self.shift
71
+ self.unshift(new_line)
72
+ end
73
+ # puts "* StripPath: #{self.first}"
74
+ end
75
+
76
+ def setDir(dir)
77
+ dir.strip!
78
+ dir.gsub!(/^\//,"")
79
+ dir.gsub!(/\/$/,"")
80
+ dir += "/" unless dir == ''
81
+ self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)(.*)( HTTP\/.*)/, "\\1#{dir}\\3")
82
+ end
83
+
84
+ def appendDir(dir)
85
+ dir.gsub!(/^\//,"")
86
+ self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*\/).*( HTTP\/.*)/, "\\1#{dir}\\2")
87
+
88
+ end
89
+
90
+ def add_post_parm(parm,value)
91
+ line = self.last
92
+ return false if line !~ /=/
93
+ line += "&#{parm}=#{value}"
94
+ self.pop
95
+ self.push line
96
+ end
97
+
98
+ def add_get_parm(parm,value)
99
+ line = self.shift
100
+ new_p = "&"
101
+ new_p = "?" if not self.element =~ /\?/
102
+ new_p += parm
103
+ line.gsub!(/( HTTP\/.*)/, "#{new_p}=#{value}\\1")
104
+ self.unshift(line)
105
+ end
106
+
107
+ def addHeader(header, value)
108
+ self_copy = []
109
+ self_copy.concat(self.headers)
110
+ self_copy.push "#{header}: #{value}\r\n"
111
+
112
+ unless self.body.nil?
113
+ self_copy.push "\r\n"
114
+ #self_copy.concat(self.body)
115
+ self_copy.push self.body
116
+ end
117
+
118
+ self.replace(self_copy)
119
+
120
+ end
121
+
122
+ def removeURI
123
+ if self.first =~ /(^[^[:space:]]{1,}) (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/ then
124
+ uri = $2
125
+ self.first.gsub!(/(^[^[:space:]]{1,}) (#{Regexp.quote(uri)})/,"\\1 /")
126
+ # puts "* Removed URI: #{uri}"
127
+ # puts self.first
128
+ return uri
129
+ else
130
+ return nil
131
+ end
132
+ #self.first.gsub!(/^(.*)(https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/,"\\1/")
133
+ end
134
+
135
+ def removeBody
136
+ self.pop if self[-2].strip.empty?
137
+ end
138
+
139
+ def restoreURI(uri)
140
+ if self.first =~ /(^[^[:space:]]{1,}) \/(.*) (HTTP\/.*)/ then
141
+ method = $1
142
+ rest = $2
143
+ http = $3.strip
144
+ #self.first.gsub!(/^\w*/, "#{method} #{uri}#{rest}")
145
+ self.shift
146
+ self.unshift "#{method} #{uri}#{rest} #{http}\r\n"
147
+ return self.first
148
+ else
149
+ return nil
150
+ end
151
+ #self.first.gsub!(/^(.*)(https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/,"\\1/")
152
+ end
153
+
154
+ #
155
+ # R E M O V E _ H E A D E R
156
+ #
157
+
158
+ def removeHeader(header)
159
+ begin
160
+ eoh_index = self.length
161
+ eoh_index -= 1 unless self.body.nil?
162
+
163
+ self.delete_if {|x| self.index(x) <= eoh_index and x =~ /#{header}/i }
164
+ rescue => bang
165
+ puts bang
166
+ puts bang.backtrace if $DEBUG
167
+ puts self
168
+ puts "====="
169
+ end
170
+ end
171
+
172
+ # removeUrlParms
173
+ # Function: Remove all parameter within the URL
174
+ #
175
+ def removeUrlParms
176
+ line = self.shift
177
+ new_line = "#{line}"
178
+ # get end-of-path-index
179
+ eop_index = line.rindex(/[^ HTTP]\//)
180
+ # get start of parms
181
+ sop_index = line.index(/(\?|&)/, eop_index)
182
+ # find end-of-url
183
+ eou_index = line.index(/ HTTP/)
184
+
185
+ unless sop_index.nil?
186
+ new_line = line[0..sop_index-1]
187
+ new_line += line[eou_index..-1]
188
+ end
189
+
190
+ self.unshift new_line
191
+ end
192
+
193
+ def removeHeader_OLD(header)
194
+ # p "REMOVE HEADER: #{header}"
195
+ begin
196
+ self_copy = []
197
+ eoh = false
198
+ self.each do |line|
199
+ puts self if line.nil?
200
+ if not eoh == true then
201
+ if not line =~ /#{header}/i
202
+ self_copy.push line unless line.nil?
203
+ end
204
+ else
205
+ self_copy.push line unless line.nil?
206
+ end
207
+
208
+ if line and line.strip.empty? then
209
+ eoh = true
210
+ end
211
+ end
212
+ self.replace(self_copy)
213
+
214
+ rescue => bang
215
+ puts bang
216
+ puts bang.backtrace if $DEBUG
217
+ puts self
218
+ puts "====="
219
+ end
220
+ end
221
+
222
+ def replace_header(header, value)
223
+
224
+ end
225
+
226
+ def fix_session(pattern,value)
227
+
228
+ end
229
+
230
+ def fix_content_length
231
+ return false if self.body.nil?
232
+ eoh_index = self.length - 2
233
+ self.map!{ |x|
234
+ x.gsub!(/^(Content-Length: )(\d+)/, "\\1#{self.body.length.to_s}") if self.index(x) <= eoh_index
235
+ x
236
+ }
237
+ end
238
+
239
+ def fixupContentLength
240
+ te = self.transferEncoding
241
+ if te == Watobo::TE_CHUNKED then
242
+ # puts "Transfer-Encoding = TE_CHUNKED"
243
+ # puts self.body
244
+ self.removeHeader("Transfer-Encoding")
245
+ self.addHeader("Content-Length", "0")
246
+ new = []
247
+ new.concat self.headers
248
+ new.push "\r\n"
249
+
250
+ bytes_to_read = 0
251
+ body = []
252
+ is_new_chunk = false
253
+
254
+ off = 0
255
+ new_body = ''
256
+
257
+ body_orig = self.body
258
+ puts body_orig.class
259
+ while body_orig[off..-1] =~ /^([0-9a-fA-F]{1,6})\r\n/
260
+ len_raw = "#{$1}"
261
+
262
+ len = len_raw.hex
263
+
264
+ chunk_start = off + len_raw.length + 2
265
+ chunk_end = chunk_start + len
266
+
267
+ break if len == 0
268
+
269
+ new_body.chomp!
270
+ new_body += "#{body_orig[chunk_start..chunk_end]}"
271
+
272
+ off = chunk_end + 2
273
+ end
274
+
275
+ new.push new_body
276
+ self.replace(new)
277
+ self.fix_content_length
278
+ # puts "= FIXED ="
279
+ # puts self.headers
280
+ elsif te == Watobo::TE_NONE then
281
+ self.fix_content_length
282
+ end
283
+
284
+ end
285
+
286
+ def setRawQueryParms(parm_string)
287
+ return nil if parm_string.nil?
288
+ return nil if parm_string == ''
289
+ new = ""
290
+ path = Regexp.quote(self.path)
291
+ #puts path
292
+ if self.first =~ /(.*#{path})/ then
293
+ new = $1 << "?" << parm_string
294
+ end
295
+ self.first.gsub!(/(.*) (HTTP\/.*)/, "#{new} \\2")
296
+ end
297
+
298
+ def appendQueryParms(parms)
299
+ return if parms.nil?
300
+ return if parms == ''
301
+
302
+ puts self.first
303
+ puts self.file_ext
304
+
305
+ pref = (self.file_ext =~ /\?/) ? '&' : '?'
306
+ puts "append query parms"
307
+ self.first.gsub!(/(.*) (HTTP\/.*)/, "\\1#{pref}#{parms} \\2")
308
+
309
+ end
310
+
311
+ def setCookie(cname="Cookie", value=nil)
312
+ return nil if value.nil?
313
+
314
+ self.map!{ |l|
315
+ break if l.strip.empty?
316
+ if l =~ /^#{cname}:/i
317
+ l = "#{cname}: #{value}"
318
+ end
319
+ }
320
+ end
321
+
322
+ # sets post data
323
+ def setData(data)
324
+ return if data.nil?
325
+ if self.has_body?
326
+ self.pop
327
+ self.push data
328
+ else
329
+ self.push("\r\n")
330
+ self.push data
331
+ end
332
+ end
333
+
334
+ def setMethod(method)
335
+ self.first.gsub!(/(^[^[:space:]]{1,}) /, "#{method} ")
336
+ end
337
+
338
+ def setHTTPVersion(version)
339
+ self.first.gsub!(/HTTP\/(.*)$/, "HTTP\/#{version}")
340
+ # puts "HTTPVersion fixed: #{self.first}"
341
+ end
342
+ end
343
+ end
344
+ end
345
+ end
@@ -0,0 +1,88 @@
1
+ # .
2
+ # transcoders.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Mixin
24
+ module Transcoders
25
+
26
+ def url_encode
27
+ CGI::escape(self)
28
+ end
29
+
30
+ def url_decode
31
+ CGI::unescape(self)
32
+ end
33
+
34
+
35
+ def b64decode
36
+ begin
37
+ b64string = self
38
+ rs = Base64.decode64(b64string)
39
+ return rs
40
+ rescue
41
+ return ""
42
+ end
43
+ end
44
+
45
+
46
+ def b64encode
47
+ begin
48
+ plain = self
49
+ rs = Base64.encode64(plain)
50
+ # we only need a simple string without linebreaks
51
+ rs.gsub!(/\n/,'')
52
+ rs.strip!
53
+ return rs
54
+ rescue
55
+ return ""
56
+ end
57
+ end
58
+
59
+ def hex2int
60
+ begin
61
+ plain = self.strip
62
+ if plain =~ /^[0-9a-fA-F]{1,8}$/ then
63
+ return plain.hex
64
+ else
65
+ return ""
66
+ end
67
+ rescue
68
+ return ""
69
+ end
70
+ end
71
+
72
+ def hexencode
73
+ begin
74
+
75
+
76
+ self.unpack("H*")[0]
77
+ rescue
78
+ return ""
79
+ end
80
+
81
+ end
82
+ def hexdecode
83
+
84
+ [ self ].pack("H*")
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,32 @@
1
+ # .
2
+ # mixins.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Mixins
24
+ mixins_path = File.expand_path(File.join(File.dirname(__FILE__), "mixins"))
25
+ # puts "* loading mixins #{mixins_path}"
26
+ Dir.glob("#{mixins_path}/*.rb").each do |cf|
27
+ puts "+ #{File.basename(cf)}" if $DEBUG
28
+ require File.join("watobo","mixins", File.basename(cf))
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ # .
2
+ # check_regex.rb
3
+ #
4
+ # Copyright 2012 by siberas, http://www.siberas.de
5
+ #
6
+ # This file is part of WATOBO (Web Application Tool Box)
7
+ # http://watobo.sourceforge.com
8
+ #
9
+ # WATOBO is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation version 2 of the License.
12
+ #
13
+ # WATOBO is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with WATOBO; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ # .
22
+ module Watobo
23
+ module Utils
24
+ def Utils.checkRegex(pattern)
25
+ begin
26
+ # use nice string to test pattern ;)
27
+ "watobo rocks!!!" =~ /#{pattern}/i
28
+ return true
29
+ rescue => bang
30
+ # puts bang
31
+ return false, bang
32
+ end
33
+ end
34
+
35
+ end #--- Utils
36
+ end #---Watobo