Slide 1

Slide 1 text

Ruby, Ransomware and Cryptosystem

Slide 2

Slide 2 text

hello! I am 吳宗育 You can find me at [email protected] https://github.com/zongyuwu/RansomRB

Slide 3

Slide 3 text

About me ✘ Software Engineer/Researcher in Trend Micro ✘ Interested in: Cryptography, Malware, Network Security

Slide 4

Slide 4 text

Agenda ✘ What is ransomware? ✘ Build our own ransomware using Ruby ✘ Discuss how we use cryptosystem

Slide 5

Slide 5 text

What is Ransomware?

Slide 6

Slide 6 text

What is Ransomware ✘ Ransomware is a kind of malicious software (or virus) ✘ Malicious software will Show off Steal things Control things… ✘ In addition, Ransomware also.. Lock the data/system and ask for ransom

Slide 7

Slide 7 text

Ransomware Samples Bromium, Understanding Crypto-Ransomware In-Depth Analysis of the Most Popular Malware Families, https://www.bromium.com/sites/default/files/bromium-report-ransomware.pdf L. Abrams, Jigsaw Ransomware Decrypted: Will delete your files until you pay the Ransom, http://www.bleepingcomputer.com/news/security/jigsaw-ransomware-decrypted-will-delete-your-files-until-you-pay-the- ransom/

Slide 8

Slide 8 text

TrendLabs, The Reign of Ransomware, http://www.trendmicro.com/cloud-content/us/pdfs/security-intelligence/reports/rpt-the-reign-of-ransomware.pdf

Slide 9

Slide 9 text

TrendLabs, The Reign of Ransomware, http://www.trendmicro.com/cloud-content/us/pdfs/security-intelligence/reports/rpt-the-reign-of-ransomware.pdf

Slide 10

Slide 10 text

TrendLabs, The Reign of Ransomware, http://www.trendmicro.com/cloud-content/us/pdfs/security-intelligence/reports/rpt-the-reign-of-ransomware.pdf

Slide 11

Slide 11 text

Why is Ransomware so Popular? Growth of Data Crypto Currency Ransomware

Slide 12

Slide 12 text

Build Our Own Ransomware ✘ Our goal is to discuss how to securely use cryptosystem ✘ Cryptosystem is the core of ransomware  Build our own ransomware to learn how to use cryptosystem

Slide 13

Slide 13 text

Introduction to Cryptosystem

Slide 14

Slide 14 text

Symmetric Cipher ✘ Advantage Fast ✘ Limitation Pre-share the key SSL2Buy, Symmetric vs. Asymmetric Encryption – What are differences? https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-encryption-what-are-differences/

Slide 15

Slide 15 text

Asymmetric Cipher ✘ Advantage Open encryption ✘ Limitation Slow SSL2Buy, Symmetric vs. Asymmetric Encryption – What are differences? https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-encryption-what-are-differences/

Slide 16

Slide 16 text

Asyemmtric Ciphers in Ruby OpenSSL::PKey::DH OpenSSL::PKey::DSA OpenSSL::PKey::EC OpenSSL::PKey::RSA

Slide 17

Slide 17 text

When We Visit a Website

Slide 18

Slide 18 text

Build Our Ransomware?

Slide 19

Slide 19 text

Functionalities ✘ Encrypt the data of victims ✘ Decrypt the data after victims pay the ransome

Slide 20

Slide 20 text

Functionalities 1 ✘ How to encrypt the data of victims Symmetric? Advantage: Fast Limitation: Pre-share key Asymmetric? Advatage: Open encryption Limitation: Slow

Slide 21

Slide 21 text

Ciphers in Ruby 2.3.1 :002 > require 'openssl' 2.3.1 :003 > puts OpenSSL::Cipher.ciphers AES-128-CBC AES-128-CBC-HMAC-SHA1 AES-128-CFB ... ✘ Provide AES, DES, RC4, RC5, CAMELLIA, BlowFish, … Ruby OpenSSL::Cipher, http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/Cipher.html Ruby openssl source code, https://github.com/ruby/openssl/blob/master/lib/openssl/cipher.rb

Slide 22

Slide 22 text

Which Cipehr Should We Use? RC4 ✘ SSL and WEP early version standard ✘ Prohibited by IETF, Mozilla Firefox ✘ Should NOT be used DES ✘ 1976 FIPS standard ✘ Dispute : S-Box Backdoor ✘ Key length too short ✘ Should NOT be used AES ✘ Current SSL and FIPS standard A. Popov, Prohibiting RC4 Cipher Suites, https://tools.ietf.org/html/rfc7465 A. King, Deprecating the RC4 Cipher, https://blog.mozilla.org/security/2015/09/11/deprecating-the-rc4-cipher/ S. Kumar et al., How to Break DES for BC 8,980, http://www.copacobana.org/paper/copacobana_SHARCS2006.pdf Transport Layer Security, https://en.wikipedia.org/wiki/Transport_Layer_Security#Cipher E. Rescorla, The Transport Layer Security (TLS) Protocol Version 1.3, https://tools.ietf.org/html/draft-ietf-tls-tls13-11

Slide 23

Slide 23 text

Encrypting Data Using AES

Slide 24

Slide 24 text

Encrypting Data Using AES

Slide 25

Slide 25 text

✘ Encrypt the data of victims ✘ Decrypt the data after victims pay the ransome Functionalities

Slide 26

Slide 26 text

Functionalities 2 Decrypt the data Hard Coded ✘ Hard coded the key ✘ Use the key to decrypt ✘ Insecure Send key to Server ✘ Better ✘ Need Network Encrypt the key A by some other key B? ✘ Key(AES) to encrypt data ✘ Key(PKey) to encrypt Key(AES)

Slide 27

Slide 27 text

Functionalities 2 Decrypt the data ✘ How to encrypt key without pre-share key? Symmetric? Advantage: Fast Limitation: Pre-share key Asymmetric? Advatage: Open encryption Limitation: Slow

Slide 28

Slide 28 text

Asymmetric Cipher ✘ Advantage Open encryption ✘ Limitation Slow SSL2Buy, Symmetric vs. Asymmetric Encryption – What are differences? https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-encryption-what-are-differences/

Slide 29

Slide 29 text

✘ Hard code PKey in our ransomware ✘ Generate AESKey to encrypt data in victim’s host ✘ Use PKey to encrypt AESKey ✘ Only Private key can decrypt AESKey Asymmetric Cipher

Slide 30

Slide 30 text

✘ Hard code PKey in our ransomware ✘ Generate AESKey to encrypt data in victim’s host ✘ Use PKey to encrypt AESKey ✘ Only Private key can decrypt AESKey Asymmetric Cipher

Slide 31

Slide 31 text

Asymmetric Cipher RSA Elliptic Curve

Slide 32

Slide 32 text

Using RSA

Slide 33

Slide 33 text

N: Modulus e: encrypt exponent d: decrypt exponent p: prime p q: prime q RSA Parameters Public Private

Slide 34

Slide 34 text

✘ RSA is based on Large integer factorization problem ✘ Key length (N length) should >= 2048 (bits) ✘ Stop using RSA-512 right now ✘ RSA-1024 is vulnerable to super computation resource Using RSA Safely • Z. Wu et al., A Study on The Misuse of RSA in the Field, 2016 • L. Valentaet al., Factoring as a Service, in Financial Cryptography and Data Security,Barbados, 2016

Slide 35

Slide 35 text

Generate RSA

Slide 36

Slide 36 text

✘ Using 3 or 65537 (default) for encrypt expoent (e) ✘ Generate RSA key only in high entropy enviroment Using RSA Safely • Z. Wu et al., A Study on The Misuse of RSA in the Field, 2016 • S. Yileket al., When private keys are public: results from the 2008 DebianOpenSSLvulnerability, in ACM IMC, 2009 • Debian OpenSSL Predictable PRNG, https://github.com/g0tmi1k/debian-ssh • N. Heninger et al., Mining Your Ps and Qs: Detection of Widespread Weak Keys in Network Devices, in USENIX, 2012 • A. Everspaugh et al., Not-So-Random Numbers in Virtualized Linux and the Whirlwind RNG View Document, IEEE S&P, 2014 • L. Valentaet al., Factoring as a Service, in Financial Cryptography and Data Security, 2016 • D. Boneh, Twenty Years of Attacks on the RSA Cryptosystem, Notices of the AMS, 1999

Slide 37

Slide 37 text

Encrypt AESKey By RSA

Slide 38

Slide 38 text

✘ Send AESKey.enc and AESIV.enc to server ✘ Server decrypt them and send back to client ✘ Use AESKey and AESIV to decrypt data Decrypt

Slide 39

Slide 39 text

thanks! Any questions? You can find me at [email protected]

Slide 40

Slide 40 text

Reference 1. Bromium, Understanding Crypto-Ransomware In-Depth Analysis of the Most Popular Malware Families, https://www.bromium.com/sites/default/files/bromium-report-ransomware.pdf 2. L. Abrams, Jigsaw Ransomware Decrypted: Will delete your files until you pay the Ransom, http://www.bleepingcomputer.com/news/security/jigsaw-ransomware-decrypted-will-delete-your-files-until-you- pay-the-ransom/ 3. TrendLabs, The Reign of Ransomware, http://www.trendmicro.com/cloud-content/us/pdfs/security- intelligence/reports/rpt-the-reign-of-ransomware.pdf 4. SSL2Buy, Symmetric vs. Asymmetric Encryption – What are differences? , https://www.ssl2buy.com/wiki/symmetric- vs-asymmetric-encryption-what-are-differences/ 5. Ruby OpenSSL::Cipher, http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/Cipher.html 6. Ruby openssl source code, https://github.com/ruby/openssl/blob/master/lib/openssl/cipher.rb 7. A. Popov, Prohibiting RC4 Cipher Suites, https://tools.ietf.org/html/rfc7465 8. A. King, Deprecating the RC4 Cipher, https://blog.mozilla.org/security/2015/09/11/deprecating-the-rc4-cipher/ 9. S. Kumar et al., How to Break DES for BC 8,980, http://www.copacobana.org/paper/copacobana_SHARCS2006.pdf 10. Transport Layer Security, https://en.wikipedia.org/wiki/Transport_Layer_Security#Cipher 11. E. Rescorla, The Transport Layer Security (TLS) Protocol Version 1.3, https://tools.ietf.org/html/draft-ietf-tls-tls13-11 12. Z. Wu et al., A Study on The Misuse of RSA in the Field

Slide 41

Slide 41 text

Reference 13. L. Valentaet al., Factoring as a Service, in Financial Cryptography and Data Security,Barbados, 2016 14. S. Yileket al., When private keys are public: results from the 2008 DebianOpenSSLvulnerability, in ACM IMC, 2009 15. Debian OpenSSL Predictable PRNG, https://github.com/g0tmi1k/debian-ssh 16. N. Heninger et al., Mining Your Ps and Qs: Detection of Widespread Weak Keys in Network Devices, in USENIX, 2012 17. A. Everspaugh et al., Not-So-Random Numbers in Virtualized Linux and the Whirlwind RNG View Document, IEEE S&P, 2014 18. L. Valentaet al., Factoring as a Service, in Financial Cryptography and Data Security, 2016 19. D. Boneh, Twenty Years of Attacks on the RSA Cryptosystem, Notices of the AMS, 1999 20. Dual EC DRBG 後門事件的歷史發展摘要及雜記, http://ckhung0.blogspot.tw/2014/03/dual-ec-drbg.html 21. J. B. Bos, Selecting Elliptic Curves for Cryptography: An Efficiency and Security Analysis, Selecting Elliptic Curves for Cryptography