본문 바로가기

리눅스

[명령어] nmap 명령어

728x90

nmap 명령어

nmap 버전

$ nmap -V

Nmap version 6.40 ( http://nmap.org )
Platform: x86_64-redhat-linux-gnu
Compiled with: nmap-liblua-5.2.2 openssl-1.0.2k libpcre-8.32 libpcap-1.5.3 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

nmap 사용법

Usage: nmap [Scan Type(s)] [Options] {target specification}

TCP 포트 오픈 여부 확인

- SYN 스탤스 스캔(-sS)

$ nmap -sS 8.8.8.8

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 17:14 KST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.0099s latency).
Not shown: 998 filtered ports
PORT    STATE SERVICE
53/tcp  open  domain
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 4.24 seconds

- TCP 연결 스캔(-sT)

$ nmap -sT 8.8.8.8

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 17:13 KST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.029s latency).
Not shown: 998 filtered ports
PORT    STATE SERVICE
53/tcp  open  domain
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 6.33 seconds

- 특정 포트 스캔

$ nmap -sX 8.8.8.8 -p 53

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 17:18 KST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.00032s latency).
PORT   STATE  SERVICE
53/tcp closed domain

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds
$ nmap -sT -p sangchul.kr 80

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 18:20 KST
Nmap scan report for sangchul.kr (27.0.236.139)
Host is up (0.00055s latency).
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds
$ nmap -sT sangchul.kr -p 8080

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 18:22 KST
Nmap scan report for sangchul.kr (27.0.236.139)
Host is up (0.00048s latency).
PORT     STATE  SERVICE
8080/tcp closed http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.28 seconds
$ nmap -sT sangchul.kr -p 4433

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 18:22 KST
Nmap scan report for sangchul.kr (27.0.236.139)
Host is up (0.00025s latency).
PORT     STATE    SERVICE
4433/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 0.48 seconds
STATE : open, closed, filtered(방화벽 실행 중...)

UDP 포트 오픈 여부 확인

- UDP 연결 스캔(-sU)

$ nmap -sU 8.8.8.8

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 17:13 KST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.0075s latency).
Not shown: 999 open|filtered ports
PORT      STATE  SERVICE
33459/udp closed unknown

Nmap done: 1 IP address (1 host up) scanned in 4.02 seconds

- 특정 포트 스캔

$ nmap -sUX 8.8.8.8 -p 53

Starting Nmap 6.40 ( http://nmap.org ) at 2022-01-24 17:18 KST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.00035s latency).
PORT   STATE         SERVICE
53/tcp closed        domain
53/udp open|filtered domain

Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds

이미지 출처-https://miro.medium.com/max/1400/1*UGT98z-hU-CwyeabC5b_vA.png

Nmap Port Status
open : 스캔 된 포트가 Listen 상태임을 나타낸다.
closed : 포트 스캐닝을 한 시점은 listen 상태가 아님을 나타낸다.
filtered : 방화벽이나 필터에 막혀, 해당 포트의 open/close 여부를 판별할 수 없다.
unfilterd : unfilterd 상태의 포트 접근은 가능하나, 그 포트가 열려있는지 닫혀있는지를 NMPA에서는 판별할 수 없음을 의미한다.
open|filtered : 대상 포트가 open 상태인지, filtered 상태인지 알 수 없을 때를 의미한다.
closed|unfiltered : 대상 포트가 closed 상태인지, unfiltered 상태인지 알 수 없을 때를 의미한다.

참고 사이트

- https://nmap.org/book/scan-methods-udp-scan.html

- https://kimhyun2017.tistory.com/208

- https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=minki0127&logNo=220705883469

- https://koayyongcett.medium.com/lesson-6-network-vulnerability-and-scanning-udp-scan-d06c75787f5

 

 

728x90