zoukankan      html  css  js  c++  java
  • kernel pwn 入门环境搭建

    刚开始上手kernel pwn,光环境就搭了好几天,应该是我太菜了。。

    好下面进入正题,环境总共就由两部分构成,qemu和gdb。这两个最好都需要使用源码安装。

    我使用的安装环境为

    qemu:安装前要先安装

    sudo apt-get install libsdl2-2.0 
    sudo apt-get install libsdl2-dev
    sudo apt-get install libpixman-1-dev
    sudo apt-get install flex bison

    否则会出现QEMU界面弹不出来的问题。

    源码下载网址:https://download.qemu.org/

    然后是编译安装:

    ./configure --enable-debug  --target-list=x86_64-softmmu
    sudo make
    sudo make install

    gdb:

    一开始使用的是直接安装的gdb,然后卸不掉了,只好重新建一个虚拟机来配环境。

    gdb源码下载官网:http://www.gnu.org/software/gdb/download/
    gdb源码下载地址:http://ftp.gnu.org/gnu/gdb 
    国内镜像:https://mirrors.nju.edu.cn/gnu/

    gdb在源码编译前要先改gdb/remote.c中的process_g_packet函数,其中没有做处理而报了个error,这里添加处理:

    if (buf_len > 2 * rsa->sizeof_g_packet)
    error (_("Remote 'g' packet reply is too long: %s"), rs->buf);
    改为
    if (buf_len > 2 * rsa->sizeof_g_packet) {
        rsa->sizeof_g_packet = buf_len;
        for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
        {
            if (rsa->regs[i].pnum == -1)
                continue;
            if (rsa->regs[i].offset >= rsa->sizeof_g_packet)
                rsa->regs[i].in_g_packet = 0;
            else
                rsa->regs[i].in_g_packet = 1;
        }
    }

    否则的话在之后使用gdb连上之后可能会报selected thread is running。以及Remote 'g' packet reply is too long的错误。

    对于该错误,网上有相关建议是在gdb中set architecture i386:x86-64:intel设置架构,然后我这里没有效果。

    安装gdb时如果遇到makeinfo is missing on your system ,需要安装sudo apt-get install texinfo    

    另外如果有安装过gdb可以通过sudo apt-get source gdb获取到源码,但注意需要在Software&Update中把Source code勾选上。

    本来呢,故事到这里就结束了,然而并没有,。。

    然后gdb告诉我Python scripting is not supported in this copy of GDB.

     所以gdb的安装为

    sudo apt-get install texinfo
    ./configure --with-python make make install

    然后又新建一个虚拟机跑了一遍,。。

    然后要将虚拟机->硬件->虚拟化Inter VT-x/EPT..选中。

    不然会出现如下错误:

    Could not access KVM kernel module: No such file or directory
    qemu-system-x86_64: failed to initialize KVM: No such file or directory

     然后是相关工具的安装:

    sudo pip install pwntools
    sudo pip install ropper
    
    git clone https://github.com/pwndbg/pwndbg
    cd pwndbg
    ./setup.sh
  • 相关阅读:
    log4j.properties 配置示例
    spark去重计数操作(代码示例)
    mysql数据库
    Mysql之sql语句操作
    mysql修改root密码的多种方法
    mysql的主从复制过程
    mysql命令用法复习笔记
    Linux下如何查看系统启动时间和运行时间安装时间
    一键系统优化15项脚本
    MongoDB
  • 原文地址:https://www.cnblogs.com/61355ing/p/10386955.html
Copyright © 2011-2022 走看看