Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using an ATTACKMODE for Ethernet, the typical approach is to
sleep
for a few seconds and see if an IP was obtained (TARGET_IP, TARGET_HOSTNAME, HOST_IP). However, usingsleep
results in possibly not waiting long enough or waiting too long.This update adds a loop to these three variables to wait up to an optionally provided timeout. So giving the command:
will wait up to 60 seconds for an IP, but returning sooner if one is obtained. If no IP is received within the timeout, TARGET_IP is left empty. Likewise, if no timeout is provided in the first place,
no looping is performed. As such, existing payloads using GET are unaffected.
Additionally, I couldn't understand why
sort | uniq
andsort | uniq | tail -n1
were used as they indicated different ideas.sort | uniq
for TARGET_IP didn't usetail
meaning a single line was presumed. But this same thinking was not used for TARGET_HOST which appliedtail -n1
. Furthermore, thesort|uniq|tail -n1
for TARGET_HOST didn't necessarily use the most current lease's hostname.So, assuming the most current lease is the lease we want the information from and the most current lease is last in the file (my tests supported this assumption), we can use
tac
instead ofcat
to simply match the first hostname and/or lease text. This allowed the use of the-m1
switch forgrep
(only return the first match) resulting in a single line and from the current lease. This also allowed removed the need forsort
,uniq
, andtail
.Finally, I combined two of the
sed
s on TARGET_HOSTNAME which filter the double quote and semicolons.Sorry for the wordiness of this request; I'm somewhat new to GitHub still.
-- comments on commit --