2.5 KiB
2.5 KiB
LPIC-3 335.2: Penetration testing
Scan this VM from the peer with nmap: fingerprint it, check that a firewall change does what you expect, and run some NSE scripts. Only ever scan machines you own.
Before you start
Setup installed nginx and runs it on ports 80, 8080 and 8081, so there
is something to find. The peer, at 10.99.0.2 (name peer), is the
scanner; it sits on this VM's second network, where this VM is
10.99.0.1. Run commands there with sudo ip netns exec lepeer COMMAND.
It shares this VM's files, so a scan it saves in /root/scans is here
too.
The firewall, if it's running, is yours to open for ports 80, 8080 and
8081. Keep your scans in /root/scans. The nftables table only lasts
until a reboot.
Tasks
- Install nmap (and
ndiff, on Ubuntu). From the peer, find the hosts on10.99.0.0/24, then run a SYN scan of ports 22, 80, 443, 8080 and 8081 on10.99.0.1, saved in all formats as/root/scans/before. Ports 22, 80, 8080 and 8081 must showopen. - From the peer, probe the services and the operating system on ports
22, 80 and 8080, with the XML output in
/root/scans/services.xml. Write the nginx version it found (just the number, like1.2.3) to/root/lab-answers/2. - On this VM, install nftables if it's missing and add a table
inet scanlabthat drops port 8080 and rejects port 8081 with a TCP reset, for the peer only. Port 80 must still answer the peer. - From the peer, scan again as in task 1, saved as
/root/scans/after. Then run an ACK scan of ports 22, 8080 and 8081, and write the port it reports asfilteredto/root/lab-answers/4. - Compare the two scans with
ndiffand save its output in/root/scans/diff.txt. (Ubuntu only: AlmaLinux has nondiff.) - Run the
ssh2-enum-algosscript against port 22 and save the output in/root/scans/ssh-algos.txt. Count the NSE scripts in thevulncategory and write the number to/root/lab-answers/6.
Hints
nmap -sn 10.99.0.0/24;nmap -sS -p ... -oA before 10.99.0.1.-sV -O -oX FILE;nginx -vtells you the answer to check against.nft add table,add chain ... '{ type filter hook input priority 0; policy accept; }',add rule ... ip saddr 10.99.0.2 tcp dport 8080 drop,... reject with tcp reset. From the peer:curl --max-time 3 http://10.99.0.1:8080/.-sAsorts ports intofilteredandunfiltered.ndiff before.xml after.xml.--script NAME;/usr/share/nmap/scripts/script.dblists each script's categories.