Skip to content

Commit 4c50456

Browse files
committed
Update docs to support links with anchors
1 parent 2b2e20b commit 4c50456

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Behind the scenes these docs are built and deployed to https://docs.metasploit.c
1818
You can modify existing documentation files within `metasploit-framework.wiki/` with an editor of your choice and send a pull request.
1919
To add a new page, modify `navigation.rb`. Full details are found beside the `NAVIGATION_CONFIG` constant.
2020

21+
## Adding links
22+
23+
For linking to other docs the Github markdown syntax `[[link text|relative_path_to_docs]]` is used. Behind the scenes these
24+
links will be verified at build time to ensure there's no 404 links.
25+
26+
Note: It is also possible to use the syntax `[[link text|relative_path_to_docs#section]]` - but this navigation will happen client side, and
27+
there is no validation that these sections exist at build time. It is possible for future edits to a markdown file to break these links.
28+
2129
## Setup
2230

2331
### Developer build

docs/build.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,18 @@ def pages
191191
def extract_absolute_wiki_links(markdown)
192192
new_links = {}
193193

194-
markdown.scan(%r{(https?://github.com/rapid7/metasploit-framework/wiki/([\w().%_-]+))}) do |full_match, old_path|
194+
markdown.scan(%r{(https?://github.com/rapid7/metasploit-framework/wiki/([\w().%_#-]+))}) do |full_match, old_path|
195195
full_match = full_match.gsub(/[).]+$/, '')
196196
old_path = URI.decode_www_form_component(old_path.gsub(/[).]+$/, ''))
197197

198-
new_path = new_path_for(old_path)
199-
replacement = "{% link docs/#{new_path} %}"
198+
begin
199+
old_path_anchor = URI.parse(old_path).fragment
200+
rescue URI::InvalidURIError
201+
old_path_anchor = nil
202+
end
203+
204+
new_path = new_path_for(old_path, old_path_anchor)
205+
replacement = "{% link docs/#{new_path} %}#{old_path_anchor ? "##{old_path_anchor}" : ""}"
200206

201207
link = {
202208
full_match: full_match,
@@ -216,19 +222,26 @@ def extract_absolute_wiki_links(markdown)
216222
# '[[Custom name|Relative Path]]'
217223
# '[[Custom name|relative-path]]'
218224
# '[[Custom name|./relative-path.md]]'
225+
# '[[Custom name|./relative-path.md#section-anchor-to-link-to]]'
226+
# Note that the page target resource file is validated for existence at build time - but the section anchors are not
219227
def extract_relative_links(markdown)
220228
existing_links = @links
221229
new_links = {}
222230

223-
markdown.scan(/(\[\[([\w\/_ '().:,-]+)(?:\|([\w\/_ '():,.-]+))?\]\])/) do |full_match, left, right|
231+
markdown.scan(/(\[\[([\w\/_ '().:,-]+)(?:\|([\w\/_ '():,.#-]+))?\]\])/) do |full_match, left, right|
224232
old_path = (right || left)
225-
new_path = new_path_for(old_path)
233+
begin
234+
old_path_anchor = URI.parse(old_path).fragment
235+
rescue URI::InvalidURIError
236+
old_path_anchor = nil
237+
end
238+
new_path = new_path_for(old_path, old_path_anchor)
226239
if existing_links[full_match] && existing_links[full_match][:new_path] != new_path
227240
raise "Link for #{full_match} previously resolved to #{existing_links[full_match][:new_path]}, but now resolves to #{new_path}"
228241
end
229242

230243
link_text = left
231-
replacement = "[#{link_text}]({% link docs/#{new_path} %})"
244+
replacement = "[#{link_text}]({% link docs/#{new_path} %}#{old_path_anchor ? "##{old_path_anchor}" : ""})"
232245

233246
link = {
234247
full_match: full_match,
@@ -245,8 +258,8 @@ def extract_relative_links(markdown)
245258
new_links
246259
end
247260

248-
def new_path_for(old_path)
249-
old_path = old_path.gsub(' ', '-')
261+
def new_path_for(old_path, old_path_anchor)
262+
old_path = old_path.gsub(' ', '-').gsub("##{old_path_anchor}", '')
250263
matched_pages = pages.select do |page|
251264
!page[:folder] &&
252265
(File.basename(page[:path]).downcase == "#{File.basename(old_path)}.md".downcase ||

docs/metasploit-framework.wiki/kerberos/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ sequenceDiagram
103103
## Common Kerberos workflows
104104

105105
- User enumeration / bruteforcing - the [[auxiliary/scanner/kerberos/kerberos_login|pentesting/active-directory/kerberos/kerberos_login.md]] module can be used to enumerate user accounts or bruteforce credentials
106-
- AS-REP Roasting - Some Kerberos accounts may be configured with a `Do not require Kerberos preauthentication` flag. For these accounts a Kerberos TGT will be returned by the KDC without needing to authenticate. These TGTs can be bruteforced to learn the original user's credentials. The [[auxiliary/scanner/kerberos/kerberos_login|pentesting/active-directory/kerberos/kerberos_login.md]] module implements this workflow.
106+
- AS-REP Roasting - Some Kerberos accounts may be configured with a `Do not require Kerberos preauthentication` flag. For these accounts a Kerberos TGT will be returned by the KDC without needing to authenticate. These TGTs can be bruteforced to learn the original user's credentials. The [[auxiliary/scanner/kerberos/kerberos_login|pentesting/active-directory/kerberos/kerberos_login.md#asreproasting]] module implements this workflow.
107107
- Forging Tickets - After compromising a KDC or service account it is possible to forge tickets for persistence. The [[auxiliary/admin/kerberos/forge_ticket|pentesting/active-directory/kerberos/forge_ticket.md]] module can forge both Golden and Silver tickets.
108108
- Inspecting Tickets - Kerberos tickets can be inspected with the [[auxiliary/admin/kerberos/inspect_ticket|pentesting/active-directory/kerberos/inspect_ticket.md]] module. If the encryption key is known, the decrypted contents can be displayed.
109109
- [[Service authentication|kerberos/service_authentication.md]] - Using Kerberos to authenticate via services suh as WinRM/Microsoft SQL Server/SMB/LDAP/etc

documentation/modules/auxiliary/gather/kerberos_enumusers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ msf6 auxiliary(gather/kerberos_enumusers) > run rhost=192.168.123.228 domain=dom
4545
msf6 auxiliary(gather/kerberos_enumusers) >
4646
```
4747

48-
### ASREPRoast Cracking
48+
### ASREPRoasting
4949

5050
Accounts that have `Do not require Kerberos preauthentication` enabled, will receive an ASREP response with a ticket present.
5151
The technique of cracking this token offline is called ASREPRoasting.

documentation/modules/auxiliary/scanner/kerberos/kerberos_login.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ msf6 auxiliary(gather/kerberos_enumusers) > run rhost=192.168.123.133 domain=DEM
6767
[*] Auxiliary module execution completed
6868
```
6969

70-
### ASREPRoast Cracking
70+
### ASREPRoasting
7171

7272
Accounts that have `Do not require Kerberos preauthentication` enabled, will receive an ASREP response with a ticket-granting-ticket present.
7373
The technique of cracking this ticket offline is called ASREPRoasting.

0 commit comments

Comments
 (0)