逆向工程实验虚拟机实验环境配置

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-23 11:45   105   0

0x00 环境

软件:vmware workstation pro 15.5, ubuntu 18.04.3 LTS

0x01 配置步骤

1、更换Ubuntu软件下载源

(Ubuntu自带的软件下载源是国外的网址,国内访问比较慢,经常会导致软件下载中断)

备份:

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

修改:

$ sudo gedit /etc/apt/sources.list

(网上大多教程都使用vim或者vi来进行编辑,但gedit的图形界面相较于它们都更加编辑,而且系统自带的)

将sources.list中的内容更替为以下内容:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新:

$ sudo apt update

2、关闭地址随机化保护

查看当前的地址随机化保护模式(“2”表示已经打开):

$ cat /proc/sys/kernel/randomize_va_space

关闭:

$ sudo su
# echo 0 > /proc/sys/kernel/randomize_va_space

3、安装gcc/g++

$ sudo apt update
$ sudo apt install build-essential

4、安装python下的pwntools

ubuntu18.04默认自带python3,不带python2,而且pwntools也开始支持python3了,所以直接用python3-pip来安装就好

$ sudo su
# apt-get update
# apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
# python3 -m pip install --upgrade pip
# python3 -m pip install --upgrade git+https://github.com/Gallopsled/pwntools.git@dev3

上述方法不可用时可尝试以下方法:

$ sudo su
# git clone https://github.com/Gallopsled/pwntools
# cd pwntools
# python3 setup.py install

如果需要python2下的pwntools安装,参考如下指令:

$ sudo su
# apt-get update
# apt-get install python2.7 python-pip python-dev git libssl-dev libffi-dev build-essential
# pip install --upgrade pip
# pip install --upgrade pwntools

5、安装Docker

更新源:

$ sudo apt update

启用https:

$ sudo apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加GPG key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

添加稳定版的源:

$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

安装Docker CE:

$ sudo apt update
$ sudo apt install -y docker-ce

参考:

https://www.linuxidc.com/Linux/2019-07/159613.htm

6、安装peda或pwndbg

安装peda:

$ git clone https://github.com/longld/peda.git ~/peda
$ echo “source ~/peda/peda.py” >> ~/.gdbinit
$ echo “DONE! debug your program with gdb and enjoy”

安装pwndbg:

$ git clone https://github.com/pwndbg/pwndbg
$ cd pwndbg
$ ./setup.sh

参考:

http://www.peckerwood.top/post/peda_vs_pwndbg_gdb/

我无法使用文中的“优雅方法”,所以就用了最笨的方方法,每次想要切换时就去编辑~/.gdbinit,~/gdbinit里面修改为:

source ~/peda/peda.py

# source ~/pwndbg/gdbinit.py

peda和pwndbg在gdb中无法同时使用,不用哪个就用#注释掉它,保存后直接运行gdb即可看见当前使用的是哪个插件。

7、安装32位的依赖库

实验过程中需要编译出32的位的ELF文件,懒得再装一个32位的虚拟机,所以直接装32位的依赖库就好(ubuntu18.04好像是没有32位的,想要装32位的系统得去找16.04及以下的版本)

$ sudo apt install lib32ncurses5
$ sudo apt install lib32z1
$ sudo apt-get install lib32stdc++6

0x03 配置过程中需要注意的点

1、安装软件时出现提示所装软件的系统依赖部件版本过低

ubuntu-18.04.3-desktop-amd64.iso这个镜像刚刚装好时,系统会出现一个弹窗让你更新系统,忽略掉它,直接执行上述的安装操作就可以了。此外,尽量使用vmware先创建一个空白盘的虚拟机,再自行添加镜像,执行标准的linux系统安装过程。

2、关于apt install与apt-get install

ubuntu系统官方现在推荐使用apt install(特殊需求和软件要求另论)。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP