bqm 1.0.2 → 1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bqm +33 -5
  3. data/data/query-sets.json +6 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348a96aed509a774a1848651efa6a17d52aac51e47b2e229daeba4fb933771a6
4
- data.tar.gz: b2262ae4e6b24773b97cd4e19e2f4ba4bcf9e1f2dc8d4af6da2653d30b02e56a
3
+ metadata.gz: 0f38e89871f7a22fe4917e8a66011a93b11bfa2557fa51035062b8fe06b9b6b4
4
+ data.tar.gz: a37b68ffe558b5e387ee9253d7ca01f25a2bdb5a2e39fa63997577a2d9979c08
5
5
  SHA512:
6
- metadata.gz: 9dc21de90441bfc6add73d79b01c52ce5e530b28c94c62560913dea39805cb2615139a41da329ebba966d8aa964262ff6aaefc352b3c8246c43a2f9dc43465e5
7
- data.tar.gz: ca1d114fdb1d024d4565d061ef669ecedaf89ecfe89be730658c8823b739a40ce2d9cadce380a47c6ed9079587b302c5b7ebb2773e9f7a2208e3040790a3866a
6
+ metadata.gz: bc2f3b83876b97cb41002d5508f745becdffdb3953d0fcefa721017acefb06e9026ecb0a4c5f27f5f5f503d87b78a53ff45cdf1ffd2e240c748c4518627430e5
7
+ data.tar.gz: f0d0bee9d057c113bcfa7c92897896166cd05df20a392e1941dc6f4f6f2f2f8fa39f31fe106ce1b7f0fbd2832df25ef776c5534ab8f876ac4f75f26c8df355df
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,25 @@ 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
+ src = JSON.load_file(source)
63
+ src['sets']
64
+ end
65
+
49
66
  if __FILE__ == $PROGRAM_NAME
50
67
  source = find_dataset
51
- data = merge(source)
52
- queries = deduplicate(data).map(&:data)
53
68
 
54
69
  require 'optparse'
55
70
  options = {}
@@ -57,16 +72,29 @@ if __FILE__ == $PROGRAM_NAME
57
72
  parser.banner = 'Usage: bqm [options]'
58
73
 
59
74
  parser.on('-o', '--output-path PATH', 'Path where to store the query file')
75
+ parser.on('-l', '--list', 'List available datasets')
60
76
  parser.separator ''
61
77
  parser.separator 'Example: bqm -o ~/.config/bloodhound/customqueries.json'
62
78
  end.parse!(into: options)
63
79
 
64
80
  out = options[:'output-path']
65
- if out
81
+ list = options[:list]
82
+ if list
83
+ puts '[+] Available datasets:'
84
+ pretty_link(get_datasets(source)).each do |l|
85
+ puts l
86
+ end
87
+ elsif out
88
+ puts '[+] Fetching and merging datasets'
89
+ data = merge(source)
90
+ puts '[+] Removing duplicates'
91
+ queries = deduplicate(data).map(&:data)
92
+
66
93
  File.open(out, 'w') do |file|
67
94
  json = JSON.pretty_generate({ 'queries' => queries })
68
95
  file.write(json)
69
96
  end
97
+ puts "[+] All queries have been merged in #{out}"
70
98
  else
71
99
  puts 'Help: bqm -h'
72
100
  end
data/data/query-sets.json CHANGED
@@ -6,6 +6,11 @@
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,7 +1,7 @@
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre ZANNI