Can mitmproxy log 'TLS Client Hello' & 'TLS Server Hello' messages? - ssl

Mitmproxy logs the http and https requests and responses from a device that is under the proxy. Http/https is on the Application layer in the OSI model, I was wondering if mitmproxy can log 'TLS Client Hello' and 'TLS Server Hello' messages - is there an option? TLS is not in the application layer so I think it is not logged in any manner by mitmproxy. Can experts please confirm my understanding?

Related

Wireshark not receiving Certificate packet from server

I'm using Wireshark to analyse network traffic for a TLS request. I can filter the request based on the website IP address and I can see things like TCP session setup (3-way handshake), client hello, server hello, etc. Based on my understanding I should be receiving a "certificate" packet from the server after the 'Server Hello' where I can see the website certificate as well as any intermediate certificates... but unfortunately I'm not receiving a "certificate" packet...
I've tried this on Windows (Wireshark version Version 3.6.6) and Ubuntu 20.04 (Wireshark version 3.2.3) and it's the same for both.
Should I be receiving a certificate packet? If so, any clues as to why I'm not seeing it?

How to know if SSL established at HAProxy level on app level?

I have an HAProxy instance that is available from the web, and redirects incoming requests to my local app.
The communication between the client and my HAProxy can be secured via ssl but not necessarily, and I need to know at my application level if the communication is secure or not.
Unfortunately, from my understanding, the communication I get in my app is already "decrypted" from all the SSL communications, HAProxy handling the "SSL wrapping".
Is there a way to know for sure that the client is using SSL/TLS or no?
Thank you in advance.
Update The communication is not HTTP but TCP at HAProxy.
This is the purpose of the X-Forwarded-Proto.
You can make HAProxy insert that header if ssl traffic was decrypted by HAProxy:
http-request set-header X-Forwarded-Proto https if { ssl_fc }
Then your application will just have to check the X-Forwarded-Proto.

SSL load balancing and client ip

Context
debian 64bits.
I try to learn https. I created a loadbalancer but I cannot answer tthe client directly from the backend since it receive the LB ip.
Question
I would like to know how I could achieve the following with ssl connection:
client -------> loadbalancer Level4 -----> 3 backends (ssl termination) -----> Back to client
The goal is to avoid decrypting on the loadbalancer but still be able to send the requests to each of the backend servers, decrypt there and send back to client directly.
Any way to make it happen ?

How to make Socks request over http proxy?

I have built an application called Tun2Socks GUI. It's program to make Socks proxy o be transparent.
Usually it use SSH port forward or TOR as SOCKS service, but I want it can use HTTP proxy too. So I build SOCKS5 proxy my self that connect to that HTTP proxy. It's working good with capturing HTTP request from client to be sent to HTTP Proxy.
The problem when the client send SSL request, I cannot capture the request to be forwarded. How the best method to make SSL request from SOCKS proxy through HTTP Proxy?
Schema of request transportation like here :
Client SSL request > SOCKS Proxy > HTTP Proxy > Internet
Thanks
When a client intentionally wants to establish an SSL session with a target server through a proxy, it does not establish an SSL session with the proxy itself. The client first tells the proxy to establish a connection to the target server, and THEN the client initiates an SSL session with the target server. In that situation, it is not possible for the proxy to sniff the traffic as it is encrypted, nor should it be trying to. A proxy is just a pass-through, it exchanges raw data back and forth between client and server as needed. The proxy should not care what kind of requests the client is sending, since the client tells the proxy where to connect.
If you have injected your proxy in between the client and server in such a way that the client has no knowledge that your proxy exists, the client will not know that it needs to adjust its requests to make them proxy-friendly. The client will be connected to your proxy but it will think it is connected to the target server, and thus will initiate an SSL handshake that your proxy will have to respond to. Only then will your proxy have access to the client's request data (provided the handshake is successful, such as if the client does not verify peer certificates), and can then tunnel the unencrypted data to the next proxy as needed.
Update: I just thought of another scenario that should work for both cleartext and SSL connections. Regardless of whether you are transparently redirecting the client's outbound connection to your SOCKS proxy without the client knowing about it, or the client intentionally connects to the SOCKS proxy and tells it where to go, the SOCKS proxy knows the client's target host/IP:port. The SOCKS proxy can either connect directly to the target, or it can connect to the HTTP proxy and ask it to create a tunnel to the target via the HTTP CONNECT method. If successful, the client has a viable connection to the target, and any data the client sends, SSL or otherwise, will flow as-is to the target, and vice versa. Neither the SOCKS proxy nor the HTTP proxy needs to know anything about the client's request other than the target host/IP:port. That is in the initial SOCKS request, either captured from the intercepted TCP header, or explicit from the client.

HTTPS Web(only)Proxy

I just read over node-tls-proxy (http://code.google.com/p/node-tls-proxy/), a https proxy. I like the idea of it, but I'm not getting why this proxy needs a local http server (see the local-proxy.js script).
So I was wondering if this is necessary?
My idea of the proxy was actually like this: Client -> HTTPS Connection to trusted Server/Proxy -> Internets
In this case network sniffing between the Client and the Server wouldn't (hardly) be possible because it would be ssl encrypted.
Thanks,
Seb
If I get the idea correctly, the goal is to set up a "remote" proxy in a location that one trusts to be secure. Your client shall only communicate with this remote proxy using TLS, the remote proxy is then allowed to do the actual (no longer encrypted) HTTP requests.
What you do on the client side now is this: you configure the "local" proxy in your browser. Since you type "http://..." in your browser even when using the proxy, your browser will initiate an unencrypted HTTP connection to the local proxy first. Then the local proxy will open an encrypted TLS connection to the remote proxy and forward your request over a secured channel.
This means you need the local proxy for the purpose of "transforming" HTTP into HTTPS requests because your browser will dutifully only use HTTP when asked to make an actual HTTP request.