arachni 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +37 -0
  3. data/README.md +18 -3
  4. data/lib/arachni/element/capabilities/auditable.rb +5 -1
  5. data/lib/arachni/element/capabilities/auditable/taint.rb +37 -2
  6. data/lib/arachni/platform/fingerprinter.rb +4 -4
  7. data/lib/arachni/platform/manager.rb +15 -1
  8. data/lib/arachni/platforms.rb +2 -1
  9. data/lib/arachni/rpc/server/framework/distributor.rb +2 -2
  10. data/lib/arachni/spider.rb +1 -1
  11. data/lib/arachni/ui/cli/utilities.rb +1 -1
  12. data/lib/version +1 -1
  13. data/modules/audit/file_inclusion.rb +126 -0
  14. data/modules/audit/os_cmd_injection.rb +11 -9
  15. data/modules/audit/path_traversal.rb +21 -21
  16. data/modules/audit/source_code_disclosure.rb +16 -15
  17. data/modules/audit/sqli.rb +13 -6
  18. data/modules/audit/sqli/patterns/access +3 -0
  19. data/modules/audit/sqli/patterns/coldfusion +1 -0
  20. data/modules/audit/sqli/patterns/db2 +5 -0
  21. data/modules/audit/sqli/patterns/emc +2 -0
  22. data/modules/audit/sqli/patterns/firebird +2 -0
  23. data/modules/audit/sqli/patterns/frontbase +1 -0
  24. data/modules/audit/sqli/patterns/hsqldb +1 -0
  25. data/modules/audit/sqli/patterns/informix +3 -0
  26. data/modules/audit/sqli/patterns/ingres +3 -0
  27. data/modules/audit/sqli/patterns/interbase +2 -0
  28. data/modules/audit/sqli/patterns/maxdb +2 -0
  29. data/modules/audit/sqli/patterns/mssql +24 -0
  30. data/modules/audit/sqli/patterns/mysql +15 -0
  31. data/modules/audit/sqli/patterns/oracle +6 -0
  32. data/modules/audit/sqli/patterns/pgsql +8 -0
  33. data/modules/audit/sqli/patterns/sqlite +5 -0
  34. data/modules/audit/sqli/patterns/sybase +3 -0
  35. data/modules/recon/common_files/filenames.txt +1 -0
  36. data/modules/recon/localstart_asp.rb +67 -0
  37. data/path_extractors/comments.rb +30 -0
  38. data/path_extractors/meta_refresh.rb +8 -4
  39. data/plugins/uncommon_headers.rb +91 -0
  40. data/reports/html/default/issue.erb +1 -1
  41. data/reports/html/default/plugins.erb +3 -3
  42. data/reports/plugin_formatters/html/uncommon_headers.rb +47 -0
  43. data/reports/plugin_formatters/stdout/uncommon_headers.rb +37 -0
  44. data/reports/plugin_formatters/xml/discovery.rb +2 -0
  45. data/reports/plugin_formatters/xml/timing_attacks.rb +2 -0
  46. data/reports/plugin_formatters/xml/uncommon_headers.rb +38 -0
  47. data/reports/plugin_formatters/xml/uniformity.rb +2 -1
  48. data/reports/xml/buffer.rb +9 -5
  49. data/spec/arachni/element/capabilities/auditable/taint_spec.rb +295 -82
  50. data/spec/arachni/framework_spec.rb +48 -35
  51. data/spec/arachni/platform/manager_spec.rb +3 -2
  52. data/spec/modules/audit/file_inclusion_spec.rb +25 -0
  53. data/spec/modules/audit/path_traversal_spec.rb +3 -3
  54. data/spec/modules/audit/sqli_spec.rb +2 -1
  55. data/spec/modules/recon/localstart_asp_spec.rb +19 -0
  56. data/spec/path_extractors/comments_spec.rb +22 -0
  57. data/spec/path_extractors/meta_refresh_spec.rb +3 -3
  58. data/spec/plugins/uncommon_headers_spec.rb +64 -0
  59. data/spec/support/logs/Dispatcher - 1755-58492.log +9 -0
  60. data/spec/support/logs/Dispatcher - 1783-39171.log +21 -0
  61. data/spec/support/logs/Dispatcher - 1920-39032.log +9 -0
  62. data/spec/support/logs/Dispatcher - 1931-5309.log +19 -0
  63. data/spec/support/logs/Dispatcher - 1943-59691.log +17 -0
  64. data/spec/support/logs/Dispatcher - 1953-29898.log +13 -0
  65. data/spec/support/logs/Dispatcher - 1962-41002.log +9 -0
  66. data/spec/support/logs/Dispatcher - 1973-27626.log +9 -0
  67. data/spec/support/logs/Dispatcher - 1983-18043.log +11 -0
  68. data/spec/support/logs/Dispatcher - 1996-23139.log +11 -0
  69. data/spec/support/logs/Dispatcher - 2010-10568.log +35 -0
  70. data/spec/support/logs/Dispatcher - 2072-29284.log +21 -0
  71. data/spec/support/logs/Dispatcher - 2081-3234.log +21 -0
  72. data/spec/support/logs/Dispatcher - 2090-18129.log +23 -0
  73. data/spec/support/logs/Dispatcher - 2132-43806.log +19 -0
  74. data/spec/support/logs/Dispatcher - 2141-1327.log +17 -0
  75. data/spec/support/logs/Dispatcher - 2150-52559.log +15 -0
  76. data/spec/support/logs/Dispatcher - 2163-60400.log +11 -0
  77. data/spec/support/logs/Dispatcher - 2176-6021.log +9 -0
  78. data/spec/support/logs/Dispatcher - 2185-22991.log +9 -0
  79. data/spec/support/logs/Dispatcher - 2194-15317.log +9 -0
  80. data/spec/support/logs/Dispatcher - 2203-51674.log +9 -0
  81. data/spec/support/logs/Dispatcher - 2212-25563.log +11 -0
  82. data/spec/support/logs/Dispatcher - 2225-7249.log +9 -0
  83. data/spec/support/logs/Dispatcher - 2234-36714.log +9 -0
  84. data/spec/support/logs/Dispatcher - 2291-34161.log +63 -0
  85. data/spec/support/logs/Dispatcher - 2300-29645.log +43 -0
  86. data/spec/support/logs/Dispatcher - 2309-26961.log +39 -0
  87. data/spec/support/logs/Dispatcher - 2320-25486.log +34 -0
  88. data/spec/support/logs/Dispatcher - 2394-20678.log +28 -0
  89. data/spec/support/logs/Dispatcher - 2409-35315.log +21 -0
  90. data/spec/support/logs/Dispatcher - 2428-13197.log +13 -0
  91. data/spec/support/logs/Dispatcher - 2444-26232.log +9 -0
  92. data/spec/support/logs/Dispatcher - 2573-19232.log +19 -0
  93. data/spec/support/logs/Dispatcher - 2583-26954.log +21 -0
  94. data/spec/support/logs/Dispatcher - 2592-57040.log +15 -0
  95. data/spec/support/logs/Dispatcher - 2606-55321.log +19 -0
  96. data/spec/support/logs/Dispatcher - 2615-56847.log +21 -0
  97. data/spec/support/logs/Dispatcher - 2624-51835.log +15 -0
  98. data/spec/support/logs/Dispatcher - 2745-54916.log +17 -0
  99. data/spec/support/logs/Dispatcher - 2754-32405.log +21 -0
  100. data/spec/support/logs/Dispatcher - 2763-13372.log +13 -0
  101. data/spec/support/logs/Dispatcher - 2776-6861.log +19 -0
  102. data/spec/support/logs/Dispatcher - 2785-19122.log +21 -0
  103. data/spec/support/logs/Dispatcher - 2794-54279.log +15 -0
  104. data/spec/support/logs/Dispatcher - 2847-13871.log +17 -0
  105. data/spec/support/logs/Dispatcher - 2856-56546.log +21 -0
  106. data/spec/support/logs/Dispatcher - 2865-22921.log +13 -0
  107. data/spec/support/logs/Dispatcher - 2878-27922.log +17 -0
  108. data/spec/support/logs/Dispatcher - 2888-5399.log +21 -0
  109. data/spec/support/logs/Dispatcher - 2897-6079.log +13 -0
  110. data/spec/support/logs/Dispatcher - 3129-24131.log +19 -0
  111. data/spec/support/logs/Dispatcher - 3139-17731.log +21 -0
  112. data/spec/support/logs/Dispatcher - 3148-33704.log +15 -0
  113. data/spec/support/logs/Dispatcher - 3172-16517.log +21 -0
  114. data/spec/support/logs/Dispatcher - 3181-26384.log +25 -0
  115. data/spec/support/logs/Dispatcher - 3190-37513.log +15 -0
  116. data/spec/support/logs/Dispatcher - 3232-40996.log +17 -0
  117. data/spec/support/logs/Dispatcher - 3241-14948.log +21 -0
  118. data/spec/support/logs/Dispatcher - 3250-40285.log +13 -0
  119. data/spec/support/logs/Dispatcher - 3263-26987.log +21 -0
  120. data/spec/support/logs/Dispatcher - 3272-2729.log +25 -0
  121. data/spec/support/logs/Dispatcher - 3297-52308.log +15 -0
  122. data/spec/support/logs/Dispatcher - 3335-17008.log +17 -0
  123. data/spec/support/logs/Dispatcher - 3344-33205.log +21 -0
  124. data/spec/support/logs/Dispatcher - 3353-22917.log +13 -0
  125. data/spec/support/logs/Dispatcher - 3367-34935.log +17 -0
  126. data/spec/support/logs/Dispatcher - 3376-35370.log +21 -0
  127. data/spec/support/logs/Dispatcher - 3385-26487.log +13 -0
  128. data/spec/support/logs/Instance - 2588-19460.error.log +314 -0
  129. data/spec/support/logs/Instance - 2861-5917.error.log +314 -0
  130. data/spec/support/logs/Instance - 2893-61274.error.log +413 -0
  131. data/spec/support/logs/Instance - 2913-11030.error.log +312 -0
  132. data/spec/support/logs/Instance - 2919-17549.error.log +314 -0
  133. data/spec/support/logs/Instance - 3054-17565.error.log +312 -0
  134. data/spec/support/servers/modules/audit/file_inclusion.rb +202 -0
  135. data/spec/support/servers/modules/audit/sqli/access +3 -0
  136. data/spec/support/servers/modules/audit/sqli/firebird +1 -0
  137. data/spec/support/servers/modules/audit/sqli/frontbase +1 -0
  138. data/spec/support/servers/modules/audit/sqli/hsqldb +1 -0
  139. data/spec/support/servers/modules/audit/sqli/ingres +3 -0
  140. data/spec/support/servers/modules/audit/sqli/maxdb +2 -0
  141. data/spec/support/servers/modules/audit/sqli/mssql +0 -5
  142. data/spec/support/servers/modules/audit/sqli/oracle +1 -1
  143. data/spec/support/servers/modules/audit/sqli/sybase +3 -0
  144. data/spec/support/servers/modules/recon/localstart_asp.rb +5 -0
  145. data/spec/support/servers/plugins/uncommon_headers.rb +16 -0
  146. metadata +202 -4
  147. data/modules/audit/sqli/regexp_ids.txt +0 -69
  148. data/plugins/redundant_vectors.rb +0 -34
@@ -134,7 +134,7 @@
134
134
 
135
135
  <% if variation['injected'] %>
136
136
  <strong>Injected value</strong>:
137
- <pre> <%=escapeHTML(variation['injected'])%> </pre>
137
+ <pre> <%=escapeHTML( variation['injected'].inspect )%> </pre>
138
138
  <br/>
139
139
  <%end%>
140
140
 
@@ -9,9 +9,9 @@
9
9
 
10
10
  <% plugins.each_pair do |name, html|%>
11
11
  <div id="<%=name%>">
12
- <blockquote><pre>
13
- <%=prep_description( get_plugin_info( name )[:description] )%>
14
- </pre></blockquote>
12
+ <blockquote>
13
+ <pre><%=prep_description( get_plugin_info( name )[:description] )%></pre>
14
+ </blockquote>
15
15
 
16
16
  <p><%=html.force_encoding( 'utf-8' )%></p>
17
17
  </div>
@@ -0,0 +1,47 @@
1
+ =begin
2
+ Copyright 2010-2013 Tasos Laskos <tasos.laskos@gmail.com>
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ =end
16
+
17
+ class Arachni::Reports::HTML
18
+
19
+ # @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
20
+ class PluginFormatters::UncommonHeaders < Arachni::Plugin::Formatter
21
+ include Utils
22
+
23
+ def run
24
+ ERB.new( tpl ).result( binding )
25
+ end
26
+
27
+ def tpl
28
+ <<-HTML
29
+ <ul>
30
+ <% results.each do |url, headers| %>
31
+ <li>
32
+ <a href="<%= url %>"><%= escapeHTML( url ) %></a>
33
+
34
+ <ul>
35
+ <% headers.each do |name, value| %>
36
+ <li><%= name %>: <%= value %></li>
37
+ <%end%>
38
+ </ul>
39
+
40
+ </li>
41
+ <%end%>
42
+ </ul>
43
+ HTML
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ Copyright 2010-2013 Tasos Laskos <tasos.laskos@gmail.com>
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ =end
16
+
17
+ class Arachni::Reports::Stdout
18
+
19
+ #
20
+ # @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
21
+ #
22
+ class PluginFormatters::UncommonHeaders < Arachni::Plugin::Formatter
23
+
24
+ def run
25
+ results.each do |url, headers|
26
+ print_status url
27
+
28
+ headers.each do |name, value|
29
+ print_info "#{name}: #{value}"
30
+ end
31
+
32
+ print_line
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -30,6 +30,8 @@ class PluginFormatters::Discovery < Arachni::Plugin::Formatter
30
30
  " index=\"#{issue['index'].to_s}\" name=\"#{issue['name']}\"" +
31
31
  " url=\"#{issue['url']}\" />"
32
32
  end
33
+
34
+ buffer
33
35
  end
34
36
 
35
37
  end
@@ -31,6 +31,8 @@ class PluginFormatters::TimingAttacks < Arachni::Plugin::Formatter
31
31
  " url=\"#{issue['url']}\" element=\"#{issue['elem']}\" " +
32
32
  " variable=\"#{issue['var']}\" method=\"#{issue['method']}\" />"
33
33
  end
34
+
35
+ buffer
34
36
  end
35
37
 
36
38
  end
@@ -0,0 +1,38 @@
1
+ =begin
2
+ Copyright 2010-2013 Tasos Laskos <tasos.laskos@gmail.com>
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ =end
16
+
17
+ class Arachni::Reports::XML
18
+
19
+ # @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
20
+ class PluginFormatters::UncommonHeaders < Arachni::Plugin::Formatter
21
+ include Buffer
22
+
23
+ def run
24
+ results.each do |url, headers|
25
+ append "<url value='#{escape( url )}'>"
26
+
27
+ headers.each do |name, value|
28
+ add_header name, value
29
+ end
30
+
31
+ end_tag 'url'
32
+ end
33
+
34
+ buffer
35
+ end
36
+
37
+ end
38
+ end
@@ -26,7 +26,6 @@ class PluginFormatters::Uniformity < Arachni::Plugin::Formatter
26
26
 
27
27
  def run
28
28
  uniformals = results['uniformals']
29
- pages = results['pages']
30
29
 
31
30
  uniformals.each do |id, uniformal|
32
31
  start_uniformals id
@@ -37,6 +36,8 @@ class PluginFormatters::Uniformity < Arachni::Plugin::Formatter
37
36
 
38
37
  end_tag 'uniformals'
39
38
  end
39
+
40
+ buffer
40
41
  end
41
42
 
42
43
  def add_uniformal( idx, uniformal )
@@ -59,15 +59,19 @@ module Arachni::Reports::XML::Buffer
59
59
  def add_headers( type, headers )
60
60
  start_tag type
61
61
  headers.each_pair do |name, value|
62
- if value.is_a?( Array ) #&& name.downcase == 'set-cookie'
63
- append "<field name=\"#{name}\" value=\"#{escape( value.join( "\n" ) )}\" />"
64
- else
65
- append "<field name=\"#{name}\" value=\"#{escape( value )}\" />"
66
- end
62
+ add_header( name, value )
67
63
  end
68
64
  end_tag type
69
65
  end
70
66
 
67
+ def add_header( name, value )
68
+ if value.is_a?( Array ) #&& name.downcase == 'set-cookie'
69
+ append "<field name=\"#{name}\" value=\"#{escape( value.join( "\n" ) )}\" />"
70
+ else
71
+ append "<field name=\"#{name}\" value=\"#{escape( value )}\" />"
72
+ end
73
+ end
74
+
71
75
  def add_tags( tags )
72
76
  start_tag 'tags'
73
77
  tags.each { |name| append "<tag name=\"#{name}\" />" }
@@ -64,130 +64,343 @@ describe Arachni::Element::Capabilities::Auditable::Taint do
64
64
 
65
65
  context 'when called with option' do
66
66
 
67
- context 'for matching with' do
68
-
69
- describe :regexp do
70
- context 'with valid :match' do
71
- it 'verifies the matched data with the provided string' do
72
- @positive.taint_analysis( @seed,
73
- regexp: /my_.+d/,
74
- match: @seed,
75
- format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
76
- )
77
- @auditor.http.run
78
- issues.size.should == 1
79
- issues.first.injected.should == @seed
80
- issues.first.verification.should be_false
81
- end
67
+ describe :regexp do
68
+ context String do
69
+ it 'tries to match the provided pattern' do
70
+ @positive.taint_analysis( @seed,
71
+ regexp: @seed,
72
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
73
+ )
74
+ @auditor.http.run
75
+ issues.size.should == 1
76
+ issues.first.injected.should == @seed
77
+ issues.first.verification.should be_false
82
78
  end
79
+ end
83
80
 
84
- context 'with invalid :match' do
85
- it 'does not log an issue' do
86
- @positive.taint_analysis( @seed,
87
- regexp: @seed,
88
- match: 'blah',
89
- format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
90
- )
91
- @auditor.http.run
92
- issues.should be_empty
93
- end
81
+ context Array do
82
+ it 'tries to match the provided patterns' do
83
+ @positive.taint_analysis( @seed,
84
+ regexp: [@seed],
85
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
86
+ )
87
+ @auditor.http.run
88
+ issues.size.should == 1
89
+ issues.first.injected.should == @seed
90
+ issues.first.verification.should be_false
94
91
  end
92
+ end
95
93
 
96
- context 'without :match' do
97
- it 'tries to match the provided pattern' do
98
- @positive.taint_analysis( @seed,
99
- regexp: @seed,
100
- format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
101
- )
102
- @auditor.http.run
103
- issues.size.should == 1
104
- issues.first.injected.should == @seed
105
- issues.first.verification.should be_false
106
- end
107
- end
94
+ context Hash do
95
+ it 'assigns the relevant platform to the issue' do
96
+ regexps = {
97
+ windows: /#{@seed} w.*/,
98
+ php: /#{@seed} p.*/,
99
+ }
108
100
 
109
- context 'when the page matches the regexp even before we audit it' do
110
- it 'flags the issue as requiring manual verification' do
111
- seed = 'Inject here'
101
+ @positive.taint_analysis(
102
+ "#{@seed} windows",
103
+ regexp: regexps.dup,
104
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
105
+ )
112
106
 
113
- @positive.taint_analysis( 'Inject here',
114
- regexp: 'Inject he[er]',
107
+ @auditor.http.run
108
+
109
+ issues.size.should == 1
110
+ issues[0].platform.should == :windows
111
+ issues[0].regexp.should == regexps[:windows].to_s
112
+ issues[0].verification.should be_false
113
+ end
114
+
115
+ context 'when the payloads are per platform' do
116
+ it 'only tries to matches the regexps for that platform' do
117
+ issues = []
118
+ Arachni::Module::Manager.on_register_results_raw do |results|
119
+ issues += results
120
+ end
121
+
122
+ payloads = {
123
+ windows: "#{@seed} windows",
124
+ php: "#{@seed} php",
125
+ asp: "#{@seed} asp"
126
+ }
127
+
128
+ regexps = {
129
+ windows: /#{@seed} w.*/,
130
+ php: /#{@seed} p.*/,
131
+
132
+ # Can match all but should only match
133
+ # against responses of the ASP payload.
134
+ asp: /#{@seed}/
135
+ }
136
+
137
+ @positive.taint_analysis(
138
+ payloads.dup,
139
+ regexp: regexps.dup,
115
140
  format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
116
141
  )
142
+
117
143
  @auditor.http.run
118
- issues.size.should == 1
119
144
 
120
- issue = issues.first
145
+ issues.size.should == 3
146
+ payloads.keys.each do |platform|
147
+ issue = issues.find{ |i| i.platform == platform }
121
148
 
122
- issue.injected.should == seed
123
- issue.verification.should be_true
124
- issue.remarks[:auditor].should be_any
149
+ issue.injected.should == payloads[platform]
150
+ issue.platform.should == platform
151
+ issue.regexp.should == regexps[platform].to_s
152
+ issue.verification.should be_false
153
+ end
125
154
  end
126
- it 'adds a remark' do
127
- seed = 'Inject here'
128
155
 
129
- @positive.taint_analysis( 'Inject here',
130
- regexp: 'Inject he[er]',
131
- format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
132
- )
133
- @auditor.http.run
134
- issues.size.should == 1
135
-
136
- issue = issues.first
137
-
138
- issue.injected.should == seed
139
- issue.verification.should be_true
140
- issue.remarks[:auditor].should be_any
156
+ context 'when there is not a payload for the regexp platform' do
157
+ it 'matches against all payload responses and assigns the pattern platform to the issue' do
158
+ payloads = {
159
+ windows: "#{@seed} windows",
160
+ php: "#{@seed} php",
161
+ }
162
+
163
+ regexps = {
164
+ # Can match all but should only match
165
+ # against responses of the ASP payload.
166
+ asp: /#{@seed}/
167
+ }
168
+
169
+ @positive.taint_analysis(
170
+ payloads.dup,
171
+ regexp: regexps.dup,
172
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
173
+ )
174
+
175
+ @auditor.http.run
176
+
177
+ issues.size.should == 1
178
+ issue = issues.first
179
+
180
+ issue.platform.should == :asp
181
+ issue.regexp.should == regexps[:asp].to_s
182
+ issue.verification.should be_false
183
+ end
141
184
  end
185
+ end
186
+ end
142
187
 
188
+ context 'with valid :match' do
189
+ it 'verifies the matched data with the provided string' do
190
+ @positive.taint_analysis( @seed,
191
+ regexp: /my_.+d/,
192
+ match: @seed,
193
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
194
+ )
195
+ @auditor.http.run
196
+ issues.size.should == 1
197
+ issues.first.injected.should == @seed
198
+ issues.first.verification.should be_false
143
199
  end
144
200
  end
145
201
 
146
- describe :substring do
147
- it 'tries to find the provided substring' do
202
+ context 'with invalid :match' do
203
+ it 'does not log an issue' do
148
204
  @positive.taint_analysis( @seed,
149
- substring: @seed,
205
+ regexp: @seed,
206
+ match: 'blah',
150
207
  format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
151
208
  )
152
209
  @auditor.http.run
210
+ issues.should be_empty
211
+ end
212
+ end
213
+
214
+ context 'when the page matches the regexp even before we audit it' do
215
+ it 'flags the issue as requiring manual verification' do
216
+ seed = 'Inject here'
217
+
218
+ @positive.taint_analysis( 'Inject here',
219
+ regexp: 'Inject he[er]',
220
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
221
+ )
222
+ @auditor.http.run
223
+ issues.size.should == 1
224
+
225
+ issue = issues.first
226
+
227
+ issue.injected.should == seed
228
+ issue.verification.should be_true
229
+ issue.remarks[:auditor].should be_any
230
+ end
231
+ it 'adds a remark' do
232
+ seed = 'Inject here'
233
+
234
+ @positive.taint_analysis( 'Inject here',
235
+ regexp: 'Inject he[er]',
236
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
237
+ )
238
+ @auditor.http.run
239
+ issues.size.should == 1
240
+
241
+ issue = issues.first
242
+
243
+ issue.injected.should == seed
244
+ issue.verification.should be_true
245
+ issue.remarks[:auditor].should be_any
246
+ end
247
+
248
+ end
249
+ end
250
+
251
+ describe :substring do
252
+
253
+ context String do
254
+ it 'tries to match the provided pattern' do
255
+ @positive.taint_analysis( @seed,
256
+ substring: @seed,
257
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
258
+ )
259
+ @auditor.http.run
153
260
  issues.size.should == 1
154
261
  issues.first.injected.should == @seed
155
262
  issues.first.verification.should be_false
156
263
  end
264
+ end
265
+
266
+ context Array do
267
+ it 'tries to match the provided patterns' do
268
+ @positive.taint_analysis( @seed,
269
+ substring: [@seed],
270
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
271
+ )
272
+ @auditor.http.run
273
+ issues.size.should == 1
274
+ issues.first.injected.should == @seed
275
+ issues.first.verification.should be_false
276
+ end
277
+ end
278
+
279
+ context Hash do
280
+ it 'assigns the relevant platform to the issue' do
281
+ substrings = {
282
+ windows: "#{@seed} w",
283
+ php: "#{@seed} p",
284
+ }
285
+
286
+ @positive.taint_analysis(
287
+ "#{@seed} windows",
288
+ substring: substrings.dup,
289
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
290
+ )
291
+
292
+ @auditor.http.run
157
293
 
158
- context 'when the page includes the substring even before we audit it' do
159
- it 'flags the issue as requiring manual verification' do
160
- seed = 'Inject here'
294
+ issues.size.should == 1
295
+ issues[0].platform.should == :windows
296
+ issues[0].regexp.should == substrings[:windows].to_s
297
+ issues[0].verification.should be_false
298
+ end
161
299
 
162
- @positive.taint_analysis( 'Inject here',
163
- regexp: 'Inject here',
300
+ context 'when the payloads are per platform' do
301
+ it 'only tries to matches the regexps for that platform' do
302
+ issues = []
303
+ Arachni::Module::Manager.on_register_results_raw do |results|
304
+ issues += results
305
+ end
306
+
307
+ payloads = {
308
+ windows: "#{@seed} windows",
309
+ php: "#{@seed} php",
310
+ asp: "#{@seed} asp"
311
+ }
312
+
313
+ substrings = {
314
+ windows: "#{@seed} w",
315
+ php: "#{@seed} p",
316
+
317
+ # Can match all but should only match
318
+ # against responses of the ASP payload.
319
+ asp: @seed
320
+ }
321
+
322
+ @positive.taint_analysis(
323
+ payloads.dup,
324
+ substring: substrings.dup,
164
325
  format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
165
326
  )
327
+
166
328
  @auditor.http.run
167
- issues.size.should == 1
168
329
 
169
- issue = issues.first
330
+ issues.size.should == 3
331
+ payloads.keys.each do |platform|
332
+ issue = issues.find{ |i| i.platform == platform }
170
333
 
171
- issue.injected.should == seed
172
- issue.verification.should be_true
173
- issue.remarks[:auditor].should be_any
334
+ issue.injected.should == payloads[platform]
335
+ issue.platform.should == platform
336
+ issue.regexp.should == substrings[platform].to_s
337
+ issue.verification.should be_false
338
+ end
174
339
  end
175
340
  end
176
-
177
341
  end
178
342
 
179
- describe :ignore do
180
- it 'ignores matches whose response also matches the ignore patterns' do
181
- @positive.taint_analysis( @seed,
182
- substring: @seed,
183
- format: [ Arachni::Module::Auditor::Format::STRAIGHT ],
184
- ignore: @seed
343
+ context 'when the page includes the substring even before we audit it' do
344
+ it 'flags the issue as requiring manual verification' do
345
+ seed = 'Inject here'
346
+
347
+ @positive.taint_analysis( 'Inject here',
348
+ regexp: 'Inject here',
349
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
185
350
  )
186
351
  @auditor.http.run
187
- issues.should be_empty
352
+ issues.size.should == 1
353
+
354
+ issue = issues.first
355
+
356
+ issue.injected.should == seed
357
+ issue.verification.should be_true
358
+ issue.remarks[:auditor].should be_any
188
359
  end
360
+
361
+ context 'when there is not a payload for the substring platform' do
362
+ it 'matches against all payload responses and assigns the pattern platform to the issue' do
363
+ payloads = {
364
+ windows: "#{@seed} windows",
365
+ php: "#{@seed} php",
366
+ }
367
+
368
+ substrings = {
369
+ # Can match all but should only match
370
+ # against responses of the ASP payload.
371
+ asp: @seed
372
+ }
373
+
374
+ @positive.taint_analysis(
375
+ payloads.dup,
376
+ substring: substrings.dup,
377
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ]
378
+ )
379
+
380
+ @auditor.http.run
381
+
382
+ issues.size.should == 1
383
+ issue = issues.first
384
+
385
+ issue.platform.should == :asp
386
+ issue.regexp.should == substrings[:asp].to_s
387
+ issue.verification.should be_false
388
+ end
389
+ end
390
+
189
391
  end
392
+ end
190
393
 
394
+ describe :ignore do
395
+ it 'ignores matches whose response also matches the ignore patterns' do
396
+ @positive.taint_analysis( @seed,
397
+ substring: @seed,
398
+ format: [ Arachni::Module::Auditor::Format::STRAIGHT ],
399
+ ignore: @seed
400
+ )
401
+ @auditor.http.run
402
+ issues.should be_empty
403
+ end
191
404
  end
192
405
  end
193
406