Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an...

34
Jeroen van Beek 1

Transcript of Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an...

Page 1: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Jeroen van Beek

1

Page 2: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

2

Page 3: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Inadequate OS and application security:◦ Data abuse Stolen information

◦ Bandwidth abuse (botnets) Host illegal media

DDoS

◦ Legal issues White house hacked

with on of your IPs

◦ You are responsible!

3

Page 4: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

4

Page 5: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest
Page 6: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Many application protect sensitive information◦ In the end protected by an authentication token Today mostly account + password

A chain is as strong as it’s weakest link◦ Default passwords◦ Password reset procedures

Some real-life examples

6

Page 7: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

7

Just a cheap internet router

Page 8: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Just a global ERPsoftware vendor

8

Page 9: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Just a global network equipment vendor

9

Page 10: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Just a nuclearmissle

10

Page 11: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

loenix:/tmp# cat pass.c

#include <iostream>

#include <string>

using namespace std;

int main ()

{

string secret = "reAlly_c0mpl3x_Passw0rd!", user = "";

cout << "Please enter the password: ";

cin >> user;

if(secret.compare(user) != 0)

cout << "wrong password\n";

else

cout << "welcome!\n";

return 0;

}

loenix:/tmp# g++ pass.c -o pass

loenix:/tmp# strings pass

/lib/ld-linux.so.2

..

..

[^_]

reAlly_c0mpl3x_Passw0rd!

Please enter the password:

wrong password

welcome!

11

Page 12: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Detection:◦ Compile a list of default passwords of all applications◦ Put the list in your IDS◦ Lots of false positives (e.g. web page containing

example /etc/shadow), false negatives (e.g. encryption)

Prevention:◦ Perform source code reviews (if possible)◦ Use application baseline standards https://benchmarks.cisecurity.org/

12

Page 13: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

One of the most abused software flaws Caused by improper bounds checking◦ Writing >n or more bytes to a n bytes buffer

Typically a C / C++ problem In many cases exploitable Overwrite memory◦ Overwrite stack / heap with jump to malicious code

Create account Open shell …

13

Page 14: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

bofh@tunnel:~/ot$ cat overflow.c

#include <iostream>

using namespace std;

int main ()

{

char c[12]; // 11 characters + 0x00

cout << "What would you like me to echo? ";

cin >> c;

cout << "You said: " << c << "\n";

return 0;

}

bofh@tunnel:~/ot$ ./overflow

What would you like me to echo? hello

You said: hello

bofh@tunnel:~/ot$ ./overflow

What would you like me to echo? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

You said: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Segmentation fault

bofh@tunnel:~/ot$

14

Page 15: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

15

Page 16: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Detection (more or less):◦ Static source code analysis◦ Fuzzing

Prevention (more or less):◦ Programming language: Try to avoid C and C++ for security-critical applications If possible…

◦ Use trusted secure libraries (and keep them up-to-date!): A vulnerable library might also affect your safe code!

◦ ASLR◦ NX◦ Use secure coding standards http://www.securecoding.cert.org/

16

Page 17: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Address Space Layout Randomization Buffer overflows are exploited by shell code◦ Shell code typically uses system calls◦ System calls, stack, heap, libraries are located on fixed positions◦ ASLR places them at random locations◦ Shell code calls wrong addresses

Crash (== secure)

Enabled on recent OSs in some form:◦ Windows: Vista+: full ASLR by default◦ Linux: 2.6+: weak ASLR by default, distro specific◦ OS X 10.8+: full ASLR by default

Creating a reliable exploit is more difficult◦ Not impossible!

17

Page 18: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

ASLR needs to be used to be effective◦ Example for Linux: OS + apache2 + mysql + php5

+sshd (PIE = Position Independant Executable)

Similar for other Oss OT project?

18

Page 19: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

No eXecute Buffer overflows are exploited by shell code◦ Shell code often executes code in data memory◦ NX prevent execution of code from data memory

Shell code is not executed

Enabled on recent OSs in some form:◦ Windows: XP SP2+: DEP by default◦ Linux 2.6+: depend on distribution and version◦ OS X 10.5+: W^X on stack and heap by default

Creating a reliable exploit is more difficult◦ Not impossible!

19

Page 20: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Write random value before stack return pointer Check value on return Buffer overflow exploit overwrites value alert Creating a reliable exploit is more difficult◦ Not impossible!

20

Page 21: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest
Page 22: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

In many cases authentication mechanisms are:◦ Closed source◦ Based on proprietary protocols◦ Backward compatible with older versions◦ Not using key / hash diversification◦ Poorly tested

Important risks:◦ Authentication bypass◦ Reduced key entropy Decode / crack complex passwords

22

Page 23: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest
Page 24: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Well-known example: MS LanManager (LM):◦ Really 0ldskewl: OS/2 & MS-DOS era◦ Enabled by default until Windows Vista For all passwords < 15 positions Backward compatibility What’s the problem?

24

Page 25: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Password complexity:◦ Character set ^ length◦ 14 position password using [a-z][A-Z][0-9] 62 ^ 14 = 12.401.769.434.657.526 giga combinations Brute force cracking takes… forever

LAN manager◦ 14 position password using [A-Z][0-9]◦ Divides the password in two 7 position parts◦ Uppercase only 36 ^ 7 = 78 gig combinations Brute force cracking takes… hours

25

Page 26: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

If a password hash is the same on every system, you can pre-calculate hashes◦ Large look-up table

The art is perfected: rainbow tables◦ Time versus storage trade-off◦ http://lasecwww.epfl.ch/pub/lasec/doc/Oech03.pdf

Crack complex passwords within minutes◦ Free tables for LM, NTLM, MD5, SHA-1, …

GPU based cracking◦ https://hashcat.net/

26

Page 27: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Detection:◦ Detect known downgrade attacks◦ Besides that quite difficult…

Prevention:◦ Review the used algorithms before using them If possible… Use proven open standards

◦ Use salting Do not use: hash(password) Instead use: random + hash(password + random) Attack time will grow (depending on number of salts used) Generic rainbow tables won’t work anymore

27

Page 28: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Program flow manipulation: Skip / manipulate checks:◦ Games◦ Password checks◦ Bank transfer integrity checks◦ …

Static: Change the file on disk

E.g. IDA Pro http://www.hex-rays.com/idapro/

Dynamic: Don’t change the file on disk

Change program flow in run-time

E.g. OllyDbg http://www.ollydbg.de/

28

Page 29: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Attacks on SWIFT environments http://baesystemsai.blogspot.nl/2016/04/tw

o-bytes-to-951m.html

29

Page 30: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Example bypassing a security check◦ In then end it’s just a 0 or a 1… In this case: Boolean expression Let’s swap yes and no!

◦ OllyDbg

30

Page 31: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

Detection:◦ Static analysis: none?◦ Dynamic analysis: check for debuggers Cat and mouse game

◦ Application ‘patches’ (cracks, backdoors, …): Application whitelisting: verify checksums: Windows AppLocker, SELinux

Look for changes (good or bad): https://github.com/Tripwire/tripwire-open-source

Prevention:◦ Application signing◦ Obfuscate / encrypt the application code Only slows an attacker down!

31

Page 32: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

32

Page 33: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest
Page 34: Jeroen van Beek - OS3Many application protect sensitive information In the end protected by an authentication token Today mostly account + password A chain is as strong as it’s weakest

J.C.vanBeek uva.nl

34