bqm 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/bqm.rb +73 -0
- data/data/query-sets.json +11 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e2f3d5208930a05737b9a4a7689d4e3fd8a3b75c7d2c914169008386c9fce38
|
4
|
+
data.tar.gz: 349dfdeb788a612d2a4231a8a8ee05ead1631bb0d4743b28daad92d5f35d55f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a6089672981c16b887f00815e4f8ea9b3819792c12503cb862d3149cb75ed6c1422955cf2d6893d5bd4d9905dffaf55106c1982a88f82857af10591019611c3
|
7
|
+
data.tar.gz: 4cce267816043816f8fd56046b6aa481e3d6d920274462b77da4766d5c23bfda99977aa4fb02256975f3dd8beb77d4b883c0171994019dc50b94843c33af0023
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Alexandre ZANNI at ACCEIS
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/bqm.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
def find_dataset
|
8
|
+
source_file = 'query-sets.json'
|
9
|
+
source_file_paths = ['./data', '/usr/share/bqm/data', '~/.local/share/bqm/data']
|
10
|
+
source_file_paths.each do |path|
|
11
|
+
candidate = "#{path}/#{source_file}"
|
12
|
+
return candidate if File.file?(candidate) && File.readable?(candidate)
|
13
|
+
end
|
14
|
+
raise IOError, "The dataset file #{source_file} does not exist or is unreadable."
|
15
|
+
end
|
16
|
+
|
17
|
+
def merge(source)
|
18
|
+
src = JSON.load_file(source)
|
19
|
+
queries = []
|
20
|
+
src['sets'].each do |s|
|
21
|
+
customqueries = Net::HTTP.get(URI(s))
|
22
|
+
data = JSON.parse(customqueries)
|
23
|
+
queries += data['queries']
|
24
|
+
end
|
25
|
+
queries
|
26
|
+
end
|
27
|
+
|
28
|
+
# Query class just for the sake of having custom comparison
|
29
|
+
class BQMquery
|
30
|
+
attr_accessor :data
|
31
|
+
|
32
|
+
def initialize(query)
|
33
|
+
@data = query
|
34
|
+
end
|
35
|
+
|
36
|
+
def eql?(other)
|
37
|
+
@data['name'].eql?(other.data['name']) && @data['queryList'].eql?(other.data['queryList'])
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash
|
41
|
+
@data.hash
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def deduplicate(data)
|
46
|
+
data.map { |x| BQMquery.new(x) }.uniq
|
47
|
+
end
|
48
|
+
|
49
|
+
if __FILE__ == $PROGRAM_NAME
|
50
|
+
source = find_dataset
|
51
|
+
data = merge(source)
|
52
|
+
queries = deduplicate(data).map(&:data)
|
53
|
+
|
54
|
+
require 'optparse'
|
55
|
+
options = {}
|
56
|
+
OptionParser.new do |parser|
|
57
|
+
parser.banner = 'Usage: bqm.rb [options]'
|
58
|
+
|
59
|
+
parser.on('-o', '--output-path PATH', 'Path where to store the query file')
|
60
|
+
parser.separator ''
|
61
|
+
parser.separator 'Example: bqm.rb -o ~/.config/bloodhound/customqueries.json'
|
62
|
+
end.parse!(into: options)
|
63
|
+
|
64
|
+
out = options[:'output-path']
|
65
|
+
if out
|
66
|
+
File.open(out, 'w') do |file|
|
67
|
+
json = JSON.pretty_generate({ 'queries' => queries })
|
68
|
+
file.write(json)
|
69
|
+
end
|
70
|
+
else
|
71
|
+
puts 'Help: bqm.rb -h'
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"sets": [
|
3
|
+
"https://raw.githubusercontent.com/ly4k/Certipy/main/customqueries.json",
|
4
|
+
"https://raw.githubusercontent.com/CompassSecurity/BloodHoundQueries/master/customqueries.json",
|
5
|
+
"https://raw.githubusercontent.com/hausec/Bloodhound-Custom-Queries/master/customqueries.json",
|
6
|
+
"https://raw.githubusercontent.com/awsmhacks/awsmBloodhoundCustomQueries/master/customqueries.json",
|
7
|
+
"https://raw.githubusercontent.com/porterhau5/BloodHound-Owned/master/customqueries.json",
|
8
|
+
"https://raw.githubusercontent.com/ZephrFish/Bloodhound-CustomQueries/main/customqueries.json",
|
9
|
+
"https://raw.githubusercontent.com/Scoubi/BloodhoundAD-Queries/master/customqueries.json"
|
10
|
+
]
|
11
|
+
}
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bqm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexandre ZANNI
|
8
|
+
autorequire:
|
9
|
+
bindir: "."
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Deduplicate custom BloudHound queries from different datasets and merge
|
14
|
+
them in one customqueries.json file.
|
15
|
+
email: alexandre.zanni@europe.com
|
16
|
+
executables:
|
17
|
+
- bqm.rb
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- "./bqm.rb"
|
22
|
+
- LICENSE
|
23
|
+
- bqm.rb
|
24
|
+
- data/query-sets.json
|
25
|
+
homepage: https://github.com/Acceis/bqm
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata:
|
29
|
+
bug_tracker_uri: https://github.com/Acceis/bqm/issues
|
30
|
+
homepage_uri: https://github.com/Acceis/bqm
|
31
|
+
source_code_uri: https://github.com/Acceis/bqm/
|
32
|
+
rubygems_mfa_required: 'true'
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.6.0
|
42
|
+
- - "<"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '3.2'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.3.7
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Download BloudHound query lists, deduplicate entries and merge them in one
|
55
|
+
file.
|
56
|
+
test_files: []
|