봔하는 수달

[2022 RSA Conference 시리즈] Breaking Prometheus Ransomware Crypto Goes Wrong 본문

정보보안/동향

[2022 RSA Conference 시리즈] Breaking Prometheus Ransomware Crypto Goes Wrong

봔수달 2023. 1. 19. 10:47

2022년도 6월 우연한 기회로 해외연수의 기회가 주어졌다. 

 

결론부터 말하자면 학생으로서 본분의 일과 일정이 겹쳐서 대면으로 참석할 수 있는 기회는 포기했지만 정말 운이 좋게도 온라인 티켓으로 대체를 해주셔서 인상적으로 봤던 몇가지를 기록하고자 한다. 

오늘은 그 중 가장 인상깊었던 랜섬웨어의 암호 취약점을 통해 복호화하는 세션에 대해서 리뷰하고자한다.

 

개인 보고서는 공유 불가합니다!

https://www.youtube.com/watch?v=PlOjfpXWRyE 

Breaking Prometheus Ransomware Crypto Goes Wrong

 

Break Ransomware

해당 세션에서는 프로메테우스 랜섬웨어의 암호 취약점을 이용하여 랜섬웨어를 복호화하는 원리와 시연을 확인할 수 있었다. 최초 분석가는 랜섬웨어를 분석하고 간파하기 위해 아래와 같은 전략을 수립한다.

 

Identify source material
Ÿ public code re-use

Identify weaknesses

Ÿ Focus on the file encryption key and associated parameters

Think outside of the box

Ÿ Don’t try to get the private key

Ÿ Don’t try to brute force entire key space

client had a ransomware event

Ÿ Multiple ransomware binaries discovered across several machines

Ÿ Encrypted files and no good backups

File submitted for analysis

Ÿ Prometheus ransomware

 

위 내용은 기본적으로 특정 랜섬웨어뿐만 아닌 통상적인 랜섬웨어를 분석할 때에도 사용되는 방법론으로 RaaS의 랜섬웨어의 특징인 Public 코드에 대해서 재사용률이 높고 무리하게 개인 키와 전체 키 공간에서 무작위 대입 공격을 수행하는 행위는 지양하라는 말이 담겨있다.

 

Methodology about Analyzing Prometheus

해당 분석가는 다음과 같은 분석 스텝을 소개하였다.

First – Undertstand the ransomware behavior

가장 먼저 해당 랜섬웨어의 행위에 대해서 알아야한다. 그렇기에 샌드박스 환경 에서 수행을 하여 해당 랜섬웨어의 행위를 관찰한다.

Ÿ Run in analysis environment sandbox

Ÿ Observe behavior

Second – Determine “How” exactly Prometheus encrypts files

어떤 방식으로 프로메테우스가 파일을 암호화하는지 확인하기 위해 리버스 엔지

니어링을 통해 암호화 루틴을 분석하고 복구 가능 여부를 확인한다.

Ÿ Determine the encryption method

Ÿ Work backwards to dermine the inputs to the encryption algorithm and

whether we could recover them

 

분석을 통해 샘플 사이에서 변경되지 않은 하드코딩 되어있는 IV(Initial Vector)를 사용하는 부분을 확인한다.

해당 랜섬웨어에서의 키 생성 루틴은 C#에서 제공하는 Random 함수를 사용하였고 32비트 이하의 값을 이용함, 이를 통해 분석가는 해당 비트를 통해서 파일 암호화 키를 생성하는데 사용할 것이라고 추측.

 

그리하여 분석가는 Random 함수의 레퍼런스를 분석을 진행하여 다음과 같은 사실을 확인.
Ÿ Random() by default uses Environment. TickCount as the seed.
Ÿ Environment.TickCount is a 32-bit number representing the amount of
time since the system started

 

Remarks

해당 속성의 값은 시스템 타이머에서 파생되며 32비트 부호에 있는 정수로 저장됩니다. TickCount 속성은 시스템 타이머에서 파생되므로 일반적으로 10~16ms의 범위인 시스템 타이머의 해상도로 제한됩니다.

 

Predicting Environment.TickCount

Ÿ In order to guess the key, you need a place to start. This helps limit the

 

keyspace you need to brute force.

Ÿ Take the difference between the boot time and a file time stamp.

Ÿ If its less than INT_MAX, no further operations are required.

Ÿ Otherwise, obtain the offset from INT_MIN and add it to INT_MIN

 

Decryption Optimizations
Ÿ There are potential optimizations due to the seed being dependent on time.
Ÿ Files encrypted after another file will have a larger seed value.
Ÿ It is possible to sort files by last write time in order to not have to continuously recalculate the potentioal tic count and ensure that the estimates are more accurate.
Ÿ Seed values are relatively close to each other on each infected device.


암호에 사용되는 시드가 시간에 따라 달라지기 때문에 잠재적으로 최적화가있습니다. 이는 파일 이후에 암호화된 파일의 시드 값이 더 크다는 특성을갖고있고 이를 카운트하며 지속적으로 재 계산하기 위해  쓰기 시간별로 파일을 정렬하면 감염된 장치별 시드 값이 상대적으로 가깝다는 것을 확인 가능합니다.

 

Break once, then reapply

Ÿ Malware familes often reused code (even vulnerable code)

Ÿ Ransomware famileds have similar vulnerabilities.

Ÿ Some data is hard-coded

Ÿ Non-secure random number generators rely on the seed value entirely for randomness

Ÿ Applicable to other ransomware families and multiple programming languages

Ÿ C# Random, Java Random, C rand() etc ...

 

Ransomware Family Vulnerability
Prometheus Used C# Random to Generate Keys
AtomSilo Used time64() and rand() to generate keys
LockFile Used time64() and rand() to generate keys
Bandana Used C# Random to generate keys
Chaos Used C# Random to generate keys
PartyTicket (new) Default seed value of Golang's Math.Rand() - generated key is constant

악성코드의 경우 비슷한 유형의 코드 패턴을 가진 것 들을 패밀리라고 통칭한다.

이런 비슷한 코드들의 경우 보통 코드 재사용률이 높은데 코드에 취약점이 존재하더라도 재사용률이 상당히 높다. 이러한 취약점을 가진 랜섬웨어는 패밀리에서 유사한 취약점을 가지고 있습니다.

 

Example – Bandana Ransomware

Ÿ Like Prometheus, Bandana is Written in C#

Ÿ Uses AES-256 to Encrypt Files

Ÿ Added a new layer – RFC2898DeriveBytes class

Ÿ In order to the obtain key, we need the “password” passed to the function RFC2898DeriveBytes()

    Ÿ Luckily “password” is generated by C#’s Random() and SHA256 hashed

Ÿ SHA256 Hash the results of the potential “password”

Ÿ Pass the “password” to RFC2898DeriveBytes

    Ÿ Get the “Key” and “IV”

Ÿ Files are encrypted with AES-256-CBC using PKCS7 padding

Ÿ Decrypt file data and attempt to match to known plaintext value

Ÿ Key Difference

    Ÿ Only one encryption key is used to encrypt all files

    Ÿ Decrypting file data and attempt to match to known plaintext value

    Ÿ Allows for guaranteed decryption, if at least one file encrypted on the system has known content

 

Example: Chaos Ransomware

Ÿ Chaos ransomware is also like Prometheus

    Ÿ Hardcoded salt (1, 2, 3, 4, 5, 6, 7, 8)

    Ÿ RFC2898DeriveBytes, with Random() generated password

    Ÿ AES-256-CBC encryption

    Ÿ Main difference is the File format:

        Ÿ “<EncryptedKey>” + <RSA encrypted RFC2898DeriveBytes password> + “<EncryptedKey>” + <Encrypted Data>
 

Investigate Creating a Decryptor Framework

Ÿ To create a decryptor that exploits key generation weaknesses:

    Ÿ Determine the encrypted file format

    Ÿ Extract the encrypted data - remove any junk

    Ÿ Determine the encryption algorithm

Ÿ Determine success

Ÿ Some areas of the ransomware samples will require deeper analysis 

 

Determine the Encrypted File Format

Ÿ Requires detailed analysis

Ÿ Usually consists of two parts:

    Ÿ Encrypted data

    Ÿ Symmetic(대칭) Key and IV

        Ÿ Encrypted with an asymmetric algorithm

 

Failures & Lessons learned

Ÿ 다양한 랜섬웨어 암호화 로직에서 해독기는 고정된 단일 크기로 접근하는 방식은 사용이 불가능하다.

Ÿ 키 취약점이 존재하더라도 암호화된 파일과 암호화 이전 파일을 갖고 있지 않은 경우에는 해독할 수 없다.

Ÿ Prometheus를 사용하면 암호화된 키가 파일에 추가됩니다. 그러나 해당 키는 OAEP 패딩으로 암호화되므로 파일의 암호화된 키를 암호화된 추측키와 비교할 수 없다.

Ÿ 새로운 버전의 유사한 랜섬웨어는 우리가 암호화를 깨더라도 수정한 버전으로 다시 출시 될 것이다.

Ÿ Framwork development and research is on-going.

 

 

 

Comments