와이어샤크를 통해 패킷 분석을 하는 경우, 아래와 같이 문자열이 <xx> 로 보이는 경우가 있다. 문자열로 추측이 되는데 무엇일까? 한글이 이렇게 표현되는 경우가 있다. 왜 와이어샤크에서 한글이 깨져보일까?
와이어샤크에서는 한글 컨버전이 제대로 안돼 한글을 windows-1252 코드로 표현한 것이다. 참고로 영어와 서방 언어 윈도우에서 기본으로 사용되는 코드페이지이다.

가끔 이렇게 표현되는 한글이 무엇일까? 필요한 경우가 있다. 간단한 것은 우리가 알아볼 수 있도록 컨버전을 하는 것이다. 다양한 방법을 통해서 할 수 있겠는데, 일단 필자는 다음과 같이 파이썬을 통해 해 보았다.
x 변수에 각 값을 넣어주고, 디코드를 EUC_KR 로 해 보았다.
>>> x = "\xb0\xe6\xbf\xb5\xc1\xf6\xbf\xf8\xc6\xc0"
>>> print x.decode("euc_kr")
경영지원팀
>>>
그러면 짠 하고 의미가 나타난다. 넷바이오스 관련한 것을 보다보면 이러한 이름뒤에 <00>, <1b>, <20>, <1c> 를 볼 수 있다. 예를 들면 , TEST<00>, 홍길동<1C> 와 같은 것들이다. 위에서도 마찬가지로 이름에서 젤 마지막에 붙은 <00> 은 실제 이름이 아니고 다른 의미이므로 그것은 떼어내고 변환해야 한다.
이렇게 변환외에도 알수 있는 방법은 출발지 IP 를 보고 nbtstat 명령어를 통해 보는 것이다.
C:\>nbtstat -A 192.168.x.x
Local Area Connection:
Node IpAddress: [192.168.x.x] Scope Id: []
NetBIOS Remote Machine Name Table
Name Type Status
---------------------------------------------
TEST12 <00> UNIQUE Registered
경영지원팀 <00> GROUP Registered
MAC Address = 00-19-B9-XX-XX-XX
단, 같은 네트워크 라면 모르지만 원격의 경우는 여러 제약이 있으므로 패킷만 전달받은 상태에서는 이렇게 알기 힘드므로 직접 변환 작업등이 필요하다.
아래 도표는 NetBios 의 Number 를 정리한 도표이다.
Name | Number | Type | Usage |
<computername> | 00 | U | Workstation Service |
<computername> | 01 | U | Messenger Service |
<''_MSBROWSE_> | 01 | G | Master Browser |
<computername> | 03 | U | Messenger Service |
<computername> | 06 | U | RAS Server Service |
<computername> | 1F | U | NetDDE Service |
<computername> | 20 | U | File Server Service |
<computername> | 21 | U | RAS Client Service |
<computername> | 22 | U | Exchange Interchange |
<computername> | 23 | U | Exchange Store |
<computername> | 24 | U | Exchange Directory |
<computername> | 30 | U | Modem Sharing Server Service |
<computername> | 31 | U | Modem Sharing Client Service |
<computername> | 43 | U | SMS Client Remote Control |
<computername> | 44 | U | SMS Admin Remote Control Tool |
<computername> | 45 | U | SMS Client Remote Chat |
<computername> | 46 | U | SMS Client Remote Transfer |
<computername> | 4C | U | DEC Pathworks TCPIP Service |
<computername> | 52 | U | DEC Pathworks TCPIP Service |
<computername> | 87 | U | Exchange MTA |
<computername> | 6A | U | Exchange IMC |
<computername> | BE | U | Network Monitor Agent |
<computername> | BF | U | Network Monitor Apps |
<username> | 03 | U | Messenger Service |
<domain> | 00 | G | Domain Name |
<domain> | 1B | U | Domain Master Browser |
<domain> | 1C | G | Domain Controllers |
<domain> | 1D | U | Master Browser |
<domain> | 1E | G | Browser Service Elections |
<INet~Services> | 1C | G | Internet Information Server |
<IS~Computer_name> | 00 | U | Internet Information Server |
<computername> | [2B] | U | Lotus Notes Server |
IRISMULTICAST | [2F] | G | Lotus Notes |
IRISNAMESERVER | [33] | G | Lotus Notes |
Forte_$ND800ZA | [20] | U | DCA Irmalan Gateway Service |
또 다른 예제를 보자. 아래는 LLMNR 프로토콜에서 이름 쿼리를 한 것인데. 위에서 본것과 같이 <xx> 로 표현된 것이 아니라 \xxx\xxx 와 같이 표현되었다. 이건 또 무엇일까? 이 값은 OCT 로 표현된 것이다. 즉, 네트워크 패킷을 덤프할때 시스템 언어의 영향을 받아 덤프할때 언어 표현이 달라진 것이다.

자, 이것은 아래와 같이 변환을 해보자. (참고로 파이썬은 윈도우에서도 사용이 가능하다)
Query 값을 복사할때는 Detail 창에서 해당 값 위에서 오른쪽 클릭을 하면 Copy->Value 를 통해 쉽게
복사가 가능하다는 것을 잊지말자!
# python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = "\355\231\215\352\270\270\353\217\231"
>>> type(x)
<type 'str'>
>>> print x.decode('utf-8')
홍길동
>>>
내용을 utf-8 로 디코드 해 보았더니 홍길동 이라는 이름이 나온다. 자, 필요한 경우 한글로 변환해서
패킷 분석에 도움이 될만한 정보를 얻어보도록 하자!
[참고]
1. Windows-1252
trackback from: Python - SFTP, FTP 파일 업로드
답글삭제# -*- coding:utf-8 -*- # http://ysksoft.com(skyoon) import ftplib import paramiko from socket import * class LibFTP: def __init__(self, ftp_host, ftp_port, ftp_mode=''): if ftp_mode == 'ssl': self._ftp = LibFTPSSL(ftp_host, ftp_port) else: self._ftp = L..