Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
cookie fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Crowley committed Jun 9, 2024
1 parent 0fa75d2 commit 13c0be3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cookie-clicker/chall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cookie Clicker
categories:
- webex
value: 100
flag: bcactf{Y0u_W3renT_Supp0sE_t0_WIN_123}
flag: bcactf{H0w_Did_Y0u_Cl1ck_S0_M4ny_T1mes_123}
description: "You need to get 1e20 cookies, hope you have fun clicking!"
authors:
- Jack
Expand Down
13 changes: 6 additions & 7 deletions cookie-clicker/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,34 @@ io.on('connection', (socket) => {
});

socket.on('chat message', (msg) => {
io.emit('chat message', msg);
socket.emit('chat message', msg);
});

socket.on('receivedError', (msg) => {
sessions[id] = errors[id]
io.emit('recievedScore', JSON.stringify({"value":sessions[id]}));
socket.emit('recievedScore', JSON.stringify({"value":sessions[id]}));
});

socket.on('click', (msg) => {
let json = JSON.parse(msg)

if (sessions[id] > 1e20) {
console.log("TEST")
io.emit('recievedScore', JSON.stringify({"value":"bcactf{Y0u_W3renT_Supp0sE_t0_WIN_123}"}));
socket.emit('recievedScore', JSON.stringify({"value":"bcactf{H0w_Did_Y0u_Cl1ck_S0_M4ny_T1mes_123}"}));
return;
}

if (json.value != sessions[id]) {
io.emit("error", "previous value does not match")
socket.emit("error", "previous value does not match")
}

let oldValue = sessions[id]
let newValue = Math.floor(Math.random() * json.power) + 1 + oldValue

sessions[id] = newValue
io.emit('recievedScore', JSON.stringify({"value":newValue}));
socket.emit('recievedScore', JSON.stringify({"value":newValue}));

if (json.power > 10) {
io.emit('error', JSON.stringify({"value":oldValue}));
socket.emit('error', JSON.stringify({"value":oldValue}));
}

errors[id] = oldValue;
Expand Down
12 changes: 6 additions & 6 deletions cookie-clicker/server/provided.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ io.on('connection', (socket) => {
});

socket.on('chat message', (msg) => {
io.emit('chat message', msg);
socket.emit('chat message', msg);
});

socket.on('receivedError', (msg) => {
sessions[id] = errors[id]
io.emit('recievedScore', JSON.stringify({"value":sessions[id]}));
socket.emit('recievedScore', JSON.stringify({"value":sessions[id]}));
});

socket.on('click', (msg) => {
let json = JSON.parse(msg)

if (sessions[id] > 1e20) {
console.log("TEST")
io.emit('recievedScore', JSON.stringify({"value":"bcactf{flag}"}));
socket.emit('recievedScore', JSON.stringify({"value":"flag"}));
return;
}

if (json.value != sessions[id]) {
io.emit("error", "previous value does not match")
socket.emit("error", "previous value does not match")
}

let oldValue = sessions[id]
let newValue = Math.floor(Math.random() * json.power) + 1 + oldValue

sessions[id] = newValue
io.emit('recievedScore', JSON.stringify({"value":newValue}));
socket.emit('recievedScore', JSON.stringify({"value":newValue}));

if (json.power > 10) {
io.emit('error', JSON.stringify({"value":oldValue}));
socket.emit('error', JSON.stringify({"value":oldValue}));
}

errors[id] = oldValue;
Expand Down

0 comments on commit 13c0be3

Please sign in to comment.