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

Fix issue with execution of perl due to gsub not matching across newlines #4356

Merged
merged 1 commit into from Dec 11, 2014

Conversation

marcwickenden
Copy link
Contributor

When using, for example, the cmd/unix/reverse payload, this exploit was not working because the remote host was returning a value for the perl path that included newlines. Example:

/usr/bin/perl
jVUgZjLq
$

The gsub was not matching across newlines and therefore the exploit files written to /var/tmp contained

/usr/bin/perl

$

as the interpreter and failed to run.

The simple fix is to match across newlines with the m modifier. Tested against Ubuntu 8.04 and Exim 4.69.

@jhart-r7
Copy link
Contributor

This seems innocent enough, however I can't reproduce the issue:

irb(main):009:0> buff = `which perl;echo #{token}`
=> "/usr/bin/perl\nadfadf\n"
irb(main):010:0> buff.gsub(token, "").gsub(/\/perl.*/, "/perl").strip
=> "/usr/bin/perl"

@marcwickenden
Copy link
Contributor Author

The output from my server doesn't look like your example. I get a newline after the token plus a dollar sign, presumably from the underlying bash shell - as in my initial example above. It may be that on different systems this is not what is returned but the m modifier should work in both cases.

@jhart-r7
Copy link
Contributor

Agreed. This should work in both cases.

@jhart-r7 jhart-r7 self-assigned this Dec 11, 2014
@jhart-r7 jhart-r7 merged commit 245b764 into rapid7:master Dec 11, 2014
jhart-r7 added a commit that referenced this pull request Dec 11, 2014
@jhart-r7
Copy link
Contributor

All I could do for validation on this is confirm the module still loads correctly since my test targets don't reproduce the bug. The gsub is safe.

@marcwickenden marcwickenden deleted the fix_exim4_string_format branch December 11, 2014 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants