先天八卦操

admin 2022年1月5日22:48:52CTF专场评论13 views1976字阅读6分35秒阅读模式

>

>

先天八卦操

cheyenne

Baguafuck-encode:

from PIL import Image
import math

# 生成阳爻
yang = Image.new('RGB', (48, 10), (0, 0, 0))

# 生成阴爻
yin = Image.new('RGB', (48, 10), (0, 0, 0))
tmp = Image.new('RGB', (12, 10), (255, 255, 255))
yin.paste(tmp, (18, 0))

# 生成八卦
def bagua(int):
    if 0 <= int <= 7:
        s = str(bin(int))[2:].zfill(3)
        img = Image.new('RGB', (64, 64), (0, 0, 0))
        box = Image.new('RGB', (63, 63), (255, 255, 255))
        img.paste(box, (0, 0))
        for i in range(3):
            if s[2-i] == '0':
                img.paste(yang, (8, 7 + i * 20))
            elif s[2-i] == '1':
                img.paste(yin, (8, 7 + i * 20))
        return(img)

dic = {}
for i in range(8):
    dic['><+-.,[]'[i]] = i

def baguafuck(code, width, path):
    code = code.replace(' ', '').replace('\n', '').replace('\r', '')
    l = len(code)
    height = math.ceil(l / width)
    img = Image.new('RGB', (width * 64, height * 64), (255, 255, 255))
    for i in range(l):
        x = (i % width) * 64
        y = (i // width) * 64
        img.paste(bagua(dic]), (x, y))
    img.save(path)

path = 'C:/Users/Administrator/Desktop/8guafuck/'
hw = '++++++++++[->++++++++++<]>++++.---.+++++++..+++.++++++++.--------.+++.------.--------.<'
flag = '+++++++++[->+++++++++<]>++++++++++++++++++.<++++[->++++<]>+.<+++[->---<]>-----.<+++[->+++<]>++++.<+++[->---<]>--.+++++++.++++++++.++++.<+++++++[->-------<]>--.<++++[->----<]>----.<+++++++[->+++++++<]>+++++++++++..+++++++++.<+++++[->-----<]>-.<++++[->----<]>-.<+++++[->-----<]>----.<++++++++[->++++++++<]>++++.<++++[->----<]>------.------.<++++++[->------<]>--.+.<+++++++[->+++++++<]>+++++++++++++.<+++++++++[->---------<]>.<+++++++++[->+++++++++<]>+++++++++++.<'

baguafuck(hw, 22, path + 'helloworld.png')
baguafuck(flag, 22, path + 'flag.png')

Baguafuck-decode:

from PIL import Image

def baguafuck_decode(path):
    img = Image.open(path)
    w, h = img.size

    dic = '><+-.,[]'
    code = ''

    for y in range(0, h, 64):
        for x in range(0, w, 64):
            check = img.getpixel((x + 8, y + 7))
            tmp = ''
            if check == (0, 0, 0):
                for k in range(3):
                    p = img.getpixel((x + 26, y + 47 - 20 * k))
                    if p == (0, 0, 0):
                        tmp += '0'
                    elif p == (255, 255, 255):
                        tmp += '1'
                code += dic[int(tmp, 2)]

    print(code)

path = 'C:/Users/Administrator/Desktop/8guafuck/'

baguafuck_decode(path + 'helloworld.png')
baguafuck_decode(path + 'flag.png')

cheyenne

额外IDAT数据块的来源:
https://www.mm683.com/album-fzly/47973


特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日22:48:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  先天八卦操 http://cn-sec.com/archives/719356.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: