MoeCTF2023_AI

MoeCTF2023_AI

入门指北

Flag = moectf{A_B_C_D} ,官方是建议的不带GPU支持的PyTorch安装指令是:

pip3 A B C D

moectf{install_torch_torchvision_torchaudio}

在这里插入图片描述


EZ MLP

import numpy as np

def fc(x, weight, bias):
    # return np.matmul(x, weight) + bias矩阵相乘
    return np.matmul(weight, x) + bias

def forward(x):
    z1 = fc(x, w1, b1)
    z2 = fc(z1, w2, b2)
    y = fc(z2, w3, b3)
    return y

w1 = np.load('npys/w1.npy')
b1 = np.load('npys/b1.npy')
w2 = np.load('npys/w2.npy')
b2 = np.load('npys/b2.npy')
w3 = np.load('npys/w3.npy')
b3 = np.load('npys/b3.npy')

float2chr = lambda f: chr(int(np.round((f + 1) * 255 / 2)))

inputs = np.load('npys/inputs.npy')
flag = ''
for i in range(len(inputs)):
    y = forward(inputs[i])
    c0 = float2chr(y[0, 0])
    c1 = float2chr(y[1, 0])
    flag += c0 + c1
print('moectf{' + flag + '}')
# moectf{fR13NdsHlP_15_M491C!}
# Hints:
#  > Fix the bug in the code to get the flag, only one line of code needs to be changed.
#  > Understand the code and the figure(Example.jpg) before flag submission.
#  > Example.jpg is only for tutorial and demonstration, no hidden information contained.

ABC

import numpy as np

from PIL import Image
A = np.load('A.npy')
B = np.load('B.npy')
C = np.load('C.npy')

num_rows, num_cols = A.shape
print(num_rows,num_cols)
num_rows, num_cols = B.shape
print(num_rows,num_cols)
num_rows, num_cols = C.shape
print(num_rows,num_cols)

inputs=np.matmul(A, B)
inputs=np.matmul(inputs, C)
print(inputs)
num_rows, num_cols = inputs.shape

im = Image.new('RGB', (num_rows, num_cols))
white = (255, 255, 255)
black = (0, 0, 0)
for i in range(num_rows):
    for j in range(num_cols):
        if inputs[i,j]<0:
            print("-1",end=" ")
            im.putpixel((i, j), black)
        else:
            print("1",end=" ")
            im.putpixel((i, j), white)
    print()

im.save("flag.jpg")

在这里插入图片描述

moectf{U_C4n_D0_uR_AipH4_B_See_2023}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值