どのくらいの覚悟で言ってるんですの|

r_0xy

园龄:5个月粉丝:1关注:1

📂CTF
🔖CTFpwn
2024-10-30 10:40阅读: 68评论: 0推荐: 0

环境搭建(主要是pwn)

前言

在环境配置的过程中好多都是突发奇想的想法,而且绝大部分都是美化,同时还有一些是之前配置的,但是后来发现更好的于是废弃的东西,为了以防万一我还是留着了

如果有人要看这篇文章配置pwn环境的话我建议还是用wsl+vscode的搭配,pwn所需要的环境工具直接看这个文章的pwn章节就行了

环境配置的一些其他东西

CTF-PWN环境搭建手册-CSDN博客

pwndbg的安装和gdb使用-CSDN博客

[pwn]调试:gdb+pwndbg食用指南_pwndbg查看栈内容-CSDN博客

Kali 更换源(超详细,附国内优质镜像源地址)_kali换源-CSDN博客

vim ~/.gdbinit
set context-output /dev/pts/2 #设置dbg的输出在tty为2的窗口中,找数据舒服

设置ASLR为0,防止本地打不通,远程打通的情况

su
echo 0 > /proc/sys/kernel/randomize_va_space
sudo passwd root #设置root密码

sudo apt install vim #安装vim

sudo apt install tree
sudo apt install curl
sudo apt install python3-pip
sudo apt install tldr
tldr --update

apt-get install build-essential    # build-essential packages, include binary utilities, gcc, make, and so on
apt-get install man                # on-line reference manual
apt-get install gcc-doc            # on-line reference manual for gcc
apt-get install gdb                # GNU debugger
apt-get install git                # revision control system

换源

lsb_release -a #查看版本
vim /etc/apt/sources.list
apt-get upgrade

阿里云Ubuntu镜像:https://developer.aliyun.com/mirror/ubuntu

去对应镜像网站复制对应版本的源

gitclone加速

第一种:在git仓库前添加gitclone.com的前缀(推荐)

比如,作者想要下载这个库,只需要原始的url

git clone https://github.com/tendermint/tendermint.git

将url改为:

git clone https://gitclone.com/github.com/tendermint/tendermint.git

fish shell(不如zsh)

sudo apt-add-repository ppa:fish-shell/release-3 
#添加 fish-shell/release-3 PPA 到系统的 APT 源列表。
sudo apt update

sudo apt install fish

fish -v #检查版本

设置vi模式

$ vi ~/.config/fish/config.fish
# 其他代码
fish_vi_key_bindings

设置默认

chsh -s /usr/bin/fish #然后关机重启

zsh(推荐)

Zsh 安装与配置,使用 Oh-My-Zsh 美化终端https://www.haoyep.com/posts/zsh-config-oh-my-zsh/#%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE

sudo apt-get install zsh

chsh -s /bin/zsh #设置默认终端

sudo apt install git #下载git
#或者使用 wget 下载脚本并安装:
sh -c "$(wget -O- https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"

# 中国用户可以使用 gitee.com 上的官方镜像加速下载
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
#在 ~/.zshrc 设置 ZSH_THEME="powerlevel10k/powerlevel10k"。接下来,终端会自动引导你配置 powerlevel10k。

安装插件(可选)

git clone https://gitclone.com/github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://gitclone.com/github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

kali-zsh配置(推荐)

由于kali的zsh太长了,请自行去kali里翻kali的zsh配置,然后复制到其他机器上.

复制到~/.zshrc里面

把kali的zsh-autosuggestions和zsh-syntax-highlighting放到/usr/share里面

启用插件(可选)

修改~/.zshrc中插件列表为:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract web-search)

开启新的 Shell 或执行 source ~/.zshrc,就可以开始体验插件。

重新配置oh-myzsh(可选)

p10k configure

vim模式

把代码添加到~/.zshrc

# Enable vi mode
bindkey -v

重启或者source ~/.zshrc

vi-mode插件

把vi-mode添加到plugins后面

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(
  vi-mode
)
VI_MODE_SET_CURSOR=true #启用更改模式光标改变

快捷键

ctrl-p :历史记录中的上一个命令

ctrl-n :历史记录中的下一个命令

vv : 在 Vim 中编辑当前命令行

其他都和vim差不多

tldr

sudo apt update
npm cache clean -f

npm install -g n
sudo npm install n -g

sudo n stable
n stable #升级到最新稳定版

sudo npm install -g tldr
sudo apt install curl
sudo apt install python3-pip
pip3 install tldr
tldr --update

切换npm源

下载vim插件用

国内npm源镜像(npm加速下载) 指定npm镜像_npm 国内镜像-CSDN博客

nodejs

sudo apt update && sudo apt upgrade
sudo apt install nodejs npm

vim

更新vim,要不然没法用coc

sudo add-apt-repository ppa:jonathonf/vim 
sudo apt update
sudo apt upgrade

~/.vimrc

" Comments in Vimscript start with a `"`.

" If you open this file in Vim, it'll be syntax highlighted for you.

" Vim is based on Vi. Setting `nocompatible` switches from the default
" Vi-compatibility mode and enables useful Vim functionality. This
" configuration option turns out not to be necessary for the file named
" '~/.vimrc', because Vim automatically enters nocompatible mode if that file
" is present. But we're including it here just in case this config file is
" loaded some other way (e.g. saved as `foo`, and then Vim started with
" `vim -u foo`).
set nocompatible

" Turn on syntax highlighting.
syntax on

" Disable the default Vim startup message.
set shortmess+=I

" Show line numbers.
set number

" This enables relative line numbering mode. With both number and
" relativenumber enabled, the current line shows the true line number, while
" all other lines (above and below) are numbered relative to the current line.
" This is useful because you can tell, at a glance, what count is needed to
" jump up or down to a particular line, by {count}k to go up or {count}j to go
" down.
set relativenumber

" Always show the status line at the bottom, even if you only have one window open.
set laststatus=2

" The backspace key has slightly unintuitive behavior by default. For example,
" by default, you can't backspace before the insertion point set with 'i'.
" This configuration makes backspace behave more reasonably, in that you can
" backspace over anything.
set backspace=indent,eol,start

" By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't
" shown in any window) that has unsaved changes. This is to prevent you from "
" forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find
" hidden buffers helpful enough to disable this protection. See `:help hidden`
" for more information on this.
set hidden

" This setting makes search case-insensitive when all characters in the string
" being searched are lowercase. However, the search becomes case-sensitive if
" it contains any capital letters. This makes searching more convenient.
set ignorecase
set smartcase

" Enable searching as you type, rather than waiting till you press enter.
set incsearch

" Unbind some useless/annoying default key bindings.
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this.

" Disable audible bell because it's annoying.
set noerrorbells visualbell t_vb=

" Enable mouse support. You should avoid relying on this too much, but it can
" sometimes be convenient.
set mouse+=a

" Try to prevent bad habits like using the arrow keys for movement. This is
" not the only possible bad habit. For example, holding down the h/j/k/l keys
" for movement, rather than using more efficient movement commands, is also a
" bad habit. The former is enforceable through a .vimrc, while we don't know
" how to prevent the latter.
" Do this in normal mode...

"make vim past from(copy to) the system's clipboard
set clipboard=unnamed




call plug#begin('~/.vim/plugged')
Plug 'jiangmiao/auto-pairs'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'godlygeek/tabular'
Plug 'lilydjwg/fcitx.vim'
call plug#end()


" Time in milliseconds (default 0)
let g:Illuminate_delay = 0
"coc配置
" Use <Tab> and <S-Tab> to navigate the completion list
inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1) :
      \ CheckBackspace() ? "\<Tab>" :
      \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
"suggest.noselect": true

"Symbol renaming
nmap <leader>rn <Plug>(coc-rename)

vim-plug

使用之前升级vim版本

mkdir ~/.vim
cd ~/.vim
mkdir plugged plugin syntax colors doc autoload

~/.vim文件夹下目录介绍

~/.vim/autoload/它是一个非常重要的目录,尽管听起来比实际复杂。简而言之,它里面放置的是当你真正需要的时候才被自动加载运行的文件,而不是在vim启动时就加载。
~/.vim/colors/是用来存放vim配色方案的。
~/.vim/plugin/存放的是每次启动vim都会被运行一次的插件,也就是说只要你想在vim启动时就运行的插件就放在这个目录下。我们可以放从vim-plug官方下载下来的插件.vim
~/.vim/syntax/语法描述脚本。我们放有关文本(比如c语言)语法相关的插件
~/.vim/doc/为插件放置文档的地方。例如:help的时候可以用到。
~/.vim/ftdetect/中的文件同样也会在vim启动时就运行。有些时候可能没有这个目录。ftdetect代表的是“filetype detection(文件类型检测)”。此目录中的文件应该用自动命令(autocommands)来检测和设置文件的类型,除此之外并无其他。也就是说,它们只该有一两行而已。
~/.vim/ftplugin/此目录中的文件有些不同。当vim给缓冲区的filetype设置一个值时,vim将会在~/.vim/ftplugin/ 目录下来查找和filetype相同名字的文件。例如你运行set filetype=derp这条命令后,vim将查找~/.vim/ftplugin/derp.vim此文件,如果存在就运行它。不仅如此,它还会运行ftplugin下相同名字的子目录中的所有文件,如~/.vim/ftplugin/derp/这个文件夹下的文件都会被运行。每次启用时,应该为不同的文件类型设置局部缓冲选项,如果设置为全局缓冲选项的话,将会覆盖所有打开的缓冲区。
~/.vim/indent/这里面的文件和ftplugin中的很像,它们也是根据它们的名字来加载的。它放置了相关文件类型的缩进。例如python应该怎么缩进,java应该怎么缩进等等。其实放在ftplugin中也可以,但单独列出来只是为了方便文件管理和理解。
~/.vim/compiler/和indent很像,它放的是相应文件类型应该如何编译的选项。
~/.vim/after/这里面的文件也会在vim每次启动的时候加载,不过是等待~/.vim/plugin/加载完成之后才加载after里的内容,所以叫做after。
~/.vim/spell/拼写检查脚本。

下载 plug.vim 文件,根据操作系统不同,放置在以下~/.vim/autoload目录中:

mkdir -p  ~/.vim/autoload/
cp plug.vim  ~/.vim/autoload/plug.vim

安装插件

首先找到其在http://github.com的网址,然后将其追加至vimrc配置文件中的call plug#begin()和call plug#end()之间,最后执行以下命令安装所有引用的插件:

:PlugInstall

你也可以使用以下命令,指定安装特定的插件:

:PlugInstall gist-vim

coc.nvim(vim补全功能)

上手Coc.nvim 完全指南 - 阿_兵 - 博客园 (cnblogs.com)

出现fcitx.vim not loaded

这个需要nodejs

安装完coc.nvim后在vim里输入这个安装其他插件

:CocInstall coc-tsserver coc-json coc-clangd coc-pyright coc-marketplace

~/.vimrc 中添加以下内容,可以使用Tab 和 Shift+Tab 进行选择补全。

" Use <Tab> and <S-Tab> to navigate the completion list
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

在vim里用cocconfig打开"coc-setting.json"文件

{
  "suggest.noselect":true,
  "禁用coc-pyright类型的注释
  "pyright.inlayHints.enable":false,
  "取消pyright的参数和变量类型嵌体提示
  "pyright.inlayHints.variableTypes":false,
  "pyright.inlayHints.parameterTypes":false
}

clangd

sudo apt install clangd

共享目录

宿主机与虚拟机之间文件互传 - Jeffxue - 博客园 (cnblogs.com)

sudo mkdir /mnt/hgfs/
sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other

WSL使用代理

在 WSL2 中使用 Clash for Windows 代理连接 - East Monster 个人博客

系统由包管理器(如APT)管理下,使用pip

每次使用与虚拟环境相关的Python项目时,都需要先激活虚拟环境。

使用虚拟环境

避免污染系统的Python环境:

python3 -m venv venv
source venv/bin/activate
pip install LibcSearcher

这样,LibcSearcher 将被安装在虚拟环境中,而不是系统范围内。每次使用时,激活虚拟环境即可。

退出虚拟环境

deactivate

pwn

pwntools

sudo -i
sudo pip3 install pwntools

pwndbg

cd ~
git clone https://github.com/pwndbg/pwndbg.git
cd ~/pwndbg
poetry env use python3.10  ##需要创建虚拟环境
./setup.sh

ROPgadget

cd ~
sudo pip3 install capstone
git clone https://github.com/JonathanSalwan/ROPgadget.git
cd ROPgadget
sudo python3 setup.py install

如果报错 “ResolutionError: Script ‘scripts/ROPgadget’ not found in metadata at ‘/home/shenyuxin/.local/lib/python3.8/site-packages/ROPGadget-7.3.dist-info’”,执行:

sudo cp -r scripts /home/shenyuxin/.local/lib/python3.8/site-packages/ROPGadget-7.3.dist-info

glibc-all-in-one

cd ~
git clone https://github.com/matrix1001/glibc-all-in-one
cd glibc-all-in-one
sudo python3 update_list

修改uxterm大小

vim ~/.Xdefaults,然后增加以下内容

! TrueType font
UXTerm*faceName: DejaVu Sans Mono
XTerm*faceName: DejaVu Sans Mono
! Chinese
UXTerm*faceNameDoublesize: Noto Sans CJK SC
XTerm*faceNameDoublesize: Noto Sans CJK SC
! font size
UXTerm*faceSize: 10
XTerm*faceSize: 10
! color
UXTerm*background: black
UXTerm*foreground: lightgreen
XTerm*background: black
XTerm*foreground: lightgreen

UXTerm*geometry: 120x35+500+250
UXTerm*metaSendsEscape: true
UXTerm*eightBitInput: false
UXTerm*selectToClipboard: true
UXTerm*locale: zh_CN.UTF-8
Uxterm*utf8: true
Uxterm*utf8Title: true

XTerm*geometry: 120x35+500+250
XTerm*metaSendsEscape: true
XTerm*eightBitInput: false
XTerm*selectToClipboard: true
XTerm*locale: zh_CN.UTF-8
xterm*utf8: true
xterm*utf8Title: true

本文作者:r_0xy

本文链接:https://www.cnblogs.com/r0xy/p/18515332

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   r_0xy  阅读(68)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 デート RADWIMPS
  2. 2 ヨスガノソラ メインテーマ -記憶- 市川淳
デート - RADWIMPS
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.