67
1 TCP/IP TCP/IP Perversion Perversion Rares Stefan, Third Rares Stefan, Third Brigade Inc. Brigade Inc. SecTor 2007 SecTor 2007

TCP/IP Perversion

  • Upload
    phuong

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

TCP/IP Perversion. Rares Stefan, Third Brigade Inc. SecTor 2007. Introduction. Perspective from a researcher focused on protecting hosts from malware Implementing kernel-based protection mechanisms Insight into a potential class of network driver malware. The Rise of Silent Malware. - PowerPoint PPT Presentation

Citation preview

Page 1: TCP/IP Perversion

1

TCP/IP TCP/IP PerversionPerversion

Rares Stefan, Third Brigade Rares Stefan, Third Brigade Inc.Inc.

SecTor 2007SecTor 2007

Page 2: TCP/IP Perversion

2

IntroductionIntroduction

Perspective from a researcher focused on Perspective from a researcher focused on protecting hosts from malwareprotecting hosts from malware

Implementing kernel-based protection Implementing kernel-based protection mechanismsmechanisms Insight into a potential class of network driver Insight into a potential class of network driver

malwaremalware

Page 3: TCP/IP Perversion

3

The Rise of Silent MalwareThe Rise of Silent Malware

Three main areas of interest in malware Three main areas of interest in malware R&D:R&D:

Delivery and activationDelivery and activation

Hiding presence - rootkit techniquesHiding presence - rootkit techniques

Evasion - Minimize operating noiseEvasion - Minimize operating noise Show no signs of activity on the infected systemShow no signs of activity on the infected system Show no traces of network activity on the wireShow no traces of network activity on the wire

Page 4: TCP/IP Perversion

4

Operational ChallengesOperational Challenges

Operate on wire dataOperate on wire data

Active at a layer that guarantees transparency Active at a layer that guarantees transparency to the hostto the host

Correctly perform inline IP reassembly and Correctly perform inline IP reassembly and TCP stream reassemblyTCP stream reassembly

Allow for arbitrary injection/removal of data in Allow for arbitrary injection/removal of data in TCP sessionsTCP sessions

Page 5: TCP/IP Perversion

5

Operational Challenges…part Operational Challenges…part deuxdeux

Maintain silence on the host:Maintain silence on the host: Never initiate TCP sessionsNever initiate TCP sessions Never receive TCP open-session requestsNever receive TCP open-session requests Do not rely on TCP port splicing if the infected Do not rely on TCP port splicing if the infected

host is a serverhost is a server Do not rely on static motherships if the Do not rely on static motherships if the

infected host is a workstationinfected host is a workstation Packet modifications should not be easily Packet modifications should not be easily

visible in local network tracesvisible in local network traces

Page 6: TCP/IP Perversion

6

Operational Challenges…Operational Challenges…part troispart trois

Maintain silence on the wireMaintain silence on the wire

Only make use of legitimate TCP sessionsOnly make use of legitimate TCP sessions

Do not alter protocol semantics - Do not alter protocol semantics - resistance to network anomaly detection resistance to network anomaly detection enginesengines

Piggyback on encrypted channels (SSL) Piggyback on encrypted channels (SSL) and multiple TCP sessions for large data and multiple TCP sessions for large data transferstransfers

Page 7: TCP/IP Perversion

7

Miniport driverMiniport driver

NDISNDIS NDIS.SYSNDIS.SYS

Intermediate driverIntermediate driver

PF hook PF hook

FW hook FW hook

TDI TDI

User LandUser Land

TCP/IPTCP/IP

Driver Implementation Pre-Driver Implementation Pre-VistaVista

Never

Access to data stream, not packets

Some interesting areas

No guaranteed access to outbound payload

NDIS hooking

- Some delivery challenges- Most flexibility - Driver signing issues- Complete control over hardware drivers to transport protocol communications

Page 8: TCP/IP Perversion

8

Rogue Network Driver Rogue Network Driver FrameworkFramework

Firewall hook kernel module for basic Firewall hook kernel module for basic packet header operations packet header operations

IM Filter driver:IM Filter driver: Inline IP reassemblyInline IP reassembly Inline TCP stream reassemblyInline TCP stream reassembly TCP session normalizationTCP session normalization

Page 9: TCP/IP Perversion

9

Packet Header ModificationsPacket Header Modifications

Page 10: TCP/IP Perversion

10

Infected WorkstationInfected Workstation

BOB

ALICE

server

DNAT – DstIP_server -> DstIP_Bob

SNAT/DNAT – SrcIP_Alice -> SrcIP_Bob DstIP_Bob -> dstIP_server

Translated request reaches server

https://server

10.0.1.124

10.0.1.26

Page 11: TCP/IP Perversion

11

Infected WorkstationInfected Workstation

BOB

ALICE

server

DNAT – DstIP_server -> DstIP_Bob

SNAT/DNAT – SrcIP_Alice -> SrcIP_Bob DstIP_Bob -> dstIP_server

Translated request reaches server

https://server

10.0.1.124

10.0.1.26

Page 12: TCP/IP Perversion

12

Infected ServerInfected Server

ALICE

Server

https://serverhttps request served

telnet server:80

Selective DN(P)AT:

SrcIP_Alice SrcIP_serverDst_Port_443 DstPort_135

Page 13: TCP/IP Perversion

13

Infected ServerInfected Server

ALICE

Server

https://serverhttps request served

telnet server:80

Selective DN(P)AT:

SrcIP_Alice SrcIP_serverDst_Port_443 DstPort_135

Page 14: TCP/IP Perversion

14

Packet Header OpportunitiesPacket Header Opportunities Passive covert channelsPassive covert channels

http://www.invisiblethings.org/papers/http://www.invisiblethings.org/papers/passivepassive--covertcovert--channelschannels-linux.pdf-linux.pdf http://www.ouah.org/neural_networks_vs_NUSHU.pdf http://www.ouah.org/neural_networks_vs_NUSHU.pdf http://staff.science.uva.nl/~delaat/snb-2005-2006/p27/report.pdfhttp://staff.science.uva.nl/~delaat/snb-2005-2006/p27/report.pdf

Port splicing Port splicing Most significant; communicating the original Most significant; communicating the original

intent:intent: DNAT on outgoing SYN – change destination address DNAT on outgoing SYN – change destination address

to that of the MIMto that of the MIM Insert original dstIP in header fields Insert original dstIP in header fields MIM double NATMIM double NAT

Page 15: TCP/IP Perversion

15

Why Payload InjectionWhy Payload Injection ??

Access to packet dataAccess to packet data

High bandwidth channelHigh bandwidth channel

Bypass application proxiesBypass application proxies

Altering TCP data length on the wire is not Altering TCP data length on the wire is not trivial!trivial!

Page 16: TCP/IP Perversion

16

Inline InjectionInline Injection

Support for IP reassembly on incoming Support for IP reassembly on incoming traffic and IP fragmentation on outbound traffic and IP fragmentation on outbound traffictraffic

Support for TCP stream reassembly – Support for TCP stream reassembly – datagram reordering, injection of datagram reordering, injection of acknowledgements and resets, among acknowledgements and resets, among other thingsother things

Page 17: TCP/IP Perversion

17

Inline TCP ReassemblyInline TCP Reassembly

Maintain two edges (pre and post modification):Maintain two edges (pre and post modification): ISNISN MaxSeqMaxSeq MaxAckMaxAck WindowWindow Maximum SeqNo of Filtered DataMaximum SeqNo of Filtered Data Maximum AckNo of Filtered DataMaximum AckNo of Filtered Data Queue/counter for non Ack-ed datagramsQueue/counter for non Ack-ed datagrams Queue/counter for not sent datagramsQueue/counter for not sent datagrams Needed Window ScaleNeeded Window Scale Actual Window ScaleActual Window Scale

Page 18: TCP/IP Perversion

18

SMTP Injection – Eliminating SMTP Injection – Eliminating Bob from the EquationBob from the Equation

Reduces the complexity of MIM and random Reduces the complexity of MIM and random redirectionredirection

Works with application level proxiesWorks with application level proxies

Replace RCPT TO argument or inject additional Replace RCPT TO argument or inject additional RCPT TO (BCC)RCPT TO (BCC)

Increases the probability detection – SMTP Increases the probability detection – SMTP server logsserver logs

Page 19: TCP/IP Perversion

19

SMTP InjectionSMTP Injection

BOB

SMTP Server

Alice

Sends Bob message

Driver injects BCC to Eva

Eva

So does Eva

Bob receives original message

Page 20: TCP/IP Perversion

20

SMTP Injection DemoSMTP Injection DemoVid1

Page 21: TCP/IP Perversion

21

Page 22: TCP/IP Perversion

22

Page 23: TCP/IP Perversion

23

HTTP InjectionHTTP Injection TCP Headers useless – need to find workaroundTCP Headers useless – need to find workaround

Easy workaround but we need to be careful:Easy workaround but we need to be careful: Transparent proxies (Initial HTTP request looks Transparent proxies (Initial HTTP request looks

normal, so we’ll always assume we may be normal, so we’ll always assume we may be transparently “proxied”)transparently “proxied”)

Direct proxies – easy to spot in HTTP(s) requestsDirect proxies – easy to spot in HTTP(s) requests

URI & Headers will help us redirect/leak dataURI & Headers will help us redirect/leak data Make use of Authorization, Cookies headers – they Make use of Authorization, Cookies headers – they

won’t be scrubbedwon’t be scrubbed POST data also presents injection opportunitiesPOST data also presents injection opportunities

Page 24: TCP/IP Perversion

24

HTTP InjectionHTTP Injection

BOB

ALICE

http://www.google.com

Web Proxy – Content Filtering

Change request; Inject Data

google.com

Page 25: TCP/IP Perversion

25

HTTP InjectionHTTP Injection

BOB

ALICE

http://www.google.com

Web Proxy – Content Filtering

Change request; Inject Data

google.com

Page 26: TCP/IP Perversion

26

BOB

SSL Injection DemoSSL Injection Demo

https://somebank.com

Perimeter Security

Inject Data

somebank.com

ALICE

Page 27: TCP/IP Perversion

27

BOB

SSL Injection DemoSSL Injection Demo

https://somebank.com

Perimeter Security

Inject Data

somebank.com

ALICE

Page 28: TCP/IP Perversion

28

SSL Alice – browser videoSSL Alice – browser video

Page 29: TCP/IP Perversion

29

Detecting Network Driver Detecting Network Driver MalwareMalware

Conventional detection mechanismsConventional detection mechanisms AV, AS signatures; configuration mgmtAV, AS signatures; configuration mgmt

New detection mechanismsNew detection mechanisms Traffic based detection?Traffic based detection?

Malicious destinations, ISN analysisMalicious destinations, ISN analysis Network trace diff – local vs. remoteNetwork trace diff – local vs. remote NDIS based sniffer for better visibility?NDIS based sniffer for better visibility?

OtherOther Host based application control ineffectiveHost based application control ineffective DLP?DLP? … …

Page 30: TCP/IP Perversion

30

ConclusionsConclusions

Passive kernel malware difficult to spotPassive kernel malware difficult to spot

There are significant implementation There are significant implementation challenges for coderschallenges for coders

Prevention remains key approachPrevention remains key approach

Page 31: TCP/IP Perversion

31

Thank YouThank You

Page 32: TCP/IP Perversion

32

Infected WorkstationInfected Workstation

Page 33: TCP/IP Perversion

33

Alice – Browser CaptureAlice – Browser Capture

Page 34: TCP/IP Perversion

34

Alice-Bob Network TracesAlice-Bob Network Traces

Page 35: TCP/IP Perversion

35

Alice Driver_SNATAlice Driver_SNAT

Page 36: TCP/IP Perversion

36

Alice_SNATAlice_SNAT

Page 37: TCP/IP Perversion

37

Back to Infected WorkstationBack to Infected Workstation

Page 38: TCP/IP Perversion

38

Bob_Double_NATBob_Double_NAT

Page 39: TCP/IP Perversion

39

Bob_Double_NATBob_Double_NAT

Page 40: TCP/IP Perversion

40

Bob_Double_NATBob_Double_NAT

Page 41: TCP/IP Perversion

41

Bob_Double_NATBob_Double_NAT

Page 42: TCP/IP Perversion

42

Back to Infected WorkstationBack to Infected Workstation

Page 43: TCP/IP Perversion

43

Infected ServerInfected Server

Page 44: TCP/IP Perversion

44

Server network traceServer network trace

Page 45: TCP/IP Perversion

45

Server SNAT&DPATServer SNAT&DPAT

Page 46: TCP/IP Perversion

46

Back to Infected ServerBack to Infected Server

Page 47: TCP/IP Perversion

47

HTTP InjectionHTTP Injection

Page 48: TCP/IP Perversion

48

Alice – browser videoAlice – browser video

Page 49: TCP/IP Perversion

49

Alice – network traceAlice – network trace

Page 50: TCP/IP Perversion

50

Alice - original dataAlice - original data

Page 51: TCP/IP Perversion

51

Alice – driver workAlice – driver work

Page 52: TCP/IP Perversion

52

Alice – driver workAlice – driver work

Page 53: TCP/IP Perversion

53

Alice – driver workAlice – driver work

Page 54: TCP/IP Perversion

54

Alice – driver workAlice – driver work

Page 55: TCP/IP Perversion

55

Back to HTTP InjectionBack to HTTP Injection

Page 56: TCP/IP Perversion

56

Bob – driver workBob – driver work

Page 57: TCP/IP Perversion

57

Bob – modified requestBob – modified request

Page 58: TCP/IP Perversion

58

Bob – driver workBob – driver work

Page 59: TCP/IP Perversion

59

Bob – driver workBob – driver work

Page 60: TCP/IP Perversion

60

Back to HTTP InjectionBack to HTTP Injection

Page 61: TCP/IP Perversion

61

SSL InjectionSSL Injection

Page 62: TCP/IP Perversion

62

Alice – original dataAlice – original data

Page 63: TCP/IP Perversion

63

Post Insert – Wire Noise!Post Insert – Wire Noise!

Page 64: TCP/IP Perversion

64

Alice – SSL cleanAlice – SSL clean

Page 65: TCP/IP Perversion

65

Back to SSL InjectionBack to SSL Injection

Page 66: TCP/IP Perversion

66

Bob – Post modification. Clean!!Bob – Post modification. Clean!!

Page 67: TCP/IP Perversion

67

Back to SSL InjectionBack to SSL Injection