본문 바로가기

Linux/보안

네트워크 서비스 보안 - tcpdump



tcpdump

telnet은 암호화 하지 않고 패킷을 전송하는데 이는 보안에 취약하다.
tcpdump 명령어를 이용해 telnet의 패킷 전송 그 예를 본다.


 
[root@server3 ~]# tcpdump port 23 -l -vvv -x -X > dump.txt - tcpdump 명령어를 이용해 port 23 에 대한 접속 정보를 dump.txt 파일에 저장한다.
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes


------------------------------------------

다른 컴퓨터에서 접속시도
[root@server2 ~]# telnet 10.10.33.3
Trying 10.10.33.3...
Connected to 10.10.33.3 (10.10.33.3).
Escape character is '^]'.
CentOS release 5.2 (Final)
Kernel 2.6.18-92.el5 on an i686
login: test1 - telnet 접속을 위해 ID 와 PASSWORD를 입력한다.
Password:
Last login: Fri Jan 30 14:52:12 from 10.10.33.3

------------------------------------------

ctrl+c 를 클릭하면

100 packets captured
200 packets received by filter  - 이렇게 누군가가 # telnet 10.10.33.3 으로 텔넷 접속을 하게 되면 로그인 기록이 남게 된다.
0 packets dropped by kernel

[root@server3 ~]# vi dump.txt - dump.txt 파일 분석해보면 로그인 기록을 통해 ID와 PASSWORD를 알수 있게 된다.




dump.txt 분석방법

 
[root@server3 ~]# vi dump.txt

login 으로 검색한 다음

14:56:39.357791 IP (tos 0x10, ttl  64, id 4873, offset 0, flags [DF], proto: TCP (6), length: 59) server3.co.kr.telnet > 10.10.33.2.37030: P, cksum 0xa487 (correct), 170:177(7) ack 146 win 46 <nop,nop,timestamp 21971166 21845717>
    0x0000:  4510 003b 1309 4000 4006 d18b 0a0a 2103  E..;..@.@.....!.
    0x0010:  0a0a 2102 0017 90a6 287f 331d 2716 6c0d  ..!.....(.3.'.l.
    0x0020:  8018 002e a487 0000 0101 080a 014f 40de  .............O@.
    0x0030:  014d 56d5 6c6f 6769 6e3a 20              .MV.login:.

server3.co.kr.telnet > 10.10.33.2.37030
- IP주소 : 10.10.33.2 을 가진 사용자가 포트번호 : 37030 로 내 컴퓨터(server3.co.kr)에 텔넷 접속을 해서 로그인 요청을 하고 있고
               server3.co.kr 이 응답 및 요청 하고 있다.

- ack 146 : 응답번호는 ack 146 이다. 이제 ack 146 의 응답을 찾는다.  

14:56:40.261365 IP (tos 0x10, ttl  64, id 23851, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x8f12 (correct), 146:147(1) ack 177 win 46 <nop,nop,timestamp 21846620 21971166>
    0x0000:  4510 0035 5d2b 4000 4006 876f 0a0a 2102  E..5]+@.@..o..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c0d 287f 3324  ..!.....'.l.(.3$
    0x0020:  8018 002e 8f12 0000 0101 080a 014d 5a5c  .............MZ\
    0x0030:  014f 40de 74                             .O@.t

10.10.33.2.37030 > server3.co.kr.telnet
- 10.10.33.2 가 server3.co.kr의 요청에 응답하고 있다.
- 146:147(1) : ack 146 의 요청에 대해서 응답하고 있다.

이런 방식으로 146:147 -> 147:148 -> 148:149 식으로 계속 따라가서 나온 문자 및 숫자를 조합해 보면 ID 와 PASSWORD를 찾을 수 있다.
그리고 ID와 PASSWORD 뿐만 아니라 10.10.33.2가 사용한 명령어 등도 알아낼수 있다.

14:56:40.366292 IP (tos 0x10, ttl  64, id 23853, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x9a1f (correct), 147:148(1) ack 178 win 46 <nop,nop,timestamp 21846725 21972070>
    0x0000:  4510 0035 5d2d 4000 4006 876d 0a0a 2102  E..5]-@.@..m..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c0e 287f 3325  ..!.....'.l.(.3%
    0x0020:  8018 002e 9a1f 0000 0101 080a 014d 5ac5  .............MZ.
    0x0030:  014f 4466 65                             .ODfe

14:56:40.628545 IP (tos 0x10, ttl  64, id 23855, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x8aad (correct), 148:149(1) ack 179 win 46 <nop,nop,timestamp 21846988 21972175>
    0x0000:  4510 0035 5d2f 4000 4006 876b 0a0a 2102  E..5]/@.@..k..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c0f 287f 3326  ..!.....'.l.(.3&
    0x0020:  8018 002e 8aad 0000 0101 080a 014d 5bcc  .............M[.
    0x0030:  014f 44cf 73                             .OD.s

14:56:40.764670 IP (tos 0x10, ttl  64, id 23857, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x881d (correct), 149:150(1) ack 180 win 46 <nop,nop,timestamp 21847124 21972437>
    0x0000:  4510 0035 5d31 4000 4006 8769 0a0a 2102  E..5]1@.@..i..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c10 287f 3327  ..!.....'.l.(.3'
    0x0020:  8018 002e 881d 0000 0101 080a 014d 5c54  .............M\T
    0x0030:  014f 45d5 74                             .OE.t

14:56:41.020418 IP (tos 0x10, ttl  64, id 23859, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0xc993 (correct), 150:151(1) ack 181 win 46 <nop,nop,timestamp 21847380 21972573>
    0x0000:  4510 0035 5d33 4000 4006 8767 0a0a 2102  E..5]3@.@..g..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c11 287f 3328  ..!.....'.l.(.3(
    0x0020:  8018 002e c993 0000 0101 080a 014d 5d54  .............M]T
    0x0030:  014f 465d 31                             .OF]1

14:56:41.216924 IP (tos 0x10, ttl  64, id 4880, offset 0, flags [DF], proto: TCP (6), length: 62) server3.co.kr.telnet > 10.10.33.2.37030: P, cksum 0x1034 (correct), 184:194(10) ack 153 win 46 <nop,nop,timestamp 21973025 21847576>
    0x0000:  4510 003e 1310 4000 4006 d181 0a0a 2103  E..>..@.@.....!.
    0x0010:  0a0a 2102 0017 90a6 287f 332b 2716 6c14  ..!.....(.3+'.l.
    0x0020:  8018 002e 1034 0000 0101 080a 014f 4821  .....4.......OH!
    0x0030:  014d 5e18 5061 7373 776f 7264 3a20       .M^.Password:.

14:56:41.556126 IP (tos 0x10, ttl  64, id 23864, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x90a8 (correct), 153:154(1) ack 194 win 46 <nop,nop,timestamp 21847915 21973025>
    0x0000:  4510 0035 5d38 4000 4006 8762 0a0a 2102  E..5]8@.@..b..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c14 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 90a8 0000 0101 080a 014d 5f6b  .............M_k
    0x0030:  014f 4821 66                             .OH!f

14:56:41.618364 IP (tos 0x10, ttl  64, id 23865, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x88ec (correct), 154:155(1) ack 194 win 46 <nop,nop,timestamp 21847978 21973405>
    0x0000:  4510 0035 5d39 4000 4006 8761 0a0a 2102  E..5]9@.@..a..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c15 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 88ec 0000 0101 080a 014d 5faa  .............M_.
    0x0030:  014f 499d 6c                             .OI.l

14:56:41.701525 IP (tos 0x10, ttl  64, id 23866, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x8182 (correct), 155:156(1) ack 194 win 46 <nop,nop,timestamp 21848061 21973427>
    0x0000:  4510 0035 5d3a 4000 4006 8760 0a0a 2102  E..5]:@.@..`..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c16 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 8182 0000 0101 080a 014d 5ffd  .............M_.
    0x0030:  014f 49b3 73                             .OI.s

14:56:41.824015 IP (tos 0x10, ttl  64, id 23867, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x85b4 (correct), 156:157(1) ack 194 win 46 <nop,nop,timestamp 21848183 21973510>
    0x0000:  4510 0035 5d3b 4000 4006 875f 0a0a 2102  E..5];@.@.._..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c17 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 85b4 0000 0101 080a 014d 6077  .............M`w
    0x0030:  014f 4a06 6e                             .OJ.n

14:56:41.945984 IP (tos 0x10, ttl  64, id 23868, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x80be (correct), 157:158(1) ack 194 win 46 <nop,nop,timestamp 21848305 21973633>
    0x0000:  4510 0035 5d3c 4000 4006 875e 0a0a 2102  E..5]<@.@..^..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c18 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 80be 0000 0101 080a 014d 60f1  .............M`.
    0x0030:  014f 4a81 72                             .OJ.r

14:56:42.116114 IP (tos 0x10, ttl  64, id 23869, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x7d98 (correct), 158:159(1) ack 194 win 46 <nop,nop,timestamp 21848476 21973755>
    0x0000:  4510 0035 5d3d 4000 4006 875d 0a0a 2102  E..5]=@.@..]..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c19 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 7d98 0000 0101 080a 014d 619c  ....}........Ma.
    0x0030:  014f 4afb 74                             .OJ.t

14:56:42.164403 IP (tos 0x10, ttl  64, id 23870, offset 0, flags [DF], proto: TCP (6), length: 53) 10.10.33.2.37030 > server3.co.kr.telnet: P, cksum 0x83bd (correct), 159:160(1) ack 194 win 46 <nop,nop,timestamp 21848524 21973925>
    0x0000:  4510 0035 5d3e 4000 4006 875c 0a0a 2102  E..5]>@.@..\..!.
    0x0010:  0a0a 2103 90a6 0017 2716 6c1a 287f 3335  ..!.....'.l.(.35
    0x0020:  8018 002e 83bd 0000 0101 080a 014d 61cc  .............Ma.
    0x0030:  014f 4ba5 6d                             .OK.m

14:56:42.415636 IP (tos 0x10, ttl  64, id 4893, offset 0, flags [DF], proto: TCP (6), length: 71) server3.co.kr.telnet > 10.10.33.2.37030: P, cksum 0x8d03 (correct), 267:286(19) ack 162 win 46 <nop,nop,timestamp 21974224 21848771>
    0x0000:  4510 0047 131d 4000 4006 d16b 0a0a 2103  E..G..@.@..k..!.
    0x0010:  0a0a 2102 0017 90a6 287f 337e 2716 6c1d  ..!.....(.3~'.l.
    0x0020:  8018 002e 8d03 0000 0101 080a 014f 4cd0  .............OL.
    0x0030:  014d 62c3 5b74 6573 7431 4073 6572 7665  .Mb.[test1@serve
    0x0040:  7233 207e 5d24 20                        r3.~]$.

------------------------------------------

tcpdump 를 이용해 찾아낸 ID와 PASSWORD는 다음과 같다.
ID : test1
PASSWORD : flsnrtm