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

Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
webelement
 
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
Antonio Musarra
 

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 (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

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

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
 
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
 
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
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

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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