Skip to content

Commit deef85d

Browse files
authored
Merge pull request #19779 from h00die/action_update_weekly
Weekly Updater Action
2 parents 7f5f459 + e6fb4f8 commit deef85d

6 files changed

+289
-76
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Weekly Data and External Tool Updater
2+
3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
actions: none
6+
checks: none
7+
contents: none
8+
deployments: none
9+
id-token: none
10+
issues: none
11+
discussions: none
12+
packages: none
13+
pages: none
14+
pull-requests: write
15+
repository-projects: none
16+
security-events: none
17+
statuses: none
18+
19+
on:
20+
schedule:
21+
# Run once a week (e.g., every Monday at 01:00 UTC)
22+
- cron: '0 1 * * 1'
23+
workflow_dispatch: # Allows manual triggering from the Actions tab
24+
25+
jobs:
26+
update-data-files:
27+
runs-on: ubuntu-latest
28+
29+
env:
30+
BUNDLE_WITHOUT: "coverage development pcap"
31+
32+
strategy:
33+
fail-fast: true
34+
matrix:
35+
ruby:
36+
- '3.2'
37+
38+
steps:
39+
- name: Install system dependencies
40+
run: sudo apt-get install libpcap-dev graphviz
41+
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
47+
- uses: ruby/setup-ruby@v1
48+
with:
49+
ruby-version: '${{ matrix.ruby }}'
50+
bundler-cache: true
51+
52+
- name: Run Ruby updater scripts
53+
run: |
54+
ruby tools/dev/update_wordpress_vulnerabilities.rb
55+
ruby tools/dev/update_joomla_components.rb
56+
ruby tools/dev/update_user_agent_strings.rb
57+
ruby tools/dev/check_external_scripts.rb -u
58+
- name: Remove vendor folder # prevent git from adding it
59+
run: rm -rf vendor
60+
61+
- name: Create Pull Request
62+
uses: peter-evans/create-pull-request@v7
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
commit-message: Update report
66+
base: master
67+
branch: weekly-updates
68+
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
69+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
70+
title: "Weekly Data Update"
71+
draft: false
72+
body: |
73+
This pull request was created automatically by a GitHub Action to update data files and external scripts.
74+
The following tools were run:
75+
- ruby tools/dev/update_wordpress_vulnerabilities.rb
76+
- ruby tools/dev/update_joomla_components.rb
77+
- ruby tools/dev/update_user_agent_strings.rb
78+
- ruby tools/dev/check_external_scripts.rb -u
79+
## Verification
80+
### Wordpress/Joomla Files
81+
- [ ] Do a sanity check, do the additions look legit?
82+
- [ ] Start `msfconsole`
83+
- [ ] `use modules/auxiliary/scanner/http/wordpress_scanner`
84+
- [ ] **Verify** it runs
85+
### JTR Files
86+
- [ ] Do a sanity check, do the additions look legit?
87+
- [ ] See https://docs.metasploit.com/docs/using-metasploit/intermediate/hashes-and-password-cracking.html#example-hashes for hashes and cracking
88+
### SharpHound
89+
- [ ] Start `msfconsole`
90+
- [ ] get a shell on a DC or box connected to a dc
91+
- [ ] `use post/windows/gather/bloodhound`
92+
- [ ] `set session`
93+
- [ ] `run`
94+
- [ ] **Verify** it runs w/o erroring
95+
- [ ] `set method disk`
96+
- [ ] **Verify** it runs w/o erroring

tools/dev/update_joomla_components.py

-16
This file was deleted.

tools/dev/update_joomla_components.rb

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env ruby
2+
# -*- coding: binary -*-
3+
4+
#
5+
# by h00die
6+
#
7+
8+
require 'optparse'
9+
require 'net/http'
10+
require 'uri'
11+
optparse = OptionParser.new do |opts|
12+
opts.banner = 'Usage: ruby tools/dev/update_joomla_components.rb [options]'
13+
opts.separator "This program updates data/wordlists/joomla.txt which is used by modules/auxiliary/scanner/http/joomla_scanner.rb to have the most up-to-date list of vuln components"
14+
opts.separator ""
15+
opts.on('-h', '--help', 'Display this screen.') do
16+
puts opts
17+
exit
18+
end
19+
end
20+
optparse.parse!
21+
22+
# colors and puts templates from msftidy.rb
23+
24+
class String
25+
def red
26+
"\e[1;31;40m#{self}\e[0m"
27+
end
28+
29+
def yellow
30+
"\e[1;33;40m#{self}\e[0m"
31+
end
32+
33+
def green
34+
"\e[1;32;40m#{self}\e[0m"
35+
end
36+
37+
def cyan
38+
"\e[1;36;40m#{self}\e[0m"
39+
end
40+
end
41+
42+
#
43+
# Display an error message, given some text
44+
#
45+
def error(txt)
46+
puts "[#{'ERROR'.red}] #{cleanup_text(txt)}"
47+
end
48+
49+
#
50+
# Display a warning message, given some text
51+
#
52+
def warning(txt)
53+
puts "[#{'WARNING'.yellow}] #{cleanup_text(txt)}"
54+
end
55+
56+
#
57+
# Display a info message, given some text
58+
#
59+
def info(txt)
60+
puts "[#{'INFO'.cyan}] #{cleanup_text(txt)}"
61+
end
62+
63+
uri = URI.parse('https://raw.githubusercontent.com/rezasp/joomscan/master/exploit/db/componentslist.txt')
64+
new_com = Net::HTTP.get(uri)
65+
66+
old = File.read('data/wordlists/joomla.txt').split("\n")
67+
68+
new_com.each_line do |com|
69+
unless old.include?("components/#{com.strip}/")
70+
old << "components/#{com.strip}/"
71+
info "Adding: components/#{com.strip}/"
72+
end
73+
end
74+
75+
old.sort!
76+
File.open('data/wordlists/joomla.txt', 'w') do |file|
77+
file.puts old
78+
end

tools/dev/update_user_agent_strings.py

-56
This file was deleted.
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env ruby
2+
# -*- coding: binary -*-
3+
4+
require 'optparse'
5+
require 'net/http'
6+
require 'uri'
7+
optparse = OptionParser.new do |opts|
8+
opts.banner = 'Usage: ruby tools/dev/update_user_agent_strings.rb [options]'
9+
opts.separator "This program updates lib/rex/user_agent.rb so Metasploit uses the most up-to-date User Agent strings across the framework."
10+
opts.separator ""
11+
opts.on('-h', '--help', 'Display this screen.') do
12+
puts opts
13+
exit
14+
end
15+
end
16+
optparse.parse!
17+
18+
# colors and puts templates from msftidy.rb
19+
20+
class String
21+
def red
22+
"\e[1;31;40m#{self}\e[0m"
23+
end
24+
25+
def yellow
26+
"\e[1;33;40m#{self}\e[0m"
27+
end
28+
29+
def green
30+
"\e[1;32;40m#{self}\e[0m"
31+
end
32+
33+
def cyan
34+
"\e[1;36;40m#{self}\e[0m"
35+
end
36+
end
37+
38+
#
39+
# Display an error message, given some text
40+
#
41+
def error(txt)
42+
puts "[#{'ERROR'.red}] #{cleanup_text(txt)}"
43+
end
44+
45+
#
46+
# Display a warning message, given some text
47+
#
48+
def warning(txt)
49+
puts "[#{'WARNING'.yellow}] #{cleanup_text(txt)}"
50+
end
51+
52+
#
53+
# Display a info message, given some text
54+
#
55+
def info(txt)
56+
puts "[#{'INFO'.cyan}] #{cleanup_text(txt)}"
57+
end
58+
59+
def cleanup_text(txt)
60+
# remove line breaks
61+
txt = txt.gsub(/[\r\n]/, ' ')
62+
# replace multiple spaces by one space
63+
txt.gsub(/\s{2,}/, ' ')
64+
end
65+
66+
def replace_agent_string(lines, replace_marker, url, regex)
67+
valid_chars = 'a-zA-Z0-9\(\);:\.,/_ '
68+
regex = regex.gsub('{VALID_CHARS}', valid_chars)
69+
info "Checking: #{replace_marker}"
70+
71+
index = lines.index { |line| line.include?(replace_marker) }
72+
raise "Couldn't find marker #{replace_marker}" if index.nil?
73+
74+
uri = URI(url)
75+
response = Net::HTTP.get_response(uri)
76+
raise "Can't retrieve #{url}" unless response.is_a?(Net::HTTPSuccess)
77+
78+
match = response.body.match(/#{regex}/)
79+
raise "Couldn't match regex #{regex}" if match.nil?
80+
81+
new_string = match[1]
82+
83+
old_line = lines[index]
84+
if old_line.include?("'#{new_string}'")
85+
puts " (Unchanged): #{new_string}"
86+
else
87+
new_line = old_line.gsub(/'(.*)'/, "'#{new_string}'")
88+
if old_line == new_line
89+
raise " Line didn't change: #{old_line}"
90+
end
91+
puts " New value is: #{new_string}"
92+
lines[index] = new_line
93+
end
94+
end
95+
96+
chrome_url = "https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome"
97+
edge_url = "https://www.whatismybrowser.com/guides/the-latest-user-agent/edge"
98+
safari_url = "https://www.whatismybrowser.com/guides/the-latest-user-agent/safari"
99+
firefox_url = "https://www.whatismybrowser.com/guides/the-latest-user-agent/firefox"
100+
101+
user_agent_filename = 'lib/rex/user_agent.rb'
102+
lines = File.read(user_agent_filename).split("\n")
103+
104+
replace_agent_string(lines, 'Chrome Windows', chrome_url, '<td>Chrome \\(Standard\\)</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Windows NT[{VALID_CHARS}]*)</span>')
105+
replace_agent_string(lines, 'Chrome MacOS', chrome_url, '<td>Chrome \\(Standard\\)</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Macintosh[{VALID_CHARS}]*)</span>')
106+
replace_agent_string(lines, 'Edge Windows', edge_url, '<td>Edge \\(Standard\\)</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Windows NT[{VALID_CHARS}]*)</span>')
107+
replace_agent_string(lines, 'Safari iPad', safari_url, '<td>\s*Safari on <b>Ipad</b>\s*</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*iPad[{VALID_CHARS}]*)</span>')
108+
replace_agent_string(lines, 'Safari MacOS', safari_url, '<td>Safari \\(Standard\\)</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Macintosh[{VALID_CHARS}]*)</span>')
109+
replace_agent_string(lines, 'Firefox Windows', firefox_url, '<td>\s*Firefox on <b>Windows</b>\s*</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Windows NT[{VALID_CHARS}]*)</span>')
110+
replace_agent_string(lines, 'Firefox MacOS', firefox_url, '<td>\s*Firefox on <b>Macos</b>\s*</td>\s*<td>\s*<ul>\s*<li><span class="code">([{VALID_CHARS}]*Macintosh[{VALID_CHARS}]*)</span>')
111+
112+
File.write(user_agent_filename, lines.join("\n") + "\n")

tools/dev/update_wordpress_vulnerabilities.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env ruby
22
# -*- coding: binary -*-
33

4-
#
5-
# Update modules/auxiliary/scanner/http/wordpress_scanner.rb to have the most
6-
# up to date list of vuln components based on exploits/scanners in the framework
74
#
85
# by h00die
96
#
@@ -12,7 +9,9 @@
129

1310
options = {}
1411
optparse = OptionParser.new do |opts|
15-
opts.banner = 'Usage: update_wordpress_vulnerabilities.rb [options]'
12+
opts.banner = 'Usage: ruby tools/dev/update_wordpress_vulnerabilities.rb [options]'
13+
opts.separator "This program updates data/wordlists/wp-exploitable-themes.txt and wp-exploitable-plugins.txt which are used by modules/auxiliary/scanner/http/wordpress_scanner.rb to have the most up-to-date list of vuln components"
14+
opts.separator ""
1615
opts.on('-h', '--help', 'Display this screen.') do
1716
puts opts
1817
exit

0 commit comments

Comments
 (0)