dnsutils 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9c80e817d2c54f1e244125038d9e18993cc5d5a
4
+ data.tar.gz: 67348af902374c176dd947795bd2dc5c2a8ef752
5
+ SHA512:
6
+ metadata.gz: 7093a62fa5f7bda31ee273524488ce83df92507c8a454b8cec28506984b580487be01ffb11e85b079afe782146311ff13a5264ff10bfc109f1fb6bd731f9b024
7
+ data.tar.gz: 9d76dd0cd7c4e4bd5f637e1aab6cdd187dc3ccebb8a88b9f93c96da5bbf4eca4b0b2beb3b110ea5cd7878083440b28ffe64efb1d764ab3d6d04319a29f49eb91
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dnsutils.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Dnsutils
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/dnsutils`. 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 'dnsutils'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dnsutils
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. Then, run `rake test` to run the tests. 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]/dnsutils.
36
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dnsutils"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/dnsutils.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dnsutils/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dnsutils"
8
+ spec.version = Dnsutils::VERSION
9
+ spec.authors = ["iagox86"]
10
+ spec.email = ["ron-git@skullsecurity.org"]
11
+
12
+ spec.summary = "A set of DNS utilities that are useful for pentesters (or just general playing)."
13
+ spec.homepage = "https://github.com/iagox86/dnsutils"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "minitest"
23
+
24
+ spec.add_dependency "nesser"
25
+ spec.add_dependency "trollop"
26
+ end
data/lib/dnslogger.rb ADDED
@@ -0,0 +1,107 @@
1
+ ##
2
+ # dnslogger.rb
3
+ # Created July 22, 2015
4
+ # By Ron Bowes
5
+ #
6
+ # See: LICENSE.md
7
+ #
8
+ # Implements a stupidly simple DNS server.
9
+ ##
10
+
11
+ $LOAD_PATH << File.dirname(__FILE__) # A hack to make this work on 1.8/1.9
12
+
13
+ require 'trollop'
14
+ require '../server/libs/dnser'
15
+
16
+ # version info
17
+ NAME = "dnslogger"
18
+ VERSION = "v1.0.0"
19
+
20
+ Thread.abort_on_exception = true
21
+
22
+ # Options
23
+ opts = Trollop::options do
24
+ version(NAME + " " + VERSION)
25
+
26
+ opt :version, "Get the #{NAME} version", :type => :boolean, :default => false
27
+ opt :host, "The ip address to listen on", :type => :string, :default => "0.0.0.0"
28
+ opt :port, "The port to listen on", :type => :integer, :default => 53
29
+
30
+ opt :passthrough, "Set to a host:port, and unanswered queries will be sent there", :type => :string, :default => nil
31
+ opt :packet_trace, "If enabled, print details about the packets", :type => :boolean, :default => false
32
+
33
+ opt :A, "Response to send back for 'A' requests", :type => :string, :default => nil
34
+ opt :AAAA, "Response to send back for 'AAAA' requests", :type => :string, :default => nil
35
+ opt :CNAME, "Response to send back for 'CNAME' requests", :type => :string, :default => nil
36
+ opt :TXT, "Response to send back for 'TXT' requests", :type => :string, :default => nil
37
+ opt :MX, "Response to send back for 'MX' requests", :type => :string, :default => nil
38
+ opt :MX_PREF, "The preference order for the MX record", :type => :integer, :default => 10
39
+ opt :NS, "Response to send back for 'NS' requests", :type => :string, :default => nil
40
+
41
+ opt :ttl, "The TTL value to return", :type => :integer, :default => 60
42
+ end
43
+
44
+ if(opts[:port] < 0 || opts[:port] > 65535)
45
+ Trollop::die :port, "must be a valid port (between 0 and 65535)"
46
+ end
47
+
48
+ puts("Starting #{NAME} #{VERSION} DNS server on #{opts[:host]}:#{opts[:port]}")
49
+
50
+ pt_host = pt_port = nil
51
+ if(opts[:passthrough])
52
+ pt_host, pt_port = opts[:passthrough].split(/:/, 2)
53
+ pt_port = pt_port || 53
54
+ puts("Any queries without a specific answer will be sent to #{pt_host}:#{pt_port}")
55
+ end
56
+
57
+ dnser = DNSer.new(opts[:host], opts[:port])
58
+
59
+ dnser.on_request() do |transaction|
60
+ request = transaction.request
61
+
62
+ if(request.questions.length < 1)
63
+ puts("The request didn't ask any questions!")
64
+ next
65
+ end
66
+
67
+ if(request.questions.length > 1)
68
+ puts("The request asked multiple questions! This is super unusual, if you can reproduce, please report!")
69
+ next
70
+ end
71
+
72
+ question = request.questions[0]
73
+
74
+ puts(request.to_s(!opts[:packet_trace]))
75
+
76
+ # If they provided a way to handle it, to that
77
+ response = question.type_s ? opts[question.type_s.to_sym] : nil
78
+ if(response)
79
+ if(question.type == DNSer::Packet::TYPE_MX)
80
+ answer = question.answer(opts[:ttl], response, opts[:MX_PREF])
81
+ else
82
+ answer = question.answer(opts[:ttl], response)
83
+ end
84
+
85
+ transaction.add_answer(answer)
86
+ puts(transaction.response.to_s(!opts[:packet_trace]))
87
+ transaction.reply!()
88
+ else
89
+ if(pt_host)
90
+ transaction.passthrough!(pt_host, pt_port, Proc.new() do |packet|
91
+ puts(packet.to_s(!opts[:packet_trace]))
92
+ end)
93
+ puts("OUT: (...forwarding upstream...)")
94
+ else
95
+ transaction.error!(DNSer::Packet::RCODE_NAME_ERROR)
96
+ puts(transaction.response.to_s(!opts[:packet_trace]))
97
+ end
98
+ end
99
+
100
+ if(!transaction.sent)
101
+ raise(StandardError, "Oops! We didn't send the response! Please file a bug")
102
+ end
103
+
104
+ end
105
+
106
+ # Wait for it to finish (never-ending, essentially)
107
+ dnser.wait()
@@ -0,0 +1,115 @@
1
+ ##
2
+ # dnslogger.rb
3
+ # Created July 22, 2015
4
+ # By Ron Bowes
5
+ #
6
+ # See: LICENSE.md
7
+ #
8
+ # Simply checks if you're the authoritative server.
9
+ ##
10
+
11
+ $LOAD_PATH << File.dirname(__FILE__) # A hack to make this work on 1.8/1.9
12
+
13
+ require 'trollop'
14
+ require '../server/libs/dnser'
15
+
16
+ # version info
17
+ NAME = "dnsmastermind"
18
+ VERSION = "v1.0.0"
19
+
20
+ Thread.abort_on_exception = true
21
+
22
+ # Options
23
+ opts = Trollop::options do
24
+ version(NAME + " " + VERSION)
25
+
26
+ opt :version, "Get the #{NAME} version", :type => :boolean, :default => false
27
+ opt :host, "The ip address to listen on", :type => :string, :default => "0.0.0.0"
28
+ opt :port, "The port to listen on", :type => :integer, :default => 53
29
+ opt :timeout, "The amount of time (seconds) to wait for a response", :type => :integer, :default => 10
30
+ opt :solution,"The answer; should be four letters, unless you're a jerk", :type => :string, :default => nil, :required => true
31
+ opt :win, "The message to display to winners", :type => :string, :default => "YOU WIN!!"
32
+ end
33
+
34
+ if(opts[:port] < 0 || opts[:port] > 65535)
35
+ Trollop::die :port, "must be a valid port (between 0 and 65535)"
36
+ end
37
+
38
+ if(opts[:solution].include?('.'))
39
+ Trollop::die :solution, "must not contain period; SHOULD only contain [a-z]{4} :)"
40
+ end
41
+ solution = opts[:solution].upcase()
42
+
43
+ puts("Starting #{NAME} #{VERSION} DNS server on #{opts[:host]}:#{opts[:port]}")
44
+
45
+ dnser = DNSer.new(opts[:host], opts[:port])
46
+
47
+ dnser.on_request() do |transaction|
48
+ begin
49
+ request = transaction.request
50
+
51
+ if(request.questions.length < 1)
52
+ puts("The request didn't ask any questions!")
53
+ next
54
+ end
55
+
56
+ if(request.questions.length > 1)
57
+ puts("The request asked multiple questions! This is super unusual, if you can reproduce, please report!")
58
+ next
59
+ end
60
+
61
+ if(request.questions[0].type != DNSer::Packet::TYPE_TXT)
62
+ next
63
+ end
64
+ guess, domain = request.questions[0].name.split(/\./, 2)
65
+ guess.upcase!()
66
+
67
+ if(guess == solution)
68
+ puts("WINNER!!!")
69
+ answer = opts[:win]
70
+ elsif(guess.length == solution.length)
71
+ saved_guess = guess
72
+ tmp_solution = solution.chars.to_a()
73
+ guess = guess.chars.to_a()
74
+ answer = ""
75
+
76
+ 0.upto(tmp_solution.length() - 1) do |i|
77
+ if(tmp_solution[i] == guess[i])
78
+ answer += "O"
79
+ tmp_solution[i] = ""
80
+ guess[i] = ""
81
+ end
82
+ end
83
+
84
+ guess.each do |c|
85
+ if(c == "")
86
+ next
87
+ end
88
+
89
+ if(tmp_solution.include?(c))
90
+ tmp_solution[tmp_solution.index(c)] = ""
91
+ answer += "X"
92
+ end
93
+ end
94
+
95
+ if(answer == "")
96
+ answer = "No correct character; keep trying!"
97
+ end
98
+
99
+ puts("Guess: #{saved_guess} => #{answer}")
100
+ else
101
+ puts("Invalid; sending instructions: #{guess}")
102
+ answer = "Instructions: guess the #{solution.length}-character string: dig -t txt [guess].#{domain}! 'O' = correct, 'X' = correct, but wrong position"
103
+ end
104
+
105
+ answer = DNSer::Packet::Answer.new(request.questions[0], DNSer::Packet::TYPE_TXT, DNSer::Packet::CLS_IN, 100, DNSer::Packet::TXT.new(answer))
106
+
107
+ transaction.add_answer(answer)
108
+ transaction.reply!()
109
+ rescue StandardError => e
110
+ puts("Error: #{e}")
111
+ puts(e.backtrace)
112
+ end
113
+ end
114
+
115
+ dnser.wait()
data/lib/dnstest.rb ADDED
@@ -0,0 +1,82 @@
1
+ ##
2
+ # dnslogger.rb
3
+ # Created July 22, 2015
4
+ # By Ron Bowes
5
+ #
6
+ # See: LICENSE.md
7
+ #
8
+ # Simply checks if you're the authoritative server.
9
+ ##
10
+
11
+ $LOAD_PATH << File.dirname(__FILE__) # A hack to make this work on 1.8/1.9
12
+
13
+ require 'trollop'
14
+ require '../server/libs/dnser'
15
+
16
+ # version info
17
+ NAME = "dnstest"
18
+ VERSION = "v1.0.0"
19
+
20
+ Thread.abort_on_exception = true
21
+
22
+ # Options
23
+ opts = Trollop::options do
24
+ version(NAME + " " + VERSION)
25
+
26
+ opt :version, "Get the #{NAME} version", :type => :boolean, :default => false
27
+ opt :host, "The ip address to listen on", :type => :string, :default => "0.0.0.0"
28
+ opt :port, "The port to listen on", :type => :integer, :default => 53
29
+ opt :domain, "The domain to check", :type => :string, :default => nil, :required => true
30
+ opt :timeout, "The amount of time (seconds) to wait for a response", :type => :integer, :default => 10
31
+ end
32
+
33
+ if(opts[:port] < 0 || opts[:port] > 65535)
34
+ Trollop::die :port, "must be a valid port (between 0 and 65535)"
35
+ end
36
+
37
+ if(opts[:domain].nil?)
38
+ Trollop::die :domain, "Domain is required!"
39
+ end
40
+
41
+ puts("Starting #{NAME} #{VERSION} DNS server on #{opts[:host]}:#{opts[:port]}")
42
+
43
+ domain = (0...16).map { ('a'..'z').to_a[rand(26)] }.join() + "." + opts[:domain]
44
+
45
+ dnser = DNSer.new(opts[:host], opts[:port])
46
+
47
+ dnser.on_request() do |transaction|
48
+ request = transaction.request
49
+
50
+ if(request.questions.length < 1)
51
+ puts("The request didn't ask any questions!")
52
+ next
53
+ end
54
+
55
+ if(request.questions.length > 1)
56
+ puts("The request asked multiple questions! This is super unusual, if you can reproduce, please report!")
57
+ next
58
+ end
59
+
60
+ question = request.questions[0]
61
+ puts("Received: #{question}")
62
+ if(question.type == DNSer::Packet::TYPE_A && question.name == domain)
63
+ puts("You have the authoritative server!")
64
+ transaction.error!(DNSer::Packet::RCODE_NAME_ERROR)
65
+ exit()
66
+ else
67
+ puts("Received a different request: #{question}")
68
+ end
69
+
70
+ # Always respond with an error
71
+ transaction.error!(DNSer::Packet::RCODE_NAME_ERROR)
72
+ end
73
+
74
+ puts("Sending: #{domain}!")
75
+ DNSer.query(domain, { :type => DNSer::Packet::TYPE_A }) do |response|
76
+ # Do nothing
77
+ end
78
+
79
+ sleep(opts[:timeout])
80
+
81
+ puts("Request timed out... you probably don't have the authoritative server. :(")
82
+ exit(0)
data/lib/dnsutils.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "dnsutils/version"
2
+
3
+ module Dnsutils
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Dnsutils
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dnsutils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - iagox86
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-09 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nesser
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: trollop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - ron-git@skullsecurity.org
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - dnsutils.gemspec
98
+ - lib/dnslogger.rb
99
+ - lib/dnsmastermind.rb
100
+ - lib/dnstest.rb
101
+ - lib/dnsutils.rb
102
+ - lib/dnsutils/version.rb
103
+ homepage: https://github.com/iagox86/dnsutils
104
+ licenses: []
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.5.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: A set of DNS utilities that are useful for pentesters (or just general playing).
126
+ test_files: []