Skip to content

Commit e64264b

Browse files
committed
Add cloud, proxy, export support
1 parent 4530273 commit e64264b

File tree

70 files changed

+1740
-961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1740
-961
lines changed

README.md

+161-40
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ $ pip install cython
1616

1717
### Installation
1818

19-
After fulfilling the prerequisites, you can directly clone this repository or download the source from our [releases](https://github.com/eiji98/CTFdScraper/releases).
19+
After fulfilling the prerequisites, you can directly clone this repository or download the source from our [releases](https://github.com/hanasuru/CTFdScraper/releases).
2020

2121
```bash
22-
$ git clone https://github.com/eiji98/CTFdScraper
22+
$ git clone https://github.com/hanasuru/CTFdScraper
2323
```
2424

2525
After that, go install its dependencies by using `pip`.
@@ -35,43 +35,92 @@ For instances, you can check helper section by passing `-h` or `--help`.
3535

3636
```bash
3737
$ python ctfd.py --help
38-
usage: ctfd.py [-h] [--data data] [--path path] [--worker worker]
39-
[--scheme scheme] [--override] [--no-download]
38+
usage: ctfd.py [-h] [--data data] [--proxy proxy] [--path path]
39+
[--worker worker] [--scheme scheme] [--enable-cloud]
40+
[--override] [--no-download] [--export]
4041
[user] [passwd] [url]
4142

4243
Simple CTFd-based scraper for challenges gathering
4344

4445
positional arguments:
4546
user Username/email
46-
passwd User password
47+
passwd Password
4748
url CTFd platform url
4849

4950
optional arguments:
5051
-h, --help show this help message and exit
51-
--data data Populate from chall.json
52+
--data data Populate from challs.json
53+
--proxy proxy Request behind proxy server
5254
--path path Target directory, default: CTF
53-
--worker worker Number of threads, default: 3
55+
--worker worker Number of threads, default: 10
5456
--scheme scheme URL scheme, default: https
55-
--override Overrides old chall file
56-
--no-download Don't download chall assets
57+
--enable-cloud Permit file download from a cloud drive, default=False
58+
--override Override existed chall file
59+
--no-download Don't download chall file
60+
--export Export challenges directory as zip, default=False
5761
5862
```
59-
### Collect challenges
63+
### Collect challenges by credentials
6064
6165
By default, you need to define `username`, `password`, and `CTFd` url respectively (use HTTPS by default).
6266
6367
```bash
6468
$ python ctfd.py user passwd https://some-domain
6569
```
6670
67-
Alternatively, you can also populate only the challenges from an existed `challs.json`. Unfortunately, you need to pass `username` & `password` in order to download the [internal files](https://github.com/CTFd/CTFd/issues/789) . Furthermore, check the [examples](./examples/CTF/challs.json).
71+
### Enable Cloud-files download
72+
73+
By default, this option are disabled due to file size issues where user accidentally spend most of internet quotas from downloading a large file. Otherwise, you can enable this opting by passing `--enable-cloud` argument
74+
75+
```bash
76+
$ python ctfd.py user passwd https://some-domain --enable-cloud
77+
```
78+
79+
Currently, only `Google-drive` and `Dropbox` that are supported.
80+
81+
As a note, the review that shows size output may be wrong (false positive) due to the usage of request.get(url, stream=True) in order to get the `Content-Length` header
82+
83+
### Override existed challenges file
84+
85+
During CTF competition, the organizer may update the current binary/file. Unfortunately, by default `CTFdScraper` couldn't override the existed challenges file. If you insist to modify the current binary/file, you need to pass `--override` argument
86+
87+
```bash
88+
$ python ctfd.py user passwd https://some-domain --override
89+
```
90+
91+
### Collect challenges by existed `challs.json`
92+
93+
Alternatively, you can also populate only the challenges from an existed `challs.json`. Additionally, you can also combine with `--enable-cloud` & `--override` to download files from a cloud drive. Furthermore, check the [examples](./examples/CTF/Arkavidia/challs.json).
6894

6995
```bash
7096
# Populate challenges only from existed data
71-
$ python2 ctfd.py --data challs.json
97+
$ python ctfd.py --data challs.json
7298
7399
# Populate challenges alongwith files
74100
$ python ctfd.py user passwd https://some-domain --data chall.json
101+
102+
# Populate challenges alongwith interal file (if public) and external file
103+
$ python ctfd.py --data chall.json --enable-cloud --override
104+
```
105+
106+
### Enable request behind proxy
107+
108+
To be able to conduct a requests behind proxy you need to pass `--proxy proxy-server` argument or manually add `export http_proxy="http://host:port"`.
109+
110+
```bash
111+
$ python ctfd.py user passwd https://some-domain --proxy 127.0.0.1:8080
112+
113+
# or set up an environtment variable
114+
$ export http_proxy = "http://127.0.0.1:8080"
115+
$ export https_proxy = "http://127.0.0.1:8080"
116+
```
117+
118+
### Wrap up the CTFd folder into a Zip file
119+
120+
For archiving purpose, you can save the `CTFd` folder as a Zip file by passing the `--export` argument
121+
122+
```bash
123+
$ python ctfd.py user passwd https://some-domain --export
75124
```
76125

77126
Lastly, the collected challenge will be saved to `CTF/${ctf_name}`
@@ -84,63 +133,135 @@ directory. You can customize the path by passing `--path pathname`argument.
84133
```bash
85134
$ tree
86135
.
87-
├── challs.json
88-
├── Crypto
89-
│ ├── 007-1
90-
│ │ ├── chall.zip
91-
│ │ └── README.md
92-
│ └── Simple Math
93-
│ ├── chall.zip
94-
│ └── README.md
95-
└── Web
96-
├── ArkavPay
97-
│ ├── ArkavPay.zip
98-
│ └── README.md
99-
├── Balasan Buruk
100-
│ └── README.md
101-
└── Edit Your Source
102-
└── README.md
136+
└── Online Playground CTF for Beginner
137+
├── challs.json
138+
├── Cryptography
139+
│   ├── Base64
140+
│   │   └── README.md
141+
│   └── Single-Byte XOR Cipher
142+
│   └── README.md
143+
├── Forensic
144+
│   ├── Data Exfil
145+
│   │   └── README.md
146+
│   └── Volatility 4
147+
│   └── README.md
148+
├── Pwn
149+
│   ├── cariuang
150+
│   │   └── README.md
151+
│   └── vault
152+
│   └── README.md
153+
├── Reverse
154+
│   ├── IFEST-password
155+
│   │   └── README.md
156+
│   └── Password
157+
│   └── README.md
158+
└── Web
159+
├── babyPHP
160+
│   └── README.md
161+
└── Optimus Prime
162+
└── README.md
103163
```
104164

105-
### Challenge README
165+
### Challenge README.md
106166

107167
```
108-
# Balasan Buruk [344 pts]
168+
# Optimus Prime [50 pts]
109169

110170
**Category:** Web
111171
**Solves:** 23
112172

113173
## Description
114-
>Saya baru saja belajar mata kuliah Jaringan Komputer, sebagai Tugas Besar, saya ditugaskan untuk membuat HTTP server sederhana tanpa menggunakan library HTTP apapun.
174+
>Optimus Prime is coming
115175
116-
`http://3.0.19.78:15001`
176+
http://18.139.8.91:3015/
117177

118-
Author: didithilmy
178+
author: Arkavidia5
119179

120180
**Hint**
121-
*
181+
* -
122182

123183
## Solution
124184

125185
### Flag
126186
```
127187
128-
129188
## Demo
130189
131-
For instances, here is the demonstration of CTFdScraper.
190+
For instances, here is the demonstration of CTFdScraper. For simplicity, the svg file was removed
191+
192+
### Scrape using credentials
193+
194+
```bash
195+
▶ python ctfd.py test 12345 http://playgroundctf.xyz
196+
✔ Login Success
197+
✔ Found 43 new challenges
198+
✔ Found 24 files (0.5 MB downloaded)
199+
200+
[Summary]
201+
✔ Web (3)
202+
✔ Reverse (3)
203+
✔ Cryptography (9)
204+
✔ Forensic (10)
205+
✔ Intro (7)
206+
✔ Survey (1)
207+
✔ Pwn (5)
208+
✔ Hacktoday 2019 - Penyisihan (5)
209+
210+
[Finished in 3.44 second]
211+
```
212+
213+
### Scrape using cloud drive support
132214

133-
![Alt text](demo.svg)
215+
```bash
216+
▶ python ctfd.py test 12345 http://playgroundctf.xyz --enable-cloud
217+
✔ Login Success
218+
✔ Loaded 43 challs from challs.json
219+
⚠ There are no new challenges
220+
✔ Found 26 files (143.0 MB downloaded)
221+
222+
[Summary]
223+
✔ Web (3)
224+
✔ Reverse (3)
225+
✔ Cryptography (9)
226+
✔ Forensic (10)
227+
✔ Intro (7)
228+
✔ Survey (1)
229+
✔ Pwn (5)
230+
✔ Hacktoday 2019 - Penyisihan (5)
231+
232+
[Finished in 9.56 second]
233+
```
134234

235+
### Scrape using existed `chall.json`
236+
237+
```bash
238+
▶ python ctfd.py --data challs.json
239+
✔ Loaded 43 challs from challs.json
240+
✔ Found 24 files (0.0 MB downloaded)
241+
242+
[Summary]
243+
✔ Web (3)
244+
✔ Reverse (3)
245+
✔ Cryptography (9)
246+
✔ Forensic (10)
247+
✔ Intro (7)
248+
✔ Survey (1)
249+
✔ Pwn (5)
250+
✔ Hacktoday 2019 - Penyisihan (5)
251+
252+
[Finished in 0.09 second]
253+
254+
```
135255

136256
## Authors
137257

138-
* **eiji98** - *Initial work*
139-
See also the list of [contributors](https://github.com/eiji98/CTFdScraper/contributors) who participated in this project.
258+
* **hanasuru** - *Initial work*
259+
260+
See also the list of [contributors](https://github.com/hanasuru/CTFdScraper/contributors) who participated in this project.
140261

141262
## License
142263

143-
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
264+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
144265

145266
## Credits
146267

0 commit comments

Comments
 (0)