May 22, 2024

PWN入门指引

如果说Crypto需要强逻辑,Reverse需要沉下心,那PWN就可以简单理解为两点都需要 / 环境配置 / Mac: - UTM - roderick师傅的Docker法 Win: Ubuntu WSL/VMware / 上手,不要着急做题,先打基础:从 CS:APP 开始 (中文翻译:深入理解计算机系统 翻译版电子书版本) 计算机N大黑书其一
Read more
July 2, 2023

PWNable.kr 肥肠适合初学者

col ssh 连上执行ls -la看看(-la参数可以浏览文件属性) cat col.c查看源文件 / #include <stdio.h> #include <string.h> unsigned long hashcode = 0x21DD09EC; unsigned long check_password(const char* p){ int* ip = (int*)p; int i; int res=0; for(i=0; i<5; i++){ res += ip[i]; } return res; } int main(int argc, char* argv[]){ if(argc<2){ printf("usage : %s [passcode]\n", argv[0]); return 0; } if(strlen(argv[1]) != 20){ printf("passcode length should be 20 bytes\n"); return 0; } if(hashcode == check_password( argv[1] )){ system("/bin/cat flag"); return 0; } else printf("wrong passcode.\n"); return 0; } 分析出需要执行 col 这个程序时传参, 而且参数需要20bytes长, 同时要求参数经过 check_password() 后等于 hashcode 变量
Read more
July 1, 2023

2023 UIUCCTF 部分题解 (内含busybox)

Misc Corny Kernel 拿到题目看见有源码和一行代码,用来连远端 / socat file:$(tty),raw,echo=0 tcp:corny-kernel.chal.uiuc.tf:1337 源码 -> pwnymodule.c // SPDX-License-Identifier: GPL-2.0-only #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> extern const char *flag1, *flag2; static int __init pwny_init(void) { pr_alert("%s\n", flag1); return 0; } static void __exit pwny_exit(void) { pr_info("%s\n", flag2); } module_init(pwny_init); module_exit(pwny_exit); MODULE_AUTHOR("Nitya"); MODULE_DESCRIPTION("UIUCTF23"); MODULE_LICENSE("GPL"); MODULE_VERSION("0.1"); 根据提示连上远端
Read more
May 30, 2023

CSAPP

lab 拆弹 第一步的exp, 进 ida 一眼顶针发现是个字符串比对 from pwn import * import sys import argparse context.log_level = 'debug' path_to_elf = '/home/lov3/PWN/OS/bomb_XBan/bomb' elf = ELF(path_to_elf) libc = elf.libc ip = sys.argv[1] # sys.argv[0] 为当前文件名 if len(sys.argv[1]) < 5: port = 0 else: port = int(sys.argv[2]) if port == 0: p = process(path_to_elf) else: p = remote(ip, port) sla = lambda x,y : p.sendlineafter(x,y) sa = lambda x,y : p.sendafter(x,y) ru = lambda x : p.recvuntil(x) def g(arg=''): if port != 0: return gdb.attach(p, arg) raw_input() def choice(op): sla('choice: ', str(op)) def arena(op): choice(1) choice(str(op)) def buy(obj): choice(2) sla('want a', obj) def use(obj): choice(3) choice(1) ru('use?\n') sa(']', obj) def leak_heap(x, y, z): ret = (z ^ 0xBAAD)<<16 ret = (ret + y ^ 0xBAAD)<<16 ret += x ^ 0xBAAD return ret p.recvuntil('day!\n') # 传回 'Border relations with Canada have never been better.' p.sendline(b'Border relations with Canada have never been better.') p.recvuntil(b'next one?\n') p.interactive()
Read more