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

Powershell CMD Encoder #2964

Merged
merged 4 commits into from Apr 1, 2014
Merged

Conversation

Meatballs1
Copy link
Contributor

Showing Windows command injection some loving.

@Meatballs1 Meatballs1 mentioned this pull request Feb 10, 2014
@jvazquez-r7
Copy link
Contributor

Processing!


def encode_buf(buf)
base64 = Rex::Text.encode_base64(Rex::Text.to_unicode("cmd.exe /c start #{buf}"))
cmd = "powershell -w hidden -nop -e #{base64}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it's a very good idea having into account which power shell isn't always available on Windows. I'd say make it with a low ranking, but since it's the only cmd encoder for windows, it would be selected anyway. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah not too worried about the scoring, theres not huge amounts of competition for this ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

heh, so that, let me see what are the feelings from other devs, since it's the only windows cmd encoder, a little worried about it depending on powershell.

Copy link
Contributor

Choose a reason for hiding this comment

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

I vote ManualRanking because of the same concern. The printf_php_mq.rb encoding module has the same issue with printf not necessarily supported by all systems, so it's ManualRanking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Presumably if the command contains bad-chars then it probably wont work. So it has a better chance of working if powershell is available (most modern systems now).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Powershell may exist on windows xp. A payload with badchars shouldnt work on XP ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

A payload with badchars probably doesn't work anywhere, but that depends on how bad it's mangled. You just gotta ask yourself one question...

lucky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someone should write a wscript encoder!

Copy link
Contributor

Choose a reason for hiding this comment

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

@wchen-r7: How ManualRanking works with encoders? Maybe I forgot something, damn it!

@Meatballs1: A payload with badchars shouldnt work on XP ;) right, the problem is it encoding payloads which would work in raw mode.

I tried to address with #3024, so exploit modules can provide compatibility options for encoders (like with payloads). But maybe ManualRanking could solve :? ping @wchen-r7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think #3024 sounds like a better plan, if the module can attest to a specific level of encoders/commands?

@jvazquez-r7
Copy link
Contributor

Hopefully if #3024 is landed we'll be able to land it easily. Providing to exploits the capacity to provide Encoder Compat options!

@wchen-r7
Copy link
Contributor

So @jvazquez-r7, @limhoff-r7 and I had a discussion about this, basically the concern is still the same, because it's possible this powershell encoder may kick in instead of the generic/none encoder (which we assume is the default one). And again, we need to worry about Windows targets that don't necessarily have powershell. Changing the ranking doesn't seem to make it any better either, because according to @jvazquez-r7 it still kicks in. In conclusion, I think we all agree that #3024 should probably be landed first.

wchen-r7 added a commit that referenced this pull request Apr 1, 2014
@wchen-r7 wchen-r7 merged commit 39be214 into rapid7:master Apr 1, 2014
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

3 participants