This commit is contained in:
Freya Murphy 2024-05-24 09:05:42 -04:00
commit c5f39ea2cd
Signed by: freya
GPG key ID: 744AB800E383AE52
128 changed files with 8555 additions and 0 deletions

4
.dockerignore Normal file
View file

@ -0,0 +1,4 @@
.git
.gitignore
deployments
target

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
src/public/css/*.css
data

428
LICENSE Normal file
View file

@ -0,0 +1,428 @@
Attribution-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-ShareAlike 4.0 International Public
License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-ShareAlike 4.0 International Public License ("Public
License"). To the extent this Public License may be interpreted as a
contract, You are granted the Licensed Rights in consideration of Your
acceptance of these terms and conditions, and the Licensor grants You
such rights in consideration of benefits the Licensor receives from
making the Licensed Material available under these terms and
conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.

22
Makefile Normal file
View file

@ -0,0 +1,22 @@
MIXINS = $(shell find src/scss -name "_*.scss")
SCSS = $(shell find src/scss -name "*.scss" -not -name "_*")
CSS = $(patsubst src/scss/%.scss,src/public/css/%.css,$(SCSS))
.PHONY: all css dir clean
css: dir $(CSS)
dir:
@mkdir -p src/public/css
clean:
@printf "\033[31m RM \033[0m%s\n" src/public/css
@rm -f src/public/css/*.css
all: clean css
$(CSS): src/public/css/%.css : src/scss/%.scss $(MIXINS)
@printf "\033[33m SCSS \033[0m%s\n" $<
@sassc --style compressed $< $@

21
build/init/Dockerfile Normal file
View file

@ -0,0 +1,21 @@
FROM alpine:3.19
# install packages
RUN apk add --no-cache postgresql16-client tini shadow
RUN rm -fr /var/cache/apk/*
# setup main user
RUN adduser -D init
RUN groupmod --gid 1000 init
RUN usermod --uid 1000 init
# copy scripts
COPY ./init /usr/local/bin/init
# remove build packages
RUN apk del shadow
# do the
USER init
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/local/bin/init"]

108
build/init/init Executable file
View file

@ -0,0 +1,108 @@
#!/bin/sh
errors=$(mktemp)
step() {
printf '\x1b[34;1m>> %s\x1b[0m\n' "$*"
}
error() {
{
printf '\x1b[31;1merror: \x1b[0m%s\n' "$*";
grep -v 'current transaction is aborted' < "$errors";
printf "\x1b[31m;1error: \x1b[0mAborting migrations, fix file(s) then restart process.";
} 1>&2;
}
try() {
"$@" 2> "$errors";
count=$(grep -c 'ERROR' < "$errors")
if [ "$count" -eq 0 ]; then
return 0;
else
return 1;
fi
}
export PGPASSWORD="$POSTGRES_PASSWORD"
psql() {
/usr/bin/psql \
-h db \
-p 5432 \
-d "$POSTGRES_DB" \
-U "$POSTGRES_USER" \
"$@"
}
pg_isready() {
/usr/bin/pg_isready \
-h db \
-p 5432 \
-d "$POSTGRES_DB" \
-U "$POSTGRES_USER"
}
curr_revision() {
psql -qtAX -f /db/rev.sql;
}
wait_until_ready() {
step 'Checking if the database is ready...';
while true; do
pg_isready;
code=$?;
if [ $code -eq 0 ]; then
break;
fi
sleep 3;
done
}
run_migrations() {
i="$1"
while true; do
name=$(printf "%04d" "$i");
file="/db/migrations/$name.sql"
if [ -f "$file" ]; then
if try psql -f "$file"; then
i=$((i+1));
continue;
else
error "An error occoured during a migration (rev $name)"
return 1;
fi
else
return 0;
fi
done
}
init () {
# reomve ready status
# so php ignores requests
rm -f /status/ready
step 'Waiting for database';
# make sure the database is running
# before we run any requests
wait_until_ready;
step 'Database ready';
step 'Peforming migrations';
# get the current revision
REV=$(curr_revision);
step "Database at revision: $REV"
# run each migration that is
# higher than our current revision
if ! run_migrations "$REV"; then
return 1;
fi
step 'Database is initialized'
# database is ready
touch /status/ready
}
init
rm "$errors"

21
build/nginx/Dockerfile Normal file
View file

@ -0,0 +1,21 @@
FROM alpine:3.19
# install packages
RUN apk add --no-cache nginx shadow tini
RUN rm -fr /var/cache/apk/*
# update nginx user
RUN groupmod --gid 1000 nginx
RUN usermod --uid 1000 nginx
# remove build packages
RUN apk del shadow
# make log syms
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
# do the
USER nginx
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]

17
build/php/Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM php:fpm-alpine
# install packages
RUN apk add --no-cache postgresql-dev runuser shadow
RUN rm -fr /var/cache/apk/*
# update php user
RUN groupmod --gid 1000 www-data
RUN usermod --uid 1000 www-data
# install php packages
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install pdo pdo_pgsql
# remove build packages
RUN apk del shadow
USER www-data

21
build/postgres/Dockerfile Normal file
View file

@ -0,0 +1,21 @@
FROM postgres:16-alpine
# install packages
RUN apk add --no-cache make git shadow
RUN rm -fr /var/cache/apk/*
# install pgjwt
RUN git clone https://github.com/michelp/pgjwt.git /tmp/pgjwt
WORKDIR /tmp/pgjwt
RUN make install
# update postgres user
RUN groupmod --gid 1000 postgres
RUN usermod --uid 1000 postgres
# remove build packages
RUN apk del make git shadow
# fix workdir
WORKDIR /
USER postgres

50
conf/nginx/nginx.conf Normal file
View file

@ -0,0 +1,50 @@
worker_processes 4;
daemon off;
pid /tmp/nginx.pid;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 70;
server_tokens off;
client_max_body_size 2m;
access_log /var/log/nginx/access.log;
server {
listen 8080;
root /opt/website;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon;
location /favicon.ico {
add_header Cache-Control "public, max-age=31536000, immutable";
root /opt/website/public/icons;
}
location /public {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
location / {
add_header Content-Security-Policy "script-src 'none'; object-src 'none'; base-uri 'none'";
root /opt/website/web;
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
}
}

View file

@ -0,0 +1,3 @@
POSTGRES_USER=website
POSTGRES_PASSWORD=cannothackme
POSTGRES_DB=website

43
docker-compose.yml Normal file
View file

@ -0,0 +1,43 @@
services:
web:
build: ./build/nginx
restart: unless-stopped
ports:
- '80:8080'
volumes:
- ./src:/opt/website:ro
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- php
php:
build: ./build/php
restart: unless-stopped
env_file:
- ./conf/postgres/database.env
volumes:
- ./src:/opt/website:ro
- ./data/status:/status:ro
depends_on:
- db
db:
build: ./build/postgres
restart: unless-stopped
env_file:
- ./conf/postgres/database.env
environment:
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
volumes:
- './data/schemas:/var/lib/postgresql/data'
- ./src/db:/db:ro
init:
build: ./build/init
env_file:
- ./conf/postgres/database.env
volumes:
- ./src/db:/db:ro
- ./data/status:/status
depends_on:
- db

View file

@ -0,0 +1,18 @@
---
name: Vaultwarden
date: 2023-02-23T18:00:00.000-04:00
desc: Hosting your own password manager is cool
---
### LastPass
Hopefully we all know of the semi-recent LastPass breach, where a lot of customers had their encrypted vaults leaked. They were still encrypted, but your passwords were now possibly out there. My vault was also sadly leaked as well. Also, I don't know why I used LastPass in the first place, since I pretty much just used the same password over and over again anyways.
### Other Options?
Well I could just keep using the same password over and over again, but we all know that is *really* not a good idea. Also that password has been in like 5 different breaches, so it was time I actually cared.
I decided to self host my own password manager, [Vaultwarden](https://hub.docker.com/r/vaultwarden/server), an unofficial Bitwarden server written in Rust. I chose it because my Hetzner server only has 2GB of RAM and only 2 VCPUs, therefore I don't really have the resources to spare. And I also chose self host since It's really easy to setup, and I don't have to worry about breaches.
### Here Is How Its Been
Vaultwarden only uses about 25MB of RAM for me, which is a really small amount. The server uses the Bitwarden API so I can use any of the very well built Bitwarden clients, and they sync together flawlessly. It also supports TOTP, therefore I no longer have to use Authy, a proprietary service, to manage my 2FA. Even in the rare chance that my server goes down, the clients store an encrypted version of the vault locally, so I will never loose my passwords.
Overall, it was really easy to set up in docker, and everything has been smooth. So if you are looking at self hosting a password manager, look at Vaultwarden.

View file

@ -0,0 +1,74 @@
---
name: IntraNet
date: 2023-09-28T10:00:00.000-04:00
desc: Securing my network
---
### IntraNet
*So what is even a IntraNet?* Well, it's an inernal network of computers contained from the outside network.
They can be used to host services, software, applications, and more, but not give access to the outside world. If you can connect
to a service from any public ip, we say thats on the public internet. Even if the application is secured, and it's open to the public going....
> Hey i exist!!!!
...anyone can access it. We all have herd of the times when companies internal services were accidentally made publically available to the outside web, and
then how they end up getting pwned (im looking at you hospitals).
> But why would I want it?
Well the main reason is it seemed fun. I like to do new things at times, and It seemed like a cool project. Also I want very
keen on keeping many of my internal services public. Yes they were secured by single sign, and ip whitelisted, but I really didnt feel like anyone
should be able to send any http request to my nextcloud instance, or any other service im running. Also whitelisting IPs was very annoying.
Ive already seen what can happen to mail servers (foreshadowing), so Id like to keep as much stuff internal that I possibly can.
### Network Architecture and Design
> Well how does it work?!
Well its fairly simple. I run a dual DNS setup, my own CA, and wireguard to add the ability to vpn into the network.
First, I run Bind on my network which runs as my internal DNS server. This reroutes any domain name under "in.freya.cat" to the device on the network that is hosting
that service. For example "cloud.in.freya.cat" is routed to my server that is running my internal Nextcloud instance. Now If I was right, you might of just tried to access
my nextcloud, but instead you should of gotten something that says ACCESS DENIED!
You have been blocked! Haha. This is where the 2nd DNS comes in. Since my domain is registered through cloudflare, any DNS request gets routed to my Hetzner VPS which acts as
a public sinkhole for my entire internal network. If you try accessing any of my services, you cant. Instead of getting the right ip, you get hetzner. And even if you knew the ip,
it wouldn't matter since they are LAN ips and arent even port forwarded outside my network. This is also why I use wireguard, as It allows me to vpn into my network and access my
services even while im away from home.
### Network Routing
Ok so thats cool and all but how do you even route your traffic?
At first, I just created IPs using the wireguard configs, and then had /etc/local.d start scripts that would `wg-quick up` on computer startup. This worked, but it made routing traffic
really hard. It was fine when I only had two servers, my VPS and my house, but as soon as I started to try to add more servers, everything fell apart. This is because in the Allowed IPs
section of a config, you have to set what IPs are routed though that wireguard interface. So if one sever adds another server I can talk too, every other server has to manually update what
they route to that server. For eaxample if Server A was talking to only Server B, but Server B could talk to Server C, Server A would have to put that Server B gets all traffic for Server B and C.
So I needed a solution to automatically generate route, beacuse doing it manually wasnt going to cut it anymore.
### OSPF
Ah, yes, the solution is OSPF. OSPF, or Open Shortest Path First, is a protocol designed for this very purpose. Its mostly seen in companies (like ISPs) that run their own ASN (autonomous system),
because they have thousands of servers that all need to be able to route traffic to eachother. So the goal was to still use wireguard to pass the traffic though, but instead to run a OSPF daemon
over those wireguard tunnels to route my traffic! The solution was a piece of software called bird. Bird can do more than OSPF, it can also route protocols such as BGP, but that is outside of the
scope for this blog post. If bird is setup of every server that was a main routing hub for my internal network, all I would have to do is say what wireguard interfaces to route ontop of. This is beacuse
bird can automatically detect the IPs that you controll on your network, meaning that once it has all the serveres it can talk to, it will automatically start asking the other servers what IPs they control,
and those servers will do the same. This them cascaces over the entire connection tree, peering IP routes to anywhere on the network to every server. Once that is all done, bird just creates a iptables route
and all is done! Woohoo!!!
### Root CA?
You might of notices I briefly mentioned that I run my own Certificate Authority, but you may be asking why? Who does that? For what reason would you need to? And I totally agree with
you. I'd rather not host it if I didn't need it, but I do have a reason. Since all my internal domains are routed to my hetzner, my internal network cant complete ACME challenges. Since
it cannot complete ACME challenges, Lets Encrypt wont give me a certificate for my domain. So I decided to run my own cerficiate authority. Now I don't do anything crazy, I just run step-ca
inside of docker. This is great because since I use Caddy for my reverse proxy, Caddy can auto request new certificates from StepCA, and everything is automated. The only thing I have to do
is install my root certificate on my devices, for which I have three. And now I have https on my internal network!
### Overview
Overall, this setup allows me to run many services I want to internally. I can run my plex server, nextcloud, photo hosting with immich, sso with authentik, irc, document hosting,
file syncing with syncthing, and still more to list. And with my setup, no one besides me and who I let on my network can even deam about accessing my services. This increases my
security, and really was just a ton of fun to figure out and setup.
Though make sure to setup wireguard to not nat every network device or theoretically it will break dockers ip routing, and theoretically it will cause containers to see all ips as internal, and
theoretically services like mailcow, an email server, will not require authentication since its totally comming from mailcow, and theoretically your email server can become an open realy. Theoretically though.

View file

@ -0,0 +1,28 @@
---
name: Mastodon
date: 2023-11-03T10:29:40.000-04:00
desc: Joining the fediverse
---
### Mastodon
Hello, small blog post today.
I am prod to announce I have joined the fediverse!!
Well Im already on matrix, but this is like the first public instance open too.
#### Experiences
So as of writing this, I have only been hosting my own instance for 2 days now. It was a bit
annoying to setup (just a few docker containers and proxy shenanigans), but hey it works now!
The main gripe I currently have with activity pub so far is the lack of discovery and reading older events.
Currently you can only search for things that you are directly federated with. So for example, my server is federated with `lgbt.tech`, so I can search for things on there. Also I cant see older posts. If I go to anyone I follow, I can only see posts since I started federating with them. Any older posts require me to go to their mastodon (or anything that supports activity pub) instance.
A cool thing though that ive noticed is that activity pub allows federation outside mastodon. So far Ive only seen lemmy accounts, but I find that cool.
#### Long way to go
Overall, I think activity pub as a protocol has a long way to go. There are some things I wish where implemented, mainly things that matrix has. But overall its really cool, and Im going to continue to use it for the foreseeable future.
Cheers!

375
src/assets/profanity.txt Normal file
View file

@ -0,0 +1,375 @@
2g1c
2 girls 1 cup
acrotomophilia
alabama hot pocket
alaskan pipeline
anal
anilingus
anus
apeshit
arsehole
assmunch
auto erotic
autoerotic
babeland
baby batter
baby juice
ball gag
ball gravy
ball kicking
ball licking
ball sack
ball sucking
bangbros
bangbus
bareback
barely legal
barenaked
bastard
bastardo
bastinado
bdsm
beaner
beaners
beaver cleaver
beaver lips
beastiality
bestiality
big black
big breasts
big knockers
big tits
bimbos
birdlock
black cock
blonde action
blonde on blonde action
blowjob
blow job
blow your load
blue waffle
blumpkin
bollocks
bondage
boner
booty call
brown showers
brunette action
bukkake
bulldyke
bullet vibe
bullshit
bung hole
bunghole
busty
buttcheeks
butthole
camel toe
camgirl
camslut
camwhore
carpet muncher
carpetmuncher
chocolate rosebuds
cialis
circlejerk
cleveland steamer
clit
clitoris
clover clamps
clusterfuck
cock
cocks
coprolagnia
coprophilia
cornhole
creampie
cum
cumming
cumshot
cumshots
cunnilingus
cunt
darkie
date rape
daterape
deep throat
deepthroat
dendrophilia
dildo
dingleberry
dingleberries
dirty pillows
dirty sanchez
doggie style
doggiestyle
doggy style
doggystyle
dog style
dolcett
domination
dominatrix
dommes
donkey punch
double dong
double penetration
dp action
dry hump
dvda
eat my ass
ecchi
ejaculation
erotic
erotism
escort
eunuch
fag
faggot
fecal
felch
fellatio
feltch
female squirting
femdom
figging
fingerbang
fingering
fisting
foot fetish
footjob
frotting
fuck buttons
fucktards
fudge packer
fudgepacker
futanari
gangbang
gang bang
gay sex
genitals
giant cock
girl on
girl on top
girls gone wild
goatcx
goatse
god damn
gokkun
golden shower
goodpoop
goo girl
goregasm
grope
group sex
g-spot
guro
hand job
handjob
hard core
hardcore
hentai
homoerotic
honkey
hooker
horny
hot carl
hot chick
how to kill
how to murder
huge fat
humping
incest
intercourse
jack off
jail bait
jailbait
jelly donut
jerk off
jigaboo
jiggaboo
jiggerboo
jizz
juggs
kike
kinbaku
kinkster
kinky
knobbing
leather restraint
leather straight jacket
lemon party
livesex
lolita
lovemaking
make me come
male squirting
masturbate
masturbating
masturbation
menage a trois
milf
missionary position
mong
motherfucker
mound of venus
mr hands
muff diver
muffdiving
nambla
nawashi
negro
neonazi
nigga
nigger
nig nog
nimphomania
nipple
nipples
nsfw images
nude
nudity
nutten
nympho
nymphomania
octopussy
omorashi
one cup two girls
one guy one jar
orgasm
orgy
paedophile
paki
panties
panty
pedobear
pedophile
pegging
penis
phone sex
piece of shit
pikey
pissing
piss pig
pisspig
playboy
pleasure chest
pole smoker
ponyplay
poof
poon
poontang
punany
poop chute
poopchute
porn
porno
pornography
prince albert piercing
pthc
pubes
pussy
queaf
queef
quim
raghead
raging boner
rape
raping
rapist
rectum
reverse cowgirl
rimjob
rimming
rosy palm
rosy palm and her 5 sisters
rusty trombone
sadism
santorum
scat
schlong
scissoring
semen
sexcam
sexo
sexual
sexually
shaved beaver
shaved pussy
shemale
shibari
shitblimp
shota
shrimping
skeet
slanteye
slut
s&m
smut
snatch
snowballing
sodomize
sodomy
spastic
spic
splooge
splooge moose
spooge
spread legs
spunk
strap on
strapon
strappado
strip club
style doggy
suicide girls
sultry women
swastika
swinger
tainted love
taste my
tea bagging
threesome
throating
thumbzilla
tight white
tits
titties
titty
tongue in a
topless
tosser
towelhead
tranny
tribadism
tub girl
tubgirl
tushy
twat
twink
twinkie
two girls one cup
undressing
upskirt
urethra play
urophilia
vagina
venus mound
viagra
vibrator
violet wand
vorarephilia
voyeur
voyeurweb
voyuer
vulva
wank
wetback
wet dream
white power
whore
worldsex
wrapping men
wrinkled starfish
yellow showers
yiffy
zoophilia

View file

@ -0,0 +1,7 @@
---
name: minecraft vulkan
repo: minecraftVulkan
---
Minecraft Vulkan is a Minecraft clone I wrote in C++, and rendered using the Vulkan API.
It is procedurally generated, and uses multi threading to offload the generating and meshing to separate threads.

View file

@ -0,0 +1,8 @@
---
name: crab
repo: crab
---
Crab, a.k.a Cool Rust Authentication Binary, is a privilege escalation program for Linux systems written in rust.
It allows users to temporarily gain root privileges for what they need, given they are allowed to in the crab conf file.
It authenticates the current user with the PAM api built into Linux.

View file

@ -0,0 +1,9 @@
---
name: xssbook
repo: xssbook
---
xssbook is a website I created for xss scripting vulnerabilities.
It is a facebook clone, backend written in rust with axum, and the frontend made in html, css, and vanilla javascript.
The site work by failing to parse user input every step of the way, and renders it as direct html.
You can view my hosted version at [xssbook.com](https://xssbook.com).

View file

@ -0,0 +1,10 @@
---
name: brainfucked
repo: brainfucked
---
brainfucked is a brainfuck dialect that makes you manage your memory manually!
The original interpreter gives you a tape of 30,000 cells, while i only give you
as much as a pointer takes up on your system: 4 or 8 depending if your on a 32bit or 64bit system.
You can than allocate a new tape and then use that! Also brainfucked is tuing complete proven by
this amzing [proof](/blog/writeup?name=proof.md) that my friend [trimill](https://trimill.xyz) made.

View file

@ -0,0 +1,8 @@
---
name: wrapper
repo: wrapper
---
wrapper is a simple and lightweight DNS server written in C. It supports custom user defined records in a config files,
and it also supports a few custom build records for fun! For example, there is a CMD record that runs a command on the
host system, and returns the result as a TXT record! Read more on the readme!

View file

@ -0,0 +1,8 @@
---
name: wig
repo: wig
---
wig is a simple DNS client written in C. It supports all the important features as most DNS clients,
but displays its results in a simple and concise format without all the clutter. It gives you what
you want fast and simple.

View file

@ -0,0 +1,8 @@
---
name: lazysphere
repo: lazysphere
---
lazysphere is a gnu coreutils/busybox clone, supporting commands such as su,
rm (the french), and also (but not exluding) yes. Its written in C
with no dependencies because they are bad.

View file

@ -0,0 +1,9 @@
---
name: tuxman
repo: tuxman
---
tuxman is a recreation of the arcade multiplayer pacman battle game where pacman
have to avoid ghosts and each eachother to win! Its written in TypeScript (im sorry),
and fetures a full map editor with custom map support. It uses [rollback](https://git.tint.red/tint/rollback)
netcode, and you can play a hosted version at [freya.cat/pacbattle](https://freya.cat/pacbattle).

View file

@ -0,0 +1,7 @@
---
name: nbtvis
repo: nbtvis
---
nbtvis, a.k.a NBT visualizer, is a simple C program that can convert Minecraft Binary NBT, String NBT,
or JSON from one format from another.

View file

@ -0,0 +1,7 @@
---
name: corn
repo: corn
---
corn is a x86_64 operating system micro kernel implemented in C. It uses the multiboot bootloader standard, and suports BIOS and UEFI boot. For memory managment, it
supportes full paging, along with a physical and virtual memory allocator, and page allocating on first write. ACPI, PCI, graphics, and debugger support also exist.

View file

@ -0,0 +1,6 @@
---
name: matrix
repo: matrix
---
matrix is a fully featured expression based bytecode vm programming language. Implemented in Rust, it has its own lexer, parser, compiler, and vm runtime environment. Alogn with the base tooling, there is a included standard library that contains standard math, string, file, and system operations to make the language able to do more than simple number crunching. Matrix also contains a built in Repl with error checking, simple completion, and syntax highlighting.

View file

@ -0,0 +1,55 @@
---
name: Brainfucked
desc: trimills turing completeness proof for brainfucked
---
### Turing-completeness proof for Brainfucked
By producing an algorithm that can translate arbitrary Brainfuck programs into
Brainfucked, we prove that the latter must have computational class greater than
or equal to the former, thus proving that Brainfucked is Turing-complete.
Proof that Brainfucked is not of a greater computational class than Brainfuck is
left as an exercise to the reader.
Since Brainfucked tapes have a limited amount of memory, we will implement a
tape as a linked list. Each item in the linked list will be a tape of length
ten with the following structure:
- The first cell contains the item's value
- The second cell is 1 if the next item has already been allocated and 0 otherwise
- The remaining 8 cells are the pointer to the next item
The second byte is not strictly necessary, as we could just check whether the pointer
is null, however it makes the translation significantly easier.
First, we prefix the output program with `++++++++++*(`. Since the original tape is
only 8 bytes wide, we need to make a new one with a size of 10. `+`, `-`, `[`, `]`,
`.`, and `,` all translate to themselves.
`>` can be translated as `>-[>++++++++++*<+]+>(`. This will allocate the next tape
if it does not yet exist and then enter it.
First, consider the case where next tape has not yet been allocated. We decrement the
allocation marker cell, which wraps around to 255, allowing us to enter the loop. We
then allocate the next tape and increment the allocation marker back to 0. After exiting
the loop, it is incremented again to 1, signalling that the next tape is now allocated.
We can then enter the newly allocated tape. If the tape was already allocated, the loop
will never be entered and the marker will remain 1.
`<` can be translated as `)<<`. We exit the current tape and move back over to the data cell.
This proof only uses a subset of Brainfucked consisting of the characters `+-<>[]()*,.`.
One of `+` or `-` can be trivially eliminated by replacing it with 255 copies of the other.
Additionally, `,` and `.` are not required for Turing-completeness, as input can be encoded into
the initial tape configuration and output can be read off the tape once the program halts.
I conjecture that no smaller subset of Brainfucked is Turing-complete.
#### Example translation script (Lua)
```lua
src = io.read("*a")
src = src:gsub("%<", ")<<")
src = src:gsub("%>", ">-[>++++++++++*<+]+>(")
src = "++++++++++*(" .. src
io.write(src)
```

View file

@ -0,0 +1,89 @@
BEGIN TRANSACTION;
SET search_path = public;
-- Migration Start
CREATE SCHEMA sys;
ALTER SCHEMA sys OWNER TO website;
CREATE TABLE sys.database_info (
name TEXT DEFAULT ''::text NOT NULL,
curr_revision INTEGER DEFAULT 0 NOT NULL
);
ALTER TABLE ONLY sys.database_info
ADD CONSTRAINT database_info_pkey PRIMARY KEY (name);
ALTER TABLE sys.database_info OWNER TO website;
INSERT INTO sys.database_info
(name, curr_revision) VALUES (current_database(), 0);
CREATE SCHEMA admin;
ALTER SCHEMA admin OWNER TO website;
CREATE SEQUENCE sys.request_log_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TYPE admin.request_log_method_type AS ENUM (
'GET', 'HEAD', 'POST', 'PUT', 'DELETE',
'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'
);
CREATE TABLE admin.request_log (
id INTEGER DEFAULT nextval('sys.request_log_id_seq'::regclass) NOT NULL,
date TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp() NOT NULL,
ip INET NOT NULL,
method admin.request_log_method_type NOT NULL,
uri TEXT NOT NULL
);
ALTER TABLE admin.request_log OWNER TO website;
ALTER TABLE ONLY admin.request_log
ADD CONSTRAINT request_log_pkey PRIMARY KEY (id);
CREATE TABLE admin.banned (
ip INET NOT NULL,
date TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp() NOT NULL,
reason TEXT DEFAULT 'unspecified'::text NOT NULL
);
ALTER TABLE admin.banned OWNER TO website;
ALTER TABLE ONLY admin.banned
ADD CONSTRAINT banned_pkey PRIMARY KEY (ip);
CREATE SEQUENCE sys.comment_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE admin.comment (
id INTEGER DEFAULT nextval('sys.comment_id_seq'::regclass) NOT NULL,
author TEXT NOT NULL,
content TEXT NOT NULL,
page TEXT NOT NULL,
created TIMESTAMP WITH TIME ZONE DEFAULT clock_timestamp() NOT NULL,
ip INET NOT NULL,
vulgar BOOLEAN DEFAULT FALSE
);
ALTER TABLE admin.comment OWNER TO website;
ALTER TABLE ONLY admin.comment
ADD CONSTRAINT comment_pkey PRIMARY KEY (id);
-- Migration End;
-- Set Current Revision
UPDATE sys.database_info SET curr_revision = 1 WHERE name = current_database();
COMMIT TRANSACTION;

21
src/db/rev.sql Normal file
View file

@ -0,0 +1,21 @@
CREATE OR REPLACE FUNCTION curr_revision()
RETURNS INTEGER
LANGUAGE plpgsql VOLATILE
AS $BODY$
DECLARE
_revision INTEGER;
BEGIN
BEGIN
SELECT curr_revision INTO _revision
FROM sys.database_info
WHERE name = current_database();
RETURN _revision;
EXCEPTION WHEN OTHERS THEN
RETURN 0;
END;
END
$BODY$;
GRANT EXECUTE ON FUNCTION curr_revision() TO website;
SELECT curr_revision();

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
src/public/buttons/eyes.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
src/public/buttons/eyes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/public/buttons/vim.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/public/buttons/vim.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

BIN
src/public/buttons/vim.webp Normal file

Binary file not shown.