From 9982723a0b804d7e3d7f0910b3c0e1a01abdca5f Mon Sep 17 00:00:00 2001 From: firmianay Date: Mon, 2 Oct 2017 22:21:25 +0800 Subject: [PATCH] add pwn_env --- doc/2.1_vm.md | 1 + doc/2.5_radare2.md | 22 ------- src/Others/2.1_pwn_env.sh | 126 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 22 deletions(-) create mode 100644 src/Others/2.1_pwn_env.sh diff --git a/doc/2.1_vm.md b/doc/2.1_vm.md index 7086552..cbabe7d 100644 --- a/doc/2.1_vm.md +++ b/doc/2.1_vm.md @@ -81,3 +81,4 @@ r2pipe #### 工具安装脚本 - ctf-tools - https://github.com/zardus/ctf-tools +- [pwn_env](../src/Others/2.1_pwn_env.sh) diff --git a/doc/2.5_radare2.md b/doc/2.5_radare2.md index 1d82e7c..5edb279 100644 --- a/doc/2.5_radare2.md +++ b/doc/2.5_radare2.md @@ -276,28 +276,6 @@ rahash2 用于计算检验和,支持字节流、文件、字符串等形式和 - `-B`:打印处每个块的哈希 - `-s`:指定字符串(而不是文件) - `-a entropy`:显示每个块的熵(`-B -b 512 -a entropy`) - - ``` - $ rahash2 -B -b 1024 a.out - 0x00000000-0x000003ff sha256: 1fd71dfb92c2c1290c3f6a09e477b470a625aef4ab262e18127e6db790c47487 - 0x00000400-0x000007ff sha256: e4829aeb02e97585d663ace279a04d51e39964367943519e4136ab23f43b642a - 0x00000800-0x00000bff sha256: 9ace05fc25ac536646f116d1030fbe03a958bc0ee3ae0af4b378e7549553bf5d - 0x00000c00-0x00000fff sha256: d7f185a66987ff7ba0ac0813ff473c5f75e988c5904399f3e24994cade489f81 - 0x00001000-0x000013ff sha256: 1c24ed40e088544cd39ec974b7ebc6f6fb57a71f7d56455625ffe4f259825671 - 0x00001400-0x000017ff sha256: 9acbb50272925734fb1d1feca94e493dcdcd213c815f6680eecd22cba17a2494 - 0x00001800-0x00001bff sha256: c202fd18e976abdae80e4519f156aa5d7ad1623cd183d85429abdb388910b88b - 0x00001c00-0x00001fff sha256: 7e23808d6acc635b763ef5b9171af1eb39a428a314e8edbdc02fd985abf19918 - 0x00002000-0x00002097 sha256: a44370a272c40becac05c369467dea4e7444dab674d7db029ff0b8be99330ba0 - $ rahash2 -B -b 1024 -a entropy a.out - 0x00000000-0x000003ff 2.820547: 35% [###############------------------------------] - 0x00000400-0x000007ff 4.855878: 60% [###########################------------------] - 0x00000800-0x00000bff 0.222447: 2% [---------------------------------------------] - 0x00000c00-0x00000fff 0.810801: 10% [####-----------------------------------------] - 0x00001000-0x000013ff 1.672678: 20% [#########------------------------------------] - 0x00001400-0x000017ff 3.942760: 49% [######################-----------------------] - 0x00001800-0x00001bff 3.153171: 39% [#################----------------------------] - 0x00001c00-0x00001fff 1.325161: 16% [#######--------------------------------------] - 0x00002000-0x00002097 0.942890: 11% [####-----------------------------------------] - ``` #### radiff2 ```text diff --git a/src/Others/2.1_pwn_env.sh b/src/Others/2.1_pwn_env.sh new file mode 100644 index 0000000..0dde660 --- /dev/null +++ b/src/Others/2.1_pwn_env.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# usage: ./2.1_pwn_env.sh [func1[ func2[ func3...]]] +# tested for debian wheezy on armhf +# from Icemakr + +function check_result() { + if [ $? -ne 0 ] + then + res="\033[32m[-]failed to "$1"\033[0m" + echo -e $res + else + res="\033[33m[+]successfully "$1"\033[0m" + echo -e $res + fi +} + + +############################# install ################################ +###################################################################### +###################################################################### + + +# install vim, git, gcc, python +function init { + #sudo apt-get update + #check_result "update apt" + + sudo apt-get install git gcc + sudo apt-get install python-dev python-pip + check_result "install python" + sudo apt-get install python3 python3-pip + check_result "install python3" + + sudo apt-get install zsh + check_result "install zsh" +} + +# set up oh-my-zsh +function oh-my-zsh { + sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" && sudo chsh -s /bin/zsh + check_result "install oh-my-zsh" +} + +# set up vim +function vim { + echo -e "set encoding=utf-8\nset fileencoding=utf-8\nset fileencodings=ucs-bom,utf-8,chinese,cp936\nset guifont=Consolas:h15\nlanguage messages zh_CN.utf-8\nset number\nset autoindent\nset smartindent\nset tabstop=4\nset autochdir\nset shiftwidth=4\nset foldmethod=manual\nsyntax enable\nset nocompatible\nset nobackup\ninoremap jk " > ~/.vimrc && sudo apt-get install vim + check_result "vim" +} + +# install pwn +function pwn { + sudo apt-get install gdb + check_result "install gdb" + sudo pip install zio + check_result "install zio" + sudo pip install pwntools + check_result "install pwntools" + sudo apt-get install socat + check_result "install socat" +} + +# install capstone +function capstone { + sudo pip install capstone + sudo pip3 install capstone + check_result "install capstone-engine" +} + +# install keystone ---gcc-4.8&&g++-4.8 is OK and gcc-4.6||g++-4.6 is awful:( +function keystone { + sudo apt-get install cmake + check_result "install CMake for keystone-engine" + git clone https://github.com/keystone-engine/keystone.git + # if failed when compiling , after meeting with all the dependency , it's best to remove the project and git clone it again to compile + mkdir -p keystone/build + cd keystone/build && ../make-share.sh && sudo make install && sudo ldconfig && cd ../bindings/python && sudo make install && sudo make install3 + check_result "install keystone-engine" + cd ../../.. +} + +# install unicorn +function unicorn { + sudo apt-get install libglib2.0-dev + check_result "install libglib2.0-dev for unicorn-engine" + git clone https://github.com/unicorn-engine/unicorn.git + # if failed when compiling , after meeting with all the dependency , it's best to remove the project and git clone it again to compile + cd unicorn && ./make.sh gcc && sudo ./make.sh install && cd bindings/python && sudo make install && sudo make install3 + check_result "install unicorn-engine" + cd ../../.. +} + +# install ROPGadget +function ROPGadget { + sudo pip install ropgadget + + sudo pip3 install ropgadget +} +# install gef +function gef { + wget -q -O- https://github.com/hugsy/gef/raw/master/gef.sh | sh + check_result "install gef" +} + +# setup checksec +function checksec { + sudo wget https://github.com/slimm609/checksec.sh/raw/master/checksec -O /usr/local/bin/checksec && chmod +x /usr/local/bin/checksec + check_result "install checksec" +} + + +if [ -z $1 ] +then + init + pwn + capstone + keystone + unicorn + ROPGadget + gef + checksec +else + for i in $@ + do + $i + done +fi