GithubHelp home page GithubHelp logo

myctf's Introduction

MYCTF

MYCTF 是一个简单易扩展的CTF程序,用于举办小型比赛,基于sqlite和文本数据库。

依赖于:tornado peewee mako

支持 python3 或 python2.7

基于 FPage 生成

特性

  • 简单方便:不需要任何服务和额外配置,开箱即用。

  • 保证公平:详细的排名规则,首先按分数排名,分数相同时先做出题的人排在前面,不受字典序影响

  • 分数加值:每道题默认有5分附加分,首个解题者拿5分,第二个4分,以此类推。

使用说明

1. 开始

首先,你应该知道什么是CTF。

当你决定举办一个小比赛的时候,可以先按最底下说的办法把服务开起来。

然后登录到 127.0.0.1:9000 去注册一个账号,因为首个注册的帐号是管理员。

端口9000可以在配置文件中修改

2. 准备题目

当你大概搞明白系统是怎么回事,就可以准备题目了。

题目准备有两种办法,一种是直接编辑 ctf 目录下的题目文件,json格式。

另一种就是去后台编辑题目,我推荐这种,而且支持富文本编辑(注意并不会做过滤!管理员注意不要故意坑答题者!)。

题目的格式放在下面了,建议用之前也先看一看为妙。

3. 管理后台

进度管理:希望管理员勤按保存,因为进度不会在答题时实时保存(调试起来很方便……),save.json是保存出的文件,注意这点。

题目管理:编辑没啥可说的,当你以手动的方式在ctf目录加了一道题或者对题目进行了修改,就可以使用重新加载题目来重新读取配置。但是如果删除题目,系统中的题目不会跟着消失。这跟后台删除不同。

重置答题系统:记录清零,分数清零,所有题目重载(当然用户是保留的)。

一些截图

首页

首页

完成答题

答题完成后,题目会被标记为绿色。ccc是先完成题的用户,所以排在a11的上面,而不是按照字典序排列。

全局开题

有人完成前置题后,新的题目开放

做题

查看题目

后台

后台主界面

后台题目管理

后台题目管理

题目编辑

附录 - 题目格式

{
    "id": 3,
    "title": "问题 3",
    "score": 50,
    "key": "123",
    "depend": [],
    "depend-g": [],
    "txt": "test",
    "extra": 0
}

tips: 这个json是魔改的,在加载之前会首先替换掉换行符,所以可以在txt写题目的时候回车。

参数解释:

  • id、title:id和标题,地球人都懂,id不重复就行了。

  • score:做出这个题目可以得到的分数。

  • key:解题的flag。

  • depend:用户做了这些题,这道题才会开放(例如[1,2])。

  • depend-g:整个系统中有人做出这些题,这道题才会开放。

  • txt:题目内容,支持html标签。

  • extra:附加分值,若不写则为默认的5分

开启服务

pip install tornado peewee mako
python app.py

LICENSE

MIT

TODO-LIST

  • 自动保存

  • 后台可以扣分

myctf's People

Contributors

fy0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

myctf's Issues

运行报错,页面无响应

`ERROR:tornado.application:Uncaught exception GET / (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:9000', method='GET', uri='/', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/www/wwwroot/ctf/view/index.py", line 8, in get
self.render(nav='index')
File "/www/wwwroot/ctf/view/init.py", line 149, in render
self.finish(tmpl.render(**kwargs))
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1154, in finish
future = self.flush(include_footers=True)
File "/www/wwwroot/ctf/view/init.py", line 174, in flush
super(View, self).flush(include_footers, callback)
TypeError: flush() takes from 1 to 2 positional arguments but 3 were given
ERROR:tornado.application:Uncaught exception in write_error
Traceback (most recent call last):
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/www/wwwroot/ctf/view/index.py", line 8, in get
self.render(nav='index')
File "/www/wwwroot/ctf/view/init.py", line 149, in render
self.finish(tmpl.render(**kwargs))
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1154, in finish
future = self.flush(include_footers=True)
File "/www/wwwroot/ctf/view/init.py", line 174, in flush
super(View, self).flush(include_footers, callback)
TypeError: flush() takes from 1 to 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1214, in send_error
self.write_error(status_code, **kwargs)
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1242, in write_error
% {"code": status_code, "message": self._reason}
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1154, in finish
future = self.flush(include_footers=True)
File "/www/wwwroot/ctf/view/init.py", line 174, in flush
super(View, self).flush(include_footers, callback)
TypeError: flush() takes from 1 to 2 positional arguments but 3 were given
ERROR:tornado.application:Exception in exception handler
Traceback (most recent call last):
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/www/wwwroot/ctf/view/index.py", line 8, in get
self.render(nav='index')
File "/www/wwwroot/ctf/view/init.py", line 149, in render
self.finish(tmpl.render(**kwargs))
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1154, in finish
future = self.flush(include_footers=True)
File "/www/wwwroot/ctf/view/init.py", line 174, in flush
super(View, self).flush(include_footers, callback)
TypeError: flush() takes from 1 to 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1704, in _execute
self._handle_request_exception(e)
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1761, in _handle_request_exception
self.send_error(500, exc_info=sys.exc_info())
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1218, in send_error
self.finish()
File "/www/wwwroot/ctf/CTF_venv/lib/python3.7/site-packages/tornado/web.py", line 1154, in finish
future = self.flush(include_footers=True)
File "/www/wwwroot/ctf/view/init.py", line 174, in flush
super(View, self).flush(include_footers, callback)
TypeError: flush() takes from 1 to 2 positional arguments but 3 were given
`

系统环境如下:python3.7,Centos7.5,

windows环境下是否可以搭建此平台

报错:
Traceback (most recent call last):
File "app.py", line 4, in
import tornado.web
File "C:\smallctf\2.7.10\lib\site-packages\tornado\web.py", line 205
application: "Application",
^
SyntaxError: invalid syntax

系统环境:windows7服务器 python 2.7.10 使用webpy的框架运行尝试(失败)

数据库问题,不能新建用户

Server started at port 9000
ERROR:tornado.application:Uncaught exception POST /signup (223.98.217.101)
HTTPServerRequest(protocol='http', host='47.240.40.250:9000', method='POST', uri='/signup', version='HTTP/1.1', remote_ip='223.98.217.101')
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3057, in execute_sql
cursor.execute(sql, params or ())
sqlite3.OperationalError: attempt to write a readonly database

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tornado/web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/home/myctf/view/user.py", line 60, in post
u = User.new(username, password)
File "/home/myctf/model/user.py", line 37, in new
return cls.create(username=username, password=password_final, salt=salt, level=level)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 6235, in create
inst.save(force_insert=True)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 6433, in save
pk = self.insert(**field_dict).execute()
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 1845, in inner
return method(self, database, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 1916, in execute
return self._execute(database)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2665, in _execute
return super(Insert, self)._execute(database)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2400, in _execute
cursor = database.execute(self)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3070, in execute
return self.execute_sql(sql, params, commit=commit)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3064, in execute_sql
self.commit()
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2831, in exit
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 183, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3057, in execute_sql
cursor.execute(sql, params or ())
peewee.OperationalError: attempt to write a readonly database
ERROR:tornado.access:500 POST /signup (223.98.217.101) 7.27ms

系统环境:ubantu16.04 python 3.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.