Skip to content

Conversation

geyslan
Copy link

@geyslan geyslan commented Sep 10, 2013

This payload is the tiniest of its kind, because it doesn't bind the socket; it just let the kernel do it, opening a random port. Use nmap to discover the open port: 'nmap -sS target -p-'.

More details: http://www.hackingbits.com/2013/03/hacking-do-dia-shell-bind-tcp-random.html and https://github.com/geyslan/SLAE/blob/master/improvements/tiny_shell_bind_tcp_random_port.asm

@wchen-r7
Copy link
Contributor

Cool stuff. Do you mind upload the source to external/source/shellcode/linux/ia32? thx.

@geyslan
Copy link
Author

geyslan commented Sep 12, 2013

Thank you. Sure, I'll do it. There are others payloads that I suggested to Tod. I'm just waiting reply. See you.

@wvu
Copy link
Contributor

wvu commented Sep 26, 2013

Nice payload.

@geyslan
Copy link
Author

geyslan commented Sep 26, 2013

Thank you.

@geyslan
Copy link
Author

geyslan commented Oct 5, 2013

Hey guys. Here is the x86_64 version.

@geyslan
Copy link
Author

geyslan commented Nov 11, 2013

I want only contribute to the tool; did the modules only with the goal to help. IMHO the syntax isn't hurting anyone. No problem if you don't want the files. Only let me know, so I'll undo the license back to GNU v3 as soon as possible.

@wvu
Copy link
Contributor

wvu commented Nov 11, 2013

Yeah, you're right. The syntax isn't hurting anymore. This is a good contribution, believe me. It's just that we use the %q syntax for descriptions, since it allows us to have a cleaner multi-line description without ' and \.

def initialize(info = {})
super(merge_info(info,
'Name' => 'Linux Command Shell, Bind TCP Random Port Inline',
'Description' => 'Listen for a connection in a random port and spawn a command shell. ' \
Copy link
Contributor

Choose a reason for hiding this comment

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

For example, you could use %q like this:

'Description' => %q{
  Listen for a connection in a random port and spawn a command shell.
  Use nmap to discover the open port: 'nmap -sS target -p-'.
  Assembly source: http://goo.gl/TAveVc
},

I also don't have to escape '.

Tod Beardsley and others added 2 commits November 11, 2013 10:33
  * Moved shortlink to a reference.
  * Reformat e-mail address.
  * Fixed whitespace
  * Use multiline quote per most other module descriptions

Still need to resplat the modules, but it's no big thang to do that
after landing. Also, References do not seem to appear for post modules
in the normal msfconsole. This is a bug in the UI, not for these modules
-- many payloads would benefit from being explicit on their references,
so may as well start with these.
@geyslan
Copy link
Author

geyslan commented Nov 11, 2013

Tod, wvu,

Now I see why to use %q. Thank you for the fixes.

@wvu
Copy link
Contributor

wvu commented Nov 11, 2013

And thank you for this sweet code. :P

@geyslan
Copy link
Author

geyslan commented Nov 11, 2013

"Also, if you'd like to add source for the x64 payload, it looks like you'd be the first in x64 Linux land (we only appear to ship source for 32-bit payloads for linux, so far)."

Tod, I would like to add the x64 source code too. Please guide me about the correct file hierarchy (path).

},
'Author' => 'Geyslan G. Bem <geyslan[at]gmail.com>',
'License' => BSD_LICENSE,
'References' => ['URL', 'https://github.com/geyslan/SLAE/blob/master/improvements/tiny_shell_bind_tcp_random_port.asm'],
Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

You can go ahead and make the change and push. I'll just fetch the PR again.

Copy link
Author

Choose a reason for hiding this comment

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

I would like but I'm in doctor right now. If you could do that, I would be thankful. If not, no problem, as soon as possible I'll be doing.

@geyslan
Copy link
Author

geyslan commented Nov 11, 2013

Fixes done, ready to analyze!

@wvu
Copy link
Contributor

wvu commented Nov 12, 2013

Okay, testing! Assembly looks great. :)

@wvu
Copy link
Contributor

wvu commented Nov 12, 2013

Tested successfully on x{86,64}. w00t!

root@kharak:~# nc -v 172.16.126.129 "$(ndiff <(nmap -Pn -T4 -n -p "$(sed 's/\t/-/' /proc/sys/net/ipv4/ip_local_port_range)" -oX - --send-ip 172.16.126.129) <(sleep 2; nmap -Pn -T4 -n -p "$(sed 's/\t/-/' /proc/sys/net/ipv4/ip_local_port_range)" -oX - --send-ip 172.16.126.129) | sed -nr 's,^\+([0-9]{5})/tcp open$,\1,p')" <<<"id; uname -a"
Connection to 172.16.126.129 58246 port [tcp/*] succeeded!
uid=0(root) gid=0(root) groups=0(root)
Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux
root@kharak:~# 

wvu added a commit that referenced this pull request Nov 12, 2013
@wvu wvu merged commit 28c5dd6 into rapid7:master Nov 12, 2013
@geyslan
Copy link
Author

geyslan commented Nov 12, 2013

wvu, thanks.

Have you tested the 64 bits version?

@wvu
Copy link
Contributor

wvu commented Nov 12, 2013

Yep. Works for me.

@geyslan
Copy link
Author

geyslan commented Nov 12, 2013

Great. Cheers! 👍

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 28c5dd6 on geyslan:master into * on rapid7:master*.

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.

4 participants