drupal_detect 0.1.0
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 +7 -0
- data/README.md +29 -0
- data/Rakefile +4 -0
- data/lib/drupal_detect/version.rb +5 -0
- data/lib/drupal_detect.rb +69 -0
- data/sig/drupal_detect.rbs +4 -0
- metadata +77 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 34a9ec9bdb821a1c7662affc37bfb2b8e303f769015cb4a687d66b4553169f37
|
|
4
|
+
data.tar.gz: ee4a23a6b332f38ea894ede086558f175b1f32d969a11c94a9ef3199be831bf4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3a89ccb6abdb95de40e24380e9d9557d134f203e5aff8b4b8c4514e97bc2bc3e62475e5582a3d7a797604862e3fa20018e65e7c2c1f392999ad05437742cfc6a
|
|
7
|
+
data.tar.gz: e1ee1bdc1e17aafcf59404763ccf5006455f77c36c9281c666b5d4f858f6f45d9da0d58c8702ac6b72b2d7fe0cca5c2103049ff45295bca5549c66fd836ff432
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# DrupalDetect
|
|
2
|
+
The purpose of this gem is to detect if the site is running Drupal. It will checked the headers of the site after sending a request to the site. If the word drupal is found in the headers it will get the version of drupal. The code will generate a score based if drupal is found in the headers. It will also go through the source of the source code and use a regex to look for the word drupal. Once again, it will add `0.5` to the drupal score. It will print the version and the `drupal_score`.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
require_relative "lib/drupal_detect"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
d = DrupalDetect::Drupal.new
|
|
15
|
+
#d.site = "https://physiologycore.umn.edu/"
|
|
16
|
+
d.site = "https://jsurgacad.com/drupal9/user/register"
|
|
17
|
+
d.drupal_score
|
|
18
|
+
d.user_brute
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/drupal_detect.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "drupal_detect/version"
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
require 'net/http'
|
|
6
|
+
require 'uri'
|
|
7
|
+
|
|
8
|
+
require 'open-uri'
|
|
9
|
+
module DrupalDetect
|
|
10
|
+
class Drupal
|
|
11
|
+
attr_accessor :site
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
@site = site
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def all
|
|
18
|
+
drupal_score
|
|
19
|
+
user_brute
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def drupal_score
|
|
23
|
+
# get a score of the possiblity that
|
|
24
|
+
# the site is using drupal. It will view the headers looking
|
|
25
|
+
# for the word drupal. The method will also get read each line
|
|
26
|
+
# of the site's source code and use a regex to match for the word drupal.
|
|
27
|
+
# and add 0.5 to the 'drupal_score'
|
|
28
|
+
drupal_score = 0
|
|
29
|
+
uri = URI(@site)
|
|
30
|
+
d = Net::HTTP.get_response(uri)
|
|
31
|
+
if d.code.to_i == 200
|
|
32
|
+
d.header.each do |k, v|
|
|
33
|
+
# it downcases the k & v to make sure it matches if it exists.
|
|
34
|
+
drupal_score += 10 if k.downcase.include?('drupal')
|
|
35
|
+
drupal_score += 10 if v.downcase.include?('drupal')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
drupal_count = 0
|
|
39
|
+
d.body.split("\n").each do |b|
|
|
40
|
+
matched = b.downcase.match(/drupal/)
|
|
41
|
+
if matched
|
|
42
|
+
drupal_count += 1
|
|
43
|
+
drupal_score += 0.5
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
doc = Nokogiri::HTML(URI.open(@site))
|
|
47
|
+
posts = doc.xpath('//meta')
|
|
48
|
+
posts.each do |l|
|
|
49
|
+
# grab the drupal version via the meta tags.
|
|
50
|
+
puts "\n\n[+] Drupal Version: #{l.attributes['content']}\n" if l.attributes['content'].to_s.include?('Drupal')
|
|
51
|
+
end
|
|
52
|
+
puts "\nDrupal Score: #{drupal_score}\n"
|
|
53
|
+
puts "Found #{drupal_count} instances of the word Drupal in the source code of the given site.\n"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def user_brute
|
|
57
|
+
(1..1000).each do |user|
|
|
58
|
+
uri = URI(File.join(@site, 'user', user.to_s))
|
|
59
|
+
u = Net::HTTP.get_response(uri).body
|
|
60
|
+
if u.include?('Page not found')
|
|
61
|
+
puts "\nUser count: #{user - 1}\n"
|
|
62
|
+
break
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: drupal_detect
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Michael-Meade
|
|
8
|
+
- Banksy
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: exe
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2025-11-08 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: nokogiri
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">="
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: net-http
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
description: Checks the headers of a site looking for drupal. It also can enumerate
|
|
43
|
+
how many users.
|
|
44
|
+
email:
|
|
45
|
+
- noway@lol.com
|
|
46
|
+
executables: []
|
|
47
|
+
extensions: []
|
|
48
|
+
extra_rdoc_files: []
|
|
49
|
+
files:
|
|
50
|
+
- README.md
|
|
51
|
+
- Rakefile
|
|
52
|
+
- lib/drupal_detect.rb
|
|
53
|
+
- lib/drupal_detect/version.rb
|
|
54
|
+
- sig/drupal_detect.rbs
|
|
55
|
+
homepage:
|
|
56
|
+
licenses: []
|
|
57
|
+
metadata: {}
|
|
58
|
+
post_install_message:
|
|
59
|
+
rdoc_options: []
|
|
60
|
+
require_paths:
|
|
61
|
+
- lib
|
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0'
|
|
72
|
+
requirements: []
|
|
73
|
+
rubygems_version: 3.4.20
|
|
74
|
+
signing_key:
|
|
75
|
+
specification_version: 4
|
|
76
|
+
summary: Detects if a site is running Drupal.
|
|
77
|
+
test_files: []
|