CTF练习题[MISC]-0和1的故事(二维码生成)
生活随笔
收集整理的這篇文章主要介紹了
CTF练习题[MISC]-0和1的故事(二维码生成)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
練習題地址:https://ctf.bugku.com/challenges/detail/id/216.html
拿到題目,txt中是01字符串
Excel手動生成
在字符后插入空格
用Excel打開
使用空格分隔
調整列寬并設置條件格式
將值為1的單元格填充背景為黑色
值為0的單元格設置字體為白色
將二維碼缺失的三角補上
掃描二維碼獲取flag
python腳本生成
生成圖片https://blog.csdn.net/qq_43528553/article/details/119084941
from PIL import Imagewith open("1和0的故事.txt", "r") as f:data = [list(i.strip()) for i in f.readlines()]# 7*7的定位標志 flag = [[1, 1, 1, 1, 1, 1, 1],[1, 0, 0, 0, 0, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 0, 0, 0, 0, 1],[1, 1, 1, 1, 1, 1, 1] ]img = Image.new("1", (25, 25)) for i in range(len(data)):for j in range(len(data[1])):# 左上角定位標志if i < 7 and j < 7:img.putpixel((i, j), flag[i][j] ^ 1)# 左下角定位標志elif i > 17 and j < 7:img.putpixel((i, j), flag[i-18][j] ^ 1)# 右上角定位標志elif i < 7 and j > 17:img.putpixel((i, j), flag[i][j-18] ^ 1)else:img.putpixel((i, j), int(data[i][j]) ^ 1)img.resize((500, 500)).show()修改了腳本,生成到Excel中
import xlwtworkbook=xlwt.Workbook() worksheet=workbook.add_sheet('My Sheet')# 顏色填充 pattern = xlwt.Pattern() # Create the Pattern pattern.pattern = xlwt.Pattern.SOLID_PATTERN # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12 pattern.pattern_fore_colour = 0 # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , almost brown), 20 = Dark Magenta, 21 = Teal, 22 = Light Gray, 23 = Dark Gray, the list goes on... style = xlwt.XFStyle() # Create the Pattern style.pattern = pattern # Add Pattern to Stylewith open("1和0的故事.txt", "r") as f:data = [list(i.strip()) for i in f.readlines()]flag = [[1, 1, 1, 1, 1, 1, 1],[1, 0, 0, 0, 0, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 1, 1, 1, 0, 1],[1, 0, 0, 0, 0, 0, 1],[1, 1, 1, 1, 1, 1, 1]]for i in range(len(data)):for j in range(len(data[1])):a=int(data[i][j])# 左上角定位標志if i < 7 and j < 7 and flag[i][j] ==1:worksheet.write(i,j,'',style)# 左下角定位標志elif i > 17 and j < 7 and flag[i-18][j] ==1:worksheet.write(i,j,'',style)# 右上角定位標志elif i < 7 and j > 17 and flag[i][j-18] ==1:worksheet.write(i,j,'',style)elif a==1:worksheet.write(i,j,'',style)worksheet.col(i).width = 500 #設置列寬(無法設置行高)workbook.save('0和1的故事.xls')總結
以上是生活随笔為你收集整理的CTF练习题[MISC]-0和1的故事(二维码生成)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 你们要的代码来了!爬了菊姐的两万条评论—
- 下一篇: 在网页上使用虚拟仿真需要使用什么技术?