cross 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.rvmrc +2 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +29 -0
- data/README.rdoc +43 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/bin/cross +44 -0
- data/cross.gemspec +25 -0
- data/lib/cross.rb +3 -0
- data/lib/cross/engine.rb +75 -0
- data/lib/cross/version.rb +3 -0
- data/lib/cross/xss.rb +22 -0
- data/spec/cross_spec.rb +4 -0
- data/spec/spec_helper.rb +12 -0
- metadata +168 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Paolo Perego
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Cross
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'cross'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install cross
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/README.rdoc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
= cross
|
2
|
+
|
3
|
+
cross is a simple and easy to use cross site scripting spotting tool. The idea
|
4
|
+
is to use mechanize to submit attack patterns to forms and read the
|
5
|
+
payload in the resulting page using nokogiri and xpath queries.
|
6
|
+
|
7
|
+
Having the result page full HTML understood my lead to have low false positives
|
8
|
+
rate.
|
9
|
+
|
10
|
+
{<img src="http://travis-ci.org/thesp0nge/cross.png" />}[http://travis-ci.org/thesp0nge/cross]
|
11
|
+
== Version
|
12
|
+
|
13
|
+
current cross version is: 0.0.0
|
14
|
+
|
15
|
+
== Wishlist
|
16
|
+
|
17
|
+
cross latest goal is automate the search for XSS in a web application, providing APIs for being called by other tools.
|
18
|
+
|
19
|
+
To accomplish this, I'd like to add in the very near future:
|
20
|
+
|
21
|
+
* honoring sitemap.xml - given the web application URL, if the sitemap.xml has
|
22
|
+
been found, cross will limit the scan in this link list (you'll be able to
|
23
|
+
override this, I'll introduce it to limit the impact of crawling a website
|
24
|
+
when URLs are dynamically generated).
|
25
|
+
* save file in a SQL form - cross will be ORM agnostic, I'll provide a SQLite3 driver as default.
|
26
|
+
* HTML5 & CSS3 reporting - even hackers want good looking web2.0 reports
|
27
|
+
* ...
|
28
|
+
|
29
|
+
== Contributing to cross
|
30
|
+
|
31
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
32
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
33
|
+
* Fork the project
|
34
|
+
* Start a feature/bugfix branch
|
35
|
+
* Commit and push until you are happy with your contribution
|
36
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
37
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
38
|
+
|
39
|
+
== Copyright
|
40
|
+
|
41
|
+
Copyright (c) 2011 Paolo Perego. See LICENSE for
|
42
|
+
further details.
|
43
|
+
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.10.0
|
data/bin/cross
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rainbow'
|
4
|
+
require 'logger'
|
5
|
+
require 'mechanize'
|
6
|
+
require 'cross'
|
7
|
+
require 'getoptlong'
|
8
|
+
|
9
|
+
opts = GetoptLong.new(
|
10
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
11
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
12
|
+
['--debug', '-D', GetoptLong::NO_ARGUMENT ],
|
13
|
+
['--exploit-url', '-u', GetoptLong::NO_ARGUMENT]
|
14
|
+
)
|
15
|
+
trap("INT") { puts '['+'INTERRUPTED'.color(:red)+']'; exit -1 }
|
16
|
+
|
17
|
+
options={:exploit_url=>false, :debug=>false}
|
18
|
+
|
19
|
+
opts.each do |opt, arg|
|
20
|
+
case opt
|
21
|
+
when '--help'
|
22
|
+
puts "usage: cross [-uDhv] target"
|
23
|
+
puts " -u: exploits the URL string instead of looking at the form values"
|
24
|
+
puts " -D: turns debug on"
|
25
|
+
puts " -v: shows version"
|
26
|
+
puts " -h: this help"
|
27
|
+
exit 0
|
28
|
+
when '--version'
|
29
|
+
puts "cross " + Cross::VERSION
|
30
|
+
exit 0
|
31
|
+
when '--debug'
|
32
|
+
options[:debug]=true
|
33
|
+
when '--exploit-url'
|
34
|
+
options[:exploit_url]=true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "cross " + Cross::VERSION + " (C) 2011, 2012 - paolo@armoredcode.com"
|
39
|
+
|
40
|
+
engine = Cross::Engine.instance
|
41
|
+
engine.start(options)
|
42
|
+
|
43
|
+
raise "cross: missing target" if ARGV.length != 1
|
44
|
+
puts "Canary found in output page. Suspected XSS" if engine.inject(ARGV.shift)
|
data/cross.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/cross/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Paolo Perego"]
|
6
|
+
gem.email = ["thesp0nge@gmail.com"]
|
7
|
+
gem.description = %q{cross is a cross site scripting testing tool}
|
8
|
+
gem.summary = %q{cross is a cross site scripting testing tool}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "cross"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Cross::VERSION
|
17
|
+
|
18
|
+
|
19
|
+
gem.add_development_dependency "rake"
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_dependency "rest-open-uri"
|
22
|
+
gem.add_dependency "mechanize"
|
23
|
+
gem.add_dependency "logger"
|
24
|
+
gem.add_dependency "rainbow"
|
25
|
+
end
|
data/lib/cross.rb
ADDED
data/lib/cross/engine.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'logger'
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
require 'cross/xss'
|
6
|
+
|
7
|
+
module Cross
|
8
|
+
# Engine is the cross class using Mechanize to inject canary and check for
|
9
|
+
# output
|
10
|
+
class Engine
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
attr_reader :agent
|
14
|
+
attr_accessor :options
|
15
|
+
|
16
|
+
# Starts the engine
|
17
|
+
def start(options={:exploit_url=>false, :debug=>false, :auth=>{}})
|
18
|
+
@agent = Mechanize.new {|a| a.log = Logger.new("cross.log")}
|
19
|
+
@agent.user_agent_alias = 'Mac Safari'
|
20
|
+
@agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
def inject(url)
|
25
|
+
if @agent.nil?
|
26
|
+
start
|
27
|
+
end
|
28
|
+
|
29
|
+
if ! @options[:auth].nil? and ! @options[:auth].empty?
|
30
|
+
@agent.add_auth(url, @options[:auth][:username], @options[:auth][:password])
|
31
|
+
end
|
32
|
+
|
33
|
+
found = false
|
34
|
+
if @options[:exploit_url]
|
35
|
+
# You ask to exploit the url, so I won't check for form values
|
36
|
+
|
37
|
+
Cross::Attack::XSS.each do |pattern|
|
38
|
+
page = @agent.get(url+pattern)
|
39
|
+
|
40
|
+
if @options[:debug]
|
41
|
+
@agent.log.debug(page.body)
|
42
|
+
end
|
43
|
+
scripts = page.search("//script")
|
44
|
+
scripts.each do |sc|
|
45
|
+
if sc.children.text.include?("alert('cross canary');")
|
46
|
+
found = true
|
47
|
+
end
|
48
|
+
if @options[:debug]
|
49
|
+
@agent.log.debug(sc.children.text)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "GET #{url+pattern}: #{found}"
|
54
|
+
end
|
55
|
+
|
56
|
+
else
|
57
|
+
page = @agent.get(url)
|
58
|
+
page.forms.each do |f|
|
59
|
+
f.fields.each do |ff|
|
60
|
+
ff.value = "<script>alert('cross canary');</script>"
|
61
|
+
end
|
62
|
+
pp = @agent.submit(f)
|
63
|
+
scripts = pp.search("//script")
|
64
|
+
scripts.each do |sc|
|
65
|
+
if sc.children.text == "alert('cross canary');"
|
66
|
+
found = true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
found
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
data/lib/cross/xss.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cross
|
2
|
+
module Attack
|
3
|
+
class XSS
|
4
|
+
|
5
|
+
def self.each
|
6
|
+
|
7
|
+
evasions = [
|
8
|
+
"<script>alert('cross canary');</script>",
|
9
|
+
"/--><script>alert('cross canary');</script>",
|
10
|
+
"/--></ScRiPt><ScRiPt>alert('cross canary');</ScRiPt>",
|
11
|
+
"//;-->alert('cross canary');",
|
12
|
+
"\"//;\nalert('cross canary');"
|
13
|
+
]
|
14
|
+
evasions.each do |pattern|
|
15
|
+
yield pattern if block_given?
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/cross_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'cross'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cross
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.20.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paolo Perego
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rest-open-uri
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mechanize
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: logger
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rainbow
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: cross is a cross site scripting testing tool
|
111
|
+
email:
|
112
|
+
- thesp0nge@gmail.com
|
113
|
+
executables:
|
114
|
+
- cross
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .document
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .rvmrc
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE
|
124
|
+
- README.md
|
125
|
+
- README.rdoc
|
126
|
+
- Rakefile
|
127
|
+
- VERSION
|
128
|
+
- bin/cross
|
129
|
+
- cross.gemspec
|
130
|
+
- lib/cross.rb
|
131
|
+
- lib/cross/engine.rb
|
132
|
+
- lib/cross/version.rb
|
133
|
+
- lib/cross/xss.rb
|
134
|
+
- spec/cross_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
homepage: ''
|
137
|
+
licenses: []
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
hash: 487062861682332119
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
hash: 487062861682332119
|
160
|
+
requirements: []
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 1.8.24
|
163
|
+
signing_key:
|
164
|
+
specification_version: 3
|
165
|
+
summary: cross is a cross site scripting testing tool
|
166
|
+
test_files:
|
167
|
+
- spec/cross_spec.rb
|
168
|
+
- spec/spec_helper.rb
|