🪬
Gzzcoo Pentest Notes
HomeWalkthroughs
  • Home
  • ACTIVE DIRECTORY PENTESTING
    • Initial Enumeration
      • Enumerating users
    • Abusing Active Directory ACLs/ACEs
      • Shadow Credentials
      • GenericWrite
      • ForceChangePassword
    • Active Directory Certificate Services (ADCS)
    • Attacking Kerberos
    • BloodHound
    • Tools
      • bloodyAD
      • Kerbrute
      • Impacket
      • ldapsearch
      • PowerView.py
  • WINDOWS PENTESTING
    • Windows Privilege Escalation
      • Abusing Tokens
      • AD Recycle Bin Group
      • DnsAdmins to DomainAdmin
      • Dumping credentials
        • Credential Hunting
        • LSASS
        • NTDS.dit
        • SAM and SYSTEM
      • Server Operators Group
  • Windows Lateral Movement
    • Pass the Hash (PtH)
    • Pass the Ticket (PtT)
      • From Windows
      • From Linux
    • Pass the Cert (PtC)
  • File Transfer
    • PowerShell
    • Remote Desktop Protocol (RDP)
    • LOLBAS
    • Protected File Transfers
    • Catching Files over HTTP/S
    • Detection and Evading Detection
  • Reverse Shell
  • PowerShell
  • LINUX PENTESTING
    • Basic Enumeration
    • Linux Privilege Escalation
  • File Transfer
    • Protected File Transfers
    • Catching Files over HTTP/S
    • GTFOBins
  • Shells
  • Reverse Shell
  • Credential Hunting
  • Passwd, Shadow & Opasswd
  • NETWORK SERVICES PENTESTING
    • FTP Port (21)
    • SSH Port (22)
    • DNS Port (53)
    • SMB Port (139, 445)
    • MSSQL Port (1433)
    • MySQL Port (3306)
    • RDP Port (3389)
  • PostgreSQL Port (5432, 5433)
  • Attacking Email Services
  • Pivoting, Tunneling and Port Forwarding
  • WEB PENTESTING
    • Local File Inclusion (LFI)
  • LaTeX Injection
  • Cypher Injection
  • Cross-Site Scripting (XSS)
  • TOOLS
    • John The Ripper
    • NetExec
    • Smbmap
    • Evil-WinRM
  • REVERSING
    • Windows executables and DLL's
    • Android APK
Con tecnología de GitBook
LogoLogo

© 2025 Gzzcoo Corp.

En esta página
  • Tratamiento de la TTY interactiva
  • Spawning Interactive Shells
  • Python
  • Perl
  • Ruby
  • Lua
  • Awk
  • Find
  • Vim

¿Te fue útil?

Exportar como PDF

Shells

Tratamiento de la TTY interactiva

Una vez que tenemos una reverse shell, es vital configurar una TTY interactiva para trabajar de forma cómoda y segura. De esta manera, evitamos cerrar la conexión accidentalmente y ganamos la facilidad de desplazarnos con las flechas o utilizar el tab para autocompletar rutas. El proceso es muy sencillo: solo hay que ajustar la tty siguiendo estos pasos para obtener una sesión más fluida y robusta.


Desde la reverse shell obtenida, script /dev/null -c bash transforma la sesión en una TTY interactiva.

VICTIM
$ script /dev/null -c bash
Script started, file is /dev/null

A continuación, hacemos Ctrl+Z para suspender la Reverse Shell.

VICTIM
www-data@test:/$ ^Z
zsh: suspended  nc -nlvp 443

Desde la reverse shell, con stty raw -echo; fg recuperamos la sesión en primer plano y reset xterm restablece la terminal para una experiencia interactiva óptima.

ATTACKER
❯ stty raw -echo; fg
ATTACKER
[1]  + continued  nc -nlvp 443
                                reset xterm

Exportamos las variables para que la terminal y la shell funcionen correctamente:

  • export TERM=xterm corrige el valor por defecto de TERM (a veces aparece como "dump") y permite usar atajos de teclado.

  • export SHELL=bash fuerza a que la shell sea bash.

VICTIM
www-data@test:/$ export TERM=xterm
www-data@test:/$ export SHELL=bash

Desde nuestra máquina revisaremos las dimensiones de nuestra terminal para ajustarlas en la máquina víctima.

ATTACKER
❯ stty size

Desde la máquina configuraremos la terminal con los valores de nuestra terminal. En el caso anterior, como ejemplo nos devolvió 40 filas y 230 columnas, el comando sería el siguiente.

VICTIM
www-data@test:/$ stty rows 40 columns 230

Spawning Interactive Shells

Python

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

Perl

perl —e 'exec "/bin/sh";'
perl: exec "/bin/sh";

El comando anterior debe ejecutarse desde un script.

Ruby

exec "/bin/sh"

El comando anterior debe ejecutarse desde un script.

Lua

os.execute('/bin/sh')

El comando anterior debe ejecutarse desde un script.

Awk

awk 'BEGIN {system("/bin/sh")}'

Find

find / -name <file> -exec /bin/awk 'BEGIN {system("/bin/sh")}' \;
find . -exec /bin/sh \; -quit

Vim

Vim to Shell

vim -c ':!/bin/sh'

Vim Escape

vim
:set shell=/bin/sh
:shell
AnteriorGTFOBinsSiguienteReverse Shell

Última actualización hace 2 meses

¿Te fue útil?