Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
realgam3 committed Jul 31, 2023
1 parent f8c77fb commit b945708
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
20 changes: 6 additions & 14 deletions CTFDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import logging
from os import path
from getpass import getpass
from requests import Session
from bs4 import BeautifulSoup
from requests.utils import CaseInsensitiveDict
from requests.sessions import urljoin, urlparse, Session
from urllib.parse import urlparse, urljoin
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from urllib.parse import unquote

__version__ = "0.2.1"
__version__ = "0.3.0"


class BadUserNameOrPasswordException(Exception):
Expand Down Expand Up @@ -97,7 +98,7 @@ def login(self, username, password):
raise NotImplementedError()

def logout(self):
raise NotImplementedError()
self.session.get(urljoin(self.url, "/logout"))


class CTFd(CTF):
Expand Down Expand Up @@ -147,9 +148,6 @@ def login(self, username, password):
return True
return False

def logout(self):
self.session.get(urljoin(self.url, "/logout"))

def __get_file_url(self, file_name):
if not file_name.startswith('/files/'):
file_name = f"/files/{file_name}"
Expand Down Expand Up @@ -190,16 +188,14 @@ def iter_challenges(self):

class rCTF(CTF):
def __init__(self, url):
self.url = url
self.session = Session()
self.logger = logging.getLogger(__name__)
super().__init__(url)
self.BarerToken = ''

@staticmethod
def __get_file_url(file_info):
return file_info['url']

def login(self, team_token):
def login(self, team_token, **kwargs):
team_token = unquote(team_token)
headers = {
'Content-type': 'application/json',
Expand All @@ -219,7 +215,6 @@ def login(self, team_token):
return False

def __iter_challenges(self):

headers = {
'Content-type': 'application/json',
'Accept': 'application/json',
Expand All @@ -239,9 +234,6 @@ def iter_challenges(self):
files=list(map(self.__get_file_url, challenge.get('files', [])))
)

def logout(self):
self.session.get(urljoin(self.url, "/logout"))


def get_credentials(username=None, password=None):
username = username or os.environ.get('CTF_USERNAME', input('User/Email: '))
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ CTFd Dump Tool - When you want to have an offline copy of a CTF.

`python CTFDump.py -u username -p password https://demo.ctfd.io/`

> or for rCFT platform
> or for rCTF platform
`python CTFDump.py -c rCTF -t [token-team] https://demo.ctfd.io/`

### Command Line Flags

See `--help` for the complete list, but in short:

```sh
```text
usage: CTFDump.py [-h] [-v] [-c {CTFd,rCTF}] [-n] [-u USERNAME] [-p PASSWORD] [-t TOKEN] url
positional arguments:
url ctf url (for example: https://demo.ctfd.io/)
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-c {CTFd}, --ctf-platform {CTFd} ctf platform (default: CTFd)
-u USERNAME, --username USERNAME username (default: None)
-p PASSWORD, --password PASSWORD password (default: None)
-t TOKEN, --token TOKEN team token for rCTF (default: None)
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-c {CTFd,rCTF}, --ctf-platform {CTFd,rCTF}
ctf platform (default: CTFd)
-n, --no-login login is not needed (default: False)
-u USERNAME, --username USERNAME username (default: None)
-p PASSWORD, --password PASSWORD password (default: None)
-t TOKEN, --token TOKEN team token for rCTF (default: None)
```
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests>= 2.24.0
beautifulsoup4>= 4.9.3
beautifulsoup4>= 4.9.3

0 comments on commit b945708

Please sign in to comment.