Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor updates to meterpreter persistence module. #2395

Closed
wants to merge 11 commits into from

Conversation

SteveJM
Copy link

@SteveJM SteveJM commented Sep 19, 2013

Slight cleanup (e.g. to keep lines less than 100 characters).
Clarification within the help text.
Resolve a minor bug in the cleanup resource file created by this module to escape the windows path separator and to not attempt to kill the agent process (this would not have worked as the pid is likely to have changed, e.g. as a result of a target system reboot).

NB: This is my first contribution so is a deliberately minor change so as to familiarise myself with the process.

Steve Martin added 3 commits September 19, 2013 07:04
Ensured lines < 80 characters. A couple of minor formatting changes
and typos.
The windows pathname needs to have the '\' separators within the path
escaped.  The kill command can not be used to terminate the agent
process as it is liable to change (e.g. after a system restart).
@wvu
Copy link
Contributor

wvu commented Sep 19, 2013

Thanks for your first contribution!

else
logs = ::File.join(Msf::Config.log_directory, 'persistence', Rex::FileUtils.clean_path(host + filenameinfo) )
logs = ::File.join(Msf::Config.log_directory, 'persistence', \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for \

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, I'll remove (along with comments).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant "those mentioned in other comments" .... ;-)

@jlee-r7
Copy link
Contributor

jlee-r7 commented Sep 20, 2013

My comments are mostly about small style issues, but it looks like the bug in the generated cleanup resource file is present in both the local exploit and the (deprecated) post module of the same name. Yes, I know it sucks we have 3 different things that perform the same task.

@SteveJM
Copy link
Author

SteveJM commented Sep 20, 2013

Is the deprecated module still going to be distributed ? (if not I won't fix).

I will re-post changes within 24hours.....

Steve Martin added 6 commits September 21, 2013 06:03
Indentation changed to universally use two spaces.
Removed superfluous " \" at the end of wrapped lines.
Added a space after some commas (where missing).  Other minor code layout changes
to keep lines < 80 characters where practical.
The windows pathname needs to have the '\' separators within the path
escaped.  The kill command cannot be used to terminate the agent
process as it is liable to change (e.g. after a system restart).
Inserted a space after commas (where it was missing).  Ensured
that line length < 80 characters where practical.
The windows pathname needs to have the '\' separators within the path
escaped.  Also clarified the return status from the "target_exec"
function; returning true/nil seems potentially counter intuitive so
changed to true/false.  The comment was also incorrect (no attempt was
made to return the pid), and the invoking code was checking for the
'nil', which whilst safe re-enforced the belief that a non-nil PID
value might be expected upon success.
@SteveJM
Copy link
Author

SteveJM commented Sep 21, 2013

Ok, the above commits have addressed the feedback provided on this thread. In summary:
Indentation issues.
Redundant escaping newline on wrapped lines removed
Equivalent changes made to the other "persistence" modules.

Need to correctly account for 'false' being returned by target_exec if the
payload failed to execute on the target.  Also clarified the return value
from 'write_script_to_target' function.
@wvu
Copy link
Contributor

wvu commented Sep 24, 2013

Make sure you use a separate branch for your PR. It's unwise to merge from your master unless you keep it pristine. Topic branches are GOOD.

@SteveJM
Copy link
Author

SteveJM commented Sep 24, 2013

Noted. Actually, I did do this on a branch at my end, then merged to my master and then pushed from there. I hadn't thought to push straight from my origin branch... (which could save me getting into a mess if I had multiple changes running concurrently).

@@ -73,7 +72,7 @@ def exploit
end

# Initial execution of script
if target_exec(script_on_target) == nil
if not target_exec(script_on_target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless target_exec(script_on_target)

Clarified logic (used 'unless' rather than 'if not' where appropriate).
Removed superfluous braces from if statement expression.
@todb-r7 todb-r7 added the misc label May 30, 2014
@Meatballs1
Copy link
Contributor

@wvu-r7 what needs to happen with this other than resolving the current merge conflict?

@wvu
Copy link
Contributor

wvu commented Jun 7, 2014

@Meatballs1: Just the conflicts(s).

@hdm hdm self-assigned this Dec 12, 2014
@hdm
Copy link
Contributor

hdm commented Dec 12, 2014

Snagging this to fix the merge conflicts and just land.

hdm pushed a commit that referenced this pull request Dec 12, 2014
hdm pushed a commit that referenced this pull request Dec 12, 2014
@hdm hdm closed this Dec 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants