📖
NOTES
  • Welcome!
  • Reference
    • Hacking
      • Penetration Testing Resources Bookmarks
        • Research Links
        • Cheat Sheet
        • Learning/Training
        • Tools
        • Payloads
        • Shell
        • AI
        • Reads
        • Podcast
        • Social Engineering
        • Payloads
      • Web/App Pentesting
        • SQL Injection
          • SQL Injection In The URL
          • SQL Injection In The Search Field
          • SQL Injection in Login forms
          • Boolean SQL Injection Blind
          • Time based SQL Injection Blind
          • Bypassing SQL Filters
          • SQL Injection with sqlmap
          • XPath Injection - Authentication Bypass
            • XPath Advanced Data Exfiltration
          • Payloads
        • XSS
          • Payloads
          • XSS Reflected
          • XSS Stored
          • Dom-based
          • Blind
        • Command Injection
          • Payloads
        • File Upload
          • Payloads
          • Bypass Filters
          • File Upload Tricks
        • SSRF
          • Payloads
        • LFI/RFI
          • Payloads
        • LDAP Injection
      • Port Swigger
        • Access control
          • Lab: Unprotected admin functionality
          • Unprotected admin functionality with unpredictable URL
          • User role controlled by request parameter
          • User ID controlled by request parameter, with unpredictable user IDs
          • User ID controlled by request parameter with password disclosure
        • Authentication
          • Username enumeration via different responses
        • Server-side request forgery (SSRF)
          • Basic SSRF against the local server
          • Basic SSRF against another back-end system
        • File Upload Vulnerabilities
          • Remote code execution via web shell upload
        • SQL Injection
          • SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
      • Burp
        • Setting up Macro for intruder
      • ☁️Cloud
        • Tools
        • AWS
          • 🪣S3 Buckets
          • Amazon IAM
          • Dockers
            • Tools
        • Azure
        • GCP
      • Networking
        • Cheat Sheet
      • Hardware Hacking
        • Computer BIOS
    • HTML/CSS/JAVA
      • Tools
      • HTTP Response Status Codes
      • Bootstrap Templates
      • SSL
      • cURL
      • Grep
    • DataBase
      • My SQL
        • Cheat Sheet
        • Tools
    • PYTHON3
      • Code Resources
      • Python Reference Guide
        • Cheat Sheet
      • Code Projects
        • Jiggler Mouse
        • loan calculator
        • Bilnd LDAP Data Exfiltration
    • SEO
      • Tools
      • On-Page SEO
      • Local SEO and Keyword Research
      • Content Optimization
      • Technical SEO
      • Off-Page SEO Tools
      • Google Ads
    • Cloud
      • AWS
        • Light Sail
          • Hosting Website on Light Sail and Namecheap
        • Boto3
      • Azure
      • GCP
    • Files
      • PDF
Powered by GitBook
On this page
  1. Reference
  2. Hacking
  3. Web/App Pentesting

Command Injection

What is Command Injection?

  • Command Injection is a type of security vulnerability where an attacker can execute arbitrary commands on a host operating system via a vulnerable application.

  • It typically occurs in web applications that improperly process user input to execute system-level commands.

How Does Command Injection Occur?

  • Vulnerable Input Processing: When user input is not properly validated or sanitized, and directly used in a system command.

  • Commonly Affected Languages/Technologies: PHP, Java, Python, Shell scripts, SQL databases with system command functions.

Examples of Command Injection

  • A web form that takes a user input (like a username) and uses it in a system command without proper validation.

  • URL parameters or HTTP headers that are concatenated directly into system commands.

Basic Example

  • Unsafe code in PHP: shell_exec('ping ' . $_GET['ip']);

  • In this example, if an attacker inputs 8.8.8.8; rm -rf /, it could lead to the execution of a harmful command (rm -rf /).

Impact

  • Data Breach: Unauthorized access to or theft of data.

  • System Compromise: Gain control over the host system.

  • Denial of Service: Disrupt services by executing resource-intensive commands.

Prevention and Mitigation

  • Input Validation: Strictly validate user inputs for expected formats.

  • Use Safe APIs: Use language-specific safe APIs that abstract command execution.

  • Escaping Inputs: Properly escape special characters in user inputs.

  • Least Privilege Principle: Run applications with the least privileges necessary.

  • Regular Security Auditing: Regularly audit code and applications for vulnerabilities.

Testing for Command Injection

  • Manual Testing: Attempt to input system commands through the application.

  • Automated Tools: Use security scanning tools like OWASP ZAP, Burp Suite.

  • Code Review: Regularly review code for potential vulnerabilities.

PreviousBlindNextPayloads

Last updated 1 year ago