{"id":619,"date":"2017-05-10T14:36:00","date_gmt":"2017-05-10T06:36:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=619"},"modified":"2023-11-04T14:48:30","modified_gmt":"2023-11-04T06:48:30","slug":"win-pe-analysis","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/619","title":{"rendered":"Win PE Analysis"},"content":{"rendered":"\n<p><strong>PE(protable executable)<\/strong><br>4D5A is PE signature<br>refer<br>https:\/\/en.wikipedia.org\/wiki\/Portable_Executable#\/media\/File:Portable_Executable_32_bit_Structure_in_SVG.svg<\/p>\n\n\n\n<p><strong>PE file consists<\/strong><br>header:<br>DOS header:64byte,starts with magic number 4D 5A 50 00,last 4 bytes is the location of PE header<br>DOS stub:<br>PE header: 24byte, starts with magic number 50 45 00 00<br>optional header:224 byte&nbsp;<br>information:96byte<br>data directory:128byte<br>sections:<br>code<br>imports<br>data&nbsp;<\/p>\n\n\n\n<p><strong>PE file analysis<\/strong><br>static analysis: collecting information without launching the executable file<br>dynamic analysis collecting information by launching the executable file<\/p>\n\n\n\n<p><br><strong>Static analysis process:<\/strong><br>1. scan by anti-virus<br>2. search for string ,&nbsp;ex: tool like process explorer or pestudio<br>3. analyze PE header<br>4. analyze import tables: list who is included,&nbsp;exe usually include dll<br>5. analyze export tables: list who include me, dll usually is included by exe<\/p>\n\n\n\n<p><strong>Dynamic analysis process:<\/strong><br>1.create test environment<br>2.colleting information using tool<br>3.process of testing the malware<\/p>\n\n\n\n<p>ps:<br>virus writer always observe their virus whether found in VT(VirusTotal), because VT have many virus sample<br>ps:<br>VT have most file sample database. if anomaly file hash is not in VT, it is anomaly.<\/p>\n\n\n\n<p><br>ps:<br><strong>Analysis by ssdeep<\/strong><br>\u8a08\u7b97fuzzy hashes\/piecewise hashes,\u7528\u4f86\u627e\u76f8\u4f3c\u7684\u6a94\u6848, \u53ef\u88ab\u7528\u4f86\u627e\u76f8\u4f3c\u7d50\u69cb\u7684\u60e1\u610f\u7a0b\u5f0f<br>ex:<br>ssdeep.exe -b bar.exe &gt; fuzzy_hash.txt<br>ssdeep.exe -bm fuzzy_hash.txt foo.exe<br>refer<br>http:\/\/ssdeep.sourceforge.net\/<\/p>\n\n\n\n<p><br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p><strong>Common static analysis tool:<\/strong><br>IDA Pro: disassembler and debugger tool(https:\/\/www.hex-rays.com)<br>PEstudio<br>preiscople.exe<br>resoucehacker<br>&#8230;omit&#8230;&nbsp;<\/p>\n\n\n\n<p><br><strong>tool:PEstudio<\/strong><br>function include below<br><strong>indicators<\/strong>: build-in rule for file behavior, if severity=1 is too much, that mean it is anomaly.<br><strong>virustotal<\/strong>: integrity VT, only submit hash, dont submit file<br><strong>file header<\/strong>: exe header<br><strong>sections<\/strong>: compare normal and anomaly program design,<br>ex: \u6b63\u5e38\u7684value of name = text,data ,rsrc<br>ex: when upx compress this file, value of name become UPX0, UPX1, UPX2<br>ex: if virtual size(size in memory) &gt; raw size(size on disk) mean the file should be changed by compression (in general situcation, both are same)<br>entry point: identify packing(\u52a0\u6bbc)<br>ps: how to know packing: find count of entry point in this file<br>Obfuscation: \u6df7\u78bc<br><strong>imported libraried<\/strong>: which api is call<br><strong>imported symbols<\/strong>: which symbol is call,<br>blacklisted is that virus often call,<br>anti-debug is a function that virus offten anti-virus, if it is too much, it is very anomacious<br>deprecated mean the fuction is ready end<br><strong>strings<\/strong>: it is like process exploerer<br>blacklist : is like above<br><strong>debug<\/strong>: look &#8220;file name&#8221;, it is source file ogrinally path of compile<br><strong>version<\/strong>: file description, like detail of windows prepority<br>ps:<br>color mean risk level<br>ps:<br>\u82e5exe\u7528\u5e95\u5c64api\uff0c\u6b64\u5de5\u5177\u6709\u5f88\u5927\u7684\u6a5f\u6703\u6703\u5c07\u6b64\u986f\u793a\u9ad8\u98a8\u96aa<br>ex: ipconfig\u6703\u4f7f\u7528\u5e95\u5c64api,\u6240\u4ee5\u6703\u88ab\u8a8d\u70ba\u662f\u9ad8\u98a8\u96aa<\/p>\n\n\n\n<p><strong><br>tool:preiscople&nbsp;<\/strong><br>output in text<br>you can look imported DLL<br>ex:<br>presicople.exe<\/p>\n\n\n\n<p><strong>tool:resoucehacker<\/strong><br>it is good to analysis GUI software<br>function include below:<br>text: some message in this file<br>cursor: mouse icon<br>dialog: operation interface<\/p>\n\n\n\n<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p><strong>Common dynamic analysis tool:<\/strong><br>OllyDbg:a 32-bit assembler level analysing debugger(http:\/\/www.ollydbg.de\/)<br>process monitor<br>snadbox tool: risk is that file is open to all world<br>Search for strings tool<br>&#8230;omit&#8230;&nbsp;<\/p>\n\n\n\n<p><strong>Search for strings tool<\/strong><br>binText: read dump fileand output in text<br>strings.exe: sysinternals tool, read dump file and output in text<\/p>\n\n\n\n<p><strong>Sandbox tool<\/strong><br>Online Sandbox<br>ex:<br>https:\/\/www.virustotal.com\/zh-tw\/<br>https:\/\/anubis.iseclab.org\/<br>https:\/\/malwr.com\/<br>Offline Sandbox<br>cuckoosandbox<br>Buster Sandbox Analyzer<br>..omit&#8230;<\/p>\n\n\n\n<p>&#8230;&nbsp;<\/p>\n\n\n\n<p><strong>tool: process monitor<\/strong><\/p>\n\n\n\n<p><strong>Observation all process<\/strong><br>1. pause by disable capture<br>2. observe all process<\/p>\n\n\n\n<p><strong>Observation one process<\/strong><br>1:configure filter: process name is &#8220;process&#8221;<br>2:run particular process<br>3: observe the particular process<br>ex:<br>1.configure filter: process name is &#8220;notepad.exe&#8221;<br>2.run notepad.exe<br>3.observe activity of notepad<\/p>\n\n\n\n<p><strong>Finding which process connect to specific IP<\/strong><br>1:configure filter: path contains &lt; ip &gt; , include<br>2:observe the particular IP using which process<\/p>\n\n\n\n<p>Obsevation recommendation:<br>1.look regsetvalue by find &#8220;regsetvalue&#8221;<br>(regsetvalue write something to regrity, why? because that is dagerous)<br>2.looke writefile by find &#8220;writefile&#8221;, then include writefile to only look writefile<br>3.look network to understand this exe connection ( only look tcp,udp)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PE(protable executable)4D5A is &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18],"tags":[],"class_list":["post-619","post","type-post","status-publish","format-standard","hentry","category-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}