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

New tincd post-auth BOF exploit module #2756

Merged
merged 4 commits into from Dec 1, 2014
Merged

New tincd post-auth BOF exploit module #2756

merged 4 commits into from Dec 1, 2014

Conversation

floyd-fuh
Copy link
Contributor

A pull request to get some feedback. I'd appreciate if you comment as well on the following:

  • additional class in module (if it should be relocated, an example would be helpful, e.g. which mixins etc.)
  • puts calls in the additional class
  • exploit development and other comments welcome?
  • Fedora ROP is on my TODO list (but I wanted to contribute the module before Christmas/holidays)
  • Although I left "average ranking" in there, the exploit works for all targets with several tested (meterpreter, reverse_tcp, exec) payloads on the first execution run and is therefore very reliable.

@wvu
Copy link
Contributor

wvu commented Dec 13, 2013

Please run this through tools/msftidy.rb and make the necessary changes. :)

@floyd-fuh
Copy link
Contributor Author

msftidy.rb runs through now

@wchen-r7
Copy link
Contributor

This is definitely a cool module. But I was wondering if you've tried the Msf::Exploit::Remote::Tcp mixin for the TincExploitClient class? The TincExploitClient class definitely needs to be implemented as a mixin, probably placed somewhere in the msf/lib/msf/core/exploit directory. And instead of using the Ruby socket, it needs to at least use Rex, otherwise the engine cannot manage the connection. Please take your time and ask questions along the way, may be a little tricky to implement.

@jlee-r7 Please feel free to add more, or correct me if I'm wrong.

@floyd-fuh
Copy link
Contributor Author

I'm trying to relocate the TincExploitClient, but wasn't able to do it so far. I'll try to use the Rex socket afterwards, but as long as it has recv and a send method that should work somehow.

At the same time I'm also working on Pidora 18 ARM exploitation target. I already control pc (eip), but have to dive into a little bit more ARM details (+ defeating NX on ARM).

As I won't have access to a computer in January, this has to wait until February 2014.

@floyd-fuh
Copy link
Contributor Author

so with the last commit the module is done from my point. I open another pull request as soon as the ARM part is done

end

def get_line()
idx = @inbuffer.index("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

index can return nil if there is no "\n", which will cause issues later. Does some other code ensure that @inbuffer has newlines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every get_line() call has a has_line() call (and if clause) right before it, so it is not possible that the index function returns nil

@floyd-fuh
Copy link
Contributor Author

Ready for another round of feedback from @jlee-r7. The code is tested and works (even with different RSA key sizes of client/server, ROP still works too).

elf_base64 = Rex::Text::encode_base64(exe)
filename = rand_text_alpha(1)
# try plain first
args = ['/bin/sh', '-c', "cd /tmp;echo #{elf_base64}|base64 -d>#{filename};chmod +x #{filename};./#{filename}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

is base64 command installed by default on Fedora?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, /tmp is often mounted noexec. At the time the exploit lands, is the current directory writable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

base64 is installed on my freshly installed Fedora 19 where I only installed the dependencies for tincd.

The current directory when the exploit lands is / and is only writable when the deamon runs as root. When the deamon runs as root the current directory is the better choice, as an unprivileged user /tmp is the better choice. I thought it's probably best if it's customizable, see commit e5a237a

@floyd-fuh
Copy link
Contributor Author

Hey there, this is a bump, @jlee-r7 can I help with anything to get this module into Metasploit? Also @mubix did you have a look?

#
def handle_write
# handle encryption queue first
if @encryption_queue.length > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, could optionally use unless @encryption_queue.length.empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@kernelsmith
Copy link
Contributor

awesome stuff @floyd-fuh, some fixes are required (some are optional) before we can land this, but thanks very much for your submission!

@floyd-fuh
Copy link
Contributor Author

@kernelsmith what do you think? I'm ready if you are.

@floyd-fuh
Copy link
Contributor Author

By now this feels like doing responsible disclosure :(

@todb-r7 todb-r7 assigned wvu and unassigned jlee-r7 Dec 1, 2014
@wvu
Copy link
Contributor

wvu commented Dec 1, 2014

Hey, @floyd-fuh. I'm really sorry about the lack of movement on this. We spoke a bit on IRC about @kernelsmith taking over, but he's probably busy now... I think this is good to go. :)

@todb-r7
Copy link

todb-r7 commented Dec 1, 2014

Merge conflicts were fixed, the rest are just style gripes but not show stoppers.

@wvu wvu merged commit 9243cfd into rapid7:master Dec 1, 2014
@todb-r7
Copy link

todb-r7 commented Dec 1, 2014

As commented on #2756 (comment), should have specs for new protocol libraries, but since it's used exactly once I'm not making a federal case out of it. worst that happens is that future changes either break all of framework or break just this module. The first case is easy to spot.

wvu added a commit that referenced this pull request Dec 1, 2014
@floyd-fuh
Copy link
Contributor Author

w00t, thanks!

@coveralls
Copy link

coveralls commented May 31, 2016

Coverage Status

Changes Unknown when pulling 9243cfd on floyd-fuh:master into * on rapid7:master*.

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

10 participants