Tricks

Reverse Shell Tricks

Spawning a TTY Shell

python -c 'import pty; pty.spawn("/bin/sh")'
echo os.system('/bin/bash')
/bin/sh -i
perl —e 'exec "/bin/sh";'
perl: exec "/bin/sh";
ruby: exec "/bin/sh"
lua: os.execute('/bin/sh')

From within IRB

exec "/bin/sh"

From within vi

:!bash

From within vi

:set shell=/bin/bash:shell

From within nmap

!sh

Double characters

Getting double characters (which is annoying)? You can clean that up with:

Shell upgrade

How to get a fully functional shell:

  • Get a tty shell, e.g.,:

  • Upgrade shell to a tty:

  • Set terminal:

  • Switch to the background with CTRL+Z.

  • Configure local shell:

  • Change to the foreground with

  • Reset the tty with

    No we have a fully functional shell. CTRL+C terminates the remote process, not the local nc, anymore.

PowerShell Tricks

Invoke-Mimikatz

The decoded base64 is:

Ubuntu disable firewall

Cron job

Depending on how your linux system is set up, you can look in:

also, many distros have:

These are simply directories that contain executables that are executed hourly, daily, weekly or monthly, per their directory name. On top of that, you can have at jobs (check /var/spool/at/), anacron (/etc/anacrontab and /var/spool/anacron/)

Cron file

Append

Search for interesting files

Look for files owned by root that we could write to. To reduce false positives, only look for files (not symlinks) and exclude proc, which is full of root-owned writable files.

SUID

weevely

Port knocking with nc

Shellshock

Quick add Admin and RDP

To start up the Remote Desktop (RDP) service.

Configure the firewall to let RDP connections in.

Now use rdesktop on Kali to log in to your newly minted account.

Nmap list all scripts

Forward traffic from a laptop's wlan0 to eth0

PC

Specify an IP address to eth0 (here 192.168.56.1)

Enable IP forwarding

Forward packets from eth0 to wlan0

Device connected to PC

Setup IP address for eth0,and add gateway

Kudos, References and Further Reading

Last updated

Was this helpful?