Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enowars5 #29

Open
wants to merge 122 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
09c954e
add frontend initial
DanielHabenicht May 11, 2021
e6f3945
just commit customization
DanielHabenicht May 11, 2021
abc5c53
some working setip
DanielHabenicht May 11, 2021
0f4844e
final draft
DanielHabenicht May 11, 2021
c31a399
delete glitch
DanielHabenicht May 11, 2021
1538538
Update mobile friendlieness
DanielHabenicht Jun 12, 2021
71f6474
add customization readme and remove previous files
DanielHabenicht Jun 12, 2021
3805fac
enable annotations
DanielHabenicht Jun 12, 2021
8b8472d
add angular app
DanielHabenicht Jun 12, 2021
d269a1d
add hmr
DanielHabenicht Jun 12, 2021
0abc45f
add autogenerated api and clearer controller code
DanielHabenicht Jun 13, 2021
501e520
add mainpage
DanielHabenicht Jun 13, 2021
2c294e1
add frontend pages
DanielHabenicht Jun 15, 2021
44ae848
add theme switch
DanielHabenicht Jun 15, 2021
d6ad284
create other pages
DanielHabenicht Jun 15, 2021
fd1a3b4
re/move old projects
DanielHabenicht Jun 17, 2021
9f9bfc8
move models
DanielHabenicht Jun 17, 2021
79f4f1f
fix imports
DanielHabenicht Jun 17, 2021
7385235
add hosting variants
DanielHabenicht Jun 17, 2021
8ab5b5d
fix css compilation
DanielHabenicht Jun 17, 2021
2c37b43
add runtime variables
DanielHabenicht Jun 17, 2021
7220ee2
add appsettings sample
DanielHabenicht Jun 17, 2021
f33e39b
add runtime variables to normal hosting
DanielHabenicht Jun 17, 2021
5c590a5
better pages
DanielHabenicht Jun 17, 2021
d4261ea
add gitpod
DanielHabenicht Jun 17, 2021
41c591e
update gitpod
DanielHabenicht Jun 17, 2021
7392668
Update .gitpod.Dockerfile
DanielHabenicht Jun 17, 2021
8f05fec
Update .gitpod.Dockerfile
DanielHabenicht Jun 17, 2021
67c2fcd
update gitpod
DanielHabenicht Jun 17, 2021
3b6b42a
update gitpod
DanielHabenicht Jun 17, 2021
a5697c5
update gitpod
DanielHabenicht Jun 17, 2021
d8235c8
gitpod
DanielHabenicht Jun 17, 2021
5144129
use v5?
DanielHabenicht Jun 17, 2021
87e03f4
fix gitpod
DanielHabenicht Jun 18, 2021
6298512
fix gitpod?
DanielHabenicht Jun 18, 2021
a4609c8
fix gitpod
DanielHabenicht Jun 18, 2021
5c2363a
hope fix
DanielHabenicht Jun 18, 2021
d8c8c19
add badge
DanielHabenicht Jun 18, 2021
33216a3
fix gitpod finally
DanielHabenicht Jun 18, 2021
192dea3
fix for real
DanielHabenicht Jun 18, 2021
d4d8c49
add github config
DanielHabenicht Jun 18, 2021
a59941b
update api
adriangronau Jun 18, 2021
c50d3d8
Improve scoreboard
adriangronau Jun 18, 2021
76260bf
Merge remote-tracking branch 'tharkay/use-better-frontend' into use-b…
adriangronau Jun 18, 2021
7b95672
Merge pull request #1 from tharkay/use-better-frontend
DanielHabenicht Jun 18, 2021
6dc2943
fix scrolling issue
DanielHabenicht Jun 18, 2021
c9742d9
fix left margin
DanielHabenicht Jun 18, 2021
6d0c63b
fix indefinite table for now
DanielHabenicht Jun 18, 2021
369bc8d
document enum strings
DanielHabenicht Jun 18, 2021
fb4cfdf
add better dialog
DanielHabenicht Jun 18, 2021
2714f55
fix gitpod again
DanielHabenicht Jun 18, 2021
7793323
add counter
DanielHabenicht Jun 18, 2021
c4e7230
Update .gitpod.yml
DanielHabenicht Jun 19, 2021
e9aaed6
remove uneeded nowarn
DanielHabenicht Jun 21, 2021
71bb8b2
update enoCore version
DanielHabenicht Jun 21, 2021
19ea686
update api
DanielHabenicht Jun 21, 2021
6c68a1e
fix build errors
DanielHabenicht Jun 21, 2021
dc09240
add scoreboard backend functionality
DanielHabenicht Jun 21, 2021
3902f84
add auto forward in frontend
DanielHabenicht Jun 21, 2021
acdf534
fix round length
DanielHabenicht Jun 22, 2021
a48b59e
fix round length
DanielHabenicht Jun 22, 2021
faf2985
fix current round reload
DanielHabenicht Jun 22, 2021
376437f
add title
DanielHabenicht Jun 22, 2021
36bd0a2
fix refresh timeframe
DanielHabenicht Jun 22, 2021
15524ff
add mock to gitpod
DanielHabenicht Jun 22, 2021
2d5840d
fix standard build
DanielHabenicht Jun 26, 2021
63c7861
fix gitpod ports
DanielHabenicht Jun 26, 2021
08ef960
fix import
DanielHabenicht Jun 26, 2021
c78755a
better teams site
DanielHabenicht Jun 26, 2021
265ccb9
remove old scoreboards
DanielHabenicht Jun 26, 2021
bae8fc7
table performance update
DanielHabenicht Jun 26, 2021
df52373
better pages
DanielHabenicht Jun 26, 2021
46b981f
link styles
DanielHabenicht Jun 26, 2021
02b0336
better menu
DanielHabenicht Jun 26, 2021
2d9abdb
improve round navigate performance
DanielHabenicht Jun 27, 2021
8ab0389
add admin page
DanielHabenicht Jun 27, 2021
7745644
add Snackbar
DanielHabenicht Jun 27, 2021
64291c0
add buttons
DanielHabenicht Jun 27, 2021
18cbbdb
fix checking controller
DanielHabenicht Jun 27, 2021
c148aa6
remove useless controller
DanielHabenicht Jun 27, 2021
815f3eb
update api
DanielHabenicht Jun 27, 2021
a5944c2
finished v1
DanielHabenicht Jun 27, 2021
b705a7d
fix budget size
DanielHabenicht Jun 28, 2021
59671c6
fix customization
DanielHabenicht Jun 28, 2021
49e20fa
fix dates and redirects
DanielHabenicht Jun 28, 2021
adcb587
reduce bundle size
DanielHabenicht Jun 28, 2021
8a968d5
fix login
DanielHabenicht Jun 28, 2021
595719a
fix sidenav
DanielHabenicht Jun 28, 2021
653f1bd
fix minor issues
DanielHabenicht Jun 29, 2021
79d7cb9
fix dockerfile copy
DanielHabenicht Jun 29, 2021
544659e
fix gitpod .env
DanielHabenicht Jun 29, 2021
e5864ce
add register now link
DanielHabenicht Jun 29, 2021
928c391
fix email
DanielHabenicht Jun 29, 2021
94d12cf
fix colors
DanielHabenicht Jun 29, 2021
06136d1
better mock
DanielHabenicht Jun 29, 2021
d2950d4
better example
DanielHabenicht Jun 30, 2021
ab73556
remove uneeded setting
DanielHabenicht Jun 30, 2021
07bcb1f
add loadtest
DanielHabenicht Jun 30, 2021
595c9f3
fix documentation links
DanielHabenicht Jul 1, 2021
07d8b14
Merge branch 'master' into enowars5
ldruschk Jul 7, 2021
c5a3cfe
Merge branch 'master' into enowars5
ldruschk Jul 7, 2021
843507c
update customization pages
ldruschk Jul 7, 2021
4dad089
fix naming
DanielHabenicht Jul 7, 2021
65df4ee
add label type=vulnbox when creating Hetzner VM
ldruschk Jul 8, 2021
3afab55
add basic GitHub Actions CI
ldruschk Jul 8, 2021
454b3fc
add .env in GitHub Actions CI
ldruschk Jul 8, 2021
9c81243
deliver static openvpn and wg config
Trolldemorted Jul 8, 2021
107580b
remove unecessary files
DanielHabenicht Jul 8, 2021
b1fc037
add attack info
DanielHabenicht Jul 8, 2021
3afe21f
use scoreboad files locally
DanielHabenicht Jul 9, 2021
27d0250
add nologo graphic
DanielHabenicht Jul 9, 2021
7e41515
add buttons
DanielHabenicht Jul 9, 2021
4f0b650
add readme
DanielHabenicht Jul 9, 2021
23eee02
add comments
DanielHabenicht Jul 9, 2021
bd97f1a
Enowars5 (#34)
DanielHabenicht Jul 9, 2021
921a294
update Enowars5 (#35)
DanielHabenicht Jul 10, 2021
61d05ae
Enowars5 (#37)
DanielHabenicht Jul 10, 2021
e9c5673
Update ScoreboardInfoController.cs
DanielHabenicht Jul 10, 2021
702b4ba
Enowars5 (#38)
DanielHabenicht Jul 10, 2021
7f4244e
Enowars5 (#39)
DanielHabenicht Jul 10, 2021
6127af6
Enowars5 (#40)
DanielHabenicht Jul 10, 2021
af15ed3
Use better frontend (#41)
DanielHabenicht Jul 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.dockerignore
Dockerfile
docker-compose.yml
bin/
obj/
**/bin/
**/obj/
**/node_modules/**/*
.vs
.vs-code
.git
Expand All @@ -17,6 +18,4 @@ obj/
/EnoLandingPageFrontend/bin
/EnoLandingPageFrontend/obj
/data
/scoreboard
/sessions

/sessions
22 changes: 22 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: docker-compose build

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: "0 0 * * *"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: add .env file
run: touch .env
- name: run docker-compose build
run: docker-compose build
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,13 @@ MigrationBackup/

# EnoLandingPage
/EnoLandingPageBackend/data
/EnoLandingPageBackend/enginedata/*.json
/EnoLandingPageBackend/appsettings.Development.json
/EnoLandingPageBackend/wwwroot
/data
/scoreboard
/sessions
docker-compose.yml
.env
mock/*.json
mock/*.info

8 changes: 8 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM gitpod/workspace-full

# From https://github.com/gitpod-io/workspace-images/blob/master/dotnet-lts/Dockerfile
USER gitpod
RUN mkdir -p /home/gitpod/dotnet && curl -fsSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 5.0 --install-dir /home/gitpod/dotnet
ENV DOTNET_ROOT=/home/gitpod/dotnet
ENV PATH=$PATH:/home/gitpod/dotnet
RUN npm install -g @angular/cli
60 changes: 60 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

image:
file: .gitpod.Dockerfile

# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
tasks:
- name: Setup
before: |
dotnet tool install --global dotnet-ef
export PATH="$PATH:$HOME/.dotnet/tools/"
cp example.env .env
- name: Run Mock
before: |
cd mock
python3 simulate_ctf.py
- name: Frontend
env:
NG_CLI_ANALYTICS: ci
before: |
cd EnoLandingPageBackend/ClientApp
npm install
npm run build
command: |
cd EnoLandingPageBackend/ClientApp
npm start
- name: Backend
before: |
mkdir EnoLandingPageBackend/data
cp EnoLandingPageBackend/appsettings.example.json EnoLandingPageBackend/appsettings.Development.json
command: |
cd EnoLandingPageBackend
dotnet watch run
openMode: split-right

# List the ports to expose. Learn more https://www.gitpod.io/docs/config-ports/
ports:
- port: 5000
onOpen: notify
- port: 5001
onOpen: ignore
- port: 4200
onOpen: ignore

vscode:
extensions:
- ms-azuretools.vscode-docker
- angular.ng-template
- esbenp.prettier-vscode
- k--kato.docomment
- https://github.com/OmniSharp/omnisharp-vscode/releases/download/v1.23.12/csharp-1.23.12.vsix

github:
prebuilds:
master: true
branches: true
pullRequests: true
pullRequestsFromForks: true
addCheck: false
addComment: false
addBadge: true
42 changes: 33 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
# Build Backend Portal
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS backend-build
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
WORKDIR /src

ARG NO_WEB_APP=true
# Fetch deps
COPY EnoLandingPage.sln EnoLandingPage.sln
COPY EnoLandingPageBackend/EnoLandingPageBackend.csproj EnoLandingPageBackend/EnoLandingPageBackend.csproj
COPY EnoLandingPageCore/EnoLandingPageCore.csproj EnoLandingPageCore/EnoLandingPageCore.csproj
COPY EnoLandingPageFrontend/EnoLandingPageFrontend.csproj EnoLandingPageFrontend/EnoLandingPageFrontend.csproj
RUN dotnet restore

# Publish
COPY EnoLandingPageBackend EnoLandingPageBackend
COPY EnoLandingPageCore EnoLandingPageCore
COPY EnoLandingPageFrontend EnoLandingPageFrontend
COPY Directory.Build.props Directory.Build.props
COPY ENOWARS.ruleset ENOWARS.ruleset
COPY stylecop.json stylecop.json
RUN dotnet publish -c Release -o /app

# Copy to runtime container
# Build Frontend in extra storage for improved caching
FROM node:14 AS build
WORKDIR /usr/src/app
COPY EnoLandingPageBackend/ClientApp/package.json EnoLandingPageBackend/ClientApp/package-lock.json ./
RUN npm install
COPY EnoLandingPageBackend/ClientApp .
RUN npm run build


# Build runtime container
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
RUN apt-get update && apt-get install gettext-base -y && apt-get clean

# Create data folder if not run as mapped volume
RUN mkdir ./data
EXPOSE 80
COPY --from=build /app .

ENV STATIC_HOSTING=false
ENV ENVSUBST_OUTPUT_DIR=/app/ClientApp/dist/ClientApp

COPY ./substitute_variables.sh /substitute_variables.sh
RUN chmod +x /substitute_variables.sh

# Copy files from other stages
COPY --from=backend-build /app .
COPY --from=build /usr/src/app/dist/ClientApp/index.html /template/index.html
COPY --from=build /usr/src/app/dist /app/ClientApp/dist
COPY ./customization /app/ClientApp/dist/ClientApp/assets/customization
COPY EnoLandingPageBackend/appsettings.json .
ENTRYPOINT ["dotnet", "EnoLandingPageBackend.dll"]
# ENTRYPOINT ["dotnet", "EnoLandingPageBackend.dll"]
ENTRYPOINT ["/bin/sh", "-c" , "/substitute_variables.sh && dotnet EnoLandingPageBackend.dll"]
12 changes: 0 additions & 12 deletions EnoLandingPage.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30711.63
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnoLandingPageCore", "EnoLandingPageCore\EnoLandingPageCore.csproj", "{7972F197-F59D-41D8-98C2-CD618BA9AF43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnoLandingPageBackend", "EnoLandingPageBackend\EnoLandingPageBackend.csproj", "{10C14526-179D-4627-9891-F2B25F353260}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnoLandingPageFrontend", "EnoLandingPageFrontend\EnoLandingPageFrontend.csproj", "{B36F02C0-04D2-4F73-A40A-73DC0EFBEB8A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D9FEE9F-BA38-439F-91EE-B9AB1CEE9EE9}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Expand All @@ -20,18 +16,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7972F197-F59D-41D8-98C2-CD618BA9AF43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7972F197-F59D-41D8-98C2-CD618BA9AF43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7972F197-F59D-41D8-98C2-CD618BA9AF43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7972F197-F59D-41D8-98C2-CD618BA9AF43}.Release|Any CPU.Build.0 = Release|Any CPU
{10C14526-179D-4627-9891-F2B25F353260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10C14526-179D-4627-9891-F2B25F353260}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10C14526-179D-4627-9891-F2B25F353260}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10C14526-179D-4627-9891-F2B25F353260}.Release|Any CPU.Build.0 = Release|Any CPU
{B36F02C0-04D2-4F73-A40A-73DC0EFBEB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B36F02C0-04D2-4F73-A40A-73DC0EFBEB8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B36F02C0-04D2-4F73-A40A-73DC0EFBEB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B36F02C0-04D2-4F73-A40A-73DC0EFBEB8A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
62 changes: 62 additions & 0 deletions EnoLandingPageBackend/Cache/AttackCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

namespace EnoLandingPageBackend.Cache
{
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
public class CustomMemoryCache<T>
{
private readonly string defaultKey = "default";
private MemoryCache _cache { get; set; }
public CustomMemoryCache()
{
_cache = new MemoryCache(new MemoryCacheOptions
{
SizeLimit = 1024
});
}

public T TryGetDefault()
{
T cacheEntry;
this._cache.TryGetValue(defaultKey, out cacheEntry);
return cacheEntry;
}
public void InvalidateDefault()
{
this._cache.Remove(defaultKey);
}

public void CreateDefault(T attackInfo)
{
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1);
_cache.Set(this.defaultKey, attackInfo, cacheEntryOptions);
}

public T GetOrCreate(object key, Func<T> createItem)
{
T cacheEntry;
if (!_cache.TryGetValue(key, out cacheEntry))// Look for cache key.
{
cacheEntry = createItem();

var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1)
.SetPriority(CacheItemPriority.Normal);

_cache.Set(key, cacheEntry, cacheEntryOptions);
}
return cacheEntry;
}

public async Task<T> GetOrCreateAsync(object key, Func<Task<T>> createItem)
{
var func = await createItem();
return this.GetOrCreate(key, () =>
{
return func;
});
}
}
}
63 changes: 63 additions & 0 deletions EnoLandingPageBackend/Cache/ScoreboardCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;

namespace EnoLandingPageBackend.Cache
{
public class ScoreboardCache
{
private readonly string defaultKey = "default";
private MemoryCache _cache { get; set; }
public ScoreboardCache()
{
_cache = new MemoryCache(new MemoryCacheOptions
{
SizeLimit = 1024
});
}

public string TryGetDefault()
{
string cacheEntry;
this._cache.TryGetValue(defaultKey, out cacheEntry);
return cacheEntry;
}
public void InvalidateDefault()
{
this._cache.Remove(defaultKey);
}

public void CreateDefault(string scoreboard)
{
var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1);
_cache.Set(this.defaultKey, scoreboard, cacheEntryOptions);
}

public string GetOrCreate(object key, Func<string> createItem)
{
string cacheEntry;
if (!_cache.TryGetValue(key, out cacheEntry))// Look for cache key.
{
cacheEntry = createItem();

var cacheEntryOptions = new MemoryCacheEntryOptions()
.SetSize(1)
.SetPriority(CacheItemPriority.Normal);

_cache.Set(key, cacheEntry, cacheEntryOptions);
}
return cacheEntry;
}

public async Task<string> GetOrCreateAsync(object key, Func<Task<string>> createItem)
{
var func = await createItem();
return this.GetOrCreate(key, () =>
{
return func;
});
}
}
}
17 changes: 17 additions & 0 deletions EnoLandingPageBackend/ClientApp/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
16 changes: 16 additions & 0 deletions EnoLandingPageBackend/ClientApp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Loading