Kali系统及Frida环境配置

本文详述了在Kali Linux系统中配置Frida环境的步骤,包括Kali的基本设置、pyenv的安装与Python多版本管理、Anaconda的安装与Python环境配置、Node.js的安装、adb和fastboot工具的配置,以及将frida-server推送到手机的过程。解决了一些配置过程中遇到的问题,如环境变量配置和Python库安装问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


前言

本文介绍Kali系统的安装和Kali系统下Frida环境的配置。

一、Kali环境基本配置

1.下载Kali系统,Vmware打开。

  • Kali官网 下载Vmware版本Kali系统,解压并使用Vmware打开。
  • 本人下载版本 kali-linux-2021.2-vmware-amd64.7z

2.环境配置

  1. 此版本kali系统默认使用 kali/kali 作为默认用户登录系统,获取root权限命令如下:

    whami 	#	查看当前用户 kali
    sudo su	#	获取root权限
    whami	#	查看当前用户 root
    passwd	# 设置新root密码
    

    passwd root

  2. 开启远程登录SSH,命令如下:

    sudo su
    cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak	#	备份ssh配置文件
    sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config	# 开启root远程登录
    systemctl enable --now ssh	#	启动ssh服务
    

    ssh

  3. 使用远程工具(cmder,MobalTerm,Xshell等)登录,此处使用cmder(下载链接:https://cmder.net/)。

    ssh远程root登录

  4. 更换kali更新源为阿里源

    #	阿里源地址如下:
    #	deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
    #	deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
    #	更新语句如下:
    cp /etc/apt/sources.list /etc/apt/sources.list.bak	# 备份配置文件
    echo "#	阿里源">/etc/apt/sources.list
    echo "deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib">>/etc/apt/sources.list
    echo "deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib">>/etc/apt/sources.list
    # 配置完成后,执行指令更新软件和系统,清除安装包
    apt update
    ape upgrade
    apt remove
    apt autoremove
    

    更新源配置

二、多版本环境控制之pyenv安装

1.pyenv安装

  • GitHub地址:https://github.com/pyenv/pyenv#installation

  • 安装pyenv

    sudo su
    curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
    
    # 若报错443连接错误,使用如下语句
    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    

    若报如下错误,拷贝

    在这里插入图片描述

    拷贝文件(https://github.com/pyenv/pyenv-installer/blob/master/bin/pyenv-installer)直接授权执行即可。

  • 写入配置文件

    经测试,官网推荐写入 ~/.bashrc 文件并不能正确安装pyenv(也可能是我配置错误。。。),此处配置 /etc/profile 文件)。

    sudo su
    # 提前备份
    cp /etc/profile /etc/profile.bak                                                                             
    # 写入配置
    echo 'export PYENV_ROOT="/root/.pyenv"' >> /etc/profile
    echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /etc/profile
    echo 'eval "$(pyenv init --path)"' >> /etc/profile
    
    source /etc/profile	#	保存配置文件
    
  • 检查安装

    pyenv version
    

    在这里插入图片描述

  • 完全卸载pyenv

    # 先将 /etc/profile 配置文件中的内容去除
    source /etc/profile	#	保存配置文件
    rm -fr /root/.pyenv	#	完全删除该目录及下载的python等内容
    
  • pyenv基本指令,参见:https://www.cnblogs.com/louyefeng/p/12031272.html,也可使用指令查看帮助。

    pyenv help	
    

2.安装Python

  • 安装Python前需要先安装依赖,否则会出现缺少依赖相关报错。

    在这里插入图片描述

     sudo su
     apt install make build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    
  • 由以上pyenv指令,查看可安装的python版本,如下

    pyenv install --list
    
  • 查看之后,安装指定版本python

    pyenv install 3.9.2 #	次数安装3.9.2版本
    pyenv versions	#	查看已安装的python版本
    pyenv uninstall [版本号] # 卸载相应版本python
    

三.多版本控制平台之 Anaconda安装

1.Anaconda安装

  • 下载Anaconda,网址:https://www.anaconda.com/products/individual/download-success

    sudo su
    uname -a # 执行指令查看linux内核版本,此版本下载x86架构
    # Linux kali 5.10.0-kali9-amd64 #1 SMP Debian 5.10.46-1kali1 (2021-06-25) x86_64 GNU/Linux
    wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh 
    
    # 授权,安装
    chmod 777 Anaconda3-2021.05-Linux-x86_64.sh  
    ./Anaconda3-2021.05-Linux-x86_64.sh
    

    注意:按默认路径一直安装,最后会让提示是否初始化,在此kali系统版本下,写入 /root/.bashrc 文件,无法添加环境变量。

    在这里插入图片描述

    解决办法:将写入 /root/.bashrc 文件的配置剪切到 /etc/profile 中。

    在这里插入图片描述

    source /etc/profile #   保存配置文件source 
    
  • 验证及禁用conda自带默认base环境。

    conda --version	# 查看conda版本
    conda config --set auto_activate_base false # 关闭默认base环境,执行后重新打开shell
    

    在这里插入图片描述

  • conda换源

    # 此处配置北京外国语学院的软件源
    conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
    conda config --set show_channel_urls yes	# 下载时显示下载通道
    
    # 查看condarc配置
    cat ~/.condarc	# 此处为 /root/.condarc
    # 或
    conda config --show channels
    
  • conda使用命令参考:

    1. https://www.cnblogs.com/szj666/p/11014929.html
    2. https://zhuanlan.zhihu.com/p/255264471
    # linux下退出虚拟环境指令
    conda deactivate
    

2.配置Python环境及Frida

  • Frida 网址:https://github.com/frida/frida/

  • 创建环境 Frida_1280_Py380,基于 python 3.8.0

    conda create -n Frida_1280_Py380 python=3.8.0 
    conda env list	# 查看所有环境
    

    在这里插入图片描述

  • 使用环境 Frida_1280_Py380,安装Frida

    conda activate Frida_1280_Py380
    # 此处注意Frida,Frida-tools,objection的版本对应关系
    python -m pip install frida==12.8.0
    python -m pip install frida-tools==5.3.0
    python -m pip install objection==1.8.4
    

    安装Frida Building wheel for frida (setup.py) 卡住,无限月读后,出现 ERROR: Failed building wheel for frida 错误。

    在这里插入图片描述

    解决方法,参考:https://blog.youkuaiyun.com/song_lee/article/details/105102108

    firda 12.8.0 地址:https://pypi.org/project/frida/12.8.0/#files

    sudo su
    wget https://files.pythonhosted.org/packages/b5/69/49c5e6922f290e6157ee5797e6545390c44e9a567eb0562771e0e0fea092/frida-12.8.0-py3.6-linux-x86_64.egg
    
    # 查找 easy_install.py 所在路径
    find . -name easy_install.py
    
    python ./anaconda3/lib/python3.8/site-packages/setuptools/command/easy_install.py frida-12.8.0-py3.6-linux-x86_64.egg
    
    # 重新安装frida12.8.0,成功
    python -m pip install frida==12.8.0
    

    在这里插入图片描述

    在这里插入图片描述

四、安装Nodejs

  • 官网下载指定版本Nodejs(https://nodejs.org/en/download/),具体可参考:Linux(Kali)安装Node.js

    curl -o node-v14.17.4-linux-x64.tar.xz https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz
    

    在这里插入图片描述

  • 解压,安装

    tar -xvf node-v14.17.4-linux-x64.tar.xz	# 根据下载的版本来配置
    mv node-v14.17.4-linux-x64 nodejs
    mv nodejs/ /usr/local/sbin/
    ln -s /usr/local/sbin/nodejs/bin/node /usr/local/sbin/ # 建立软链接
    ln -s /usr/local/sbin/nodejs/bin/npm /usr/local/sbin/
    

    在这里插入图片描述

  • npm换淘宝源

    npm config set registry https://registry.npm.taobao.org	
    npm config get registry	# 验证
    

    在这里插入图片描述

五、安装adb shell 和 fastboot

  • 下载adb shell ,网址:https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cn

    sudo su
    # 注意,此处所在路径为 /root
    wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip?hl=zh-cn
    mv platform-tools-latest-linux.zip\?hl=zh-cn platform-tools-latest-linux.zip
    7z -x platform-tools-latest-linux.zip
    
    export PATH="/root/platform-tools:$PATH"	# 测试设置环境变量
    adb shell	# 指令运行成功,写入下列配置文件
    fastboot 	# 指令也运行成功
    echo 'export PATH="/root/platform-tools:$PATH"' >> /etc/profile
    source /etc/profile	#	保存配置文件
    

    在这里插入图片描述

六、手机导入frida server

  • 官网下载对应frida-server版本,GitHub地址:https://github.com/frida/frida/releases/tag/12.8.0

  • 查看手机类型

    adb shell 
    su
    getprop ro.product.cpu.abi 
    
    # 授权
    chmod 777 frida-server-12.8.0-android-arm64
    # 启动frida_server ,默认端口 27042
    ./frida-server-12.8.0-android-arm64 
    

    在这里插入图片描述

  • 下载 frida-server,push到手机端

    sudo su
    wget https://github.com/frida/frida/releases/download/12.8.0/frida-server-12.8.0-android-arm64.xz
    xz -d frida-server-12.8.0-android-arm64.xz
    
    adb push frida-server-12.8.0-android-arm64 /data/local/tmp
    

修正内容

  • 在以上环境中出现配置写入 .bashrc 中不生效问题,是由于在当前版本Kali (2021.2)系统中使用默认 zsh 为默认shell,故只需将原本写入 .bashrc 中的配置写入 .zshrc 中即可。
    在这里插入图片描述
Kali Linux上安装内存取证工具及进行环境配置,可以按照以下步骤进行: ### 1. 更新系统 首先,确保你的Kali系统是最新的。打开终端并运行以下命令: ```bash sudo apt update sudo apt upgrade -y ``` ### 2. 安装Volatility Volatility是一个流行的内存取证工具。你可以通过以下步骤安装它: #### 方法一:使用pip安装 确保你已经安装了Python和pip。如果没有安装,可以使用以下命令安装: ```bash sudo apt install python3 python3-pip -y ``` 然后使用pip安装Volatility: ```bash pip3 install volatility3 ``` #### 方法二:从GitHub克隆并安装 你也可以从GitHub克隆Volatility的源代码并安装: ```bash git clone https://github.com/volatilityfoundation/volatility3.git cd volatility3 pip3 install -r requirements.txt ``` ### 3. 安装Rekall Rekall是另一个内存取证工具。你可以通过以下步骤安装它: #### 方法一:使用pip安装 ```bash pip3 install rekall ``` #### 方法二:从GitHub克隆并安装 ```bash git clone https://github.com/google/rekall.git cd rekall pip3 install -r requirements.txt ``` ### 4. 安装LiME LiME(Linux Memory Extractor)是一个用于捕获Linux内存的工具。你可以通过以下步骤安装它: #### 方法一:从GitHub克隆并安装 ```bash git clone https://github.com/504ensicsLabs/LiME.git cd LiME/src make sudo insmod lime.ko "path=/home/user/memory.lime format=lime" ``` ### 5. 配置环境 确保所有工具都在你的系统路径中。你可以将它们的路径添加到`.bashrc`文件中: ```bash echo 'export PATH=$PATH:/path/to/volatility3' >> ~/.bashrc echo 'export PATH=$PATH:/path/to/rekall' >> ~/.bashrc source ~/.bashrc ``` ### 6. 测试安装 最后,测试安装是否成功。你可以使用以下命令来验证Volatility和Rekall是否正常工作: ```bash volatility -h rekall -h ``` 通过以上步骤,你应该能够在Kali Linux上成功安装和配置内存取证工具。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值