BUUCTF [AFCTF2018]MagicNum

考察float存储小端序问题

72065910510177138000000000000000.000000,
71863209670811371000000.000000,
18489682625412760000000000000000.000000,
72723257588050687000000.000000,
4674659167469766200000000.000000,
19061698837499292000000000000000000000.000000

这里利用 struct库进行转换

from libnum import *
import struct

s = [
    72065910510177138000000000000000.000000,
    71863209670811371000000.000000,
    18489682625412760000000000000000.000000,
    72723257588050687000000.000000,
    4674659167469766200000000.000000,
    19061698837499292000000000000000000000.000000
]
a = b""
for i in s:
    i = float(i)
    a = a + struct.pack('<f',i)
print(a)
# print(n2s(int(a,16)))

如果是大端序就是 '>f'
这里可以将a = ""但是pack后要转换为hex(本身为byte类型)

posted @ 2023-10-01 20:46  N0zoM1z0  阅读(16)  评论(0编辑  收藏  举报