SlideShare a Scribd company logo
1 of 24
Download to read offline
OWASP Proxy

An intercepting proxy library,
    so you don’t have to
Background
•  OWASP WebScarab

•  OWASP WebScarab-NG

•  OWASP CSRFTester
  $ unzip -l CSRFTester-1.0-src.zip | grep java |
    grep webscarab | wc -l
     75
What good is this?

•  Allows visibility into communications

•  Allows modification of communications

•  Invisible to client and server
Features
•  Flexible
  –  compose your own proxy
•  Binary clean
  –  squeaky clean!
•  Performant
  –  streams as much as possible
  –  buffers only what you tell it to
•  Multi-protocol
  –  Mostly HTTP-related currently
The Simplest Proxy
requestHandler = new DefaultHttpRequestHandler
   ();
httpProxy = new HttpProxyConnectionHandler
   (requestHandler);
listen = new InetSocketAddress("localhost", 8008);
proxy = new Server(listen, httpProxy);
proxy.start();


            … isn’t very useful
Message Object Model
public interface MessageHeader {
     byte[] getHeader();
           String getStartLine() throws MessageFormatException;
           NamedValue[] getHeaders() throws MessageFormatException;
           String getHeader(String name) throws MessageFormatException;
}

public interface MutableMessageHeader {
     void setHeader(byte[] header);
           void setStartLine(String line) throws MessageFormatException;
           void setHeaders(NamedValue[] headers) throws MessageFormatException;
           void setHeader(String name, String value) throws
           MessageFormatException;
           void addHeader(String name, String value) throws
}          MessageFormatException;
           String deleteHeader(String name) throws MessageFormatException;
Message Content
public interface StreamingMessage            public interface BufferedMessage extends
   extends MutableMessageHeader {               MessageHeader {

    InputStream getContent();                    byte[] getContent();

    InputStream getDecodedContent() throws       byte[] getDecodedContent() throws
       MessageFormatException;                       MessageFormatException;

    void setContent(InputStream content);    }
    void setDecodedContent(InputStream
        content) throws                      public interface MutableBufferedMessage
        MessageFormatException;                 extends BufferedMessage,
                                                MutableMessageHeader {
}
                                                 void setContent(byte[] content);

                                                 void setDecodedContent(byte[] content)
                                                     throws MessageFormatException;

                                             }
Request
public interface RequestHeader extends MessageHeader {
    InetSocketAddress getTarget();
    boolean isSsl();
    String getMethod() throws MessageFormatException;
    String getResource() throws MessageFormatException;
    String getVersion() throws MessageFormatException;
}

public interface MutableRequestHeader extends RequestHeader,
   MutableMessageHeader {
    void setTarget(InetSocketAddress target);
    void setSsl(boolean ssl);
    void setMethod(String method) throws MessageFormatException;
    void setResource(String resource) throws MessageFormatException;
    void setVersion(String version) throws MessageFormatException;
}


                                    similar for Response
BufferedMessageInterceptor
enum Action { BUFFER, STREAM, IGNORE};

Action directRequest(MutableRequestHeader request);
void processRequest(MutableBufferedRequest request);
void requestContentSizeExceeded(BufferedRequest request, int size);
void requestStreamed(BufferedRequest request);

Action directResponse(RequestHeader request,
   MutableResponseHeader response)
void processResponse(RequestHeader request,
   MutableBufferedResponse response)
void responseContentSizeExceeded(RequestHeader request,
   ResponseHeader response, int size);
void responseStreamed(final RequestHeader request,
   BufferedResponse response);
Doing something useful
requestHandler = new DefaultHttpRequestHandler();
interceptor = new BufferedMessageInterceptor() {
     public Action directResponse(RequestHeader request,
        MutableResponseHeader response) {
        return Action.BUFFER;
     }
     public void processResponse(RequestHeader request,
        MutableBufferedResponse response) {
          try {
             System.out.println(request.getResource() + " : “ +
             response.getDecodedContent().length);
          } catch (MessageFormatException mfe) {
             mfe.printStackTrace();
          }
     }
};
requestHandler = new BufferingHttpRequestHandler(requestHandler,
    interceptor, 10240);
So what about SSL?
httpProxy = new HttpProxyConnectionHandler
  (requestHandler);
contextSelector = new
  DefaultServerContextSelector(“server.p12",
  password, password);
ssl = new SSLConnectionHandler(contextSelector,
  true, httpProxy);       // true -> autodetect SSL
httpProxy.setConnectHandler(ssl);
proxy = new Server(listen, httpProxy);
Bah! Untrusted Connections!
Per server certificates!
contextSelector = new
  AutoGeneratingContextSelector("keystore",
  "JKS", password);
Reverse Proxy

target = new InetSocketAddress(“example.com",
   80);
listen = new InetSocketAddress("localhost", 80);
proxy = new Proxy(listen, httpProxy, target);
and with SSL . . .

ssl = new SSLConnectionHandler(contextSelector,
   true, httpProxy);
target = new InetSocketAddress("www.fnb.co.za",
   443);
listen = new InetSocketAddress("localhost", 443);
proxy = new Proxy(listen, ssl, target);
How about SOCKS?

httpProxy = new HttpProxyConnectionHandler
  ( requestHandler);
socks = new SocksConnectionHandler(httpProxy,
  true);              // true -> autodetect SOCKS
proxy = new Server(listen, socks);
All together now!

httpProxy = new HttpProxyConnectionHandler
    (requestHandler);
contextSelector = new AutoGeneratingContextSelector
    (".keystore", "JKS", password);
ssl = new SSLConnectionHandler(contextSelector, true,
    httpProxy);
httpProxy.setConnectHandler(ssl);
listen = new InetSocketAddress("localhost", 8008);
socks = new SocksConnectionHandler(ssl, true);
proxy = new Server(listen, socks);
But SOCKS redirects
               EVERYTHING!
httpProxy = new HttpProxyConnectionHandler(requestHandler);
ssl = new SSLConnectionHandler(cs, true, httpProxy);
selector = new SelectiveConnectionHandler() {
     @Override
     public TargetedConnectionHandler getConnectionHandler
        (InetSocketAddress target) {
        if (target.getPort() == 80) return httpProxy;
        if (target.getPort() == 443) return ssl;
        return RELAY;
     }
};
httpProxy.setConnectHandler(selector);
socks = new SocksConnectionHandler(selector, true);
listen = new InetSocketAddress("localhost", 8008);
proxy = new Proxy(listen, socks, null);
Upstream proxies?
ProxySelector ps = new ProxySelector() {
    private Proxy direct = java.net.Proxy.NO_PROXY;
    private Proxy socks = new java.net.Proxy(Type.SOCKS, socksAddress);
    private Proxy http = new java.net.Proxy(Type.HTTP, httpAddress);
    private List<Proxy> proxies = Arrays.asList(socks, http, direct);

    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
      System.out.println("Proxy connection failed! " + ioe.getMessage());
    }

    public List<java.net.Proxy> select(URI uri) {
      return proxies;
    }
};
DefaultHttpRequestHandler requestHandler = new DefaultHttpRequestHandler
   ();
requestHandler.setProxySelector(ps);
Apache Jserv Protocol
requestHandler = new DefaultAJPRequestHandler
   ();
tomcat = new InetSocketAddress("tomcat", 8009);
requestHandler.setTarget(tomcat);
ajp = new AJPConnectionHandler
   (requestHandler);
listen = new InetSocketAddress("localhost", 8009);
proxy = new Server(listen, ajp);
HTTP -> AJP
requestHandler = new DefaultAJPRequestHandler
  ();
properties = new AJPProperties();
properties.setRemoteAddress(“127.0.0.1");
requestHandler.setProperties(properties);
tomcat = new InetSocketAddress("tomcat", 8009);
requestHandler.setTarget(tomcat);
httpProxy = new HttpProxyConnectionHandler
  (requestHandler);
Other features
•  JDBC interface for saving conversations

•  “Web Service” HttpRequestHandler to
   expose history

•  LoggingHttpRequestHandler does CLF
   logging
Resources
•  http://dawes.za.net/gitweb.cgi

•  git clone http://dawes.za.net/rogan/owasp-
   proxy/owasp-proxy.git/

•  owasp-proxy@lists.owasp.org
Questions?




rogan@dawes.za.net

More Related Content

What's hot

Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL SchemaSean Chittenden
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with nettyZauber
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaJon Moore
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talkLocaweb
 
Using ngx_lua in UPYUN
Using ngx_lua in UPYUNUsing ngx_lua in UPYUN
Using ngx_lua in UPYUNCong Zhang
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by pythonwonyong hwang
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use CasesFabrizio Farinacci
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHwebelement
 
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heureCréer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heureAmaury Bouchard
 
Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleAntonio Musarra
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Данил Иванов
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLitecharsbar
 
OpenSSH: keep your secrets safe
OpenSSH: keep your secrets safeOpenSSH: keep your secrets safe
OpenSSH: keep your secrets safeGiovanni Bechis
 

What's hot (20)

Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
 
Using ngx_lua in UPYUN
Using ngx_lua in UPYUNUsing ngx_lua in UPYUN
Using ngx_lua in UPYUN
 
Openssl
OpensslOpenssl
Openssl
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
Hack ASP.NET website
Hack ASP.NET websiteHack ASP.NET website
Hack ASP.NET website
 
Nginx-lua
Nginx-luaNginx-lua
Nginx-lua
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heureCréer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heure
 
Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per Oracle
 
Ajax basics
Ajax basicsAjax basics
Ajax basics
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
Java
JavaJava
Java
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
OpenSSH: keep your secrets safe
OpenSSH: keep your secrets safeOpenSSH: keep your secrets safe
OpenSSH: keep your secrets safe
 
SVN Hook
SVN HookSVN Hook
SVN Hook
 
Java NIO.2
Java NIO.2Java NIO.2
Java NIO.2
 

Viewers also liked

Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-introTal Be'ery
 
Fendley how secure is your e learning
Fendley how secure is your e learningFendley how secure is your e learning
Fendley how secure is your e learningBryan Fendley
 
Lesson 2 curriculum design arjay alteza
Lesson 2 curriculum design arjay altezaLesson 2 curriculum design arjay alteza
Lesson 2 curriculum design arjay altezaarjay alteza
 
Eric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core BankingEric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core BankingPositive Hack Days
 

Viewers also liked (7)

20100414 kgoon introducing_html5
20100414 kgoon introducing_html520100414 kgoon introducing_html5
20100414 kgoon introducing_html5
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-intro
 
Html5 security
Html5 securityHtml5 security
Html5 security
 
Fendley how secure is your e learning
Fendley how secure is your e learningFendley how secure is your e learning
Fendley how secure is your e learning
 
HTML5 Web Security
HTML5 Web SecurityHTML5 Web Security
HTML5 Web Security
 
Lesson 2 curriculum design arjay alteza
Lesson 2 curriculum design arjay altezaLesson 2 curriculum design arjay alteza
Lesson 2 curriculum design arjay alteza
 
Eric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core BankingEric Anklesaria. Secure SDLC - Core Banking
Eric Anklesaria. Secure SDLC - Core Banking
 

Similar to OWASP Proxy

Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfShaiAlmog1
 
Client server part 12
Client server part 12Client server part 12
Client server part 12fadlihulopi
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicIMC Institute
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsYakov Fain
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIEyal Vardi
 
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofitjSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofitjSession
 
Get Real: Adventures in realtime web apps
Get Real: Adventures in realtime web appsGet Real: Adventures in realtime web apps
Get Real: Adventures in realtime web appsdaviddemello
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 

Similar to OWASP Proxy (20)

Servlets
ServletsServlets
Servlets
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Client server part 12
Client server part 12Client server part 12
Client server part 12
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
Servlets intro
Servlets introServlets intro
Servlets intro
 
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofitjSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
 
servlets
servletsservlets
servlets
 
Get Real: Adventures in realtime web apps
Get Real: Adventures in realtime web appsGet Real: Adventures in realtime web apps
Get Real: Adventures in realtime web apps
 
cq_cxf_integration
cq_cxf_integrationcq_cxf_integration
cq_cxf_integration
 
Apache Beam de A à Z
 Apache Beam de A à Z Apache Beam de A à Z
Apache Beam de A à Z
 
ERRest
ERRestERRest
ERRest
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
java sockets
 java sockets java sockets
java sockets
 

More from Security B-Sides

Lord of the bing b-sides atl
Lord of the bing   b-sides atlLord of the bing   b-sides atl
Lord of the bing b-sides atlSecurity B-Sides
 
2010 07 BSidesLV Mobilizing The PCI Resistance 1c
2010 07 BSidesLV Mobilizing The PCI Resistance 1c 2010 07 BSidesLV Mobilizing The PCI Resistance 1c
2010 07 BSidesLV Mobilizing The PCI Resistance 1c Security B-Sides
 
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...Security B-Sides
 
Social Penetration - Mike Murray and Mike Bailey
Social Penetration - Mike Murray and Mike BaileySocial Penetration - Mike Murray and Mike Bailey
Social Penetration - Mike Murray and Mike BaileySecurity B-Sides
 
How really to prepare for a credit card compromise (PCI) forensics investigat...
How really to prepare for a credit card compromise (PCI) forensics investigat...How really to prepare for a credit card compromise (PCI) forensics investigat...
How really to prepare for a credit card compromise (PCI) forensics investigat...Security B-Sides
 
Risk Management - Time to blow it up and start over? - Alex Hutton
Risk Management - Time to blow it up and start over? - Alex HuttonRisk Management - Time to blow it up and start over? - Alex Hutton
Risk Management - Time to blow it up and start over? - Alex HuttonSecurity B-Sides
 
Security? Who cares! - Brett Hardin
Security? Who cares! - Brett HardinSecurity? Who cares! - Brett Hardin
Security? Who cares! - Brett HardinSecurity B-Sides
 
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...Security B-Sides
 
Computing Risk without Numbers: A Semantic Approach to Risk Metrics - Tim Ke...
Computing Risk without Numbers:  A Semantic Approach to Risk Metrics - Tim Ke...Computing Risk without Numbers:  A Semantic Approach to Risk Metrics - Tim Ke...
Computing Risk without Numbers: A Semantic Approach to Risk Metrics - Tim Ke...Security B-Sides
 
The Great Compliance Debate: No Child Left Behind or The Polio Vaccine
The Great Compliance Debate: No Child Left Behind or The Polio VaccineThe Great Compliance Debate: No Child Left Behind or The Polio Vaccine
The Great Compliance Debate: No Child Left Behind or The Polio VaccineSecurity B-Sides
 
Dominique Karg - Advanced Attack Detection using OpenSource tools
Dominique Karg - Advanced Attack Detection using OpenSource toolsDominique Karg - Advanced Attack Detection using OpenSource tools
Dominique Karg - Advanced Attack Detection using OpenSource toolsSecurity B-Sides
 
Enterprise Portals - Gateway to the Gold
Enterprise Portals - Gateway to the GoldEnterprise Portals - Gateway to the Gold
Enterprise Portals - Gateway to the GoldSecurity B-Sides
 
From fishing to phishing to ?
From fishing to phishing to ?From fishing to phishing to ?
From fishing to phishing to ?Security B-Sides
 
Getting punched in the face
Getting punched in the faceGetting punched in the face
Getting punched in the faceSecurity B-Sides
 
Smashing the stats for fun (and profit)
Smashing the stats for fun (and profit)Smashing the stats for fun (and profit)
Smashing the stats for fun (and profit)Security B-Sides
 

More from Security B-Sides (20)

Lord of the bing b-sides atl
Lord of the bing   b-sides atlLord of the bing   b-sides atl
Lord of the bing b-sides atl
 
The road to hell v0.6
The road to hell v0.6The road to hell v0.6
The road to hell v0.6
 
2010 07 BSidesLV Mobilizing The PCI Resistance 1c
2010 07 BSidesLV Mobilizing The PCI Resistance 1c 2010 07 BSidesLV Mobilizing The PCI Resistance 1c
2010 07 BSidesLV Mobilizing The PCI Resistance 1c
 
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...
Tastes Great vs Less Filling: Deconstructing Risk Management (A Practical App...
 
Social Penetration - Mike Murray and Mike Bailey
Social Penetration - Mike Murray and Mike BaileySocial Penetration - Mike Murray and Mike Bailey
Social Penetration - Mike Murray and Mike Bailey
 
How really to prepare for a credit card compromise (PCI) forensics investigat...
How really to prepare for a credit card compromise (PCI) forensics investigat...How really to prepare for a credit card compromise (PCI) forensics investigat...
How really to prepare for a credit card compromise (PCI) forensics investigat...
 
Risk Management - Time to blow it up and start over? - Alex Hutton
Risk Management - Time to blow it up and start over? - Alex HuttonRisk Management - Time to blow it up and start over? - Alex Hutton
Risk Management - Time to blow it up and start over? - Alex Hutton
 
Security? Who cares! - Brett Hardin
Security? Who cares! - Brett HardinSecurity? Who cares! - Brett Hardin
Security? Who cares! - Brett Hardin
 
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...
Advanced Persistent Threats (Shining the Light on the Industries' Best Kept S...
 
Computing Risk without Numbers: A Semantic Approach to Risk Metrics - Tim Ke...
Computing Risk without Numbers:  A Semantic Approach to Risk Metrics - Tim Ke...Computing Risk without Numbers:  A Semantic Approach to Risk Metrics - Tim Ke...
Computing Risk without Numbers: A Semantic Approach to Risk Metrics - Tim Ke...
 
The Great Compliance Debate: No Child Left Behind or The Polio Vaccine
The Great Compliance Debate: No Child Left Behind or The Polio VaccineThe Great Compliance Debate: No Child Left Behind or The Polio Vaccine
The Great Compliance Debate: No Child Left Behind or The Polio Vaccine
 
Dominique Karg - Advanced Attack Detection using OpenSource tools
Dominique Karg - Advanced Attack Detection using OpenSource toolsDominique Karg - Advanced Attack Detection using OpenSource tools
Dominique Karg - Advanced Attack Detection using OpenSource tools
 
2009 Zacon Haroon Meer
2009 Zacon  Haroon  Meer2009 Zacon  Haroon  Meer
2009 Zacon Haroon Meer
 
Enterprise Portals - Gateway to the Gold
Enterprise Portals - Gateway to the GoldEnterprise Portals - Gateway to the Gold
Enterprise Portals - Gateway to the Gold
 
From fishing to phishing to ?
From fishing to phishing to ?From fishing to phishing to ?
From fishing to phishing to ?
 
Getting punched in the face
Getting punched in the faceGetting punched in the face
Getting punched in the face
 
Make Tea Not War
Make Tea Not WarMake Tea Not War
Make Tea Not War
 
Smashing the stats for fun (and profit)
Smashing the stats for fun (and profit)Smashing the stats for fun (and profit)
Smashing the stats for fun (and profit)
 
Exploitation
ExploitationExploitation
Exploitation
 
Layer 2 Hackery
Layer 2 HackeryLayer 2 Hackery
Layer 2 Hackery
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

OWASP Proxy

  • 1. OWASP Proxy An intercepting proxy library, so you don’t have to
  • 2. Background •  OWASP WebScarab •  OWASP WebScarab-NG •  OWASP CSRFTester $ unzip -l CSRFTester-1.0-src.zip | grep java | grep webscarab | wc -l 75
  • 3. What good is this? •  Allows visibility into communications •  Allows modification of communications •  Invisible to client and server
  • 4. Features •  Flexible –  compose your own proxy •  Binary clean –  squeaky clean! •  Performant –  streams as much as possible –  buffers only what you tell it to •  Multi-protocol –  Mostly HTTP-related currently
  • 5. The Simplest Proxy requestHandler = new DefaultHttpRequestHandler (); httpProxy = new HttpProxyConnectionHandler (requestHandler); listen = new InetSocketAddress("localhost", 8008); proxy = new Server(listen, httpProxy); proxy.start(); … isn’t very useful
  • 6. Message Object Model public interface MessageHeader { byte[] getHeader(); String getStartLine() throws MessageFormatException; NamedValue[] getHeaders() throws MessageFormatException; String getHeader(String name) throws MessageFormatException; } public interface MutableMessageHeader { void setHeader(byte[] header); void setStartLine(String line) throws MessageFormatException; void setHeaders(NamedValue[] headers) throws MessageFormatException; void setHeader(String name, String value) throws MessageFormatException; void addHeader(String name, String value) throws } MessageFormatException; String deleteHeader(String name) throws MessageFormatException;
  • 7. Message Content public interface StreamingMessage public interface BufferedMessage extends extends MutableMessageHeader { MessageHeader { InputStream getContent(); byte[] getContent(); InputStream getDecodedContent() throws byte[] getDecodedContent() throws MessageFormatException; MessageFormatException; void setContent(InputStream content); } void setDecodedContent(InputStream content) throws public interface MutableBufferedMessage MessageFormatException; extends BufferedMessage, MutableMessageHeader { } void setContent(byte[] content); void setDecodedContent(byte[] content) throws MessageFormatException; }
  • 8. Request public interface RequestHeader extends MessageHeader { InetSocketAddress getTarget(); boolean isSsl(); String getMethod() throws MessageFormatException; String getResource() throws MessageFormatException; String getVersion() throws MessageFormatException; } public interface MutableRequestHeader extends RequestHeader, MutableMessageHeader { void setTarget(InetSocketAddress target); void setSsl(boolean ssl); void setMethod(String method) throws MessageFormatException; void setResource(String resource) throws MessageFormatException; void setVersion(String version) throws MessageFormatException; } similar for Response
  • 9. BufferedMessageInterceptor enum Action { BUFFER, STREAM, IGNORE}; Action directRequest(MutableRequestHeader request); void processRequest(MutableBufferedRequest request); void requestContentSizeExceeded(BufferedRequest request, int size); void requestStreamed(BufferedRequest request); Action directResponse(RequestHeader request, MutableResponseHeader response) void processResponse(RequestHeader request, MutableBufferedResponse response) void responseContentSizeExceeded(RequestHeader request, ResponseHeader response, int size); void responseStreamed(final RequestHeader request, BufferedResponse response);
  • 10. Doing something useful requestHandler = new DefaultHttpRequestHandler(); interceptor = new BufferedMessageInterceptor() { public Action directResponse(RequestHeader request, MutableResponseHeader response) { return Action.BUFFER; } public void processResponse(RequestHeader request, MutableBufferedResponse response) { try { System.out.println(request.getResource() + " : “ + response.getDecodedContent().length); } catch (MessageFormatException mfe) { mfe.printStackTrace(); } } }; requestHandler = new BufferingHttpRequestHandler(requestHandler, interceptor, 10240);
  • 11. So what about SSL? httpProxy = new HttpProxyConnectionHandler (requestHandler); contextSelector = new DefaultServerContextSelector(“server.p12", password, password); ssl = new SSLConnectionHandler(contextSelector, true, httpProxy); // true -> autodetect SSL httpProxy.setConnectHandler(ssl); proxy = new Server(listen, httpProxy);
  • 13. Per server certificates! contextSelector = new AutoGeneratingContextSelector("keystore", "JKS", password);
  • 14. Reverse Proxy target = new InetSocketAddress(“example.com", 80); listen = new InetSocketAddress("localhost", 80); proxy = new Proxy(listen, httpProxy, target);
  • 15. and with SSL . . . ssl = new SSLConnectionHandler(contextSelector, true, httpProxy); target = new InetSocketAddress("www.fnb.co.za", 443); listen = new InetSocketAddress("localhost", 443); proxy = new Proxy(listen, ssl, target);
  • 16. How about SOCKS? httpProxy = new HttpProxyConnectionHandler ( requestHandler); socks = new SocksConnectionHandler(httpProxy, true); // true -> autodetect SOCKS proxy = new Server(listen, socks);
  • 17. All together now! httpProxy = new HttpProxyConnectionHandler (requestHandler); contextSelector = new AutoGeneratingContextSelector (".keystore", "JKS", password); ssl = new SSLConnectionHandler(contextSelector, true, httpProxy); httpProxy.setConnectHandler(ssl); listen = new InetSocketAddress("localhost", 8008); socks = new SocksConnectionHandler(ssl, true); proxy = new Server(listen, socks);
  • 18. But SOCKS redirects EVERYTHING! httpProxy = new HttpProxyConnectionHandler(requestHandler); ssl = new SSLConnectionHandler(cs, true, httpProxy); selector = new SelectiveConnectionHandler() { @Override public TargetedConnectionHandler getConnectionHandler (InetSocketAddress target) { if (target.getPort() == 80) return httpProxy; if (target.getPort() == 443) return ssl; return RELAY; } }; httpProxy.setConnectHandler(selector); socks = new SocksConnectionHandler(selector, true); listen = new InetSocketAddress("localhost", 8008); proxy = new Proxy(listen, socks, null);
  • 19. Upstream proxies? ProxySelector ps = new ProxySelector() { private Proxy direct = java.net.Proxy.NO_PROXY; private Proxy socks = new java.net.Proxy(Type.SOCKS, socksAddress); private Proxy http = new java.net.Proxy(Type.HTTP, httpAddress); private List<Proxy> proxies = Arrays.asList(socks, http, direct); public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { System.out.println("Proxy connection failed! " + ioe.getMessage()); } public List<java.net.Proxy> select(URI uri) { return proxies; } }; DefaultHttpRequestHandler requestHandler = new DefaultHttpRequestHandler (); requestHandler.setProxySelector(ps);
  • 20. Apache Jserv Protocol requestHandler = new DefaultAJPRequestHandler (); tomcat = new InetSocketAddress("tomcat", 8009); requestHandler.setTarget(tomcat); ajp = new AJPConnectionHandler (requestHandler); listen = new InetSocketAddress("localhost", 8009); proxy = new Server(listen, ajp);
  • 21. HTTP -> AJP requestHandler = new DefaultAJPRequestHandler (); properties = new AJPProperties(); properties.setRemoteAddress(“127.0.0.1"); requestHandler.setProperties(properties); tomcat = new InetSocketAddress("tomcat", 8009); requestHandler.setTarget(tomcat); httpProxy = new HttpProxyConnectionHandler (requestHandler);
  • 22. Other features •  JDBC interface for saving conversations •  “Web Service” HttpRequestHandler to expose history •  LoggingHttpRequestHandler does CLF logging
  • 23. Resources •  http://dawes.za.net/gitweb.cgi •  git clone http://dawes.za.net/rogan/owasp- proxy/owasp-proxy.git/ •  owasp-proxy@lists.owasp.org