The Intrepidus Group Proxy setups for apps Who are we? Wh ? P t - - PowerPoint PPT Presentation

the intrepidus group
SMART_READER_LITE
LIVE PREVIEW

The Intrepidus Group Proxy setups for apps Who are we? Wh ? P t - - PowerPoint PPT Presentation

The Intrepidus Group Proxy setups for apps Who are we? Wh ? P t f Throwaway tools that Jeremy Allen are all similar are all similar Rajendra Umadas R j d U d Scratching the g What do we do? What do we do?


slide-1
SLIDE 1

The Intrepidus Group

slide-2
SLIDE 2

Wh ?

P t f

Who are we? Jeremy Allen

R j d U d

Proxy setups for apps Throwaway tools that

are all similar

Rajendra Umadas What do we do?

are all similar

“Scratching the What do we do? Black box Mobile App

Assessments, Thick

g Itch…”

Introducing: Mallory

Assessments, Thick Clients, Web apps

Architecture/Design What Annoys Us? Demo

2

slide-3
SLIDE 3

Other than carbon based multi cellular life forms Other than carbon‐based multi‐cellular life forms

3

slide-4
SLIDE 4

Principal Consultant at Intrepidus Group Teaches Secure Coding Principles Lead Mallory Developer OWASP, ISACA speaker

4

slide-5
SLIDE 5

f

Youngin’ of the group

  • Cisco CCNA Networking CS CompE

Computer security Bar Intrepidus Group

Mobile Application Security == fun Legacy Bugs First (of many) Black Hat Presentation

5

slide-6
SLIDE 6

6

slide-7
SLIDE 7

M bil A A t

Mobile App Assessments

QUALCOMM/BREW RIM

RIM

Windows Mobile iPhone

d d

Android

Web Application Assessments

X$$ ‐‐ It pays the bills.

X$$ It pays the bills.

Blackboxy‐stuff

Thick client apps/plugins that talk somehow

Bi t l

Binary protocols

7

slide-8
SLIDE 8

M bil A li i

Mobile Applications Often just a thick client using HTTP to transport

data data

Thick Clients

Thick Clients

Often just software using HTTP to transport data Web Applications Often just browser based apps using HTTP to

j pp g transport data.

8

slide-9
SLIDE 9

The above targets sometimes use proprietary

transport protocols.

It may be hard to force a thick client or

b l l d h h mobile app to tunnel data through HTTP proxy even if they use HTTP for transport

Web Apps may use ActiveX, Flash, or various

h d l h dd d d ff

  • ther modules that add non‐standard traffic

9

slide-10
SLIDE 10

10

slide-11
SLIDE 11

Binary protocols Non‐proxy aware apps

bl f k

TCP reassembly from packet captures “Roll your own” clients

h

It’s not using HTTP.. what is it ? Throwaway code per‐engagement

l h d

Someone else wrote the proxy and we can’t

change the code easily

11

slide-12
SLIDE 12

Cain and Able, Ettercap… Limitations: Dealing with IP Packets Not working with TCP Streams Building from Layer 3 and up??? Not optimal for application assessments Optimal for messing with the office

12

slide-13
SLIDE 13

13

slide-14
SLIDE 14

http://code.activestate.com/recipes/491264‐

mini‐fake‐dns‐server/, Host File Edit l l d

Control Application Data Endpoints You tell application who to talk to Application don’t respect DNS/Host file Can’t set DNS server Multiple Host Same Port?! Ifconfig aliased?!

14

slide-15
SLIDE 15

15

slide-16
SLIDE 16

16

slide-17
SLIDE 17

b b

Web Scarab, Burp, Paros… PFI Need to configure application and the proxy for

full duplex communication k

Use OS TCP/IP Stack

▪ No reassembly

Li i i

Limitations:

▪ Application might not support proxy setting ▪ Manual configuration of proxy endpoint ▪ Manual configuration of proxy endpoint

17

slide-18
SLIDE 18

When they just want to make our lives

difficult

No one tool can work with us to get the data

d proxied

Tools work well, just don’t meet some specific

f ff f specifications (Buffer size, platform intricacies,…)

Ti t h k it t th

Time to hack it together

18

slide-19
SLIDE 19

Gather Data Figure out what we need Server IP(s) Server Port(s) TCP or UDP? Buffer sizes??? Any other anomalous characteristics

19

slide-20
SLIDE 20

20

slide-21
SLIDE 21

‐A PREROUTING ‐i eth1 ‐p tcp ‐m tcp ‐‐dport

80 ‐j REDIRECT ‐‐to‐ports 1231

‐A PREROUTING ‐i eth1 ‐p tcp ‐m tcp ‐‐dport

443 ‐j REDIRECT ‐‐to‐ports 1232 h d

‐A PREROUTING ‐i eth1 ‐p tcp ‐m tcp ‐‐dport

4356‐j REDIRECT ‐‐to‐ports 1233

21

slide-22
SLIDE 22

netcat nc ‐l ‐p 1231 | nc host 80 nc ‐l ‐p 1232 | nc host 443 nc ‐l ‐p 1233 | nc host 4356 socat socat ‐v ‐v ‐x tcp‐listen:80 host:80

22

slide-23
SLIDE 23

f

Python to recreate client from recon above Python: Open local listening socket Read data forward to socket Manipulate data read from local socket Open remote socket to original server (from

recon)

Forward mangled data

23

And Reverse

slide-24
SLIDE 24

Application Transparent Extensible Programmatic Manual Non‐HTTP Aware Instream Modification Instream Modification Mallory X X X X X Burp (HTTP Proxies) X PFI X X X Cain and Abel X Middler X X Middler X X Ethercap X X X Netsed X X Squid X * X

24

slide-25
SLIDE 25

<redacted> <redacted>

25

slide-26
SLIDE 26

26

slide-27
SLIDE 27

Python2 6 python2 6 dev Python2.6, python2.6‐dev python‐setuptools python‐pyasn1 python‐netfilter libnetfilter‐conntrack‐dev pynetfilter conntrack

py et te _co t ac

netfilter‐extensions‐source libnetfilter‐conntrack3‐dbg libnetfilter conntrack1 0 0 99 1 i386 deb libnetfilter‐conntrack1_0.0.99‐1_i386.deb python‐paramiko (http://software.inl.fr/trac/wiki/pynetfilter_conntrack)

27

slide-28
SLIDE 28

mallory.py starts a listener (SERVER) This server accepts() connections

h d d

Each accept determines endpoint source (IP,

Port) h f l d h

Integrates with netfilter to determine the

“Original destination” (pre‐REDIRECT) h d f d

Creates 2 proxy threads (forward/reverse) to

shovel traffic back and forth l ll d h ddl f h h l

Plugins are called in the middle of the shovel

28

slide-29
SLIDE 29

We’re using “hg” (mercurial) on bitbucket to store code/track changes. After hg checkout,

ca/ : Where dynamic certs are stored

db/ Where traffic database files live

db/ : Where traffic database files live src/ : Executable python code/plugins

29

slide-30
SLIDE 30

n no transparent ‐n, ‐‐no‐transparent

Turn off the transparent proxy. This puts the proxy into a static only

  • mode. You must supply the destination IP:Port you want traffic to
  • mode. You must supply the destination IP:Port you want traffic to

go to

Example: ‐n ip:port, ‐n a.b.c.d:443

‐l, ‐‐listen

Specify the port to listen on Specify the port to listen on. Only useful with ‐‐no‐transparent. Format is:

example: ‐l 443

Default is 20755

30

slide-31
SLIDE 31

d / t ffi db ‐d / –trafficdb

Specify the traffic database name, default is "trafficdb” SQLITE d t b d SQLITE databases are used.

‐p / ‐‐proto

S if th t l t Thi i l f l ith th Specify the protocol to use. This is only useful with the no‐ transparent option. You must specify the module inside of the protocol package as well as the exact protocol class to instantiate instantiate. Example: ‐p sslproto.SSLProtocol or ‐p ssh.SSHProtocol

  • r ‐p http HTTP
  • r p http.HTTP

31

slide-32
SLIDE 32

TABLE: connections

connCount INTEGER – Uniquely identifies a TCP Stream in this database. Usedto JOIN on from flows table serverIp TEXT serverPort INTEGER : Original destination where packet is serverIp TEXT,serverPort INTEGER : Original destination where packet is going (pre‐REDIRECT) clientIp TEXT, clientPort INTEGER (Victim client)

fl TABLE: flows

Actual data in connections Buffer sizes of real connection are preserved. conncount INTEGER: Unique ID for this flow maps to connections direction TEXT,: “c2s” / “s2c” buffindex INTEGER: Increasing number for this stream O S d h timestamp FLOAT,: Seconds since epoch. buffer BLOB: The actual data received.

32

slide-33
SLIDE 33

TABLE dgram f

UDP “ ti l ” d t

TABLE: dgram : for UDP “connectionless” data

saddr : IP Address in normal dotted quad format sport Integer source port sport: Integer source port daddr : IP Addres in dotted quad dport INTEGER:destination port direction TEXT : “c2s” or “s2c” d ect o c s o s c body BLOB: The actual data contained in the packet timestamp: seconds since the epoch p p

33

slide-34
SLIDE 34

f

CLI ‐> Command Line Interface Connects to Mallory server

d

Some commands (WIP):

[a] auto send mode [m] manual mode [o] debugger off at server [o] debugger off at server [n] debugger on at server [q] quit

34

slide-35
SLIDE 35

Uses same XMLRPC mechanism to talk to server

35

slide-36
SLIDE 36

An API !

An API !

Base classes to inherit from and build custom

protocols with: protocols with: TcpProtocol, UdpProtocol

HttpProtocol Implementation ‐‐ fairly

HttpProtocol Implementation fairly complete – it’s a mod of the Python one☺

A simple “event” protocol for plugins to

A simple event protocol for plugins to register interest and call handlers on: CREATE, ACCEPT, and FORWARDING EVENTS CREATE, ACCEPT, and FORWARDING EVENTS

36

slide-37
SLIDE 37

Get up and stretch!!!! Get up and stretch!!!!

37