Skip to content

Latest commit

 

History

History
253 lines (188 loc) · 4.29 KB

API.md

File metadata and controls

253 lines (188 loc) · 4.29 KB

CTFPad REST API

Each request has to contain an apikey generated by CTFPad as HTTP header field X-Apikey

User endpoints

GET user/whoami

Returns the username to the provided apikey

Response body:

{
    "username": "username"
}

GET user/scope

Returns the scope of the current user

Response body:

{
    "scope": 1
}

PUT user/scope

Sets the scope of the current user

Request body:

{
    "scope": 2
}

Response body:

{
    "scope": 2
}

PUT user/scope/latest

Sets the scope of the current user to the newest CTF

Response body:

{
    "scope": 4
}

CTF endpoints

GET ctfs

Lists all available CTFs

Response body:

{
    "ctfs": [ {
        "id": 1,
        "name": "some ctf"
    }, {
        "id": 2,
        "name": "anyCTF"
    } ]
}

POST ctfs

Creates a new CTF with the given name

Request body:

{
    "name": "new CTF"
}

Response body:

{
    "ctf": {
         "id": 3,
         "name": "new CTF"
    }
}

GET ctfs/<$CTF>

Returns details about a specific CTF by id

Response body:

{
    "ctf": {
         "id": 2,
         "name": "anyCTF"
    }
}

GET ctfs/<$CTF>/challenges

Lists challenges for a specific CTF

Response body:

{
    "challenges": [ {
        "id": 1,
        "title": "random web",
        "category": "web",
        "points": 100,
        "done": false
    }, {
        "id": 2,
        "title": "crypto awesome"
        "category": "crypto",
        "points": 250,
        "done": true
    } ]
}

POST ctfs/<$CTF>/challenges

Creates a new challenge for a CTF

Request body:

{
    "challenge": {
        "title": "new chal",
        "category": "reversing",
        "points": 300
    }
}

Response body:

{
    "challenge": {
        "id": 3,
        "title": "new chal",
        "category": "reversing",
        "points": 300,
        "done": false
    }
}

GET ctfs/<$CTF>/files

Lists all available files for a ctf

Response body:

{
    "files": [ {
        "id": "4fb15f2bac64cccd6470753b9333534f2065ed14aca439043399a267cba7c6fb",
        "name": "test.py",
        "user": "stratumauhuur",
        "path": "/files/4fb15f2bac64cccd6470753b9333534f2065ed14aca439043399a267cba7c6fb/test.py"
    } ]
}

POST ctfs/<$CTF>/files

Upload a file for a ctf

Request body:

{
    "files": @file
}

Response body:

{
    "success": true,
    "id": "4a1da276d9cd0d245d6d186dc28148e2bc8c10b8aa19bdfeaf2e5d9dcc0ecd22"
}

Challenge endpoints

GET challenges/<$CHALLENGE>

Returns details about a specific challenge

Response body:

{
    "challenge": {
        "id": 3,
        "title": "new chal",
        "category": "reversing",
        "points": 300,
        "done": false,
        "ctf": 1
        "filecount": 2,
        "assigned": [
            "stratumauhuur"
        ]
    }
}

PUT challenges/<$CHALLENGE>/assign

Assigns the current user to the specified challenge

Response body:

{
    "assigned": [
        "stratumauhuur",
        "username"
    ]
}

DELETE challenges/<$CHALLENGE>/assign

Unassigns the current user from the specified challenge

Response body:

{
    "assgined": [
        "stratumauhuur"
    ]
}

PUT challenges/<$CHALLENGE>/done

Marks the challenge as done

DELETE challenges/<$CHALLENGE>/done

Marks the challenge as not done

GET challenges/<$CHALLENGE>/files

Lists the files for a specific challenge

Response body:

{
    "files": [ {
        "id": "4fb15f2bac64cccd6470753b9333534f2065ed14aca439043399a267cba7c6fb",
        "name": "test.py",
        "user": "stratumauhuur",
        "path": "/files/4fb15f2bac64cccd6470753b9333534f2065ed14aca439043399a267cba7c6fb/test.py"
    } ]
}

POST challenges/<$CHALLENGE>/files

Upload a file for a challenge

Request body:

{
    "files": @file
}

Response body:

{
    "success": true,
    "id": "4a1da276d9cd0d245d6d186dc28148e2bc8c10b8aa19bdfeaf2e5d9dcc0ecd22"
}