10 Oct 2019

wsl它不香吗

wsl它不香吗

安装wsl(Ubuntu 18.04)

配置Hyper终端

wsl它不香吗

https://hyper.is/
  • 配置

    进入终端后 按ctrl+,,打开.hyper.js

        // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
        // if left empty, your system's login shell will be used by default
        //
        // Windows
        // - Make sure to use a full path if the binary name doesn't work
        // - Remove `--login` in shellArgs
        //
        // Bash on Windows
        // - Example: `C:\\Windows\\System32\\bash.exe`
        //
        // PowerShell on Windows
        // - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
        shell:`C:\\Windows\\System32\\wsl.exe`,
    

    若默认打开wsl,shell应改为

    shell:`C:\\Windows\\System32\\wsl.exe`
    

环境搭建

  • 设置root用户密码

    sudo passwd root
    
  • 换源

    vim /etc/apt/sources.list
    

    修改为阿里源

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb 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 main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
      
    

    然后

    sudo apt-get update
    
  • 安装gcc、g++

    sudo apt install gcc
    sudo apt install g++
    
  • 安装Python及pip

    • python2

      sudo apt install python
      sudo apt install python-pip
      
    • python3

      sudo apt install python3
      sudo apt install python3-pip
      
  • 安装pip常用库

    下载速度慢可以换源

    (1)阿里云 http://mirrors.aliyun.com/pypi/simple/
    (2)豆瓣http://pypi.douban.com/simple/
    (3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
    (4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
    (5)华中科技大学 http://pypi.hustunique.com/
      
    pip install 包 -i 源
    

    二进制相关

    • pwntools

      pwn必备

      pip install pwntools

    • ropper

      找gadgets

      sudo pip install capstone
      sudo pip install filebytes
      sudo pip install keystone-engine
      sudo pip install ropper
      
    • angr

      二进制分析框架

      sudo apt-get install python-dev libffi-dev build-essential virtualenvwrapper
      sudo pip install angr
      
    • z3

      解方程,逆向常用

      sudo pip install z3
      

    web相关

    • requests

      HTTP库

      sudo pip install requests
      

    crypto相关

    • gmpy

      数论库

      sudo apt-get install libgmp-dev
      sudo apt-get install libmpfr-dev
      sudo apt-get install libmpc-dev
      sudo pip install gmpy
      sudo pip install gmpy2
      
    • sympy

      科学计算库

      gmpy装不上sympy必装不上

      sudo pip install sympy
      
  • 安装常用工具

    • vim

      编辑器

      sudo apt install vim
      
    • git

      sudo apt install git
      

    二进制相关

    • gdb及其插件

      sudo apt install gdb
      

      pwndbg

      git clone https://github.com/pwndbg/pwndbg
      cd pwndbg
      sudo ./setup.sh
      
    • nasm

      汇编语言编译器

      sudo apt install nasm
      
    • qemu

      虚拟操作系统模拟器

      sudo apt install qemu
      

    Crypto相关

    • sagemath

      apt install sagemath
      

    web相关

    • LAMP配置

      1. 安装Apache

        sudo apt install apache2
        
      2. 安装php

        sudo apt-get install php
        sudo apt-get install libapache2-mod-php
        
      3. 安装MySql

        sudo apt-get install mysql-server
        sudo apt-get install php-mysql
        

        Mysql root密码设置

        mysql -u root -p
        空密码登陆
        
        use mysql;
        update user set plugin="mysql_native_password";
        update user set authentication_string=PASSWORD("123456") where User='root';
        flush privileges;
        exit;
        
      4. 重启服务

        sudo service mysql restart
        sudo service apache2 restart
        
    • wordpress

      1. 登陆mysql

        mysql -u root -p
        
      2. 创建wordpress数据库

        CREATE DATABASE wordpress;
        
      3. 为数据库设置用户,并配置数据库访问权限

        CREATE USER aidai;
        SET PASSWORD FOR aidai=PASSWORD('123456');
        GRANT ALL PRIVILEGES ON wordpress.* TO aidai  IDENTIFIED BY '123456';
        FLUSH PRIVILEGES;
        exit;
        
      4. 部署wordpress

        sudo mv wordpress-5.2.4-zh_CN.tar.gz /var/www/html/
        sudo cd /var/www/html/
        sudo tar -zxvf wordpress-5.2.4-zh_CN.tar.gz
        sudo mv wordpress/* /var/www/html/
        sudo chmod -R 777 /var/www/html/
        

        然后重启Apache2

        sudo service apache2 restart
        

        若使用systemctl重启可能会报错

        root@A1_D4i:/var/www/html# sudo systemctl restart apache2.service
        System has not been booted with systemd as init system (PID 1). Can't operate.
        

        浏览器访问http://127.0.0.1/wp-admin进入后台,开始安装

    misc

    • binwalk

      提取文件

      sudo apt install binwalk
      
    • foremost

      提取文件

      sudo apt install foremost
      
    • steghide

      图片隐写

      sudo apt install steghide
      
    • volatility

      内存取证

      sudo apt install volatility
      
    • sl

      小火车,做不出题可以玩玩火车

      apt install sl
      
  • 基于ruby的工具

    安装ruby

    sudo apt install ruby
    

    二进制相关

    • one_gadget

      查找one_gadget

      sudo gem install one_gadget
      

    misc

    • zsteg

      处理图片隐写

      sudo gem install zsteg
      

坑与填坑

  • wsl跑32位程序

    众所周知wsl不能跑32位程序,现在给出两种解决方案

    • qemu

      sudo apt update
      sudo apt install qemu-user-static
      sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
      
      sudo service binfmt-support start
      重启WSL并希望获得i386支持时,需要重新激活
      
      sudo dpkg --add-architecture i386
      sudo apt update
      sudo apt install gcc:i386
      
      运行32位程序报错
      /lib/ld-linux.so.2: No such file or directory
      
      sudo apt install lib32ncurses5
      
    • pwntools

      process()可以跑

  • ###权限

    对文件权限有要求的操作不要再window路径下进行

  • 图形界面

    可以折腾,但没必要,基本上不需要图形界面

    需要图形界面开虚拟机就完事了

  • LAMP 重启服务报错

    Apache2

    报错

    root@A1_D4i:$sudo service apache2 restart
     * Restarting Apache httpd web server apache2
    [Tue Oct 15 12:57:33.317060 2019] [core:warn] [pid 579] (92)Protocol not available: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT
    

    解决方案

    sudo vi /etc/apache2/apache2.conf
    

    在最后一行加上AcceptFilter http none

    mysql

    报错

    root@A1_D4i:$sudo service mysql restart
     * Stopping MySQL database server mysqld                                                                                                                                               [ OK ]
     * Starting MySQL database server mysqld
    No directory, logging in with HOME=/
    

    解决方案

    sudo service apache2 restart
    sudo service mysql stop
    sudo usermod -d /var/lib/mysql/ mysql
    sudo service mysql start
    sudo service mysql restart
    

Tags:
0 comments



本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议CC BY-NC-ND 4.0)进行许可。

This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0).