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

Initial testing with new virtual desktop #230

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build-an-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WEBTOP_TAG=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.virtualdesktop.ta
echo "Pulling in required images to actually run $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG & $WEBTOP_IMAGE:$WEBTOP_TAG."
echo "If you see an authentication failure: pull them manually by the following 2 commands"
echo "'docker pull $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG'"
echo "'docker pull $WEBTOP_IMAGE:$WEBTOP_TAG'" &
echo "'docker pull $WEBTOP_IMAGE:$WEBTOP_TAG'"
docker pull $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG &
docker pull $WEBTOP_IMAGE:$WEBTOP_TAG &
docker build -t local/wrongsecrets-balancer:$version ./wrongsecrets-balancer &
Expand Down
2 changes: 1 addition & 1 deletion helm/wrongsecrets-ctf-party/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ virtualdesktop:
maxInstances: 500
# -- Juice Shop Image to use
image: jeroenwillemsen/wrongsecrets-desktop-k8s
tag: 1.6.3
tag: up3
repository: commjoenie/wrongSecrets
resources:
request:
Expand Down
4 changes: 4 additions & 0 deletions wrongsecrets-balancer/src/kubernetes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,10 @@ const createDesktopDeploymentForTeam = async ({ team, passcodeHash }) => {
name: 'PUID',
value: '1000',
},
{
name: 'TITLE',
value: 'WrongSecrets CTF Desktop',
},
{
name: 'PGID',
value: '1000',
Expand Down
38 changes: 28 additions & 10 deletions wrongsecrets-balancer/src/proxy/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,25 @@ function proxyTrafficToJuiceShop(req, res) {
req.headers['referer'].includes(currentReferrerForDesktop)) ||
(req.headers['Referer'] !== undefined &&
req.headers['Referer'].includes(currentReferrerForDesktop)) ||
req.path === '/js/filebrowser.js' ||
req.path === '/css/filebrowser.css' ||
req.path === '/files/socket.io/socket.io.js' ||
req.path === '/js/vendor/jquery.min.js' ||
req.path === '/files/socket.io/' ||
req.path === '/files/socket.io/socket.io.js.map'
req.path === '/css/filebrowser.css' ||
req.path === '/audio/socket.io/socket.io.js' ||
req.path === '/files/socket.io/socket.io.js' ||
req.path === '/files/socket.io/socket.io.js.map' ||
req.path === '/js/filebrowser.js' ||
req.path === '/js/vendor/jquery.min.js' ||
req.path === '/public/css/filebrowser.css' ||
req.path === '/public/css/files.svg' ||
req.path === '/public/css/kclient.css' ||
req.path === '/public/css/speaker.svg' ||
req.path === '/public/js/filebrowser.js' ||
req.path === '/public/js/jquery.min.js' ||
req.path === '/public/js/kclient.js' ||
req.path === '/public/js/pcm-player.js' ||
req.path === '/vnc/vendor/interact.min.js' ||
req.path === '/vnc/vendor/interact.min.js.map' ||
req.path === '/vnc/dist/runtime.bundle.js' ||
req.path === '/vnc/dist/vendors~main.bundle.js' ||
req.path.includes('vnc')
) {
target = {
target: `http://${teamname}-virtualdesktop.${teamname}.svc:8080`,
Expand All @@ -140,11 +153,16 @@ function proxyTrafficToJuiceShop(req, res) {
ws: true,
};
}
logger.info(`we got ${teamname} requesting ${target.target}`);
logger.info(`we got ${teamname} requesting ${target.target} for ${req.path}`);

if (req.path === '/guaclite') {
if (
req.path === '/guaclite' ||
req.path === '/websockify' ||
!!req.query.EIO
) {
let server = res.socket.server;
logger.info('putting ws through for /quaclite');
logger.info(`putting ws through for ${req.path}`);
logger.info(`putting ws through for ${req.query}`);
server.on('upgrade', function (req, socket, head) {
cookieParser(get('cookieParser.secret'))(req, null, () => {});

Expand All @@ -170,7 +188,7 @@ function proxyTrafficToJuiceShop(req, res) {
logger.info(`Got malformed teamname: ${teamname}s`);
return res.redirect('/balancer/');
}
logger.info(`proxying upgrade request for: ${req.url} with team ${connectTeamname}`);
logger.info(`proxying connect request for: ${req.url} with team ${connectTeamname}`);
proxy.ws(req, socket, head, {
target: `ws://${connectTeamname}-virtualdesktop.${connectTeamname}.svc:8080`,
ws: true,
Expand Down