Building an IPS solution for inline usage during Red Teaming - - PowerPoint PPT Presentation

building an ips solution for inline usage during red
SMART_READER_LITE
LIVE PREVIEW

Building an IPS solution for inline usage during Red Teaming - - PowerPoint PPT Presentation

Building an IPS solution for inline usage during Red Teaming Repurposing defensive technologies for offensive Red Team operations K. Mladenov A. Zismer { kmladenov,azismer } @os3.nl Master Students in System and Network Engineering University


slide-1
SLIDE 1

Building an IPS solution for inline usage during Red Teaming

Repurposing defensive technologies for offensive Red Team operations

  • K. Mladenov
  • A. Zismer

{kmladenov,azismer}@os3.nl

Master Students in System and Network Engineering University of Amsterdam

February 2017

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 1 / 29

slide-2
SLIDE 2

Outline

1

Introduction Background information Research question

2

Investigating IDS/IPS engines Types of IDS/IPS engines How can an IPS help?

3

Evading investigation and detection Defeating OS detection Hiding services

4

Conclusion Future work

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 2 / 29

slide-3
SLIDE 3

The idea

Originally from Deloitte.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 3 / 29

slide-4
SLIDE 4

The idea

Originally from Deloitte. For use during penetration tests (Red Teaming)

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 3 / 29

slide-5
SLIDE 5

The idea

Originally from Deloitte. For use during penetration tests (Red Teaming) Prevent the attackers from doing detectable mistakes

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 3 / 29

slide-6
SLIDE 6

Research question

In how far is it possible to design a transparent device that disguises an attacker’s computer inside a local network?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 4 / 29

slide-7
SLIDE 7

Research question

In how far is it possible to design a transparent device that disguises an attacker’s computer inside a local network?

1 How can outgoing traffic be filtered and sanitised by an IPS?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 4 / 29

slide-8
SLIDE 8

Research question

In how far is it possible to design a transparent device that disguises an attacker’s computer inside a local network?

1 How can outgoing traffic be filtered and sanitised by an IPS? 2 How can incoming traffic be handled to evade investigation and

detection?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 4 / 29

slide-9
SLIDE 9

Types of IDS/IPS engines

Network based Deployed either to listen to replica of the traffic or inline. Can get visibility over the entire network if properly placed. Fail short with encrypted traffic.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 5 / 29

slide-10
SLIDE 10

Types of IDS/IPS engines

Network based Deployed either to listen to replica of the traffic or inline. Can get visibility over the entire network if properly placed. Fail short with encrypted traffic. Host based Can get full visibility over traffic about to be {en/de}crypted. Imposes some difficulty with managing multiple instances on multiple computers.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 5 / 29

slide-11
SLIDE 11

Types of IDS/IPS engines

Network based Deployed either to listen to replica of the traffic or inline. Can get visibility over the entire network if properly placed. Fail short with encrypted traffic. Host based Can get full visibility over traffic about to be {en/de}crypted. Imposes some difficulty with managing multiple instances on multiple computers. In our case a network-based solution would do the job. But should it be signature or anomaly based?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 5 / 29

slide-12
SLIDE 12

How can intruders get detected?

By doing things detectable by an IDS.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 6 / 29

slide-13
SLIDE 13

How can intruders get detected?

By doing things detectable by an IDS. But also: Passively Different Operating systems behave in different ways for things not standardised in RFC. Some examples include TTL and initial TCP window size.

OS TTL TCP window (B) Windows 7 128 8192 Windows 10 128 8192 Kali Linux 64 29200

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 6 / 29

slide-14
SLIDE 14

How can intruders get detected?

By doing things detectable by an IDS. But also: Passively Different Operating systems behave in different ways for things not standardised in RFC. Some examples include TTL and initial TCP window size.

OS TTL TCP window (B) Windows 7 128 8192 Windows 10 128 8192 Kali Linux 64 29200

Actively By doing active scans against them. More about to follow.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 6 / 29

slide-15
SLIDE 15

How can an IPS help?

By using built-in normalizers. For IP traffic - handle the TTL. For TCP traffic - handle the initial TCP window size.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 7 / 29

slide-16
SLIDE 16

How can an IPS help?

By using built-in normalizers. For IP traffic - handle the TTL. For TCP traffic - handle the initial TCP window size. So how did the selected engines perform? IPS Engine TTL handling TCP window handling Snort 2.9.9.0 yes no Snort 3 alpha yes no Suricata 3.2 no no

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 7 / 29

slide-17
SLIDE 17

How can an IPS help?

By using built-in normalizers. For IP traffic - handle the TTL. For TCP traffic - handle the initial TCP window size. So how did the selected engines perform? IPS Engine TTL handling TCP window handling Snort 2.9.9.0 yes no Snort 3 alpha yes no Suricata 3.2 no no

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 7 / 29

slide-18
SLIDE 18

But is really Suricata that bad?

Not really. It has LuaJIT support!

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 8 / 29

slide-19
SLIDE 19

But is really Suricata that bad?

Not really. It has LuaJIT support! And that means scripting, triggered by a rule! Including executing commands from the system shell!

drop tcp 10.0.0.200 any -> any any (msg:"TCP SYN for inspection by LUA"; flags:S; sid 1000002; rev :001; luajit:tcpinspect.lua;)

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 8 / 29

slide-20
SLIDE 20

How did the IPS get connected to the network?

There was a need for a solution that did not require scripting... But how did it get attached in this transparent device?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 9 / 29

slide-21
SLIDE 21

Active detection

TCP/IP fingerprinting

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 10 / 29

slide-22
SLIDE 22

Active detection

TCP/IP fingerprinting Service and version detection

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 10 / 29

slide-23
SLIDE 23

TCP/IP fingerprinting

unspecified situations in the RFCs of TCP/IP

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 11 / 29

slide-24
SLIDE 24

TCP/IP fingerprinting

unspecified situations in the RFCs of TCP/IP → different OS specific implementations of the TCP/IP stack

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 11 / 29

slide-25
SLIDE 25

TCP/IP fingerprinting

unspecified situations in the RFCs of TCP/IP → different OS specific implementations of the TCP/IP stack Nmap sends a variety of probing packets

ICMP TCP UDP

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 11 / 29

slide-26
SLIDE 26

TCP/IP fingerprinting

unspecified situations in the RFCs of TCP/IP → different OS specific implementations of the TCP/IP stack Nmap sends a variety of probing packets

ICMP TCP UDP

results of different tests are combined to create an individual fingerprint

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 11 / 29

slide-27
SLIDE 27

TCP/IP fingerprinting

unspecified situations in the RFCs of TCP/IP → different OS specific implementations of the TCP/IP stack Nmap sends a variety of probing packets

ICMP TCP UDP

results of different tests are combined to create an individual fingerprint known OS/fingerprint mappings are stored in a database

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 11 / 29

slide-28
SLIDE 28

Nmap OS fingerprint format

SCAN(V=5.05 BETA1%D=8/23% OT =22% CT =1% CU =42341% PV=N%DS =0% DC=L%G=Y%TM=4 A91CB90% P=i686 -pc -linux -gnu) SEQ(SP=C9%GCD =1% ISR=CF%TI=Z%CI=Z%II=I%TS=A) OPS(O1= M400CST11NW5 %O2= M400CST11NW5 %O3= M400CNNT11NW5 % O4= M400CST11NW5 %O5= M400CST11NW5 %O6=M400CST11) WIN(W1 =8000% W2 =8000% W3 =8000% W4 =8000% W5 =8000% W6 =8000) ECN(R=Y%DF=Y%T=40%W=8018%O= M400CNNSNW5 %CC=N%Q=) T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD =0%Q=) T2(R=N) T3(R=Y%DF=Y%T=40%W=8000%S=O%A=S+%F=AS%O= M400CST11NW5 %RD =0%Q=) T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD =0%Q=) T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD =0%Q=) T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD =0%Q=) T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD =0%Q=) U1(R=Y%DF=N%T=40% IPL =164% UN =0% RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G) IE(R=Y%DFI=N%T=40% CD=S)

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 12 / 29

slide-29
SLIDE 29

Nmap OS detection

$ sudo nmap -O 10.0.0.220 Starting Nmap 7.01 ( https :// nmap.org ) at 2017 -02 -06 21:47 CET Nmap scan report for 10.0.0.220 Host is up (0.000063s latency). Not shown: 999 closed ports PORT STATE SERVICE 22/ tcp

  • pen

ssh MAC Address: 00:0C:29:40: E7:6A (VMware) Device type: general purpose Running: Linux 3.X|4.X # OS detection correct OS CPE: cpe :/o:linux: linux_kernel :3 cpe :/o:linux: linux_kernel :4 OS details: Linux 3.2 - 4.0 Network Distance: 1 hop OS detection

  • performed. Please

report any incorrect results at https :// nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 3.20 seconds

Listing 1: Inspecting a Ubuntu machine with kernel 4.4.0-59-generic

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 13 / 29

slide-30
SLIDE 30

How can OS detection be evaded?

IP Personality

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-31
SLIDE 31

How can OS detection be evaded?

IP Personality

kernel patch that can simulate multiple OS fingerprints needs to be compiled into the kernel

  • nly available for 2.4 Linux kernels
  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-32
SLIDE 32

How can OS detection be evaded?

IP Personality

kernel patch that can simulate multiple OS fingerprints needs to be compiled into the kernel

  • nly available for 2.4 Linux kernels

honeyD

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-33
SLIDE 33

How can OS detection be evaded?

IP Personality

kernel patch that can simulate multiple OS fingerprints needs to be compiled into the kernel

  • nly available for 2.4 Linux kernels

honeyD

virtual honeypot framework simulates networks of low-interaction honeypots

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-34
SLIDE 34

How can OS detection be evaded?

IP Personality

kernel patch that can simulate multiple OS fingerprints needs to be compiled into the kernel

  • nly available for 2.4 Linux kernels

honeyD

virtual honeypot framework simulates networks of low-interaction honeypots Personality engine to simulate TCP/IP stack

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-35
SLIDE 35

How can OS detection be evaded?

IP Personality

kernel patch that can simulate multiple OS fingerprints needs to be compiled into the kernel

  • nly available for 2.4 Linux kernels

honeyD

virtual honeypot framework simulates networks of low-interaction honeypots Personality engine to simulate TCP/IP stack apt-get install honeyd

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 14 / 29

slide-36
SLIDE 36

Simulating a Windows XP machine with honeyD

1 create

winxp

2 set winxp

personality "Microsoft Windows XP Professional "

3 set winxp

default tcp action reset

4 set winxp

default udp action reset

5 set winxp

default icmp action closed

6 add winxp udp port 123 open 7 add winxp tcp port 3389

proxy 10.0.0.60:3389

8 add winxp tcp port 22 proxy

$ipsrc :22

9 add winxp tcp port 23 "/etc/honeypot/scripts/fake_telnet.sh" 10 11 bind

10.0.0.200 winxp

Listing 2: honeyd.conf

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 15 / 29

slide-37
SLIDE 37

Service and version detection

Nmap uses two methods to detect a service

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 16 / 29

slide-38
SLIDE 38

Service and version detection

Nmap uses two methods to detect a service

1

statically mapping well-known ports to their services

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 16 / 29

slide-39
SLIDE 39

Service and version detection

Nmap uses two methods to detect a service

1

statically mapping well-known ports to their services

2

attempting to interact with the services to obtain more details:

application name version number

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 16 / 29

slide-40
SLIDE 40

Service and version detection

Nmap uses two methods to detect a service

1

statically mapping well-known ports to their services

2

attempting to interact with the services to obtain more details:

application name version number OS family

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 16 / 29

slide-41
SLIDE 41

Nmap service and version detection

$ sudo nmap -sV 10.0.0.205 Starting Nmap 7.01 ( https :// nmap.org ) at 2017 -02 -06 22:39 CET Nmap scan report for 10.0.0.205 Host is up (0.000047s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/ tcp

  • pen

ssh OpenSSH 7.2 p2 Ubuntu 4ubuntu2 .1 (Ubuntu Linux; protocol 2.0) 80/ tcp

  • pen

http Apache httpd 2.4.18 (( Ubuntu)) MAC Address: 00:0C:29:16:3C:76 (VMware) Service Info: OS: Linux; CPE: cpe :/o:linux: linux_kernel Service detection

  • performed. Please

report any incorrect results at https :// nmap.org/ submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.10 seconds

Listing 3: Inspecting a Ubuntu machine with and ssh service and apache running

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 17 / 29

slide-42
SLIDE 42

How can service detection be evaded?

Beacons are connecting to CnC server through port 80 Port 80 is suspicious

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 18 / 29

slide-43
SLIDE 43

How can service detection be evaded?

Beacons are connecting to CnC server through port 80 Port 80 is suspicious → Can we detect an Nmap scan and temporary close port 80?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 18 / 29

slide-44
SLIDE 44

How does Nmap perform a service scan?

Figure: Result of 1000 Nmap scans

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 19 / 29

slide-45
SLIDE 45

How to react to connection attempts to closed ports?

Port knocking:

listening to secret sequences of port connections

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 20 / 29

slide-46
SLIDE 46

How to react to connection attempts to closed ports?

Port knocking:

listening to secret sequences of port connections

  • pening another port, if a certain sequence is detected
  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 20 / 29

slide-47
SLIDE 47

How to react to connection attempts to closed ports?

Port knocking:

listening to secret sequences of port connections

  • pening another port, if a certain sequence is detected

knockD is a very flexible port knocking daemon

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 20 / 29

slide-48
SLIDE 48

Configuring knockD

1 # closing port 22 if 2222 , 3333 and 4444 are knocked 2 [ opencloseSSH ] 3 sequence = 2222 ,3333 ,4444 4 seq_timeout = 15 5 tcpflags = syn ,ack 6 start_command = iptables

  • A INPUT -s %IP% -p tcp
  • -syn
  • -dport 22 -j ACCEPT

7 cmd_timeout = 10 8 stop_command = iptables

  • D INPUT -s %IP% -p tcp
  • -syn
  • -dport 22 -j ACCEPT

Listing 4: knockd.conf

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 21 / 29

slide-49
SLIDE 49

Configuring knockD

1 # close port 80 if either of 199, 3306 , 554, ... is knocked 2 [close80] 3 sequence = 199/3306/554/143/22/3389/8888/ ... 4 seq_timeout = 15 5 tcpflags = syn ,ack 6 start_command = iptables

  • A INPUT -s %IP% -p tcp -m multiport
  • -dports 80 -j REJECT

7 cmd_timeout = 10 8 stop_command = iptables

  • D INPUT -s %IP% -p tcp -m multiport
  • -dports

80 -j REJECT

Listing 5: knockd.conf

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 22 / 29

slide-50
SLIDE 50

Configuring knockD

1 # separate rule for each port 2 [ close80_199 ] 3 sequence = 199 4 seq_timeout = 15 5 tcpflags = syn ,ack 6 start_command = iptables

  • A INPUT -s %IP% -p tcp -m multiport
  • -dports 80 -j REJECT

7 cmd_timeout = 10 8 stop_command = iptables

  • D INPUT -s %IP% -p tcp -m multiport
  • -dports

80 -j REJECT 9 [ close80_3306 ] 10 sequence = 3306 11 seq_timeout = 15 12 tcpflags = syn ,ack 13 start_command = iptables

  • A INPUT -s %IP% -p tcp -m multiport
  • -dports 80 -j REJECT

14 cmd_timeout = 10 15 stop_command = iptables

  • D INPUT -s %IP% -p tcp -m multiport
  • -dports

80 -j REJECT 16 ...

Listing 6: knockd.conf

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 23 / 29

slide-51
SLIDE 51

Configuring knockD

1 # rules for all possible permutations 2 [ close80_199_3306 ] 3 sequence = 199 ,3306 4 seq_timeout = 15 5 tcpflags = syn ,ack 6 start_command = iptables

  • A INPUT -s %IP% -p tcp -m multiport
  • -dports 80 -j REJECT

7 cmd_timeout = 10 8 stop_command = iptables

  • D INPUT -s %IP% -p tcp -m multiport
  • -dports

80 -j REJECT 9 [ close80_199_554 ] 10 sequence = 199 ,554 11 seq_timeout = 15 12 tcpflags = syn ,ack 13 start_command = iptables

  • A INPUT -s %IP% -p tcp -m multiport
  • -dports 80 -j REJECT

14 cmd_timeout = 10 15 stop_command = iptables

  • D INPUT -s %IP% -p tcp -m multiport
  • -dports

80 -j REJECT 16 ...

Listing 7: knockd.conf

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 24 / 29

slide-52
SLIDE 52

Configuring knockD

running multiple instances of knockD with different rules multiple sequences can be detected in parallel if Nmap starts scanning with port 80, it cannot be hidden

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 25 / 29

slide-53
SLIDE 53

Reliability

Figure: Result of 1000 Nmap scans

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 26 / 29

slide-54
SLIDE 54

Conclusion

We were able to implement a transparent solution which can protect the attacker from being easily detected. At this point it requires additional configuration and has some tradeoffs between different options.

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 27 / 29

slide-55
SLIDE 55

Conclusion

We were able to implement a transparent solution which can protect the attacker from being easily detected. At this point it requires additional configuration and has some tradeoffs between different options. Future work

Improving reliability of hiding port 80 Replace the functionality of external daemons by Lua scripts

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 27 / 29

slide-56
SLIDE 56

Demo

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 28 / 29

slide-57
SLIDE 57

Questions?

  • K. Mladenov, A. Zismer (UvA)

IPS solution for Red Teaming February 2017 29 / 29