pseudorandom algorithms
play

Pseudorandom Algorithms Derek Soeder Christopher Abad - PowerPoint PPT Presentation

Black-Box Assessment of Pseudorandom Algorithms Derek Soeder Christopher Abad Gabriel Acevedo dsoeder@cylance.com cabad@cylance.com gacevedo@cylance.com Agenda About PRNGs PRNGs by Example Attack Methodology


  1. Black-Box Assessment of Pseudorandom Algorithms Derek Soeder Christopher Abad Gabriel Acevedo dsoeder@cylance.com cabad@cylance.com gacevedo@cylance.com

  2. Agenda • About PRNGs • PRNGs by Example • Attack Methodology • The Tool: Prangster • Demonstration

  3. Who we are Advanced Threat Protection ∙ Incident Response ∙ Special Projects ∙ Research Christopher Abad, Gabriel Acevedo, Derek Soeder Cylance Labs Division, Cylance, Inc. “The Science of Security”

  4. About PRNGs

  5. About PRNGs • Pseudorandom number generator • Deterministic, appears unpredictable • Designed for simplicity and performance • Not secure • Cryptographically secure random number generator (CSRNG) • Accumulates entropy • Designed for security

  6. About PRNGs Entropy Application Entropy Output source Seed Pseudorandom PRNG numbers State

  7. About PRNGs Seed State • Derived from “entropy” or • Internal state of PRNG supplied by application • Transformed for each • Initial internal state is pseudorandom number derived from it generated Some states might not map to a seed

  8. About PRNGs • Consuming pseudorandom numbers • Modular (“take -from- bottom”) • Multiplicative (“take -from- top”)

  9. About PRNGs • Modular (take-from-bottom) % Modulus % Limit % Output modulus / Discard divisor

  10. About PRNGs • Multiplicative (take-from-top) % Modulus ∙ Limit / Output divisor / Discard divisor

  11. About PRNGs Ordinal value Symbol • Pseudorandom number • One unit of pseudorandom from PRNG, processed by application output, usually a application byte or character • Used to select a symbol for • Mapping from numbers to pseudorandom output symbols is the “alphabet” • Size of alphabet = “limit”

  12. About PRNGs • Alphabet • Decided by application • Pseudorandom numbers to symbols via alphabet is a generalized but common pattern • Example: • abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!@#$%^&*&*()-+_= • ‘ a ’ = 0, ‘ Z ’ = 51, ‘ * ’ = 69 or 71, ‘ = ’ = 77, etc.

  13. PRNGs by Example

  14. PRNGs by Example • Linear congruential generator (LCG) • Array-based • Miscellaneous

  15. PRNGs by Example • Linear congruential generator (LCG) • Next state: s i = (A ∙ s i-1 + C) % M • Output: x i = (s i / D) % R • A = multiplier C = increment M = modulus D = discard divisor R = output modulus (RAND_MAX + 1)

  16. PRNGs by Example • LCG examples: PRNG A C M D R MSVCRT 2 32 2 16 2 15 214013 2531011 2 16 2 32 Java 2 48 0x5DEECE66D 11 2 17 2 31 BSD libc 16807 0 2147483647 1 2147483647 VBScript 2 24 2 24 0xFD43FD 0xC39EC3 1 1.000 000 40014 0 2147483563 MSSQL/PHP 012 324 2147483563 40692 0 2147483399 788 164

  17. PRNGs by Example • Array-based • Array of N integers modulo M • Two indices with a fixed separation • a k = (a k ± a k+Sep ) % M a k+Sep = (a k+Sep ± a k ) % M • At most M N possible states, > possible seeds

  18. PRNGs by Example • Array-based examples: PRNG N Sep Index ± M D Operation .NET 55 21 +1 2147483647 1 a k = (a k - a k+Sep ) % M 2 32 glibc (3) 31 3 +1 2 a k+Sep = (a k + a k+Sep ) % M x = rotr(a k , 13) + a k+Sep 17 2 32 PureBasic 10 -1 1 a k = rotr(b k , 5) + b k+Sep 17 b k = x

  19. PRNGs by Example • Array-based exhibit recurrence relations • .NET: x i+55 = x i - x i+21 + error • glibc (3): x i+31 = x i + x i+28 + error • Error • Caused by interactions of “hidden” state • Stymies prediction • Can actually be useful

  20. PRNGs by Example • Miscellaneous • Google V8: “multiply -with- carry” • Next state: s i = 18273 ∙ (s i-1 % 2 16 ) + (s i-1 / 2 16 ) t i = 36969 ∙ (t i-1 % 2 16 ) + (t i-1 / 2 16 ) • Output: x i = (2 14 ∙ ( s i % 2 18 ) + (t i % 2 18 )) / 2 32 • Perl: uses platform’s libc rand() / (RAND_MAX + 1)

  21. Attack Methodology

  22. Attack Methodology • Identify pseudorandom output • Collect samples • Isolate truly pseudorandom portion • Determine complete alphabet • Detect biases if possible

  23. Attack Methodology • Recover seed from output • Guess PRNG if not known • Guess alphabet • Usually the most obvious arrangement • Use biases/error if available • Exploit • Forward/reverse prediction • Recover entropy

  24. The Tool: Prangster

  25. The Tool: Prangster • Why? • Functions • {Output, alphabet}  Seed(s) • {Seed, alphabet}  Next/previous output • {Seed, ± n}  Seed for n th next/previous state

  26. The Tool: Prangster • Benchmarks ABCDEFGHIJKLMNOP ABCDEFGH ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNO PRNG Full naive brute-force from A..Z from A..Z P from A..Z BSD libc 26 seconds 1 second 1 second 1 second Java 96 days 20 minutes 2 seconds < 1 second MSVCRT 63 seconds < 1 second < 1 second 1 < second 19,856 years 145 seconds V8 < 1 second < 1 second 1 < second (Full state) (Half state)

  27. Demonstration

  28. Questions?

  29. Thank you! Derek Soeder Christopher Abad Gabriel Acevedo dsoeder@cylance.com cabad@cylance.com gacevedo@cylance.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend