Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
reteps committed Jun 18, 2024
1 parent 60a3047 commit 0e6d6ef
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 13 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,71 @@

rCTF is redpwnCTF's CTF platform. It is developed and (used to be) maintained by the [redpwn](https://redpwn.net) CTF team.

## Installation

install.

```
curl https://get.rctf.redpwn.net > install.sh && chmod +x install.sh
./install.sh
```

build the image.

```
docker build -t us-central1-docker.pkg.dev/dotted-forest-314903/rctf/rctf .
```

update docker compose.

```
# docker-compose.yml
version: '2.2'
services:
rctf:
image: us-central1-docker.pkg.dev/dotted-forest-314903/rctf/rctf # redpwn/rctf:${RCTF_GIT_REF}
restart: always
ports:
- '127.0.0.1:8080:80'
networks:
- rctf
env_file:
- .env
environment:
- PORT=80
volumes:
- ./conf.d:/app/conf.d
depends_on:
- redis
- postgres
redis:
image: redis:6.0.6
restart: always
command: ["redis-server", "--requirepass", "${RCTF_REDIS_PASSWORD}"]
networks:
- rctf
volumes:
- ./data/rctf-redis:/data
postgres:
image: postgres:12.3
restart: always
ports:
- '127.0.0.1:5432:5432'
environment:
- POSTGRES_PASSWORD=${RCTF_DATABASE_PASSWORD}
- POSTGRES_USER=rctf
- POSTGRES_DB=rctf
networks:
- rctf
volumes:
- ./data/rctf-postgres:/var/lib/postgresql/data
networks:
rctf: {}
```



## Getting Started

To get started with rCTF, visit the docs at [rctf.redpwn.net](https://rctf.redpwn.net/installation/)
Expand Down
26 changes: 13 additions & 13 deletions server/api/challs/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ export default {
if (oldSolve && (+oldSolve.metadata.score) < +submittedScore) {
await db.solves.removeSolvesByUserIdAndChallId({ userid: uuid, challengeid })
}
// If this is a new best performance, update the challenge
const maxScore = (challenge.rankedMetadata || {}).maxScore || -1
if (maxScore === -1 || +submittedScore > +maxScore) {
challenge.rankedMetadata = { ...(challenge.rankedMetadata || {}), maxScore: +submittedScore }
await db.challenges.upsertChallenge(challengeToRow(challenge))
}

// If this is a new worst performance, update the challenge
const minScore = (challenge.rankedMetadata || {}).minScore || -1
if (minScore === -1 || +submittedScore < +minScore) {
challenge.rankedMetadata = { ...(challenge.rankedMetadata || {}), minScore: +submittedScore }
await db.challenges.upsertChallenge(challengeToRow(challenge))
}
}

// If this is a new best performance, update the challenge
const maxScore = (challenge.rankedMetadata || {}).maxScore || -1
if (maxScore === -1 || +submittedScore > +maxScore) {
challenge.rankedMetadata = { ...(challenge.rankedMetadata || {}), maxScore: +submittedScore }
await db.challenges.upsertChallenge(challengeToRow(challenge))
}

// If this is a new worst performance, update the challenge
const minScore = (challenge.rankedMetadata || {}).minScore || -1
if (minScore === -1 || +submittedScore < +minScore) {
challenge.rankedMetadata = { ...(challenge.rankedMetadata || {}), minScore: +submittedScore }
await db.challenges.upsertChallenge(challengeToRow(challenge))
}

await db.solves.newSolve({ id: uuidv4(), challengeid: challengeid, userid: uuid, createdat: new Date(), metadata })
return (challengeType === 'ranked') ? responses.goodFlagRanked : responses.goodFlag
Expand Down

0 comments on commit 0e6d6ef

Please sign in to comment.