Command Injection
Become VeryLazyTech member! 🎁
Follow us on:
✖ Twitter @VeryLazyTech.
👾 Github @VeryLazyTech.
📜 Medium @VeryLazyTech.
📺 YouTube @VeryLazyTech.
📩 Telegram @VeryLazyTech.
🕵️♂️ My Site @VeryLazyTech.
Visit our shop for e-books and courses. 📚
Basic info
Command Injection is a critical vulnerability that allows an attacker to execute arbitrary system commands on a server hosting an application. If an application improperly handles user input and passes it to the operating system, an attacker can escape the intended function and execute system commands with the same privileges as the application.
Depending on where your input is being injected you may need to terminate the quoted context (using " or ') before the commands.
🛠️ How Command Injection Works
Applications that interact with the OS (e.g., calling system functions) without properly validating user input can be exploited.
Example: Vulnerable Code (PHP)
<?php
$user = $_GET['user'];
system("ping -c 4 " . $user);
?>💡 Problem: The script takes the user parameter and directly appends it to the ping command without validation.
💣 Attack: Inject ; cat /etc/passwd to execute an extra command!
http://target.com/ping.php?user=127.0.0.1;cat /etc/passwdCommand Injection/Execution
Limition Bypasses
If you are trying to execute arbitrary commands inside a linux machine you will be interested to read about this Bypasses:
Examples
Parameters
Here are the top 25 parameters that could be vulnerable to code injection and similar RCE vulnerabilities:
wfuzz
ffuf
Time based data exfiltration
Extracting data: char by char
DNS based data exfiltration
Based on the tool from https://github.com/HoLyVieR/dnsbin also hosted at dnsbin.zhack.ca
Online tools to check for DNS based data exfiltration:
dnsbin.zhack.ca
pingb.in
Filtering bypass
Windows
Linux
Learn & practice For the OSCP.
Last updated
Was this helpful?