hiding for persistance - backdooring linux systems

33
Hiding for Persistence - Backdooring Linux Systems

Upload: christiaan-ottow

Post on 13-Apr-2017

134 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Hiding for Persistance - Backdooring Linux Systems

Hiding for Persistence - Backdooring Linux Systems

Page 2: Hiding for Persistance - Backdooring Linux Systems

Key messages

• They’re out to get you

• Kernel backdoors are hard to find

• However, most attackers are not so

motivated or well equipped

• There is a lot you can do

Page 3: Hiding for Persistance - Backdooring Linux Systems

Hi

Christiaan Ottow

• Developer, Sysop, Hacker

• Security Coach @ Computest / Pine Digital Security

[email protected]

• @cottow

Page 4: Hiding for Persistance - Backdooring Linux Systems

Performance Security TestAutomation

Page 5: Hiding for Persistance - Backdooring Linux Systems
Page 6: Hiding for Persistance - Backdooring Linux Systems

Reasons you get pwned

• Spam

• DDoS

• Ransomware

• To pwn others

• To do you damage

• Lulz

• Espionage

Page 7: Hiding for Persistance - Backdooring Linux Systems

Your adversary

• Crime groups

• State-sponsored attackers

• People you’ve pissed off

• Bored teenagers

Page 8: Hiding for Persistance - Backdooring Linux Systems

discover hack monetise

Page 9: Hiding for Persistance - Backdooring Linux Systems

discover hack monetise

persistence

Page 10: Hiding for Persistance - Backdooring Linux Systems

The bad news

Page 11: Hiding for Persistance - Backdooring Linux Systems

The good news

Page 12: Hiding for Persistance - Backdooring Linux Systems

How?

Page 13: Hiding for Persistance - Backdooring Linux Systems

How to do persistence as uid > 0

• “hidden” directories

• “.. “ (note the space)

• innocuous filenames

• libglsconv.so

• process renaming

• write to argv[0]

Page 14: Hiding for Persistance - Backdooring Linux Systems

How to do persistence as uid == 0

• hide inside existing executables

• patch /bin/su

• patch processes in memory

• attach to sshd, patch, detach

• kernel module

• loadable backdoors!

• firmware backdoor

• hardware has own microcontroller and “OS”

Page 15: Hiding for Persistance - Backdooring Linux Systems

<prayer to the demo gods>

Page 16: Hiding for Persistance - Backdooring Linux Systems

#include <stdio.h>

int main() { printf(“Hello, world!\n”); return 0; }

Page 17: Hiding for Persistance - Backdooring Linux Systems

int main() { … printf(“hi”);…}

Standard C library

kernel

printf()

write()

Page 18: Hiding for Persistance - Backdooring Linux Systems

main()

sys_write()

0x00000000

0xc0000000

0xffffffff

user spacememory

kernel memory

printf()

call 0x804031d

mov eax, 0x4int 0x80

Page 19: Hiding for Persistance - Backdooring Linux Systems

libc libc libcuser

kernel

disk input devices

app app

interrupt interruptsyscall syscall

applibc

Page 20: Hiding for Persistance - Backdooring Linux Systems

Let’s look at the code

Page 21: Hiding for Persistance - Backdooring Linux Systems
Page 22: Hiding for Persistance - Backdooring Linux Systems

0xc00a3400 0xc0990d00

0xc09912a4

0xc0993600

0xc099fe0a

0xc00a3404

0xc00a3408

0xc00a340c

0xc099….

0xc099….

0xc00a…..

0xc00a…..

Page 23: Hiding for Persistance - Backdooring Linux Systems

0xc00a3400 0xc0990d00

0xc09912a4

0xc0993600

0xc099fe0a

0xc00a3404

0xc00a3408

0xc00a340c

0xc099….

0xc099….

0xc00a…..

0xc00a…..

push r15mov r15d,edipush r14mov r14,rsipush r13mov r13,rdxpush r12lea r12,[rip+0x207f78] push rbplea rbp,[rip+0x207f78]

Page 24: Hiding for Persistance - Backdooring Linux Systems

0xc00a3400 0xc0990d00

0xc09912a4

0xc0993600

0xcfe89a40

0xc00a3404

0xc00a3408

0xc00a340c

0xc099….

0xc099….

0xc00a…..

0xc00a…..

push r15mov r15d,edipush r14mov r14,rsipush r13mov r13,rdxpush r12lea r12,[rip+0x207f78] push rbplea rbp,[rip+0x207f78]

call 0xc099fe0a<filter results>

Page 25: Hiding for Persistance - Backdooring Linux Systems

Let’s look at the code

Page 26: Hiding for Persistance - Backdooring Linux Systems

Detection

• syscall table should be predictable and boring

• server’s external behaviour doesn’t lie - the hacker has a business case

• cat and mouse game between detection and hiding

• volatility framework for memory inspection

Page 27: Hiding for Persistance - Backdooring Linux Systems

Prevention - kernel level

• grsecurity / selinux

• disallow anomalous behaviour

• limit what root kan do

• disable module loading

Page 28: Hiding for Persistance - Backdooring Linux Systems

Prevention - hardening

• remove unnecessary tools like compilers

• isolate services (chroot / containers / cgroups / apparmor)

• see CIS and Certified Secure guidelines

Page 29: Hiding for Persistance - Backdooring Linux Systems

Prevention - HIDS

• tripwire / OSSEC

• trigger on anomalous events

Page 30: Hiding for Persistance - Backdooring Linux Systems

Conclusions

• They’re out to get you

• Most of them aren’t that well resourced

• A good backdoor is next to impossible to find

• There are excellent mitigations to take

• Spend your time and money wisely

Page 31: Hiding for Persistance - Backdooring Linux Systems

Dan is het ookniet leukwww.werkenbijcomputest.nl

Als het niet kapot kan..

Page 32: Hiding for Persistance - Backdooring Linux Systems
Page 33: Hiding for Persistance - Backdooring Linux Systems

Image credits

• Why girl: http://www.cellmaxxindo.com

• Lulz: Image courtesy of http://knowyourmeme.com

• Trump: http://www.northcountrypublicradio.org/

• The good news: http://theverybesttop10.com

• The bad news: http://stuffpoint.com

• Questions: http://www.slideshare.net/linaroorg/sfo15tr6-server-ecosystem-day-

part-6a