관리 메뉴

kisoo

1.Zeus 자료조사 본문

01.About Programming /4.Security Lab

1.Zeus 자료조사

JamesK78 2011. 11. 3. 15:39

1.zeus 동향

zeus는 봇넷을 빌드,배포,관리에 필요한 모든 도구를 제공하는 툴킷이다.

zeus 툴킷은 세 개의 조합으로 이루어져 있는데

첫번째가  봇넷을 업데이트 하고 유지보수하는 control pannel

두 번째,감염될 실행 바이너리및 구성파일(수집정책 및 봇넷환경 정책)을 생성하는 confiuable Builder
세번째는 수집된 정보를 체계적으로 뷰잉 할 수 있는  Viewer (검색,소팅 등등) 로 구성되어 있다.

 

zeus 툴킷은 많은 사용자에게 상업적으로 판매되고(700$) 있으며  ,이에 따른 zeus 변종이 계속해서 증가하고 있는 추세다.

또한 , 상용버전에 대한 홍보 역할을 하는 무료 공개버전도 배포되고 있어서 앞으로 이러한  zeus  변종은 더욱 크게 증가 할 것으로 보인다.

더욱 무시무시 한 것은 , 기존의  zeus  bot이 C&C에 의해서만 업데이트를 했다고 하면 , 변종 봇은 p2p 형태로 봇 맵을 형성하여

서로 최신 버전으로 업데이트 하고 있다는 것이다.

즉,기존 버전들에서 쓰이던 도메인 생성 알고리즘( DGA)을 버리고 대신 IP 주소 목록을 내장해 P2P 방식으로 감염 PC에 신규 소프트웨어와 구성 파일을 전달한다.

이것은 감염 컴퓨터가 업데이트를 얻기 위해 접촉할 마스터 URL이 더 이상 없는 것이다.

 

제우스 트래커가 최근 발견한 이 버전에서는 새롭게 감염된 PC가 명령 및 업데이트된 구성 파일을 수신하기 위해 접촉할 IP 주소 목록을 포함시킴으로써 위의 전략(P2P)을 실현한다.

새롭게 감염된 PC는 높은 숫자의 포트 상에서 UDP 패킷을 발송하면서 비슷한 피어를 찾는다.

봇넷 안의 다른 감염 PC의 반응이 있으면 그 PC에서 신규 IP 목록을 받는다.

또한 이 봇넷을 제어하는 데 아직 1개의 C&C 도메인이 쓰이고 있지만 이는 고정된 도메인이 아니라 시간의 흐름에 따라 제어 서버의 위치가 변한다.

 

또한 , 훔쳐낸 데이터를 드롭존(Dorpzone)에 전달하거나 봇넷 마스터의 명령을 수신하는 데만 사용되기 때문에 봇넷을 추적할 BinaryURL이나

ConfigURL이 더 이상 존재하지 않아 추적하기가 굉장히 어렵다.

더욱 흥미로운 점은 유효하거나 활성화된 P2P 봇이 없고 주 C&C가 정지됐을 때,

즉 모든 것이 효과가 없을 경우 봇에서는 DGA(Domain Generation Algorithm) 를 예비 기제로 사용한다는 것이다.


얼핏 보면 하나 같이 난감해 보이지만 좋은 점들도 있다.

예를 들자면, 한번에 하나의 제우스 C&C만 기능하기 때문에 이 도메인 명이 중단 내지 종결될 때마다 구성 파일을 새로 내보내야만 한다.

 

이러한 발전된 zeus에 대한 기능및 특징들을 살펴보고 (지피지기백전백승) zeus bot 탐지 및  C&C 서버를 추적하는 방법을 모색하고자 한다.

2.zeus 특징

 1) 봇이 제대로 동작하기 위해서 암호화된 설정파일(config file)을 다운로드한다 (.bin , jpg 형태 )

 2) 새로 업데이트된 봇(exe) 을 다운로드 받는다.(신규버전이 존재할 경우  )

 4) 업데이트된 설정파일 or 봇을 다운받기위해 php 웹서버에 접속한다. (URI 는 변종에 따라 바뀜)

 5)가장 최근에 발견된 최신 zeus 변종은 Peer to Peer 통신을 통해서 최신 bot으로 업데이트 한다.

   ( 기존에 C&C와 통신이 안될 경우에는 , UDP로  active node 에 Msg 를 보내어 응답하는 node 를 찾는다.

     node 와 통신이 되면, 새로운 설정파일,바이너리를 다운받는 형태이다. ) -> 변종된 소스에 반영된듯

 6) IPV4 와 IPV6 듀얼스택 지원

 7) 공격자의 명령과제어(controller)는 거의 순수 PHP Script이며 수집된 정보들은 MYSQL DB를 사용한다.
 8)클라이언트쪽에 있는 악성코드는 C++로 만들어졌다.
 9)하위 봇넷으로 botnet을 분할하는 능력(자식프로세스 생성)
 10)RC4 암호화를 사용하여 DATA 파일이나 명령어를 은폐함.( 구현이 용이해서 사용한듯)

 

 3.zeus 기능

 Zeus의 가장 큰 특징은 API Hooking으로 많은 정보를 탈취 및 저장하여 C&C에 전송하는 것이다.

 zeus는 아래의 기능을 포함하고 있고, 이 기능을 통해 탈취한 정보를 저장하고 서버로 전송한다.

 

1.화면캡쳐  : 모든입력값들 저장하여 C&C 서버로 전달

2.웹브라우저를 통해 서버로 전달되는 입력정보(입력필드 값) 를 가로챈다. ( Key Logger)

3.재부팅 과 종료

4.파일삭제

5.특정 URL 접속에 대한 차단/허용  (DNS Lookup )

6.파일/폴더 검색 및 전송

7.파일 실행 ( create process )

8.다운로드 및 실행 ( request GET and Receive)

9.인증서 탈취(crypt!PFXImportCertStore : report all public & private Keys for a Cerificate)

10.보호된 저장 영역과 쿠키를 통한 정보탈취 ( WEB Memory )

11.제우스 봇 실핼파일의 파일명 변경 (자신을 복제하여 파일명 변경 후 자신은 삭제 )

12.인터넷 시작페이지 변경

13.운영체제 버전 및 언어확인

14.지역및 시간 확인

15.실행중인 프로세스 이름 확인

16.ip주소확인

17.웹 인젝션  - 감염된 상대에게 보여지는 웹페이지 수정가능(HTTP and HTTPS captures)

18.직접 접속 후 인터넷 뱅킹 거래를 수행

 -> 감염자가 인터넷 뱅킹 사이트에 로그인 할 때 실시간으로 정보를 가로채서 알려줌

19.FTP or POP3 계정 탈취

20.하위 봇넷으로 botnet을 분할하는 능력 

20.기타등등(기능은 계속 업그레이드 되어 변종 봇으로 퍼져나가고 있음 )

 

 4.Zeus Get more sophisticated using p2p tehchniques

 1.특징

 1) P2P 봇넷에 가입된 IP list 를 사용한다.

 2) 초기 IP Address lists는  바이너리에 하드코딩 되어 있다.

 3)시스템에 감염되면, zeus 는 high port 로 UDP Packet를 보내서  active node 를 찾는다. (searching peer)

 4)active node와 통신이 되면 remote node 에서는  현재 자신이 보유하고 있는 IP ADDRESSA list 를 보내준다.

 5)발견된 remote node(active node) 에서는 자신이 보유하고 있는 config file and binary  버전을 requesting node 에 보내주어

    만일 remote node가 상위버전의 바이너리 또는 설정파일로 동작하고 있다면 , requesting node(bot) 은 high port 로 TCP 통신을 통해서

    최신 버전의 config&binary를  다운로드 한다.

 6)이러한 특징은 zeus Tracker 가 Track 할 수 있는   Binary URL  or  Config URL 이 없다는 것을 의미한다. ( 이전에는 C&C서버에서 이 역할을 모두 수행 )

 

정리 : HTTP 를 통해서 CONFIG 파일 및 최신 BOT BINARY 를 업데이트 했던 방식과 다르게 P2P 방식으로 변종되면서,

         P2P BOTNET 끼리 최신 봇을 유지하고 있으며, 한개의 C&C도메인을 유지하고 있지만 이 또한 시간의 흐름에 따라 위치가 변함.

        즉, c&c가 변경될 경우 다른 동료들의 힘을빌어 자신을 업데이트 하고 , 또한 변경된 c&c 서버의 정보 또한 업데이트 된다.

 

 

 

 5.Configuration and Bot Creation

지금까지의 자료에 의하면  ZEUS BOT 을 실행하는 첫번째 단계는 CONFIG 파일을 편집하는 것이다.

설정파일에는 BOT에 어떻게 연결할지 , 어떠한 사용자의 정보를 수집할지, 수집한 데이터를 어떻게 모을지 등등에 대한 정보가 포함되어있다.

 설정파일은 다음과 같이 두 가지로 분류된다.

 

1.Static Configuration

The StaticConfig is compiled into the bot by the Builder tool.

 

To update the StaticConfig the bots must be ordered to download a new bot version.

The available settings are:

•The name of the botnet that this bot belongs to

•The amount of time to wait between dynamic configuration file downloads.

•The time interval between uploads of logs and statistical information to the drop server. .
•The URL where the bot can get the dynamic config file.

•A URL where the bot can check its own IP address, to determine if it is behind a router or firewall.
•The encryption key that is used to hide information transmitted within the botnet.

•A language ID list that tells the bot to go into a dormant state if the infected computer's language is on the list.

 

정리 : 감염된 PC 에서 최초 봇이 실행 될 경우에  위와 같은 정보를 얻기위한 파일.즉,배포 될 때 default 정책이다.

 

2.Dynamic Configuration
The DynamicConfig is downloaded by the bot immediately after it is installed on a victim's computer.

This file is downloaded at timed intervals by the bot, and can be used to change the behaviour of the botnet.

Most of the entries control how information is collected from the infected computer.

Available settings include:

•A URL where the bot can download a new version of itself, if the command to do so is given.

•The URL of the drop server where logs, statistics and files will be uploaded and stored.

•Information used to inject additional fields into web pages viewed from the infected computer.

•A list of URLs where an emergency backup config file can be found.

•A set of URL masks used to cause or prevent logging of information.

•A set of URL masks to indicate that a screen image should be saved if the left mouse button is clicked.

•A list of pairs of URLs that are used to cause redirection from the first URL to the second. 두

•A set of URL masks used to collect TAN (Transaction Authentication) numbers - used by some banks for online authentication.

•A list of IP/URL pairs that are inserted into the infected computer's hosts file to override DNS lookups.

 

 

정리 : zeus 가 설치 된 후에 위와 같은 최신 정보를 얻기위해 최신 config 파일을 받아온다. 이를 dynamic configuration 이라 하난것이다.

         즉, 정책(config file) 을 새로 다운로드 받아서 적용한다는 것.

 

Only one physical server is needed, but additional ones can be used to distribute bot file updates and fallback configuration files.

 

3.DATA  암호화

 config file은 RC4로 암호화기법으로 암호화 되어 있다.  ( key 를 알수 있는 방법은 ... ? 알아도 이 또한 계속 변종으로 인해 변경 된다.

 수동으로 복호화된 값을 알수 있는 방법은 olly debuger 와 같은 리버싱을 하면서 MapViewOfFile api  부분을 디버깅 하면서 hex dump 를

  보면 복호화된 값을 확인할 수 있음.)

 

6.Bot Communications

 

 All Zeus botnet communications pass between the bots and one or more servers.

Only one physical server is needed, but additional ones can be used to distribute bot file updates and fallback configuration files.

Data sent through the Zeus botnet is encrypted with RC4 encryption.

In this implementation a key stream is generated from the botnet password, and is XORed with the data.

The same password is used to encrypt all data that is passed through the botnet.

Changing the botnet password requires that all of the bot executables be updated to a build that includes the new password.

The dynamic config file also must be updated and the server password changed from the Control Panel.

When a computer is infected with the Zeus bot, its first communication with the server is a request for the dynamic config file.

Unlike other data sent through the network,

the config file has already been encrypted by the Builder application and can be sent without further processing.

 

Figure 17 shows the config file being requested by the bot, returned by the control server.

 
Figure 17: The bot gets the dynamic config file


When the config file has been received, the bot will retrieve the drop server URL from it. config

The bot then HTTP POSTs some basic information about itself to the drop server, to log in and indicate that it is online.

 As long as it is running, the bot continues to HTTP POST encrypted logs and statistics to the server at timed intervals.

By default logs are sent at 1 minute intervals and statistics are sent every 20 minutes.

 

  
Figure 18: The bot POSTs basic information

 

When a bot posts data to the server, the server replies with an HTTP/1.1 200 OK response.

The Zeus server conceals an encrypted message as data within the response.

This data field is used to send commands (scripts) to the bot.

 Below is an example of the default data when no command is being sent, which is the most common case.

 

 

 
Figure 19: The server reply to the POST contains some data

 

서버에서 명령어를 보낼때 , 데이터의 사이즈가 표준 응답 사이즈보다 크다.

아래의 Figure 20을 보면 getfile 명령 보내진 후 응답 암호화된 데이터는 82 byte 이다.

 

 
Figure 20: The server reply to the POST contains a command

 

 

일반적으로  봇과 C&C 통신시  패킷의 흐름은 다음과 같은 패턴으로 동작한다.

 

1) 감염된 client는 최초 C&C server  에  설정파일(config.bin)를  요청한다.

2)C&C  Server는 암호화된 설정파일과 200 OK 로 응답한다.

3)client 는 암호화된 설정파일을 수신하고 복호화 한 후 바이너리의 메모리에 로딩한다.

4)client는 자신의 외부주소를 알기위해 요청을한다.

5)외부IP 와 함께 200 OK 로  응답한다.

6)client 는 자신이 훔친 데이타 정보와 업데이트 상태를 서버에 보고 한다.

7)서버는 잘 수신했다는 200OK 로 응답한다.

 

 

 

7.Demonstration 데모

 

zeus bot 을 생성하는 과정과 bot으로 부터 수집한 정보를 모니터링하는 과정을 담은 동영상.

 

 http://www.youtube.com/watch?v=b9Vb4zS6ZmE&t=3m53s

 

8.Find and Remove Zeus

 호스트 기반의 탐지방식으로는

기존에 보고된 Zeus의 동작 패턴과  봇이  생성하는 알려진 프로세스 및 레지스트리 키값을 모니터링 하여 탐지 하는 것이다.

맹점은  변종된 zeus는 탐지가 불가하다.

 

변종에 zeus에 대비하는 최고의 방법은 네트워크 기반의 탐지이다.

 봇과 C&C의 통신 패턴  그리고  packet 의 payload 분석으로 봇과 C&C가 통신하는 것을 탐지하는 것이다.

 

아래는 기 발견된 zeus 봇이 생성하는 프로세스 및 레지스트리 키값이다. ( 참고 )

The Zeus banking trojan is also known as Zbot, WSNPOEM, NTOS and PRG. It steals credentials for various online services like social networks, online banking accounts, ftp and email accounts. It spreads via email and Drive-by-Downloads.

Prevx, an internet security company states in their blog “The criminals are careful to infect just a few PCs with each copy of the Trojan, thereby avoiding detection by honepots/nets and subsequent researcher attention in security labs. By the time each copy of a ZEUS Trojan is identified by security researchers it’s job is done and a new fresh version will be dispatched to takeover its role.”

The blog also briefs on what to look for in a PC that may reveal a Zeus infection:

  • The ZEUS trojan will commonly use names like NTOS.EXE, LD08.EXE, LD12.EXE, PP06.EXE, PP08.EXE, LDnn.EXE and PPnn.EXE etc, so search your PCs for files with names like this. The ZEUS Trojan will typically be between 40KBytes and 150Kbytes in size.
  • Also look for a folder with the name WSNPOEM, this is also a common sign of infection for the ZEUS Trojan.
  • Finally, check the Registry lloking for RUN keys referencing any of these names.

abuse.ch ZeuS Tracker (note: This site uses a self-signed certificate, which is invalid in major browsers. The link may be verified using one of the tools here at Online Website Security Check Tools) reveals the known locations of various versions of Zeus on a Windows system as follows:

Variant 1

  • C:\WINDOWS\system32\ntos.exe
  • C:\WINDOWS\system32\wsnpoem\audio.dll
  • C:\WINDOWS\system32\wsnpoem\video.dll

Variant 2

  • C:\WINDOWS\system32\oembios.exe
  • C:\WINDOWS\system32\sysproc64\sysproc86.sys
  • C:\WINDOWS\system32\sysproc64\sysproc32.sys

Variant 3

  • C:\WINDOWS\system32\twext.exe
  • C:\WINDOWS\system32\twain_32\local.ds
  • C:\WINDOWS\system32\twain_32\user.ds

Variant 4

  • C:\WINDOWS\system32\sdra64.exe
  • C:\WINDOWS\system32\lowsec\local.ds
  • C:\WINDOWS\system32\lowsec\user.ds

Johannes Ullrich, chief research officer for the SANS Institute says “for more technically savvy users” is to check their computer’s registry key, which lists software that will start as a user logs in. The registry key can be found by following this path, he said:

  • HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit

“ZeuS will add itself to the list, typically as ‘ntos.’ But this name may, of course, change at any time. Some anti-spyware will monitor this key for changes. Whenever anti-malware alerts the user about a change, the user should be highly suspect. But frequently, the alert is quite cryptic.”

There are other “less technical ways” to detect the botnet, he said. “For example, the bot may inject additional pages into online banking login screens. If the user is all of a sudden asked for a secret question, Social Security number or other unusual items during the login process, abort the login, and call your bank or try the login from another computer.”

SecureWorks further reveals that “the location depends on whether the victim has Administrator rights. The files will most likely have the HIDDEN attribute set to hide them from casual inspection.

With Administrator rights:

  • %systemroot%\system32\sdra64.ex
  • %systemroot%\system32\lowsec
  • %systemroot%\system32\lowsec\user.ds
  • %systemroot%\system32\lowsec\user.ds.lll %systemroot%\system32\lowsec\local.ds

Without Administrator rights:

  • %appdata%\sdra64.exe
  • %appdata%\lowsec
  • %appdata%\lowsec\user.ds
  • %appdata%\lowsec\user.ds.lll
  • %appdata%\lowsec\local.ds

ZeuS also makes registry changes to ensure that it starts up with Administrator privileges:

HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon
From:
“Userinit” = “C:\WINDOWS\system32\userinit.exe”
To:
“Userinit” = “C:\WINDOWS\system32\userinit.exe,C:\WINDOWS\system32\sdra64.exe”

Without Administrator rights:

HKCU\Software\Microsoft\Windows\CurrentVersion\Run
Add:
“Userinit” = “C:\Documents and Settings\<user>\Application Data\sdra64.exe”

MMPC weighs in with a way to check for the existence of Win32/Zbot infection manually using Windows command prompt:

“A clean system by default should not have any unique ID made by the malware, so if you run the following:

  • REG QUERY “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Network” /v UID

– or –

  • REG QUERY “HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Network” /v UID

an infected machine would return the following data in the following format:

  • _ (for example, COMP1_00038EB9)

The userinit startup key specifies what program should be launched right after a user logs on to Windows. Win32/Zbot adds its path into the data value and protects that value from being changed while it is active. Running the following query returns the Zbot program:

  • REG QUERY “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” /v userinit

Trend Micro blogs that the recent variants (as of 26 Apr 2010), use random names for files and directories in a major change. The eariler variants used fixed file names. In addition this trojan now inject themselves into ctfmon.exe, explorer.exe, rdpclip.exe, taskeng.exe, taskhost.exe and wscntfy.exe.

“From this list, we can see that the new ZBOT version now “features” support for both Windows Vista and Windows 7. Taskeng.exe and Taskhost.exe are processes both found in Windows Vista and Windows 7 though neither were found in older versions such as Windows XP.”

Symantec confirms that the new variant “is now known as version 2.0 (named after the Trojan builder kit version).

Version 2.0 adds the following registry key:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\”{[VOL_GUID]}” = “%User Profile%\Application Data\\.exe”

 

9.Detection Idea

봇을 탐지하기 위한 방법은 크게 두 가지로 나뉜다.

첫번째는 ,  호스트기반의 탐지 이고

두 번째는 , 네트워크 기반이다. 

호스트기반 탐지(시그니처,프로세스 행위 ,레지스트리 등등 ) 는  1세대 백신 소프트웨어에서 이미 수집,분석,시그니처화 하는 시스템 인프라를 구성하였고 ,

zeus 기능 중 일부는 이미 백신이나 키보드 보안,캡쳐방지와 같은 기능을 담당하는 소프트웨어서 방어 할 수 있으므로,

우리는  C&C 또는 bot to bot  간의 통신 메커니즘을 분석하여 C&C의 위치 및 zeus 를 탐지한다.

 

탐지방식

C&C 와 봇의 통신 메커니즘을 통해서 패턴을 분석하여 일치하는 패킷 정보(프로세스,C&C)를 수집 하는 것이다.

 

 

 

패턴 1) C&C 와 bot 통신 ( 다운로드 및 명령하달)

  1) request : bot 이 c&c 에 접속하여 최신 설정(config.bin)파일을 요청하여 다운받는다. (GET) -> ex) Request URI: /cfg.bin

  2) reponse : download 가 완료되면 HTTP/1.1 200 OK 로 응답.

  3) request : C&C서버(php 서버)로 기본정보를 전송한다.(POST)

  4) reponse : 암호화된 C&C 명령 데이타

특징 :

  1)  2번 reponse 시에   Content-Type: application/octet-stream 인경우, 어플형식이 지정되지 않을 경우이며, bin 파일의 경우 형식이 지정되지 않음.

   2)  4번 response 시에  일반적인 reponse 보다 크며 현재는 82  ~ 84 byte 암호화된 데이타로 reply 한다.

                                                           

정리 : 위의 1~4번과 시퀀스가 일치하고 특징 1~2가 일치 할 경우

   

 

 패턴 2)C&C 와 bot 통신 (최신 바이너리를 다운로드 받을경우 )

   1) request : bot 이 c&c 서버에 최신 바이너리(exe)를 요청하여 다운 받는다.(GET) -> ex) Request URI : /40.exe

   2) Header 도 검사. 파일 시그니처 검사

 

그밖의 고려할 사항

 1) C&C 와 bot 통신 (이미지 파일을 다운로드 할 경우 )

   1)request : bot 이 C&C 에 접속하여 최신 설정 파일을 요청할때 확장자가 jpg,jpeg 와 같은 파일로 요청 할경우

   2)이미지 파일의 header (signature) 가 맞는지 검증 필요. 아닐 경우 은폐하는 것으로 간주.

   3) reponse : download 가 완료되면 HTTP/1.1 200 OK 로 응답.

   4) request : C&C서버(php 서버)로 기본정보를 전송한다.(POST)

 

 2)알려진 BinaryURL or a ConfigURL 탐지정책으로 추가

   1)현재까지 알려진 DNS 및 URI 를 접속하는 경우 봇으로 간주 (변종된 DNS 및 URI가 증가하고 있기때문에 필터링 가능 )

 

 3) 다운로드 시에 exe 파일 해쉬/파일명  탐지는 변종 봇에는 대응 할 수 없음. ( 단 , 실행되기 전에 차단은 할 수 있다고 판단됨.)

 

 10.결론

 zeus 봇을 탐지하는 방법은 C&C와 봇의 통신 패턴을 분석하여 엔진에 업데이트 하는 방법이 가장 최선이라고 판단된다.(P2P 포함 )

 봇넷과 C&C의 통신 패턴을 적용 할 수 있는 로직을 엔진에 추가하고 , 계속해서 신규 통신 패턴을 업데이트하는 것이다.

config 파일에 의해서 바이너리를 업데이트 하면 , 이전에 탐지되었던 바이너리,레지스트리키,CONFIG 파일 과 같은 시그니쳐는 의미가 없어진다.

터치엔세이프를 예를들면 ,이 정책을 요청하고 수신 할때 데이타는 변경되지만 request/reponse 패턴은 변경이 되지 않는다는 것을 비추어 볼때

zeus 소스를 가지고 있는 새로운 배포자들에게 이러한 패턴이 변경되는 것은 쉬운 일이 아니라고 판단된다.

 

 

 

 

 

 

 

 

이 글은 스프링노트에서 작성되었습니다.

Comments