news 2026/6/23 10:17:22

Fourtune_ML_CTF_Challenge

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Fourtune_ML_CTF_Challenge

搭建

慢就用我的

Dockerfile

FROM python:3.11-slim WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* RUN pip install --no-cache-dir --trusted-host mirrors.aliyun.com \ -i http://mirrors.aliyun.com/pypi/simple/ \ scikit-image requests COPY model.h5 server.py templates/ ./ EXPOSE 8080 CMD ["python", "server.py"]

Server.py

import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' from http.server import HTTPServer, BaseHTTPRequestHandler import ssl import sys import cgi import base64 import numpy as np # from skimage import io from io import BytesIO import requests import keras from PIL import Image import imghdr model = keras.models.load_model('./model.h5') print("Welcome to .....\n") print("""\ █▀▀ █▀█ █░█ █▀█ ▀█▀ █░█ █▄░█ █▀▀ █▀▄▀█ █░░ █▀▀ ▀█▀ █▀▀ █▀▀ █░█ ▄▀█ █░░ █░░ █▀▀ █▄░█ █▀▀ █▀▀ █▀░ █▄█ █▄█ █▀▄ ░█░ █▄█ █░▀█ ██▄ █░▀░█ █▄▄ █▄▄ ░█░ █▀░ █▄▄ █▀█ █▀█ █▄▄ █▄▄ ██▄ █░▀█ █▄█ ██▄ """) print("Created by: Alex Neelankavil Devassy") print("Access http://127.0.0.1 in host systems's browser") print("Press Ctrl+C to quit") with open("templates/AICorp.html","rb") as file: STATIC_HTML_PAGE = file.read() #simple web server class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): def do_GET(self): forwardedfor = str(self.headers['X-Forwarded-For']) print(f"GET {forwardedfor}") self.send_response(200) self.end_headers() self.wfile.write(STATIC_HTML_PAGE) def do_POST(self): content_length = int(self.headers["Content-Length"]) if int(content_length) > 10000000: print("File too big") self.send_response(500, "File too big") return form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={"REQUEST_METHOD":"POST", "CONTENT_TYPE":self.headers["Content-Type"], }) filename = str(form['file'].filename) forwardedfor = str(self.headers['X-Forwarded-For']) print(f"POST {forwardedfor} File: {filename} - ", end = ".") data = form["file"].file.read() print("Checking image", end = ". ") #print(data) filetype = imghdr.what(file="", h=data) print(filetype) if filetype not in ["png","jpeg","gif"]: print(f"Unsupported media type: {filetype}", end = ". ") self.send_response(415, "Only png, jpg and gif are supported.") return image = np.array(Image.open(BytesIO(data)).convert("L")) processedImage = np.zeros([1, 28, 28, 1]) for yy in range(28): for xx in range(28): processedImage[0][xx][yy][0] = float(image[xx][yy]) / 255 shownDigit = np.argmax(model.predict(processedImage)) self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() if shownDigit == 4: response = '{ "text": " Welcome Mr. ' + str(shownDigit) +'tune {++BackPropogation Magic++}"}' else: response = '{ "text": "Access Denied"}' sys.stdout.flush() self.wfile.write(bytes(response,"utf-8")) httpd = HTTPServer(("", 8080), SimpleHTTPRequestHandler) httpd.serve_forever()

攻击流程

样本对抗就好

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/23 10:12:50

【置顶干货】博主介绍,各类系统源码领取途径

文章目录关于我们项目技术支持获取博主联系方式关于我们 博主本身从事开发软件开发、有丰富的编程能力和水平、累积给上千名同学进行辅导、有自己的独立工作室,目前只专注做自己专业领域的事。团队人员有多年架构师设计经验、多人有参加校企合作经验,被…

作者头像 李华
网站建设 2026/6/23 10:04:36

凸松弛紧密度分析:割多面体、度量多面体与椭球体的体积比较

1. 项目概述:从“松弛”到“紧密度”的优化博弈在算法设计与理论计算机科学领域,我们常常需要求解一些“难啃的骨头”——NP难问题。直接求解最优解往往计算上不可行,于是“松弛”技术应运而生。它好比给一个形状不规则、难以直接测量的物体&…

作者头像 李华
网站建设 2026/6/23 9:59:21

React Navigation 核心原理与工程实践指南

1. 为什么在 React Native 里“路由”不是加个 <Router> 就完事了&#xff1f; 刚从 Web 端转来 React Native 的人&#xff0c;第一反应往往是&#xff1a;“React Router 那套我熟啊&#xff0c; <BrowserRouter> <Route> 一配&#xff0c;页面跳转…

作者头像 李华
网站建设 2026/6/23 9:56:02

移动设备远程控制风险剖析与防御实战:从漏洞利用到企业安全管控

1. 项目概述&#xff1a;一次关于移动设备安全边界的深度探讨最近在和一些做移动应用开发和安全研究的朋友交流时&#xff0c;大家不约而同地提到了一个现象&#xff1a;随着移动办公和BYOD&#xff08;自带设备办公&#xff09;的普及&#xff0c;个人手机与公司数据的边界越来…

作者头像 李华
网站建设 2026/6/23 9:49:49

JavaScript错误处理三界:哪些能catch,哪些必须绕过

1. 为什么你写的 try...catch 总是“没用”&#xff1f;——从报错消失到错误追踪失效的真相JavaScript 的try...catch是每个前端开发者入职第一天就被塞进脑子的语法糖&#xff0c;但也是最常被误用、最常被忽视、最常在生产环境里“假装工作”的错误处理机制。我带过二十多个…

作者头像 李华
网站建设 2026/6/23 9:48:20

听书APP哪个好用?帆书、喜马拉雅、微信读书、番茄畅听适合不同需求

很多人搜索“听书APP哪个好用”&#xff0c;真正想问的不是哪个平台一定最好&#xff0c;而是哪一款更适合自己的使用场景。有人想听书籍解读&#xff0c;有人想听有声小说&#xff0c;有人需要通勤陪伴&#xff0c;也有人希望先通过音频判断一本书值不值得继续读。 简单来说&…

作者头像 李华