===취미 세상 : 공부===/칼리리눅스

[정보수집] NMAP

개미민또 2022. 11. 26. 12:13
반응형

nmap은 두 말하면 입 아플 정도의 유명한 스캔 도구이다.

정보 수집하고자 하는 대상이 운영 중인 서비스를 확인 및 그 서비스의 취약점을 확인 할 수 있는 가장 유용한 도구 중 하나이다.

칼리리눅스가 아닌 윈도우에서도 nmap 도구는 사용 가능하다.

이 nmap에 대해서는 과거 정보보안기사 시험에서도 출제 되었던 것을 본 적이 있는데,

nmap 스캔 옵션에 따라 통신하는 특성이 살짝 다르기 때문이다.

그래서 옵션별 통신 방식이 어떻게 다른지 살짝 짚고 넘어가도 좋을 듯 하다.

요즘은 이런 문제가 안보이는 듯 한데..뭐 보안기사 시험 공부 하는 셈 치고..

리마인드 해보자.

728x90

1. TCP OPEN SCAN

- 공격자는 TCP SYN 패킷 전송 

- 수집 대상은 피해 대상으로, PORT 오픈 여부에 따라 SYN+ACK 혹은 RST+ACK를 전달한다

- TCP OPEN SCAN의 특징은 일반적인 3 way handshaking 과정을 거치기에 로그가 남고, 다른 스캔 방식에 비해 속도가 느리다라는 특징이 있다.

TCP OPEN SCAN


2. STEALTH SCAN

- TCP OPEN SCAN 방식은 로그가 남기에 피해자 측에서는 로그 검토를 통한 예방 활동을 할 수 있다. 따라서, 공격자 측에서는 로그가 남지 않는 스캔 방식을 사용해야 하며, STEALTH SCAN은 이러한 로그가 남지 않는 스캔 활동이 되겠다.

- 이 STEALTH SCAN의 종류로는 TCP HALF OPEN SCAN, XMAS SCAN, FIN SCAN, NULL SCAN 등 방식이 존재한다.


2.1 TCP HALF OPEN SCAN

- TCP OPEN SCAN과 큰 차이가 없어 보이는데,

- 포트 OPEN 시 공격자 측에서 3way handshke 통신이 모두 이루어지기 전

- RST 패킷을 전송하므로써 완전한 세션 성립이 안되게 한다.

- 따라서, 로그에 남지 않고 대상자의 서비스 상태만 확인할 수 있게 된다.

TCP HALF OPEN SCAN


2.2 FIN SCAN

- FIN 패킷 전송 후 수집 대상으로 부터 응답 방향에 따라 서비스 여부를 확인한다.

FIN SCAN


2.3 XMAS SCAN

- 비정상적인 패킷 조합 FIN, PSH, URG 패킷을 피해자 쪽으로 전달 후 그 응답을 보고 서비스 여부를 판단한다.

XMAS SCAN


2.4 NULL SCAN

- 역시, 비정상적인 NULL 패킷을 전송, 수집대상의 응답 방향에 따라 서비스 여부를 판단한다.

NULL SCAN


3. UDP SCAN

- UDP 프로토콜의 특성으로 신뢰성이 떨어진다고는 하는데,

- 참고로 알아두자

UDP SCAN


이제 칼리리눅스에서 nmap 을 확인해보자

먼저, nmap 옵션을 확인해 볼 필요가 있다. 어마어마한 옵션들은 namp 사용 효과에 극대화를 줄 수 있다.

nmap -h으로 확인해본다.

Nmap 7.93 ( 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 sequentially - 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
  --noninteractive: Disable runtime interactions via keyboard
  --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

어마무시한 옵션 목록이다.

이 중 스텔스 스캔 옵션으로 테스트 해보자.

nmap -sS example.com

도메인을 입력했지만, 대상 IP 주소를 입력해도 무방하다.

nmap -sS

대상 웹서버는 위와 같이 2개의 서비스는 오픈, 2개의 서비스는 close임을 알 수 있다.

나머지 996개의 포트에서는 확인 불가.


누구나 한 번 쯤은 들어봤을 도구. 그만큼 가장 기본적이면서도 유명한 스캔 도구 nmap이다.

무분별한 사용은 역시 안될 것이다.

조심조심 사용해보자.

 

 

반응형

'===취미 세상 : 공부=== > 칼리리눅스' 카테고리의 다른 글

[정보수집] dmitry  (0) 2022.12.07
[정보수집] httprint  (0) 2022.11.30
[정보수집] scapy  (0) 2022.11.25
[정보수집] unicornscan  (0) 2022.11.15
[정보수집] netenum  (0) 2022.11.14