GithubHelp home page GithubHelp logo

zju-cst / drls Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 2.0 728 KB

Zhejiang University software college dormitory random lottery system

Home Page: http://www.cst.zju.edu.cn/

License: Mozilla Public License 2.0

CSS 15.56% JavaScript 8.52% Python 63.52% HTML 12.20% Shell 0.19%

drls's Issues

第一个随机种子可篡改

根据文件DRLS/drls/public/views.py:

        # check passwd
        lock_file_path = os.path.join(app.config['UPLOAD_FOLDER'],app.config['LOCK_FILE_NAME'])
        lock = file_exists(lock_file_path)
        if lock:
            passwd = request.form['passwd']
            app.logger.info(passwd)
            app.logger.info(lock)
            passwd_file = open(lock_file_path,'r')
            real_passwd = passwd_file.readline().strip()
            passwd_file.close()
            if real_passwd != passwd:
                return JSONR(ERRCODE.UNAUTHORIZED,'password was wrong')
        else:
            pass
        seed_file_path = os.path.join(app.config['UPLOAD_FOLDER'], app.config['RANDOMSEED_FILE_NAME'])
        num_file_path = os.path.join(app.config['UPLOAD_FOLDER'], app.config['RANDOMNUM_FILE_NAME'])

第一个随机种子来自于用户输入,第二次修改需要知道lock.txt中的密码,而http://localhost:2992/刚好可以读取项目下任意文件,可篡改随机种子。

已知的随机种子导致结果可预测

文件DRLS/drls/rng.py中获取随机数使用外部随机种子:

        ran = random.uniform(0,self.range)
        return ran

第一个随机种子来源于外部文件上传,文件DRLS/drls/public/views.py:

def upload():
    if request.method == 'POST':
        seed = request.form['randomSeed']
        num = request.form['randomNum']

已知的随机种子导致结果可预测

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.