[IT-Security-2] 惡意軟體 Malware

 Malware 


Notes from RWTH Aachen University course 
“IT security 2” Wintersemester 2019/20
professor: Meyer, Ulrike Michaela

:cactus:What is malware?

  • Malware = Malicious Software
    “A program that is inserted into a system, usually covertly(偷偷的), with the intent of compromising the confidentiality, integrity or availability of the victim’s data, applications, or operating system or otherwise annoying or disrupting the victim”

    不包含巧合

:cactus: Motivation to write malware

  • 實驗、測試、取得名聲
  • 對抗官方、犯罪、對抗防毒軟體
  • 直接金錢利益(販賣商品)、間接金錢利益(取得別人商業機密)

:cactus: Classic classification

Trojan horse

  • :droplet: 定義:一個程式具有overt(明顯的)目的及covert(隱藏的)目的
  • 範例:攻擊者儲存一個指令叫ls
    使用者知道他的overt目的是列出檔案
    但covert目的是攻擊者存取的shell script內容
  • :droplet: 傳播:使用者通常是inadvertently(不經意) 的安裝
    例如:防毒軟體、source repositories、第三方套件、A片縮圖
  • :droplet: Ken Thompson’s C Compiler Hack
    1. 編寫self-reproducing(自我繁殖)程式片段
    2. 修改compiler
      若遇到login則插入一backdoor
      有此backdoor後所有的login都可接受實際密碼或fixed master password
    3. 再修改compiler,如果之後要compile新的compiler則植入backdoor
    4. 刪掉修改過的版本,替換成原本的compiler的code

     


    即使有可驗證的軟體,還是有可能有Trojan
    檢查Open source code還是無法解決Trojan

Viruses

  • :droplet: 定義:Software fragment 附在 executable 上,Virus 可以自我複製或傳遞給沒有被感染過的 executable
    若程式執行才開始執行 Virus (程式停止即停止)
    必須有人執行最一開始的 virus
  • :droplet: 如何傳播
    感染:modifying file
    modifying file:植入 virus code
    exchange infected programs/files也會造成其他裝置感染(ex. USB)

    Viruses是不是Trojen?
    :white_check_mark: Overt: 感染程式執行 Covert: 病毒行為
    :negative_squared_cross_mark: Overt: 病毒行為 Covert: 無

  • :droplet: Parts of a Virus
    • Infection mechanism (infection vector) 可以繁殖
    • Trigger 一個事件或狀態決定payload是否activated或delivered
    • Payload Virus的行為,破壞或是良性提醒
  • :droplet: Typical Phases in the Lifetime of a Virus
    • Dormant(休眠) phase
    • Propagation phase 複製自己,或是植入突變(mutation)
    • Triggering (activating) phase 被trigger(數量或時間到了)
    • Execution phase 執行function(payload)
  • :droplet: Types of viruses by target
    • Boot sector infector
    • File infector / Executable infector

      • Executable infector: 增加executable的長度
      • 容易偵測
      • 有更精巧的方式藏virus(複寫、壓縮)

    • Macro virus (較大的程式(Macro)或scripting code = application)
      • Macro: 被寫在scripting language中跟application一起被生成
      • Macro virus: 被application識別(ex. word, excel)
      • platform independent
      • 隨檔案被傳輸,virus擴散
    • Multipartite virus (多種方式感染file:感染不同type的file)
  • :droplet: Classification by Concealment Strategy
    • Encrypted virus

      • 除了解密程式之外其他都被加密(還有解密的key)
      • 偵測不易

    • Polymorphic(多態的) Viruses

      • insert到不同的program時變成不同的virus,但功能相同
      • 預防signature detection
      • 加密virus body用不同的key

    anti-virus:
    檢查signature
    檢查code: Polymorphic viruses 常用 decryption loops
    integrity檢查
    模擬CPU執行很多次(因為decrypt多次),直到opcode符合已知的virus body

    • Metamorphic(變質) Viruses
      • 變異virus body本身
      • Virus自帶原本source code且重編譯自身
      • 通常是 macro 或 script virus (macros/scripts通常是被 interpreted 而不是 compiled)

:cactus: Obfuscation and Anti-Debugging

  • :droplet:目的:避免被分析code或被signature detection檢查出virus
    • 插入garbage opcodes
    • 不同的code執行相同的功能
    • packed binaries
  • 偵測debugger及virtual machine,終止執行
  • 相同code,不同register名/不同subroutine order(n 個subroutines, n! 個變異)
  • 用instructions解密instructions
  • Zperm變異: 用jump變更code順序
  • Zmist (code integration): virus聚集成一個instruction flow,再用jump隨機到program的位址執行

:cactus: Worms

  • 利用軟體漏洞(software vunerabilities)傳播
  • :droplet:定義:a program actively(積極的) seeks machine to infect
  • 被感染的machine被用來作automated launching pad,再感染別人
  • 用軟體漏洞取得授權
  • 經網路、shared media(USB,DVD…)
  • :droplet:複製方式:
    • email: 自動傳送worm email,若點開email或附件則執行code
    • file sharing: 生成copy file,用USB等傳輸
    • remote execution: 若有網路漏洞
    • remote file access/transfer
  • :droplet:Phases in the Lifetime: (跟virus比較)
    • 跟virus相同:dormant, propagation(尋找適合感染的裝置), triggering, execution
  • :droplet:Target Discovery(尋找目標):
    • Scanning: 若worm在遠端網路被傳播,則此系統被認為是在vulnerable service中
    • address(地址) scanning stragegies:
      • random: 產生random IP address,容易被偵測因為大量traffic產生
      • Hit-list: compile list of candidate targets且感染,提供感染的machine此list
      • Topological: 用其他machine的information
      • Local subnet: host behind a firewall 試著感染同個subnet的host

:cactus: Ransomware

  • WannaCry2.0 (2017)
  • 利用Windows版本的漏洞
  • WannaCry解密 (2017)
    • 產生RSA公鑰/私鑰
    • 將私鑰傳給control server後刪掉
    • 但沒有刪除 Prime numbers
    • 若電腦沒有被 rebooted 則可用 prime numbers 由 public key 復原 private key

:cactus: Malware classification by payload

  • :droplet:System Corruption:
    • Data Destruction: 刪除data
    • Ransomware: 要求贖金
    • Physical-World Damage: 改寫BOIS使電腦無法開機
    • Logic Bomb: 觸發惡意功能
  • :droplet:Information Theft:
    • Keyloggers and spyware(取得key、螢幕截圖、麥克風、鏡頭)
    • Phishing and identity theft(Phishing或SPAM)
    • Reconnaissance(偵查), Espionage(間諜) and data exfiltration(滲出)(取得機密資訊)
  • :droplet:Stealthing – Backdoors and Rootkits:
    • Backdoor: secret entry point
    • Rootkits: 偷偷被安裝在系統中的program,有root權限

:cactus: Rootkits

  • 定義: 主要性質 Stealthiness(隱蔽性)
  • :droplet:感染途徑:
    • 偷取密碼或字典攻擊
    • buffer overflow攻擊vulnerable的program取得root權限
    • 下載rootkits並安裝
  • :droplet:分類:
    • Persistent: 系統執行時就啟動(在registry或file system中)
    • Memory based: reboot後會消失
    • User mode: Intercepts(攔截) API calls且修改return值
    • Kernel mode: 攔截API
    • Virtual machine based: 安裝VM monitor

:cactus: Terminology

  • Advanced Persistent Threat (APT): Sophisticated malware directed at specific business or political targets applied persistently and effectively(被企業或政府主導的長期malware)
  • Attack kit: Set of tools for generating malware, including propagation and payload mechanisms(生成malware的工具)
  • Auto-rooter: Malicious hacking tool used to remotely break into machines(遠端駭客軟體)
  • Flooder (DoS engine): Generates large volume of data, e.g. to carry out denial of service attack(大量資料攻擊)
  • Key logger: Captures keystrokes on the infected system(取得鑰匙圈)
  • Trojan horse: Appears to be useful but also has a secondary malicious purpose (有第二目的)
  • Bot (Zombie): Activated on an infected machine to gain remote control to launch attacks on other machines (在感染的機器上行動取得遠端控制,再影響其他機器)
Readings
Charles and Shari Pfleeger, Jonathan Marguites: Security in Computing, 2014 
    § Chapter 3.2: Malicious code
Stallings and Brown: Computer Security, 2015 
    § Chapter 6 on malicious software
Matt Bishop: Introduction to Computer Security, 2004 
    § Chapter 19: Malicious Logic
Further Reading
Jon Erickson: Hacking – The art of Exploitation, 2007
    § Chapter 3: Exploitation
Exploit data bases
    § bugtraq 
    § US-CERT
§ Ken Thompson: Reflections on Trusting Trust, 1984
§ Peter Capek et al: Marry Christmas – An Early Network Worm, 2003
§ Felix Leder, Tillmann Werner: Know Your Enemy: Containing Conficker – To Tame a Malware, 2009
§ P. Porras et al: An analysis of conficker’s logic and rendezvous protocol, 2009

留言

這個網誌中的熱門文章