Commit graph

23 commits

Author SHA1 Message Date
Jonathan Hodgson
dd71d26245 Initial https proxy work
The proxy can now sit between a client and a https web server. It does
this by looking for a CONNECT request that conventional proxies use to
open a tunnel between a client and an https server. Instead of opening
an opaque tunnel, yaip immediately sends bacck a "connection
established" response. This tells the client (browser normally) to
proceed and initiate an HTTPS connection.

I use the host that was send in the connect request to set up a fake SSL
server. If we have seen the domain before, we re-use the certificate,
otherwise we generate a new one and sign it using YAIP's built in
certificate authority.

I still need to do work on forwarding the request upstream. This is my
next job. Currently, yaip responds with a valid response of "it worked".

```
$ curl https://example.com --cacert ~/.config/yaip/cert.pem
It worked
```

Notice, we don't get any certificate errors because we are telling curl
to trust the authority that yaip uses
2022-01-30 12:25:57 +00:00
Jonathan Hodgson
1beca38af6 Early SSL Certificates creation work done
Yaip is now able to generate simple SSL certificates for a given host.

I don't currently add any extensions to the certificates (such as
alternative names). When I get to testing it with a browser I'll see
what browsers require. However, I think I'll probably generate
certificates for each host, including sub domains, to make life easier
searching.

I've also added a util function to count lines in a file that was used
for testing some of the ssl functions.
2022-01-23 15:38:24 +00:00
Jonathan Hodgson
bb62ed3b1f Starts work on https as well as some moving about
I now start the listener in the main.c file rather than proxy given that
I didn't feel proxy was the right place if a normal (non-proxied)
request came in. webserver.{c,h} and proxy.{c,h} had some changes
relating to this.

The config changed slightly - we now create a folder in ~/.config/
called yaip. This is where certificates and so on will be stored along
with the user configuration

I created a helper function to get files inside this directory (it
changes based on xdg_config_home) and updated relevant tests.

In ssl.{c,h} I have started work. If they don't exist, the tool now
creates and stores a key and certificate for the CA that this tool will
need to pretend to be. I still need to write tests for this.
2022-01-20 16:53:35 +00:00
Jonathan Hodgson
6eaad263be Moves some logic out of proxy and into main
Also fixes some segfaults caused by trying to free memory that wasn't
allocated with strdup or malloc etc.

Fixes some tests
2022-01-19 12:56:11 +00:00
Jonathan Hodgson
8a5bfe9b36 Now working for simple, non-encrypted requests
making requests to something like example.com over a non-encrypted
connection now works. Binary files are unlikely to work at the moment
although I haven't tried. Also, non-encrypted doesn't work.

I have also changed a little about how tests work. Requests tests now
display much better.
2022-01-18 21:45:58 +00:00
Jonathan Hodgson
a91a264a7a Creates barebones server to respond
When the proxy is requested directly (without an host to pass the
request to), we want to respond with something.

In burp, you can download the certificate from here. In time, I'd like
this to do the same.

I'd also like the proxy server to be interacted with via an API - this
webserver will eventually deal with that as well although that is a
little way off.
2022-01-17 14:05:21 +00:00
Jonathan Hodgson
a3a48a841e Work on responses 2022-01-17 14:04:30 +00:00
Jonathan Hodgson
8912994e1d Work on requests 2022-01-17 14:03:34 +00:00
Jonathan Hodgson
d49e86faff Small tweaks to files 2022-01-10 09:41:37 +00:00
Jonathan Hodgson
0e53f180ad renames some things in config tests 2022-01-10 09:40:34 +00:00
Jonathan Hodgson
18d50ed7a6 Small changes to proxy 2022-01-10 09:39:39 +00:00
Jonathan Hodgson
62ab5ea68d adds -g flag to gcc 2022-01-10 09:39:01 +00:00
Jonathan Hodgson
48e3092317 Split out some stuff that is shared between request and response
I now have files with the infinitely imaginative names
requestrespons.{c,h,test.c}.
2022-01-10 09:36:18 +00:00
Jonathan Hodgson
0e2b9dae2b Work on requests
This commit adds tests for a request and the implementation.

The first line of a request should now be decoded correctly
2022-01-05 21:12:11 +00:00
Jonathan Hodgson
66d4702297 Deletes binary 2022-01-05 11:06:06 +00:00
Jonathan Hodgson
f392af92c3 Updates how config options are set on command line 2021-12-28 10:00:41 +00:00
Jonathan Hodgson
8bed39700e Adds a test for defaults and fixes bug relating to it 2021-12-28 01:34:50 +00:00
Jonathan Hodgson
e42705280c Add tests for config
I have started writing tests for the config functions. This has resulted
in a few changes to the config code (tests working I guess)

I have also added a special "all" config file which (as the name
suggests) runs all test suites

In the makefile I have added the compiled test files to the clean target
and added targets for building and running tests
2021-12-28 00:28:56 +00:00
Jonathan Hodgson
c046ac37a9 Adds µnit submodule for tests 2021-12-27 21:46:47 +00:00
Jonathan Hodgson
27ddc6ccd0 Adds gitignore 2021-12-27 21:46:18 +00:00
Jonathan Hodgson
f48a110429 I have made a start
I have done some work on opening a socket and waiting for a connection.
This can be read line by line and I have started a request struct that
it will accept.

Also started on some docs. Not much is yet working. I am going to start
learning µnit for unit tests:

https://nemequ.github.io/munit/
2021-12-27 21:43:11 +00:00
Jonathan Hodgson
4e17e706fa Adds readme 2021-12-21 21:15:46 +00:00
Jonathan Hodgson
7b8c86db59 Commit committed 2021-12-21 21:13:59 +00:00