forked from Drift/pvv-nixos-config
Compare commits
5 Commits
actions
...
setup-open
Author | SHA1 | Date | |
---|---|---|---|
07d9997fff
|
|||
fa843c4a59
|
|||
e07945d49c | |||
32885891fe | |||
a6196e67fe |
13
.gitea/workflows/eval.yml
Normal file
13
.gitea/workflows/eval.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: "Eval nix flake"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
jobs:
|
||||||
|
evals:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: apt-get update && apt-get -y install sudo
|
||||||
|
- uses: https://github.com/cachix/install-nix-action@v23
|
||||||
|
- run: echo -e "show-trace = true\nmax-jobs = auto\ntrusted-users = root\nexperimental-features = nix-command flakes\nbuild-users-group =" > /etc/nix/nix.conf
|
||||||
|
- run: nix flake check
|
@@ -1,28 +0,0 @@
|
|||||||
name: "Test"
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
jobs:
|
|
||||||
evals:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- run: apt-get update && apt-get -y install sudo
|
|
||||||
- uses: https://github.com/cachix/install-nix-action@v23
|
|
||||||
- run: echo -e "show-trace = true\nmax-jobs = auto\ntrusted-users = root\nexperimental-features = nix-command flakes\nbuild-users-group =" > /etc/nix/nix.conf
|
|
||||||
- run: nix flake check
|
|
||||||
builds:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- run: apt-get update && apt-get -y install sudo
|
|
||||||
- run: su node
|
|
||||||
- run: whoami
|
|
||||||
- uses: https://github.com/cachix/install-nix-action@v23
|
|
||||||
- run: echo -e "show-trace = true\nmax-jobs = auto\ntrusted-users = root\nexperimental-features = nix-command flakes\nbuild-users-group =" > /etc/nix/nix.conf
|
|
||||||
- run: nix build --keep-going .#nixosConfigurations.bekkalokk.config.system.build.toplevel || exit 0
|
|
||||||
# - run: nix build --keep-going .#nixosConfigurations.bicep.config.system.build.toplevel || exit 0
|
|
||||||
# - run: nix build --keep-going .#nixosConfigurations.brzeczyszczykiewicz.config.system.build.toplevel || exit 0
|
|
||||||
# - run: nix build --keep-going .#nixosConfigurations.georg.config.system.build.toplevel || exit 0
|
|
||||||
# - run: nix build --keep-going .#nixosConfigurations.ildkule.config.system.build.toplevel || exit 0
|
|
||||||
# - run: nix build --keep-going .#nixosConfigurations.shark.config.system.build.toplevel || exit 0
|
|
14
flake.nix
14
flake.nix
@@ -99,6 +99,20 @@
|
|||||||
inputs.grzegorz-clients.nixosModules.grzegorz-webui
|
inputs.grzegorz-clients.nixosModules.grzegorz-webui
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
grevling = stableNixosConfig "grevling" {
|
||||||
|
modules = [
|
||||||
|
./hosts/grevling/configuration.nix
|
||||||
|
sops-nix.nixosModules.sops
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
tuba = stableNixosConfig "grevling" {
|
||||||
|
modules = [
|
||||||
|
./hosts/tuba/configuration.nix
|
||||||
|
sops-nix.nixosModules.sops
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = forAllSystems (system: {
|
devShells = forAllSystems (system: {
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
../../base.nix
|
../../base.nix
|
||||||
../../misc/metrics-exporters.nix
|
../../misc/metrics-exporters.nix
|
||||||
|
../../modules/wackattack-ctf-stockfish
|
||||||
|
|
||||||
#./services/keycloak.nix
|
#./services/keycloak.nix
|
||||||
|
|
||||||
|
17
hosts/bicep/services/matrix/smtp-authenticator/default.nix
Normal file
17
hosts/bicep/services/matrix/smtp-authenticator/default.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{ lib, buildPythonPackage, fetchFromGitHub }:
|
||||||
|
|
||||||
|
buildPythonPackage rec {
|
||||||
|
pname = "matrix-synapse-smtp-auth";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "An SMTP auth provider for Synapse";
|
||||||
|
homepage = "pvv.ntnu.no";
|
||||||
|
license = licenses.agpl3Only;
|
||||||
|
maintainers = with maintainers; [ dandellion ];
|
||||||
|
};
|
||||||
|
}
|
11
hosts/bicep/services/matrix/smtp-authenticator/setup.py
Normal file
11
hosts/bicep/services/matrix/smtp-authenticator/setup.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="matrix-synapse-smtp-auth",
|
||||||
|
version="0.1.0",
|
||||||
|
py_modules=['smtp_auth_provider'],
|
||||||
|
author="Daniel Løvbrøtte Olsen",
|
||||||
|
author_email="danio@pvv.ntnu.no",
|
||||||
|
description="An SMTP auth provider for Synapse",
|
||||||
|
license="AGPL-3.0-only"
|
||||||
|
)
|
@@ -0,0 +1,45 @@
|
|||||||
|
from typing import Awaitable, Callable, Optional, Tuple
|
||||||
|
|
||||||
|
from smtplib import SMTP_SSL as SMTP
|
||||||
|
|
||||||
|
import synapse
|
||||||
|
from synapse import module_api
|
||||||
|
|
||||||
|
|
||||||
|
class SMTPAuthProvider:
|
||||||
|
def __init__(self, config: dict, api: module_api):
|
||||||
|
self.api = api
|
||||||
|
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
api.register_password_auth_provider_callbacks(
|
||||||
|
auth_checkers={
|
||||||
|
("m.login.password", ("password",)): self.check_pass,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
async def check_pass(
|
||||||
|
self,
|
||||||
|
username: str,
|
||||||
|
login_type: str,
|
||||||
|
login_dict: "synapse.module_api.JsonDict",
|
||||||
|
):
|
||||||
|
if login_type != "m.login.password":
|
||||||
|
return None
|
||||||
|
|
||||||
|
result = False
|
||||||
|
with SMTP(self.config["smtp_host"]) as smtp:
|
||||||
|
password = login_dict.get("password")
|
||||||
|
try:
|
||||||
|
smtp.login(username, password)
|
||||||
|
result = True
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if result == True:
|
||||||
|
userid = self.api.get_qualified_user_id(username)
|
||||||
|
if not self.api.check_user_exists(userid):
|
||||||
|
self.api.register_user(username)
|
||||||
|
return (userid, None)
|
||||||
|
else:
|
||||||
|
return None
|
@@ -22,9 +22,18 @@ in {
|
|||||||
group = config.users.users.matrix-synapse.group;
|
group = config.users.users.matrix-synapse.group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sops.secrets."matrix/sliding-sync/env" = {
|
||||||
|
sopsFile = ../../../../secrets/bicep/matrix.yaml;
|
||||||
|
key = "sliding-sync/env";
|
||||||
|
};
|
||||||
|
|
||||||
services.matrix-synapse-next = {
|
services.matrix-synapse-next = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
plugins = [
|
||||||
|
(pkgs.python3Packages.callPackage ./smtp-authenticator { })
|
||||||
|
];
|
||||||
|
|
||||||
dataDir = "/data/synapse";
|
dataDir = "/data/synapse";
|
||||||
|
|
||||||
workers.federationSenders = 2;
|
workers.federationSenders = 2;
|
||||||
@@ -34,6 +43,8 @@ in {
|
|||||||
workers.eventPersisters = 2;
|
workers.eventPersisters = 2;
|
||||||
workers.useUserDirectoryWorker = true;
|
workers.useUserDirectoryWorker = true;
|
||||||
|
|
||||||
|
enableSlidingSync = true;
|
||||||
|
|
||||||
enableNginx = true;
|
enableNginx = true;
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
@@ -81,7 +92,15 @@ in {
|
|||||||
enable_registration = false;
|
enable_registration = false;
|
||||||
registration_shared_secret_path = config.sops.secrets."matrix/synapse/user_registration".path;
|
registration_shared_secret_path = config.sops.secrets."matrix/synapse/user_registration".path;
|
||||||
|
|
||||||
password_config.enabled = lib.mkForce false;
|
password_config.enabled = true;
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
{ module = "smtp_auth_provider.SMTPAuthProvider";
|
||||||
|
config = {
|
||||||
|
smtp_host = "smtp.pvv.ntnu.no";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
trusted_key_servers = [
|
trusted_key_servers = [
|
||||||
{ server_name = "matrix.org"; }
|
{ server_name = "matrix.org"; }
|
||||||
@@ -192,6 +211,9 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.matrix-synapse.sliding-sync.environmentFile = config.sops.secrets."matrix/sliding-sync/env".path;
|
||||||
|
|
||||||
|
|
||||||
services.redis.servers."".enable = true;
|
services.redis.servers."".enable = true;
|
||||||
|
|
||||||
services.nginx.virtualHosts."matrix.pvv.ntnu.no" = lib.mkMerge [({
|
services.nginx.virtualHosts."matrix.pvv.ntnu.no" = lib.mkMerge [({
|
||||||
|
36
hosts/grevling/configuration.nix
Normal file
36
hosts/grevling/configuration.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{ config, pkgs, values, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
# Include the results of the hardware scan.
|
||||||
|
./hardware-configuration.nix
|
||||||
|
../../base.nix
|
||||||
|
../../misc/metrics-exporters.nix
|
||||||
|
|
||||||
|
./services/openvpn
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
networking.hostName = "grevling";
|
||||||
|
|
||||||
|
# systemd.network.networks."30-eno1" = values.defaultNetworkConfig // {
|
||||||
|
# matchConfig.Name = "eno1";
|
||||||
|
# address = with values.hosts.georg; [ (ipv4 + "/25") (ipv6 + "/64") ];
|
||||||
|
# };
|
||||||
|
|
||||||
|
# List packages installed in system profile
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
];
|
||||||
|
|
||||||
|
# List services that you want to enable:
|
||||||
|
|
||||||
|
# This value determines the NixOS release from which the default
|
||||||
|
# settings for stateful data, like file locations and database versions
|
||||||
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||||
|
# this value at the release version of the first install of this system.
|
||||||
|
# Before changing this value read the documentation for this option
|
||||||
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||||
|
system.stateVersion = "23.05"; # Did you read the comment?
|
||||||
|
|
||||||
|
}
|
40
hosts/grevling/hardware-configuration.nix
Normal file
40
hosts/grevling/hardware-configuration.nix
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/33825f0d-5a63-40fc-83db-bfa1ebb72ba0";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" =
|
||||||
|
{ device = "/dev/disk/by-uuid/145E-7362";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices =
|
||||||
|
[ { device = "/dev/disk/by-uuid/7ed27e21-3247-44cd-8bcc-5d4a2efebf57"; }
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.enp2s2.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
}
|
77
hosts/grevling/services/openvpn/default.nix
Normal file
77
hosts/grevling/services/openvpn/default.nix
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{ pkgs, lib, values, ... }:
|
||||||
|
{
|
||||||
|
services.openvpn.servers."ov-tunnel" = {
|
||||||
|
config = let
|
||||||
|
conf = {
|
||||||
|
# TODO: use aliases
|
||||||
|
local = "129.241.210.191";
|
||||||
|
port = 1194;
|
||||||
|
proto = "udp";
|
||||||
|
dev = "tap";
|
||||||
|
|
||||||
|
# TODO: set up
|
||||||
|
ca = "";
|
||||||
|
cert = "";
|
||||||
|
key = "";
|
||||||
|
dh = "";
|
||||||
|
|
||||||
|
# Maintain a record of client <-> virtual IP address
|
||||||
|
# associations in this file. If OpenVPN goes down or
|
||||||
|
# is restarted, reconnecting clients can be assigned
|
||||||
|
# the same virtual IP address from the pool that was
|
||||||
|
# previously assigned.
|
||||||
|
ifconfig-pool-persist = ./ipp.txt;
|
||||||
|
|
||||||
|
server-bridge = builtins.concatStringsSep " " [
|
||||||
|
"129.241.210.129"
|
||||||
|
"255.255.255.128"
|
||||||
|
"129.241.210.253"
|
||||||
|
"129.241.210.254"
|
||||||
|
];
|
||||||
|
|
||||||
|
keepalive = "10 120";
|
||||||
|
cipher = "none";
|
||||||
|
|
||||||
|
user = "nobody";
|
||||||
|
group = "nobody";
|
||||||
|
|
||||||
|
status = "/var/log/openvpn-status.log";
|
||||||
|
|
||||||
|
client-config-dir = pkgs.writeTextDir "tuba" ''
|
||||||
|
# Sett IP-adr. for tap0 til tubas PVV-adr.
|
||||||
|
ifconfig-push ${values.services.tuba-tap} 255.255.255.128
|
||||||
|
# Hvordan skal man faa dette til aa funke, tro?
|
||||||
|
#ifconfig-ipv6-push 2001:700:300:1900::xxx/64
|
||||||
|
|
||||||
|
# La tuba bruke std. PVV-gateway til all trafikk (unntatt
|
||||||
|
# VPN-tunnellen).
|
||||||
|
push "redirect-gateway"
|
||||||
|
'';
|
||||||
|
|
||||||
|
persist-key = true;
|
||||||
|
persist-tun = true;
|
||||||
|
|
||||||
|
verb = 5;
|
||||||
|
|
||||||
|
explicit-exit-notify = 1;
|
||||||
|
};
|
||||||
|
in lib.pipe conf [
|
||||||
|
(lib.filterAttrs (_: value: !(builtins.isNull value || value == false)))
|
||||||
|
(builtins.mapAttrs (_: value:
|
||||||
|
if builtins.isList value then builtins.concatStringsSep " " (map toString value)
|
||||||
|
else if value == true then value
|
||||||
|
else if builtins.any (f: f value) [
|
||||||
|
builtins.isString
|
||||||
|
builtins.isInt
|
||||||
|
builtins.isFloat
|
||||||
|
lib.isPath
|
||||||
|
lib.isDerivation
|
||||||
|
] then toString value
|
||||||
|
else throw "Unknown value in grevling openvpn config, deading now\n${value}"
|
||||||
|
))
|
||||||
|
(lib.mapAttrsToList (name: value: if value == true then name else "${name} ${value}"))
|
||||||
|
(builtins.concatStringsSep "\n")
|
||||||
|
(x: x + "\n\n")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
0
hosts/grevling/services/openvpn/ipp.txt
Normal file
0
hosts/grevling/services/openvpn/ipp.txt
Normal file
36
hosts/tuba/configuration.nix
Normal file
36
hosts/tuba/configuration.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{ config, pkgs, values, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
# Include the results of the hardware scan.
|
||||||
|
./hardware-configuration.nix
|
||||||
|
../../base.nix
|
||||||
|
../../misc/metrics-exporters.nix
|
||||||
|
|
||||||
|
./services/openvpn
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
networking.hostName = "tuba";
|
||||||
|
|
||||||
|
# systemd.network.networks."30-eno1" = values.defaultNetworkConfig // {
|
||||||
|
# matchConfig.Name = "eno1";
|
||||||
|
# address = with values.hosts.georg; [ (ipv4 + "/25") (ipv6 + "/64") ];
|
||||||
|
# };
|
||||||
|
|
||||||
|
# List packages installed in system profile
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
];
|
||||||
|
|
||||||
|
# List services that you want to enable:
|
||||||
|
|
||||||
|
# This value determines the NixOS release from which the default
|
||||||
|
# settings for stateful data, like file locations and database versions
|
||||||
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||||
|
# this value at the release version of the first install of this system.
|
||||||
|
# Before changing this value read the documentation for this option
|
||||||
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||||
|
system.stateVersion = "23.05"; # Did you read the comment?
|
||||||
|
|
||||||
|
}
|
40
hosts/tuba/hardware-configuration.nix
Normal file
40
hosts/tuba/hardware-configuration.nix
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/33825f0d-5a63-40fc-83db-bfa1ebb72ba0";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" =
|
||||||
|
{ device = "/dev/disk/by-uuid/145E-7362";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices =
|
||||||
|
[ { device = "/dev/disk/by-uuid/7ed27e21-3247-44cd-8bcc-5d4a2efebf57"; }
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.enp2s2.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
}
|
54
hosts/tuba/services/openvpn/default.nix
Normal file
54
hosts/tuba/services/openvpn/default.nix
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{ lib, values, ... }:
|
||||||
|
{
|
||||||
|
services.openvpn.servers."ov-tunnel" = {
|
||||||
|
config = let
|
||||||
|
conf = {
|
||||||
|
# TODO: use aliases
|
||||||
|
client = true;
|
||||||
|
dev = "tap";
|
||||||
|
proto = "udp";
|
||||||
|
remote = "129.241.210.191 1194";
|
||||||
|
|
||||||
|
resolv-retry = "infinite";
|
||||||
|
nobind = true;
|
||||||
|
|
||||||
|
# # TODO: set up
|
||||||
|
ca = "";
|
||||||
|
cert = "";
|
||||||
|
key = "";
|
||||||
|
remote-cert-tls = "server";
|
||||||
|
cipher = "none";
|
||||||
|
|
||||||
|
user = "nobody";
|
||||||
|
group = "nobody";
|
||||||
|
|
||||||
|
status = "/var/log/openvpn-status.log";
|
||||||
|
|
||||||
|
persist-key = true;
|
||||||
|
persist-tun = true;
|
||||||
|
|
||||||
|
verb = 5;
|
||||||
|
|
||||||
|
# script-security = 2;
|
||||||
|
# up = "systemctl restart rwhod";
|
||||||
|
};
|
||||||
|
in lib.pipe conf [
|
||||||
|
(lib.filterAttrs (_: value: !(builtins.isNull value || value == false)))
|
||||||
|
(builtins.mapAttrs (_: value:
|
||||||
|
if builtins.isList value then builtins.concatStringsSep " " (map toString value)
|
||||||
|
else if value == true then value
|
||||||
|
else if builtins.any (f: f value) [
|
||||||
|
builtins.isString
|
||||||
|
builtins.isInt
|
||||||
|
builtins.isFloat
|
||||||
|
lib.isPath
|
||||||
|
lib.isDerivation
|
||||||
|
] then toString value
|
||||||
|
else throw "Unknown value in tuba openvpn config, deading now\n${value}"
|
||||||
|
))
|
||||||
|
(lib.mapAttrsToList (name: value: if value == true then name else "${name} ${value}"))
|
||||||
|
(builtins.concatStringsSep "\n")
|
||||||
|
(x: x + "\n\n")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
74
modules/wackattack-ctf-stockfish/chess.py
Normal file
74
modules/wackattack-ctf-stockfish/chess.py
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from stockfish import *
|
||||||
|
from inputimeout import inputimeout
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
|
thinking_time = 1000
|
||||||
|
|
||||||
|
game = Stockfish(path="./stockfish", depth=15, parameters={"Threads": 1, "Minimum Thinking Time": thinking_time, "UCI_Chess960": True})
|
||||||
|
|
||||||
|
def create_random_position():
|
||||||
|
pos = "/pppppppp/8/8/8/8/PPPPPPPP/"
|
||||||
|
rank8 = ["r","r","b","q","k","b","n","n"]
|
||||||
|
|
||||||
|
while rank8.index("k") < [i for i, n in enumerate(rank8) if n == "r"][0] or rank8.index("k") > [i for i, n in enumerate(rank8) if n == "r"][1] or [i for i, n in enumerate(rank8) if n == "b"][0] % 2 == [i for i, n in enumerate(rank8) if n == "b"][1] % 2:
|
||||||
|
random.seed(datetime.now().microsecond)
|
||||||
|
random.shuffle(rank8)
|
||||||
|
|
||||||
|
rank1 = [c.upper() for c in rank8]
|
||||||
|
pos = "".join(rank8) + pos + "".join(rank1) + " w KQkq - 0 1"
|
||||||
|
game.set_fen_position(pos)
|
||||||
|
|
||||||
|
def player_won():
|
||||||
|
with open("flag.txt") as file:
|
||||||
|
flag = file.read()
|
||||||
|
print(flag)
|
||||||
|
exit()
|
||||||
|
|
||||||
|
def get_fast_player_move():
|
||||||
|
try:
|
||||||
|
time_over = inputimeout(prompt='Your move: ', timeout=5)
|
||||||
|
except Exception:
|
||||||
|
time_over = 'Too slow, you lost!'
|
||||||
|
print(time_over)
|
||||||
|
exit()
|
||||||
|
return time_over
|
||||||
|
|
||||||
|
def check_game_status():
|
||||||
|
evaluation = game.get_evaluation()
|
||||||
|
turn = game.get_fen_position().split(" ")[1]
|
||||||
|
if evaluation["type"] == "mate" and evaluation["value"] == 0 and turn == "w":
|
||||||
|
print("Wow, you beat me!")
|
||||||
|
player_won()
|
||||||
|
elif evaluation["type"] == "mate" and evaluation["value"] == 0 and turn == "b":
|
||||||
|
print("Hah, I won again")
|
||||||
|
exit()
|
||||||
|
if evaluation["type"] == "draw":
|
||||||
|
print("It's a draw!")
|
||||||
|
print("Impressive, but I am still undefeated.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
create_random_position()
|
||||||
|
print("Welcome to fischer chess.\nYou get 5 seconds per move. Good luck")
|
||||||
|
print(game.get_board_visual())
|
||||||
|
print("Heres the position for this game, Ill give you a few seconds to look at it before we start.")
|
||||||
|
time.sleep(3)
|
||||||
|
while True:
|
||||||
|
server_move = game.get_best_move_time(thinking_time)
|
||||||
|
game.make_moves_from_current_position([server_move])
|
||||||
|
check_game_status()
|
||||||
|
print(game.get_board_visual())
|
||||||
|
print(f"My move: {server_move}")
|
||||||
|
player_move = get_fast_player_move()
|
||||||
|
if type(player_move) != str or len([player_move]) != 1:
|
||||||
|
print("Illegal input")
|
||||||
|
exit()
|
||||||
|
try:
|
||||||
|
game.make_moves_from_current_position([player_move])
|
||||||
|
check_game_status()
|
||||||
|
except:
|
||||||
|
print("Couldn't comprehend that")
|
||||||
|
exit()
|
108
modules/wackattack-ctf-stockfish/default.nix
Normal file
108
modules/wackattack-ctf-stockfish/default.nix
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
{ config, pkgs, lib, ... }: let
|
||||||
|
stockfish = with pkgs.python3Packages; buildPythonPackage rec {
|
||||||
|
pname = "stockfish";
|
||||||
|
version = "3.28.0";
|
||||||
|
disabled = pythonOlder "3.7";
|
||||||
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "zhelyabuzhsky";
|
||||||
|
repo = pname;
|
||||||
|
rev = version;
|
||||||
|
hash = "sha256-XLgVjLV2QXeTYPjP/lwc0LH850LKJsymFlrAMkAn8HU=";
|
||||||
|
};
|
||||||
|
|
||||||
|
format = "setuptools";
|
||||||
|
nativeBuildInputs = [
|
||||||
|
setuptools
|
||||||
|
];
|
||||||
|
|
||||||
|
propagatedBuildInputs = [
|
||||||
|
pytest-runner
|
||||||
|
];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
inputimeout = with pkgs.python3Packages; buildPythonPackage rec {
|
||||||
|
pname = "inputimeout";
|
||||||
|
version = "1.0.4";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "johejo";
|
||||||
|
repo = pname;
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-Fh1CaqJOK58nURt4imkhCmZKG2eJlP/Hi10SarUJ+Fs=";
|
||||||
|
};
|
||||||
|
|
||||||
|
format = "setuptools";
|
||||||
|
nativeBuildInputs = [ setuptools ];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = pkgs.writers.writePython3 "chess" {
|
||||||
|
libraries = [
|
||||||
|
stockfish
|
||||||
|
inputimeout
|
||||||
|
];
|
||||||
|
|
||||||
|
# Fy!
|
||||||
|
flakeIgnore = [ "F403" "F405" "E231" "E265" "E302" "E305" "E501" "E722" ];
|
||||||
|
} (builtins.replaceStrings [''path="./stockfish"''] [''path="${pkgs.stockfish}/bin/stockfish"''] (builtins.readFile ./chess.py));
|
||||||
|
in
|
||||||
|
{
|
||||||
|
sops.secrets."keys/wackattack_ctf/flag" = { };
|
||||||
|
|
||||||
|
systemd.sockets."wackattack-ctf-stockfish" = {
|
||||||
|
description = "Save some azure credit for the rest of us";
|
||||||
|
partOf = [ "wackattack-ctf-stockfish.service" ];
|
||||||
|
wantedBy = [ "sockets.target" ];
|
||||||
|
|
||||||
|
socketConfig = {
|
||||||
|
ListenStream = "0.0.0.0:9999";
|
||||||
|
Accept = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services."wackattack-ctf-stockfish@" = {
|
||||||
|
description = "Save some azure credit for the rest of us";
|
||||||
|
after = [ "network.target" ];
|
||||||
|
requires = [ "wackattack-ctf-stockfish.socket" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
DynamicUser = true;
|
||||||
|
WorkingDirectory = "%d";
|
||||||
|
Restart = "always";
|
||||||
|
StandardInput = "socket";
|
||||||
|
LoadCredential = "flag.txt:${config.sops.secrets."keys/wackattack_ctf/flag".path}";
|
||||||
|
|
||||||
|
Exec = script;
|
||||||
|
|
||||||
|
# systemd hardening go barr
|
||||||
|
ProcSubset = "pid";
|
||||||
|
ProtectProc = "invisible";
|
||||||
|
AmbientCapabilities = "";
|
||||||
|
CapabilityBoundingSet = "";
|
||||||
|
NoNewPrivileges = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
ProtectHome = true;
|
||||||
|
PrivateTmp = true;
|
||||||
|
PrivateDevices = true;
|
||||||
|
PrivateUsers = true;
|
||||||
|
ProtectHostname = true;
|
||||||
|
ProtectClock = true;
|
||||||
|
ProtectKernelTunables = true;
|
||||||
|
ProtectKernelModules = true;
|
||||||
|
ProtectKernelLogs = true;
|
||||||
|
ProtectControlGroups = true;
|
||||||
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||||
|
RestrictNamespaces = true;
|
||||||
|
LockPersonality = true;
|
||||||
|
RestrictRealtime = true;
|
||||||
|
RestrictSUIDSGID = true;
|
||||||
|
RemoveIPC = true;
|
||||||
|
PrivateMounts = true;
|
||||||
|
SystemCallArchitectures = "native";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@@ -13,6 +13,9 @@ mediawiki:
|
|||||||
database: ENC[AES256_GCM,data:EvVK3Mo6cZiIZS+gTxixU4r9SXN41VqwaWOtortZRNH+WPJ4xcYvzYMJNg==,iv:JtFTRLn3fzKIfgAPRqRgQjct7EdkEHtiyQKPy8/sZ2Q=,tag:nqzseG6BC0X5UNI/3kZZ3A==,type:str]
|
database: ENC[AES256_GCM,data:EvVK3Mo6cZiIZS+gTxixU4r9SXN41VqwaWOtortZRNH+WPJ4xcYvzYMJNg==,iv:JtFTRLn3fzKIfgAPRqRgQjct7EdkEHtiyQKPy8/sZ2Q=,tag:nqzseG6BC0X5UNI/3kZZ3A==,type:str]
|
||||||
keycloak:
|
keycloak:
|
||||||
database: ENC[AES256_GCM,data:76+AZnNR5EiturTP7BdOCKE90bFFkfGlRtviSP5NHxPbb3RfFPJEMlwtzA==,iv:nS7VTossHdlrHjPeethhX+Ysp9ukrb5JD7kjG28OFpY=,tag:OMpiEv9nQA7v6lWJfNxEEw==,type:str]
|
database: ENC[AES256_GCM,data:76+AZnNR5EiturTP7BdOCKE90bFFkfGlRtviSP5NHxPbb3RfFPJEMlwtzA==,iv:nS7VTossHdlrHjPeethhX+Ysp9ukrb5JD7kjG28OFpY=,tag:OMpiEv9nQA7v6lWJfNxEEw==,type:str]
|
||||||
|
keys:
|
||||||
|
wackattack_ctf:
|
||||||
|
flag: ENC[AES256_GCM,data:cZCaGb/u/OZgAvXnuJPL3XqmnIa26Rl2IUpWpG/fpt/dJ7+/KssXVa6A5G6ObQhF7deCmTxuoVP8JU+DQzYRr0ftvKhLJ87rgzrE3j+UkA==,iv:3uFkNqXlVj94klU20yPIUd8tIeyUIfp0++2wkdIkiYM=,tag:OZMyEt118u10F5vSUFZE7A==,type:str]
|
||||||
sops:
|
sops:
|
||||||
kms: []
|
kms: []
|
||||||
gcp_kms: []
|
gcp_kms: []
|
||||||
@@ -46,8 +49,8 @@ sops:
|
|||||||
akVjeTNTeGorZjJQOVlMeCtPRUVYL3MK+VMvGxrbzGz4Q3sdaDDWjal+OiK+JYKX
|
akVjeTNTeGorZjJQOVlMeCtPRUVYL3MK+VMvGxrbzGz4Q3sdaDDWjal+OiK+JYKX
|
||||||
GHiMXVHQJZu/RrlxMjHKN6V3iaqxZpuvLAEJ2Lzy5EOHPtuiiRyeHQ==
|
GHiMXVHQJZu/RrlxMjHKN6V3iaqxZpuvLAEJ2Lzy5EOHPtuiiRyeHQ==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
lastmodified: "2023-09-17T02:02:24Z"
|
lastmodified: "2023-10-26T19:59:04Z"
|
||||||
mac: ENC[AES256_GCM,data:Lkvj9UOdE/WZtFReMs6n8ucFuJNPb76ZhPHFpYAEqYEe8d9FdMPMzq05DBAJe9IqpFS0jc9SWxJUPHfGgoMR8nPciZuR/mpJ+4s/cRkPbApwBPcLlvatE/qkbcxzoLlb1vN0gth5G/U7UEfk5Pp9gIz6Yo4sEIS3Za42tId1MpI=,iv:s3VELgU/RJ98/lbQV3vPtOLXtwFzB3KlY7bMKbAzp/g=,tag:D8s0XyGnd8UhbCseB/TyFg==,type:str]
|
mac: ENC[AES256_GCM,data:uH0RfKBjjbYvxjl4XyoXWvwUpi+W7IQZjBdC5UoslotToTw0xnici2fKxPNZ9aFJsukLMPLC+tsT/shUqW373f/NyhsJt0Vb2YtuozFQyQstZQEpnm4WuVoFR/MEjAra/PaM4ATHSGgDuHa7qrpdKTLnrMOai5ZqxLfFbLws3dA=,iv:47hHzrnfZG5NtCN0HjziZdDBJTr451/kvY95GpB3G2M=,tag:3TCs7DSeWB6NujDUlQVGjA==,type:str]
|
||||||
pgp:
|
pgp:
|
||||||
- created_at: "2023-05-21T00:28:40Z"
|
- created_at: "2023-05-21T00:28:40Z"
|
||||||
enc: |
|
enc: |
|
||||||
@@ -70,4 +73,4 @@ sops:
|
|||||||
-----END PGP MESSAGE-----
|
-----END PGP MESSAGE-----
|
||||||
fp: F7D37890228A907440E1FD4846B9228E814A2AAC
|
fp: F7D37890228A907440E1FD4846B9228E814A2AAC
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.7.3
|
version: 3.8.1
|
||||||
|
@@ -2,6 +2,8 @@ synapse:
|
|||||||
turnconfig: ENC[AES256_GCM,data:mASRjYa4C9WRow4x0XYRrlCE5LMJUYaId+o62r1qhsyJPa2LzrI=,iv:5vYdubvMDjLS6soiWx2DzkEAATb9NFbSS/Jhuuz1yI8=,tag:wOW07CQMDbOiZNervee/pg==,type:str]
|
turnconfig: ENC[AES256_GCM,data:mASRjYa4C9WRow4x0XYRrlCE5LMJUYaId+o62r1qhsyJPa2LzrI=,iv:5vYdubvMDjLS6soiWx2DzkEAATb9NFbSS/Jhuuz1yI8=,tag:wOW07CQMDbOiZNervee/pg==,type:str]
|
||||||
user_registration: ENC[AES256_GCM,data:ZDZfEEvyw8pg0WzhrdC8747ed+ZR2ZA8/WypJd/iDkmIy2RmxOeI0sE=,iv:l61mOlvzpCql4fC/eubBSU6px21et2WcpxQ6rFl14iw=,tag:sVDEAa3xipKIi/6isCjWew==,type:str]
|
user_registration: ENC[AES256_GCM,data:ZDZfEEvyw8pg0WzhrdC8747ed+ZR2ZA8/WypJd/iDkmIy2RmxOeI0sE=,iv:l61mOlvzpCql4fC/eubBSU6px21et2WcpxQ6rFl14iw=,tag:sVDEAa3xipKIi/6isCjWew==,type:str]
|
||||||
signing_key: ENC[AES256_GCM,data:6UpfiRlX9pRM7zhdm7Mc8y8EItLzugWkHSgE0tGpEmudCTa1wc60oNbYfhKDWU81DT/U148pZOoX1A==,iv:UlqCPicPm5eNBz1xBMI3A3Rn4t/GtldNIDdMH5MMnLw=,tag:HHaw6iMjEAv5b9mjHSVpwA==,type:str]
|
signing_key: ENC[AES256_GCM,data:6UpfiRlX9pRM7zhdm7Mc8y8EItLzugWkHSgE0tGpEmudCTa1wc60oNbYfhKDWU81DT/U148pZOoX1A==,iv:UlqCPicPm5eNBz1xBMI3A3Rn4t/GtldNIDdMH5MMnLw=,tag:HHaw6iMjEAv5b9mjHSVpwA==,type:str]
|
||||||
|
sliding-sync:
|
||||||
|
env: ENC[AES256_GCM,data:DsU1qKTy5sn06Y0S5kFUqZHML20n6HdHUdXsQRUw,iv:/TNTc+StAZbf6pBY9CeXdxkx8E+3bak/wOqHyBNMprU=,tag:er5u4FRlSmUZrOT/sj+RhQ==,type:str]
|
||||||
coturn:
|
coturn:
|
||||||
static-auth-secret: ENC[AES256_GCM,data:y5cG/LyrorkDH+8YrgcV7DY=,iv:ca90q2J3+NOy51mUBy4TMKfYMgWL4hxWDdsKIuxRBgU=,tag:hpFCns1lpi07paHyGB7tGQ==,type:str]
|
static-auth-secret: ENC[AES256_GCM,data:y5cG/LyrorkDH+8YrgcV7DY=,iv:ca90q2J3+NOy51mUBy4TMKfYMgWL4hxWDdsKIuxRBgU=,tag:hpFCns1lpi07paHyGB7tGQ==,type:str]
|
||||||
mjolnir:
|
mjolnir:
|
||||||
@@ -41,8 +43,8 @@ sops:
|
|||||||
cGxZVnFhdXRka2drTGdkVk1iM0pFL1kK2ry7b2cLYPfntWi/BV3K2O+mHt3242Ef
|
cGxZVnFhdXRka2drTGdkVk1iM0pFL1kK2ry7b2cLYPfntWi/BV3K2O+mHt3242Ef
|
||||||
sI2JLLQYHeAhxjFdCzP1RDR+Wu/pRxZje6xuTZ9I9TKNmm+LhAXHQw==
|
sI2JLLQYHeAhxjFdCzP1RDR+Wu/pRxZje6xuTZ9I9TKNmm+LhAXHQw==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
lastmodified: "2023-09-15T04:40:21Z"
|
lastmodified: "2023-10-22T00:31:46Z"
|
||||||
mac: ENC[AES256_GCM,data:ZJVHLbpSu/nIzl5FJfRdg2ymRN5M+zJXNUpi1hBt2MBmvK+1ed2ElhMe5x7pyasSDdaUtXDo7ghkUF7vE46Wo6Z9dvlAvhwWm7Y2AWfUe5SFVwzqlOCjSKRPFrQrL7PcDBtMj4twtwhc4XsfJoUSuigWW2m21BKtEZSuuxLRqLA=,iv:ufFbfMaNHydbkwq6lxN1dQJldkAbtqais/CZFkoDhb4=,tag:uMj0LaiU0obIlw/+HJJdKg==,type:str]
|
mac: ENC[AES256_GCM,data:UpnaUfRxvdyzBy5x4EC3w5LQ1qWxILTQhpyVPd9whTzQMAivAHT0pVmP9aE4T9w3NcWTaghp+f70GmQXx/OCC6DsRCWtU9pFHRj12YUowM3yB5lVTOomOLZQ9m4gUXw5I2GZHWBJn8CyosDcBMlXz2tiR91v/8Ulh6sDSAO86U0=,iv:5GcgRvbpqDEslZruKHM/TcMaF52A5X7AK41DEbrsRIQ=,tag:ndDgCRyX1aDRnzEUNmpoMw==,type:str]
|
||||||
pgp:
|
pgp:
|
||||||
- created_at: "2023-05-06T21:31:39Z"
|
- created_at: "2023-05-06T21:31:39Z"
|
||||||
enc: |
|
enc: |
|
||||||
|
14
values.nix
14
values.nix
@@ -21,6 +21,12 @@ in rec {
|
|||||||
ipv4 = pvv-ipv4 213;
|
ipv4 = pvv-ipv4 213;
|
||||||
ipv6 = pvv-ipv6 213;
|
ipv6 = pvv-ipv6 213;
|
||||||
};
|
};
|
||||||
|
grevling-tap = {
|
||||||
|
ipv4 = pvv-ipv4 251;
|
||||||
|
};
|
||||||
|
tuba-tap = {
|
||||||
|
ipv4 = pvv-ipv4 252;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
hosts = {
|
hosts = {
|
||||||
@@ -49,6 +55,14 @@ in rec {
|
|||||||
ipv4 = pvv-ipv4 204;
|
ipv4 = pvv-ipv4 204;
|
||||||
ipv6 = pvv-ipv6 "1:4f"; # Wtf øystein og daniel why
|
ipv6 = pvv-ipv6 "1:4f"; # Wtf øystein og daniel why
|
||||||
};
|
};
|
||||||
|
grevling = {
|
||||||
|
ipv4 = pvv-ipv4 198;
|
||||||
|
ipv6 = pvv-ipv6 198;
|
||||||
|
};
|
||||||
|
tuba = {
|
||||||
|
ipv4 = pvv-ipv4 199;
|
||||||
|
ipv6 = pvv-ipv6 199;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultNetworkConfig = {
|
defaultNetworkConfig = {
|
||||||
|
Reference in New Issue
Block a user