bqm 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bqm +37 -5
  3. data/data/query-sets.json +8 -3
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348a96aed509a774a1848651efa6a17d52aac51e47b2e229daeba4fb933771a6
4
- data.tar.gz: b2262ae4e6b24773b97cd4e19e2f4ba4bcf9e1f2dc8d4af6da2653d30b02e56a
3
+ metadata.gz: 28bbff6c42f4653702f6e091868d7b54e83b461c3501a5eeffd5d423a04445e2
4
+ data.tar.gz: dc65921e523353a6ab7ae6be055e901c9cb8d83c4fb1f2c7483e8029d2408903
5
5
  SHA512:
6
- metadata.gz: 9dc21de90441bfc6add73d79b01c52ce5e530b28c94c62560913dea39805cb2615139a41da329ebba966d8aa964262ff6aaefc352b3c8246c43a2f9dc43465e5
7
- data.tar.gz: ca1d114fdb1d024d4565d061ef669ecedaf89ecfe89be730658c8823b739a40ce2d9cadce380a47c6ed9079587b302c5b7ebb2773e9f7a2208e3040790a3866a
6
+ metadata.gz: 2fe4cc56dd34eed52c1d817867bad75399a4df798a66f87d897141441fee53418e3d1e3d33818efb97c49c928156db66ff0874215977ec6c1972d43b4d2e6a9e
7
+ data.tar.gz: 57b22d6b6724487fb7316b746c3fb6c3d0236de816a057cfafefb09e7321a80b27d5df77cd51b0f474a525ed62830486c7e1e478acaf7c5fdc4fd394478aecff
data/bin/bqm CHANGED
@@ -15,9 +15,9 @@ def find_dataset
15
15
  end
16
16
 
17
17
  def merge(source)
18
- src = JSON.load_file(source)
18
+ sets = get_datasets(source)
19
19
  queries = []
20
- src['sets'].each do |s|
20
+ sets.each do |s|
21
21
  customqueries = Net::HTTP.get(URI(s))
22
22
  data = JSON.parse(customqueries)
23
23
  queries += data['queries']
@@ -46,10 +46,29 @@ def deduplicate(data)
46
46
  data.map { |x| BQMquery.new(x) }.uniq
47
47
  end
48
48
 
49
+ # Transform a list of raw github links to pretty github links
50
+ # from https://raw.githubusercontent.com/namespace/project/branch/file.ext
51
+ # to https://github.com/namespace/project/blob/branch/file.ext
52
+ def pretty_link(lst)
53
+ output = []
54
+ lst.each do |link|
55
+ _protocol, _void, _host, namespace, project, branch, *path = link.split('/')
56
+ output << " https://github.com/#{namespace}/#{project}/blob/#{branch}/#{path.join('/')}"
57
+ end
58
+ output
59
+ end
60
+
61
+ def get_datasets(source)
62
+ begin # ruby 3.0+
63
+ src = JSON.load_file(source)
64
+ rescue NoMethodError # ruby 2.7 retro-compatibility
65
+ src = JSON.parse(File.read(source))
66
+ end
67
+ src['sets']
68
+ end
69
+
49
70
  if __FILE__ == $PROGRAM_NAME
50
71
  source = find_dataset
51
- data = merge(source)
52
- queries = deduplicate(data).map(&:data)
53
72
 
54
73
  require 'optparse'
55
74
  options = {}
@@ -57,16 +76,29 @@ if __FILE__ == $PROGRAM_NAME
57
76
  parser.banner = 'Usage: bqm [options]'
58
77
 
59
78
  parser.on('-o', '--output-path PATH', 'Path where to store the query file')
79
+ parser.on('-l', '--list', 'List available datasets')
60
80
  parser.separator ''
61
81
  parser.separator 'Example: bqm -o ~/.config/bloodhound/customqueries.json'
62
82
  end.parse!(into: options)
63
83
 
64
84
  out = options[:'output-path']
65
- if out
85
+ list = options[:list]
86
+ if list
87
+ puts '[+] Available datasets:'
88
+ pretty_link(get_datasets(source)).each do |l|
89
+ puts l
90
+ end
91
+ elsif out
92
+ puts '[+] Fetching and merging datasets'
93
+ data = merge(source)
94
+ puts '[+] Removing duplicates'
95
+ queries = deduplicate(data).map(&:data)
96
+
66
97
  File.open(out, 'w') do |file|
67
98
  json = JSON.pretty_generate({ 'queries' => queries })
68
99
  file.write(json)
69
100
  end
101
+ puts "[+] All queries have been merged in #{out}"
70
102
  else
71
103
  puts 'Help: bqm -h'
72
104
  end
data/data/query-sets.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "sets": [
3
3
  "https://raw.githubusercontent.com/ly4k/Certipy/main/customqueries.json",
4
- "https://raw.githubusercontent.com/CompassSecurity/BloodHoundQueries/master/customqueries.json",
4
+ "https://raw.githubusercontent.com/CompassSecurity/BloodHoundQueries/master/BloodHound_Custom_Queries/customqueries.json",
5
5
  "https://raw.githubusercontent.com/hausec/Bloodhound-Custom-Queries/master/customqueries.json",
6
6
  "https://raw.githubusercontent.com/awsmhacks/awsmBloodhoundCustomQueries/master/customqueries.json",
7
7
  "https://raw.githubusercontent.com/porterhau5/BloodHound-Owned/master/customqueries.json",
8
8
  "https://raw.githubusercontent.com/ZephrFish/Bloodhound-CustomQueries/main/customqueries.json",
9
- "https://raw.githubusercontent.com/Scoubi/BloodhoundAD-Queries/master/customqueries.json"
9
+ "https://raw.githubusercontent.com/Scoubi/BloodhoundAD-Queries/master/customqueries.json",
10
+ "https://raw.githubusercontent.com/InfamousSYN/bloodhound-queries/main/customqueries.json",
11
+ "https://raw.githubusercontent.com/zeronetworks/BloodHound-Tools/main/CustomQueries/customqueries.json",
12
+ "https://raw.githubusercontent.com/egypt/customqueries/master/customqueries.json",
13
+ "https://raw.githubusercontent.com/trustedsec/CrackHound/main/customqueries.json",
14
+ "https://raw.githubusercontent.com/aress31/bloodhound-utils/main/customqueries.json"
10
15
  ]
11
- }
16
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bqm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre ZANNI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Deduplicate custom BloudHound queries from different datasets and merge
14
14
  them in one customqueries.json file.
@@ -40,14 +40,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
40
  version: 2.6.0
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '3.2'
43
+ version: '3.3'
44
44
  required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  requirements: []
50
- rubygems_version: 3.3.7
50
+ rubygems_version: 3.4.1
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: Download BloudHound query lists, deduplicate entries and merge them in one