Friday, March 2, 2018

Port Scan Using Nmap and Enable IIS in Windows 2012 Server

Port scanning tools are designed to send traffic to remote systems and then gather responses that provide information about the systems and the services they provide. They are one of the most frequently used tools when gathering information about a network and the devices that are connected to it. Due to this, port scans are often the first step in an active reconnaissance of an organization.

Port scanners have a number of common features, including:
  • Host discovery
  • Port scanning and service identification
  • Service version identification
  • Operating system identification
An important part of port scanning is an understanding of common ports and services. Ports from 0–1023 are known as well-known ports or system ports, but there are quite a few higher ports that are commonly of interest when conducting port scanning. Ports ranging from 1024 to 49151 are registered ports and are assigned by the Internet Assigned Numbers Authority (IANA) when
requested.

There are some basic commands in Kali Linux that we could use to do a quick port scan and OS Fingerprinting.

root@kali:~# telnet 192.168.1.130 80      // YOU CAN ONLY TELNET  TO TCP PORTS
Trying 192.168.1.130...
Connected to 192.168.1.130.
Escape character is '^]'.

GET / HTTP/1.0           // TYPE GET / HTTP/1.0 AND PRESS ENTER A FEW TIMES

HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Sun, 04 Feb 2018 18:28:51 GMT
Accept-Ranges: bytes
ETag: "1a33a41e69dd31:0"
Server: Microsoft-IIS/8.5          // WINDOWS 2012 IIS/WEB SERVER
Date: Sun, 04 Feb 2018 18:31:06 GMT
Connection: close
Content-Length: 701
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IIS Windows Server</title>
<style type="text/css">
<!--
body {
        color:#000000;
        background-color:#0072C6;
        margin:0;
}
#container {
        margin-left:auto;
        margin-right:auto;
        text-align:center;
        }
a img {
        border:none;
}
-->
</style>
</head>
<body>
<div id="container">
<a href="http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409"><img src="iis-85.png" alt="IIS" width="960" height="600" /></a>
</div>
</body>
</html>


root@kali:~# nc 192.168.1.130 80     // NETCAT ALSO YIELDED AN IDENTICAL OUTPUT

GET / HTTP/1.0         // TYPE GET / HTTP/1.0 AND PRESS ENTER A FEW TIMES

HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Sun, 04 Feb 2018 18:28:51 GMT
Accept-Ranges: bytes
ETag: "1a33a41e69dd31:0"
Server: Microsoft-IIS/8.5    
Date: Sun, 04 Feb 2018 18:33:49 GMT
Connection: close
Content-Length: 701
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IIS Windows Server</title>
<style type="text/css">
<!--
body {
        color:#000000;
        background-color:#0072C6;
        margin:0;
}
#container {
        margin-left:auto;
        margin-right:auto;
        text-align:center;
        }
a img {
        border:none;
}
-->
</style>
</head>
<body>
<div id="container">
<a href="http://go.microsoft.com/fwlink/?linkid=66138&amp;clcid=0x409"><img src="iis-85.png" alt="IIS" width="960" height="600" /></a>
</div>
</body>
</html>


Nmap is one of the most popular port scanning tools used today. After performing scans with certain flags set in the scan packets, security analysts (and hackers) can make certain assumptions based on the responses received. These flags are used to control the TCP connection process. Here's a nice Nmap cheat sheet that you could use for reference.

root@kali:~# nmap          // TYPE nmap THEN ENTER TO SEE HELP OR COMMAND OPTIONS
Nmap 7.60 ( https://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
  -sL: List Scan - simply list targets to scan
  -sn: Ping Scan - disable port scan
  -Pn: Treat all hosts as online -- skip host discovery
  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -PO[protocol list]: IP Protocol Ping
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
  --traceroute: Trace hop path to each host
SCAN TECHNIQUES:
  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
  -sU: UDP Scan
  -sN/sF/sX: TCP Null, FIN, and Xmas scans
  --scanflags <flags>: Customize TCP scan flags
  -sI <zombie host[:probeport]>: Idle scan
  -sY/sZ: SCTP INIT/COOKIE-ECHO scans
  -sO: IP protocol scan
  -b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
  -p <port ranges>: Only scan specified ports
    Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
  --exclude-ports <port ranges>: Exclude the specified ports from scanning
  -F: Fast mode - Scan fewer ports than the default scan
  -r: Scan ports consecutively - don't randomize
  --top-ports <number>: Scan <number> most common ports
  --port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
  -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
  -sC: equivalent to --script=default
  --script=<Lua scripts>: <Lua scripts> is a comma separated list of
           directories, script-files or script-categories
  --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
  --script-args-file=filename: provide NSE script args in a file
  --script-trace: Show all data sent and received
  --script-updatedb: Update the script database.
  --script-help=<Lua scripts>: Show help about scripts.
           <Lua scripts> is a comma-separated list of script-files or
           script-categories.
OS DETECTION:
  -O: Enable OS detection
  --osscan-limit: Limit OS detection to promising targets
  --osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
  Options which take <time> are in seconds, or append 'ms' (milliseconds),
  's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
  -T<0-5>: Set timing template (higher is faster)
  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
  --min-parallelism/max-parallelism <numprobes>: Probe parallelization
  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
      probe round trip time.
  --max-retries <tries>: Caps number of port scan probe retransmissions.
  --host-timeout <time>: Give up on target after this long
  --scan-delay/--max-scan-delay <time>: Adjust delay between probes
  --min-rate <number>: Send packets no slower than <number> per second
  --max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
  -f; --mtu <val>: fragment packets (optionally w/given MTU)
  -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
  -S <IP_Address>: Spoof source address
  -e <iface>: Use specified interface
  -g/--source-port <portnum>: Use given port number
  --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
  --data <hex string>: Append a custom payload to sent packets
  --data-string <string>: Append a custom ASCII string to sent packets
  --data-length <num>: Append random data to sent packets
  --ip-options <options>: Send packets with specified ip options
  --ttl <val>: Set IP time-to-live field
  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
  --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
  -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
     and Grepable format, respectively, to the given filename.
  -oA <basename>: Output in the three major formats at once
  -v: Increase verbosity level (use -vv or more for greater effect)
  -d: Increase debugging level (use -dd or more for greater effect)
  --reason: Display the reason a port is in a particular state
  --open: Only show open (or possibly open) ports
  --packet-trace: Show all packets sent and received
  --iflist: Print host interfaces and routes (for debugging)
  --append-output: Append to rather than clobber specified output files
  --resume <filename>: Resume an aborted scan
  --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
  --webxml: Reference stylesheet from Nmap.Org for more portable XML
  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
  -6: Enable IPv6 scanning
  -A: Enable OS detection, version detection, script scanning, and traceroute
  --datadir <dirname>: Specify custom Nmap data file location
  --send-eth/--send-ip: Send using raw ethernet frames or IP packets
  --privileged: Assume that the user is fully privileged
  --unprivileged: Assume the user lacks raw socket privileges
  -V: Print version number
  -h: Print this help summary page.
EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sn 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES


root@kali:~# nmap -sn 192.168.1.0/24        // TO DO QUICK PING SCAN ON LIVE HOSTS AND DETECT ITS MAC ADDRESS
Starting Nmap 7.60 ( https://nmap.org ) at 2018-02-05 03:41 PST
Stats: 0:00:03 elapsed; 0 hosts completed (0 up), 255 undergoing ARP Ping Scan
ARP Ping Scan Timing: About 33.92% done; ETC: 03:41 (0:00:08 remaining)
Nmap scan report for 192.168.1.1
Host is up (0.16s latency).
MAC Address: 00:00:AB:FD:4E:01 (Logic Modeling)
Nmap scan report for 192.168.1.2
Host is up (0.0083s latency).
MAC Address: AA:BB:CC:80:01:00 (Unknown)
Nmap scan report for 192.168.1.3
Host is up (0.017s latency).
MAC Address: CA:02:12:1C:00:00 (Unknown)
Nmap scan report for 192.168.1.100
Host is up (0.0058s latency).
MAC Address: 08:00:27:E6:1A:6D (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.1.110
Host is up (0.0048s latency).
MAC Address: 08:00:27:C2:80:BE (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.1.130
Host is up (0.0098s latency).
MAC Address: 08:00:27:9A:CE:F4 (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.1.120
Host is up.
Nmap done: 256 IP addresses (7 hosts up) scanned in 5.78 seconds


root@kali:~# nmap -O -sV 192.168.1.130       // USE NMAP FOR PORT SCAN AND OS DETECTION
Starting Nmap 7.60 ( https://nmap.org ) at 2018-02-03 19:10 PST
Nmap scan report for 192.168.1.130
Host is up (0.0013s latency).
Not shown: 999 filtered ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Microsoft IIS httpd 8.5
MAC Address: 08:00:27:9A:CE:F4 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Microsoft Windows 2012
OS CPE: cpe:/o:microsoft:windows_server_2012:r2
OS details: Microsoft Windows Server 2012 or Windows Server 2012 R2
Network Distance: 1 hop
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 19.79 seconds


There's a GUI version of Nmap called Zenmap. To open Zenmap, just type zenmap in Kali Linux terminal and press Enter. It will automatically open the Zenmap application.


You can also go to Applications > 01 – Information Gathering > Zenmap (eye icon).




Type the IP range (in CIDR notation) on Target field > click Scan or just press Enter (Intense scan is the default). The Nmap Command will auto complete below and you can edit it as needed. The Intense Scan took several minutes to complete (depends on the IP range and alive hosts). Nmap (Zenmap) was able to perform port scan and OS Fingerprint on hosts in my virtual lab.
 


This is the Nmap scan report for 192.168.1.1, which is my Cisco ASA firewall. I had Telnet opened (for lab purpose) which is considered an insecure management protocol (sent in clear text).
 


This is the Nmap scan report for 192.168.1.2, which is my IOU Layer 2 Switch. It also has Telnet opened (TCP port 23) and it's just one hop away based on the traceroute output.
 


This is the Nmap scan report for 192.168.1.3, which is a Cisco IOS Router.
 


This is the Nmap scan report for 192.168.1.110, which is my Metasploitable Linux. It's an intentionally vulnerable version of Ubuntu Linux and has a lot of TCP and UDP ports opened.



This is the Nmap scan report on 192.168.1.130, which is my Windows 2012 R2 Server. You can quickly tell which OS the host is running based on the OS logo beside the IP address.
 

You can also perform scanning on a specific host. I did a Quick scan plus on 192.168.1.130 and look at the info on each tab.







These are the steps for enabling the IIS (Web) Service on a Windows 2012 R2 Server. Go to Server Manager > Dashboard > Add roles and features > click Next.




Choose Role-based or feature-based installation (default option) > click Next.
 


Choose a server (local server is chosen by default) > click Next.



Under Roles > enable/tick Web Server (IIS)



Click Add Features > click Next.
 



There’s no need to enable additional Features. Click Next.
 


Click Next.
 


Enable additional Role Services or just leave the default. In my case I’ve enabled Logging Tools and FTP Service > click Next.
 


Click Install.
 


To activate the evaluation license for 180 days, type the slmgr.vbs /rearm command in command prompt and restart the server.

No comments:

Post a Comment