Skip to content

Commit c080329

Browse files
committed
Update module after feedback
Looks like I can't decide on certain style preferences. Not keen on using blank?, but I've used it before. Time to commit? Also, fail_with has been fixed for aux and post since rapid7#8643. Use it!
1 parent ff1c855 commit c080329

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

documentation/modules/auxiliary/gather/nis_bootparamd_domain.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@ If the link is down, you can find it via the Wayback Machine.
1717
After that is done, install `bootparamd` however your OS provides it.
1818

1919
Make sure you add a client to the `bootparams` file, which is usually at
20-
`/etc/bootparams`. The client should be added to `/etc/hosts` if it
21-
isn't already resolvable.
20+
`/etc/bootparams`.
21+
22+
Here is an example `bootparams` file (courtesy of
23+
[@bcoles](https://github.com/bcoles)):
24+
25+
```
26+
clientname root=nfsserver:/export/clientname/root
27+
```
28+
29+
You can read the `bootparams(5)` man page for more info.
30+
31+
Lastly, the client should be added to `/etc/hosts` if it isn't already
32+
resolvable.
2233

2334
## Options
2435

modules/auxiliary/gather/nis_bootparamd_domain.rb

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def initialize(info = {})
3333

3434
register_options([
3535
OptEnum.new('PROTOCOL', [true, 'Protocol to use', 'udp', %w{tcp udp}]),
36-
OptAddress.new('CLIENT', [true, 'Client from target\'s bootparams file'])
36+
OptAddress.new('CLIENT', [true, "Client from target's bootparams file"])
3737
])
3838

3939
register_advanced_options([
@@ -52,11 +52,9 @@ def run
5252
1 # Program Version: 1
5353
)
5454
rescue Rex::ConnectionError
55-
print_error('Could not connect to portmapper')
56-
return
55+
fail_with(Failure::Unreachable, 'Could not connect to portmapper')
5756
rescue Rex::Proto::SunRPC::RPCError
58-
print_error('Could not connect to bootparamd')
59-
return
57+
fail_with(Failure::Unreachable, 'Could not connect to bootparamd')
6058
end
6159

6260
# Flavor: AUTH_NULL (0)
@@ -76,33 +74,30 @@ def run
7674
bootparam_whoami # Boot Parameters
7775
)
7876
rescue Rex::Proto::SunRPC::RPCError
79-
print_error('Could not call bootparamd procedure')
80-
return
77+
fail_with(Failure::NotFound, 'Could not call bootparamd procedure')
8178
rescue Rex::Proto::SunRPC::RPCTimeout
82-
print_error('Could not disclose NIS domain name (try another CLIENT?)')
83-
return
79+
fail_with(Failure::NotVulnerable,
80+
'Could not disclose NIS domain name (try another CLIENT?)')
8481
ensure
8582
# Shut it down! Shut it down forever!
8683
sunrpc_destroy
8784
end
8885

89-
if res.nil?
90-
print_error('Invalid response from server')
91-
return
86+
unless res
87+
fail_with(Failure::Unknown, 'No response from server')
9288
end
9389

9490
bootparams = begin
9591
Timeout.timeout(datastore['XDRTimeout']) do
9692
parse_bootparams(res)
9793
end
9894
rescue Timeout::Error
99-
print_error('XDR decoding timed out (try increasing XDRTimeout?)')
100-
return
95+
fail_with(Failure::TimeoutExpired,
96+
'XDR decoding timed out (try increasing XDRTimeout?)')
10197
end
10298

103-
if bootparams.nil? || bootparams.empty?
104-
print_error('Could not parse bootparams')
105-
return
99+
if bootparams.blank?
100+
fail_with(Failure::Unknown, 'Could not parse bootparams')
106101
end
107102

108103
bootparams.each do |host, domain|

0 commit comments

Comments
 (0)