hitman 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6a5e4c277a70f15b092f88487d8ba8654b29a84
4
+ data.tar.gz: cb5e4d1b018be1f34e0258f4af2b44c93afa8de5
5
+ SHA512:
6
+ metadata.gz: 66fc72fbbcb27cc1c4fa26642c0b87115b241796c3626c8e4c9f9c662b8e6191fe14cd80230e43bd81839001ca2563f5cc2b84e9517cce70bb28b40eb105e572
7
+ data.tar.gz: c40dd82ef778bb73a4a2b32af004f072f5912d9677eeafa01de974a33ee81dac05d9c61b79a7a81d7dce9c436efe5048552d222c92ef2e8183db84ddd8dd3be1
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hitman.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # Hitman
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hitman`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'hitman'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install hitman
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hitman.
36
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hitman"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hitman/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hitman"
8
+ spec.version = Hitman::VERSION
9
+ spec.authors = ["Lukas_Skywalker"]
10
+ spec.email = ["lukas.diener@hotmail.com"]
11
+
12
+ spec.summary = "API fuzzing for professionals"
13
+ spec.description = "Fuzzes all your API endpoints with the toughest input until it breaks."
14
+ spec.homepage = "https://bitbucket.org/Zeilenwerk/hitman"
15
+ spec.license = "GPLv3"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,27 @@
1
+ require "hitman/version"
2
+ require "hitman/fuzzer"
3
+
4
+ module Hitman
5
+ class Scanner
6
+ def scan_grape(target, klass)
7
+
8
+ klass.routes.each do |api|
9
+ route = Hitman::Route.new(api.route_method, api.route_path.split("\(").first)
10
+ target.routes << route
11
+ api.route_params.each do |name, details|
12
+ route.params << Hitman::Param.new(name, details[:type])
13
+ end
14
+ end
15
+ target
16
+
17
+ end
18
+
19
+ def scan_rails(target, klass)
20
+ Rails.application.routes.routes.to_a.each do |route|
21
+ name = route.name
22
+ path = route.path.spec.to_s.split('\(').first
23
+ method = route.constraints[:request_method]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,70 @@
1
+ require 'net/http'
2
+
3
+ require_relative 'target'
4
+ require_relative 'route'
5
+ require_relative 'param'
6
+ require_relative 'request'
7
+
8
+ dir = File.dirname(File.dirname(__FILE__))
9
+
10
+ Dir.glob(dir + '/hitman/iterators/*.rb') do |f|
11
+ require_relative f
12
+ end
13
+
14
+ module Hitman
15
+ class Fuzzer
16
+ def add_param(url, param_name, param_value)
17
+ uri = URI(url)
18
+ params = URI.decode_www_form(uri.query || []) << [param_name, param_value]
19
+ uri.query = URI.encode_www_form(params)
20
+ uri.to_s
21
+ end
22
+
23
+ def start(t)
24
+ puts t
25
+ puts ""
26
+
27
+ t.routes.each do |route|
28
+ url = t.host + t.prefix + route.url
29
+ puts "Checking #{url}"
30
+ iterators = []
31
+ total_iterations = 1
32
+ route.params.each do |param|
33
+ iterator = Kernel.const_get(param.type + 'Iterator').new.get
34
+ iterators << iterator
35
+ total_iterations *= iterator.length
36
+ end
37
+ next if iterators.empty?
38
+ iterations = iterators.first.product(*iterators[1..-1]) #splat == #swag
39
+
40
+ puts "Total iterations: #{total_iterations}"
41
+
42
+ iterations.each do |iteration|
43
+ uri = URI(url)
44
+ params = {}
45
+
46
+ route.params.each_with_index do |param, i|
47
+ params[param.name] = iteration[i]
48
+ end
49
+
50
+ if route.method.downcase == 'get'
51
+ uri.query = URI.encode_www_form(params.merge t.postfix)
52
+ res = Hitman::Request.get(uri)
53
+ else
54
+ uri.query = URI.encode_www_form(t.postfix)
55
+ payload = params.to_json
56
+ res = Hitman::Request.post(uri, payload)
57
+ end
58
+ if res.code.to_i >= 500 && res.code.to_i <= 599
59
+ puts "Yay, fu**ed!"
60
+ puts "URL: #{route.method} #{uri}"
61
+ puts "Params: #{params.inspect}"
62
+ puts "Continue?"
63
+ gets
64
+ end
65
+
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ class DateIterator
2
+ def get
3
+ [Date.today, 232454356, "shdsjfsdhfhsd"]
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class HashIterator
2
+ def get
3
+ [{}, {user: 'sfdgh'}, {test: 324783456374563454357667}]
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class IntegerIterator
2
+ N_BYTES = [42].pack('i').size
3
+ N_BITS = N_BYTES * 16
4
+ MAX = 2 ** (N_BITS - 2) - 1
5
+ MIN = -MAX - 1
6
+
7
+ def get
8
+ [MIN, -1, 0, 1, MAX]
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class StringIterator
2
+ def random_string(length)
3
+ rand(36**length).to_s(36)
4
+ end
5
+
6
+ def get
7
+ ['', random_string(10), random_string(500)]
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Hitman
2
+ class Param
3
+ attr_accessor :name, :type
4
+
5
+ def initialize(name, type)
6
+ @name = name
7
+ @type = type
8
+ end
9
+
10
+ def to_s
11
+ "#{name}: #{type}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module Hitman
2
+ class Request
3
+ def self.get(uri)
4
+ Net::HTTP.get_response(uri)
5
+ end
6
+
7
+ def self.post(uri, payload)
8
+ http = Net::HTTP.new(uri.host, uri.port)
9
+ request = Net::HTTP::Post.new(
10
+ uri.request_uri,
11
+ initheader = {'Content-Type' => 'application/json'}
12
+ )
13
+ request.body = payload
14
+
15
+ http.request(request)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Hitman
2
+ class Route
3
+ attr_accessor :method, :path, :params
4
+
5
+ def initialize(method, path)
6
+ @method = method
7
+ @path = path
8
+ @params = []
9
+ end
10
+
11
+ def url
12
+ path
13
+ end
14
+
15
+ def to_s
16
+ "#{method.ljust(10)} #{url.ljust(20)} #{params.join(', ')}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Hitman
2
+ class Target
3
+ attr_accessor :name, :host, :routes, :prefix, :postfix
4
+
5
+ def initialize(name, host)
6
+ @name = name
7
+ @host = host
8
+ @prefix = ''
9
+ @postfix = ''
10
+ @routes = []
11
+ end
12
+
13
+ def to_s
14
+ "Analysis for #{name}\n" +
15
+ "-------------" + "-" * name.length + "\n" +
16
+ routes.join("\n")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Hitman
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hitman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Lukas_Skywalker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Fuzzes all your API endpoints with the toughest input until it breaks.
42
+ email:
43
+ - lukas.diener@hotmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - bin/console
53
+ - bin/setup
54
+ - hitman.gemspec
55
+ - lib/hitman.rb
56
+ - lib/hitman/fuzzer.rb
57
+ - lib/hitman/iterators/date_iterator.rb
58
+ - lib/hitman/iterators/hash_iterator.rb
59
+ - lib/hitman/iterators/integer_iterator.rb
60
+ - lib/hitman/iterators/string_iterator.rb
61
+ - lib/hitman/param.rb
62
+ - lib/hitman/request.rb
63
+ - lib/hitman/route.rb
64
+ - lib/hitman/target.rb
65
+ - lib/hitman/version.rb
66
+ homepage: https://bitbucket.org/Zeilenwerk/hitman
67
+ licenses:
68
+ - GPLv3
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: API fuzzing for professionals
90
+ test_files: []