cruncher 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 133814c43253a9fa81f7ead915ff1c81bff0f3571a83638ecfcb751aa828bdff
4
+ data.tar.gz: 14bd61ae248292daab4e1d8442074b8e355a073b674ab18a6ba525e78c9ee9e7
5
+ SHA512:
6
+ metadata.gz: 0d751e0054a47898db0d72f3eefeb48ff3aabb7ff96b7a4473006eeb2c85fb6dcc702447db5690d9fde89b3100308a8b61b4577b89dd0307c632b3c098390d63
7
+ data.tar.gz: 8dc68ba16dc35797a9de4335abfe9ae420a7483a1791ff7c7d912c566c8f8d3a8c2afdac1dbb5c33a3d5cc548268515570f232a4b02964371c4bf4cf059077ba
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.7
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at peter@zenjoy.be. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cruncher.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,150 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cruncher (0.1.0)
5
+ pastel (~> 0.7.2)
6
+ phantomjs (~> 2.1.1)
7
+ sitemaps_parser (~> 0.2.3)
8
+ thor (~> 0.20.0)
9
+ tty-box (~> 0.5)
10
+ tty-color (~> 0.5)
11
+ tty-command (~> 0.9.0)
12
+ tty-config (~> 0.3.2)
13
+ tty-cursor (~> 0.7)
14
+ tty-editor (~> 0.5)
15
+ tty-file (~> 0.8.0)
16
+ tty-font (~> 0.4.0)
17
+ tty-logger (~> 0.2.0)
18
+ tty-markdown (~> 0.6.0)
19
+ tty-pager (~> 0.12)
20
+ tty-pie (~> 0.3.0)
21
+ tty-platform (~> 0.2)
22
+ tty-progressbar (~> 0.17)
23
+ tty-prompt (~> 0.19)
24
+ tty-screen (~> 0.7)
25
+ tty-spinner (~> 0.9)
26
+ tty-table (~> 0.11.0)
27
+ tty-tree (~> 0.3)
28
+ tty-which (~> 0.4)
29
+
30
+ GEM
31
+ remote: https://rubygems.org/
32
+ specs:
33
+ activesupport (6.0.2.2)
34
+ concurrent-ruby (~> 1.0, >= 1.0.2)
35
+ i18n (>= 0.7, < 2)
36
+ minitest (~> 5.1)
37
+ tzinfo (~> 1.1)
38
+ zeitwerk (~> 2.2)
39
+ concurrent-ruby (1.1.6)
40
+ diff-lcs (1.3)
41
+ equatable (0.6.1)
42
+ i18n (1.8.2)
43
+ concurrent-ruby (~> 1.0)
44
+ kramdown (1.16.2)
45
+ minitest (5.14.0)
46
+ necromancer (0.5.1)
47
+ pastel (0.7.3)
48
+ equatable (~> 0.6)
49
+ tty-color (~> 0.5)
50
+ phantomjs (2.1.1.0)
51
+ rake (12.3.3)
52
+ rouge (3.17.0)
53
+ rspec (3.9.0)
54
+ rspec-core (~> 3.9.0)
55
+ rspec-expectations (~> 3.9.0)
56
+ rspec-mocks (~> 3.9.0)
57
+ rspec-core (3.9.1)
58
+ rspec-support (~> 3.9.1)
59
+ rspec-expectations (3.9.1)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.9.0)
62
+ rspec-mocks (3.9.1)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.9.0)
65
+ rspec-support (3.9.2)
66
+ sitemaps_parser (0.2.3)
67
+ activesupport (>= 4, < 7)
68
+ strings (0.1.8)
69
+ strings-ansi (~> 0.1)
70
+ unicode-display_width (~> 1.5)
71
+ unicode_utils (~> 1.4)
72
+ strings-ansi (0.1.0)
73
+ thor (0.20.3)
74
+ thread_safe (0.3.6)
75
+ tty-box (0.5.0)
76
+ pastel (~> 0.7.2)
77
+ strings (~> 0.1.6)
78
+ tty-cursor (~> 0.7)
79
+ tty-color (0.5.1)
80
+ tty-command (0.9.0)
81
+ pastel (~> 0.7.0)
82
+ tty-config (0.3.2)
83
+ tty-cursor (0.7.1)
84
+ tty-editor (0.5.1)
85
+ tty-prompt (~> 0.19)
86
+ tty-which (~> 0.4)
87
+ tty-file (0.8.0)
88
+ diff-lcs (~> 1.3)
89
+ pastel (~> 0.7.2)
90
+ tty-prompt (~> 0.18)
91
+ tty-font (0.4.0)
92
+ tty-logger (0.2.0)
93
+ pastel (~> 0.7.0)
94
+ tty-markdown (0.6.0)
95
+ kramdown (~> 1.16.2)
96
+ pastel (~> 0.7.2)
97
+ rouge (~> 3.3)
98
+ strings (~> 0.1.4)
99
+ tty-color (~> 0.4)
100
+ tty-screen (~> 0.6)
101
+ tty-pager (0.12.1)
102
+ strings (~> 0.1.4)
103
+ tty-screen (~> 0.6)
104
+ tty-which (~> 0.4)
105
+ tty-pie (0.3.0)
106
+ pastel (~> 0.7.3)
107
+ tty-cursor (~> 0.7)
108
+ tty-platform (0.3.0)
109
+ tty-progressbar (0.17.0)
110
+ strings-ansi (~> 0.1.0)
111
+ tty-cursor (~> 0.7)
112
+ tty-screen (~> 0.7)
113
+ unicode-display_width (~> 1.6)
114
+ tty-prompt (0.21.0)
115
+ necromancer (~> 0.5.0)
116
+ pastel (~> 0.7.0)
117
+ tty-reader (~> 0.7.0)
118
+ tty-reader (0.7.0)
119
+ tty-cursor (~> 0.7)
120
+ tty-screen (~> 0.7)
121
+ wisper (~> 2.0.0)
122
+ tty-screen (0.7.1)
123
+ tty-spinner (0.9.3)
124
+ tty-cursor (~> 0.7)
125
+ tty-table (0.11.0)
126
+ equatable (~> 0.6)
127
+ necromancer (~> 0.5)
128
+ pastel (~> 0.7.2)
129
+ strings (~> 0.1.5)
130
+ tty-screen (~> 0.7)
131
+ tty-tree (0.4.0)
132
+ tty-which (0.4.2)
133
+ tzinfo (1.2.7)
134
+ thread_safe (~> 0.1)
135
+ unicode-display_width (1.7.0)
136
+ unicode_utils (1.4.0)
137
+ wisper (2.0.1)
138
+ zeitwerk (2.3.0)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ bundler (~> 2.0)
145
+ cruncher!
146
+ rake (~> 12.0)
147
+ rspec (~> 3.0)
148
+
149
+ BUNDLED WITH
150
+ 2.1.4
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Peter Dedene
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # Cruncher
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/cruncher`. 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 'cruncher'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cruncher
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 spec` 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]/cruncher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cruncher/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## Code of Conduct
39
+
40
+ Everyone interacting in the Cruncher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cruncher/blob/master/CODE_OF_CONDUCT.md).
41
+
42
+ ## Copyright
43
+
44
+ Copyright (c) 2020 Peter Dedene. See [MIT License](LICENSE.txt) for further details.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cruncher"
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(__FILE__)
@@ -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
@@ -0,0 +1,57 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "cruncher/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "cruncher"
7
+ spec.license = "MIT"
8
+ spec.version = Cruncher::VERSION
9
+ spec.authors = ["Zenjoy"]
10
+ spec.email = ["hallo@zenjoy.be"]
11
+
12
+ spec.summary = %q{Cruncher looks at your website and spits out the cookies used.}
13
+ spec.homepage = "https://github.com/zenjoy/cruncher"
14
+
15
+ #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/zenjoy/cruncher"
19
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "tty-box", "~> 0.5"
31
+ spec.add_dependency "tty-color", "~> 0.5"
32
+ spec.add_dependency "tty-command", "~> 0.9.0"
33
+ spec.add_dependency "tty-config", "~> 0.3.2"
34
+ spec.add_dependency "tty-cursor", "~> 0.7"
35
+ spec.add_dependency "tty-editor", "~> 0.5"
36
+ spec.add_dependency "tty-file", "~> 0.8.0"
37
+ spec.add_dependency "tty-font", "~> 0.4.0"
38
+ spec.add_dependency "tty-logger", "~> 0.2.0"
39
+ spec.add_dependency "tty-markdown", "~> 0.6.0"
40
+ spec.add_dependency "tty-pager", "~> 0.12"
41
+ spec.add_dependency "tty-pie", "~> 0.3.0"
42
+ spec.add_dependency "tty-platform", "~> 0.2"
43
+ spec.add_dependency "tty-progressbar", "~> 0.17"
44
+ spec.add_dependency "tty-prompt", "~> 0.19"
45
+ spec.add_dependency "tty-screen", "~> 0.7"
46
+ spec.add_dependency "tty-spinner", "~> 0.9"
47
+ spec.add_dependency "tty-table", "~> 0.11.0"
48
+ spec.add_dependency "tty-tree", "~> 0.3"
49
+ spec.add_dependency "tty-which", "~> 0.4"
50
+ spec.add_dependency "pastel", "~> 0.7.2"
51
+ spec.add_dependency "thor", "~> 0.20.0"
52
+ spec.add_dependency "phantomjs", "~> 2.1.1"
53
+ spec.add_dependency "sitemaps_parser", "~> 0.2.3"
54
+
55
+ spec.add_development_dependency "bundler", "~> 2.0"
56
+ spec.add_development_dependency "rake", "~> 10.0"
57
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'cruncher/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ ARGV.unshift(Cruncher::CLI.default_task) unless Cruncher::CLI.all_tasks.has_key?(ARGV[0]) || Cruncher::CLI.instance_variable_get(:@map).has_key?(ARGV[0])
15
+ Cruncher::CLI.start(ARGV)
16
+ rescue Cruncher::CLI::Error => err
17
+ puts "ERROR: #{err.message}"
18
+ exit 1
19
+ end
@@ -0,0 +1,6 @@
1
+ require "cruncher/version"
2
+
3
+ module Cruncher
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Cruncher
6
+ # Handle the application command line parsing
7
+ # and the dispatch to various command objects
8
+ #
9
+ # @api public
10
+ class CLI < Thor
11
+ default_task :scan
12
+
13
+ # Error raised by this runner
14
+ Error = Class.new(StandardError)
15
+
16
+ desc 'version', 'cruncher version'
17
+ def version
18
+ require_relative 'version'
19
+ puts "v#{Cruncher::VERSION}"
20
+ end
21
+ map %w(--version -v) => :version
22
+
23
+ desc 'scan URL', 'Command description...'
24
+ method_option :help, aliases: '-h', type: :boolean,
25
+ desc: 'Display usage information'
26
+ def scan(url)
27
+ if options[:help]
28
+ invoke :help, ['scan']
29
+ else
30
+ require_relative 'commands/scan'
31
+ Cruncher::Commands::Scan.new(url, options).execute
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Cruncher
6
+ class Command
7
+ extend Forwardable
8
+
9
+ def_delegators :command, :run
10
+
11
+ # Execute this command
12
+ #
13
+ # @api public
14
+ def execute(*)
15
+ raise(
16
+ NotImplementedError,
17
+ "#{self.class}##{__method__} must be implemented"
18
+ )
19
+ end
20
+
21
+ # The external commands runner
22
+ #
23
+ # @see http://www.rubydoc.info/gems/tty-command
24
+ #
25
+ # @api public
26
+ def command(**options)
27
+ require 'tty-command'
28
+ TTY::Command.new(options)
29
+ end
30
+
31
+ # The cursor movement
32
+ #
33
+ # @see http://www.rubydoc.info/gems/tty-cursor
34
+ #
35
+ # @api public
36
+ def cursor
37
+ require 'tty-cursor'
38
+ TTY::Cursor
39
+ end
40
+
41
+ # Open a file or text in the user's preferred editor
42
+ #
43
+ # @see http://www.rubydoc.info/gems/tty-editor
44
+ #
45
+ # @api public
46
+ def editor
47
+ require 'tty-editor'
48
+ TTY::Editor
49
+ end
50
+
51
+ # File manipulation utility methods
52
+ #
53
+ # @see http://www.rubydoc.info/gems/tty-file
54
+ #
55
+ # @api public
56
+ def generator
57
+ require 'tty-file'
58
+ TTY::File
59
+ end
60
+
61
+ # Terminal output paging
62
+ #
63
+ # @see http://www.rubydoc.info/gems/tty-pager
64
+ #
65
+ # @api public
66
+ def pager(**options)
67
+ require 'tty-pager'
68
+ TTY::Pager.new(options)
69
+ end
70
+
71
+ # Terminal platform and OS properties
72
+ #
73
+ # @see http://www.rubydoc.info/gems/tty-pager
74
+ #
75
+ # @api public
76
+ def platform
77
+ require 'tty-platform'
78
+ TTY::Platform.new
79
+ end
80
+
81
+ # The interactive prompt
82
+ #
83
+ # @see http://www.rubydoc.info/gems/tty-prompt
84
+ #
85
+ # @api public
86
+ def prompt(**options)
87
+ require 'tty-prompt'
88
+ TTY::Prompt.new(options)
89
+ end
90
+
91
+ # Get terminal screen properties
92
+ #
93
+ # @see http://www.rubydoc.info/gems/tty-screen
94
+ #
95
+ # @api public
96
+ def screen
97
+ require 'tty-screen'
98
+ TTY::Screen
99
+ end
100
+
101
+ # The unix which utility
102
+ #
103
+ # @see http://www.rubydoc.info/gems/tty-which
104
+ #
105
+ # @api public
106
+ def which(*args)
107
+ require 'tty-which'
108
+ TTY::Which.which(*args)
109
+ end
110
+
111
+ # Check if executable exists
112
+ #
113
+ # @see http://www.rubydoc.info/gems/tty-which
114
+ #
115
+ # @api public
116
+ def exec_exist?(*args)
117
+ require 'tty-which'
118
+ TTY::Which.exist?(*args)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,53 @@
1
+ var page = require("webpage").create(),
2
+ system = require("system"),
3
+ address,
4
+ _output = { cookies: [], resources: { js: [] } };
5
+
6
+ if (system.args.length === 1) {
7
+ console.log("Usage: phantomjs fetch_cookies.js <some URL>");
8
+ phantom.exit(-1); // -1: no input provided
9
+ }
10
+
11
+ // record callback on resource received
12
+ page.onResourceReceived = function (response) {
13
+ if (response.contentType && response.contentType.indexOf("javascript") >= 0) {
14
+ // consider only js resources
15
+ if (response.stage == "start") {
16
+ // consider only requests for js (not also responses)
17
+ _output.resources.js.push({ url: response.url }); // record resource
18
+ }
19
+ }
20
+ };
21
+
22
+ // record callback on load finished
23
+ page.onLoadFinished = function (status) {
24
+ if (status == "success") {
25
+ _output.cookies = phantom.cookies; // record cookies
26
+ console.log(JSON.stringify(_output, null, 2));
27
+ phantom.exit();
28
+ } else {
29
+ console.log("Failed to load the requested URL: " + address);
30
+ phantom.exit(-3); // -3: generic fail
31
+ }
32
+ };
33
+
34
+ // open web page
35
+ phantom.cookiesEnabled = true;
36
+ address = system.args[1];
37
+ page.open(address, function (status) {
38
+ if (status == "success") {
39
+ _output.cookies = phantom.cookies; // record cookies
40
+ } else {
41
+ console.log("Unable to open provided URL: " + address);
42
+ phantom.exit(-2); // -2: unable to open provided URL
43
+ }
44
+ });
45
+
46
+ // to avoid errors detected while parsing the page (eg. Syntax Error, Type Error, etc.)
47
+ // getting into stdout, so breaking the JSON decoding of returned output.
48
+ page.onError = function (msg, trace) {
49
+ // console.log(msg);
50
+ // trace.forEach(function(item) {
51
+ // console.log(' ', item.file, ':', item.line);
52
+ // })
53
+ };
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+
5
+ module Cruncher
6
+ module Commands
7
+ class Scan < Cruncher::Command
8
+ def initialize(url, options)
9
+ @url = url
10
+ @options = options
11
+ end
12
+
13
+ def execute(input: $stdin, output: $stdout)
14
+ require 'tty-box'
15
+
16
+ box = TTY::Box.frame "Cookie Cruncher", padding: [0,2], align: :center, border: :thick
17
+ output.puts(box + "\n")
18
+
19
+ require 'sitemaps'
20
+ require 'phantomjs'
21
+ require 'json'
22
+ require 'pastel'
23
+ require 'tty-spinner'
24
+ require 'tty-progressbar'
25
+ require 'tty-table'
26
+
27
+ pastel = Pastel.new
28
+ phantomjs_file = File.join(File.dirname(__FILE__), "./fetch.js")
29
+
30
+ spinner = TTY::Spinner.new("[:spinner] Fetching sitemap from #{pastel.white.bold(@url)}", format: :dots, hide_cursor: true)
31
+ spinner.auto_spin
32
+
33
+ sitemap = Sitemaps.fetch(@url)
34
+
35
+ nb_pages = sitemap.entries.length
36
+ spinner.success("(done - #{nb_pages} pages found)")
37
+ cookies = {}
38
+
39
+ spinner = TTY::Spinner.new("[:spinner] #{pastel.dim('(:current/:total)')} scanning :title", format: :dots, hide_cursor: true)
40
+ spinner.auto_spin
41
+
42
+ sitemap.entries.map(&:loc).each_with_index do |loc,i|
43
+ spinner.update(title: pastel.white.bold(loc.to_s), current: i + 1, total: nb_pages)
44
+
45
+ s = StringIO.new
46
+
47
+ Phantomjs.run(phantomjs_file, loc.to_s) { |line| s << line }
48
+ json = JSON.parse(s.string)
49
+
50
+ cookies_for_page = Array(json.fetch('cookies'))
51
+ cookies_for_page.each do |cookie|
52
+ domain = cookie["domain"].to_s.gsub(/^\./,'')
53
+ name = cookie["name"]
54
+ cookies[name] ||= cookie
55
+ cookies[name]['domain'] = domain
56
+ cookies[name]['found_on'] ||= []
57
+ cookies[name]['found_on'] << loc.path.to_s
58
+ end
59
+ end
60
+ spinner.success("(done)\n")
61
+
62
+ data_for_table = cookies.keys.sort.map do |name|
63
+ cookie = cookies[name]
64
+ [
65
+ cookie["domain"],
66
+ cookie["name"],
67
+ cookie["expires"],
68
+ cookie['found_on'].length == nb_pages ? pastel.dim('all pages') : cookie['found_on'].join("\n")
69
+ ]
70
+ end.sort_by(&:first)
71
+ table = TTY::Table.new(['Domain','Name','Expiration','Found on'], data_for_table)
72
+
73
+ output.puts table.render(:ascii, padding: [0,1], multiline: true)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ module Cruncher
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,433 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cruncher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zenjoy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-box
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-color
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-command
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-config
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.3.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-cursor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-editor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-file
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-font
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: tty-logger
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.2.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.2.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: tty-markdown
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.6.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: tty-pager
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.12'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.12'
167
+ - !ruby/object:Gem::Dependency
168
+ name: tty-pie
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.3.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.3.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: tty-platform
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.2'
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty-progressbar
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.17'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.17'
209
+ - !ruby/object:Gem::Dependency
210
+ name: tty-prompt
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.19'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.19'
223
+ - !ruby/object:Gem::Dependency
224
+ name: tty-screen
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '0.7'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.7'
237
+ - !ruby/object:Gem::Dependency
238
+ name: tty-spinner
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.9'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.9'
251
+ - !ruby/object:Gem::Dependency
252
+ name: tty-table
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 0.11.0
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: 0.11.0
265
+ - !ruby/object:Gem::Dependency
266
+ name: tty-tree
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '0.3'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '0.3'
279
+ - !ruby/object:Gem::Dependency
280
+ name: tty-which
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '0.4'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '0.4'
293
+ - !ruby/object:Gem::Dependency
294
+ name: pastel
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: 0.7.2
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: 0.7.2
307
+ - !ruby/object:Gem::Dependency
308
+ name: thor
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: 0.20.0
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: 0.20.0
321
+ - !ruby/object:Gem::Dependency
322
+ name: phantomjs
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - "~>"
326
+ - !ruby/object:Gem::Version
327
+ version: 2.1.1
328
+ type: :runtime
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - "~>"
333
+ - !ruby/object:Gem::Version
334
+ version: 2.1.1
335
+ - !ruby/object:Gem::Dependency
336
+ name: sitemaps_parser
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: 0.2.3
342
+ type: :runtime
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: 0.2.3
349
+ - !ruby/object:Gem::Dependency
350
+ name: bundler
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '2.0'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '2.0'
363
+ - !ruby/object:Gem::Dependency
364
+ name: rake
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - "~>"
368
+ - !ruby/object:Gem::Version
369
+ version: '10.0'
370
+ type: :development
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - "~>"
375
+ - !ruby/object:Gem::Version
376
+ version: '10.0'
377
+ description:
378
+ email:
379
+ - hallo@zenjoy.be
380
+ executables:
381
+ - cruncher
382
+ extensions: []
383
+ extra_rdoc_files: []
384
+ files:
385
+ - ".gitignore"
386
+ - ".rspec"
387
+ - ".travis.yml"
388
+ - CODE_OF_CONDUCT.md
389
+ - Gemfile
390
+ - Gemfile.lock
391
+ - LICENSE.txt
392
+ - README.md
393
+ - Rakefile
394
+ - bin/console
395
+ - bin/setup
396
+ - cruncher.gemspec
397
+ - exe/cruncher
398
+ - lib/cruncher.rb
399
+ - lib/cruncher/cli.rb
400
+ - lib/cruncher/command.rb
401
+ - lib/cruncher/commands/.gitkeep
402
+ - lib/cruncher/commands/fetch.js
403
+ - lib/cruncher/commands/scan.rb
404
+ - lib/cruncher/templates/.gitkeep
405
+ - lib/cruncher/templates/scan/.gitkeep
406
+ - lib/cruncher/version.rb
407
+ homepage: https://github.com/zenjoy/cruncher
408
+ licenses:
409
+ - MIT
410
+ metadata:
411
+ homepage_uri: https://github.com/zenjoy/cruncher
412
+ source_code_uri: https://github.com/zenjoy/cruncher
413
+ post_install_message:
414
+ rdoc_options: []
415
+ require_paths:
416
+ - lib
417
+ required_ruby_version: !ruby/object:Gem::Requirement
418
+ requirements:
419
+ - - ">="
420
+ - !ruby/object:Gem::Version
421
+ version: '0'
422
+ required_rubygems_version: !ruby/object:Gem::Requirement
423
+ requirements:
424
+ - - ">="
425
+ - !ruby/object:Gem::Version
426
+ version: '0'
427
+ requirements: []
428
+ rubyforge_project:
429
+ rubygems_version: 2.7.6.2
430
+ signing_key:
431
+ specification_version: 4
432
+ summary: Cruncher looks at your website and spits out the cookies used.
433
+ test_files: []