Ubuntu学习使用

一、Linux常用命令

pwd打印当前在哪个目录

ls列出当前路径下的文件和目录

mkdir目录名 新建目录

cd目录名 进入指定目录

python运行python解释器

二、安装PEDA

PEDA是为GDB设计的一个强大的插件,全称是Python Exploit DevelopmentAssistance for GDB。它提供了很多人性化的功能,比如高亮显示反汇编代码、寄存器、内存信息,提高了debug的效率。同时,PEDA还为GDB添加了一些实用新的命令,比如checksec可以查看程序开启了哪些安全机制等等。

安装指令:

git clone https://github.com/longld/peda.git ~/peda

echo"source ~/peda/peda.py" >> ~/.gdbinit

echo"DONE! debug your program with gdb and enjoy"

Ubuntu学习使用

接下来开始使用GDB,首先写一个简单的C语言程序:

Ubuntu学习使用

编译选项 cc -g a.c -o a

Ubuntu学习使用

这里的 a.c 是我电脑上的文件名,你自己选一个你喜欢的就可以,注意编译选项一定要加-g,这个是为GDB保留源程序的符号表选项,不然一会儿你加载程序将出现问题。生成二进制a文件以后使用命令:

Ubuntu学习使用

gdb -q ./endin

Ubuntu学习使用

-q 的目的在于消除广告。

Aslr-显示/设定GDB的ASLR(地址空间配置随机加载)设置。

Ubuntu学习使用

checksec–检查二进制文件的各种安全选项。

Ubuntu学习使用

dumpargs–函数将要被调用时,显示将要被传入函数的所有参数(默认会在反汇编代码下方自动显示)。

dumprop–在给定内存范围中Dump出所有ROPgadgets。

elfheader–从调试的ELF文件中获取头信息。

Ubuntu学习使用

elfsymbol–获取non-debugging symbol信息(plt表)。

Ubuntu学习使用

lookup–搜索属于内存范围的所有地址/对地址的引用。

patch–从string/hexstring/int开始对存储器进行校正。

pattern–生成字符串模板 写入内存用于定位溢出点。

pattern create size生成特定长度字符串。

pattern offset value定位字符串。

Ubuntu学习使用

procinfo–显示来自/ proc / pid /的各种信息。

pshow–显示各种PEDA选项和其他设置。

Ubuntu学习使用

pset-设置各种PEDA选项和其他设置。

Ubuntu学习使用

readelf–获取elf头信息

Ubuntu学习使用

ropgadget–获取二进制或库的常见ROP小工具。

ropsearch–在内存中搜索ROP小工具。

searchmem|find–在内存中查找字符串,支持正则表达式。

shellcode–生成shellcode。

skeleton–生成python漏洞利用代码模板。

vmmap–可以用来查看栈、bss段是否可以执行。

xormem–使用**对存储区域进行异或。

安装好PEDA我们的GDB界面就会变得很漂亮,接下来是GDB的使用:

(gdb) li 1 , n (n =1,2,3.....n )

比如 li 1,5 或者简写为 l 1,5将源程序的第1-5行列出来。

Ubuntu学习使用

下一步,根据行,我们可以下断点

(gdb)b 2

在第2行下断点

(gdb)b 10

在第10行下断点

Ubuntu学习使用

提示断点成功

(gdb) run

开始运行程序,到断点时候会停下来。

Ubuntu学习使用

(gdb) info locals (查看当前函数局部变量)

Ubuntu学习使用

可以看到,出现了 x 和 buf ,len 三个局部变量

现在我们的目标是 buf。

(gdb)x/32xb buf

Ubuntu学习使用

这样,我们就可以查看关于buf 里面的内容

(gdb)x 是检查的意思,32是查看多少位,比如12,55 ... 各种的,可以指定不同的格式。

比如:

(gdb)x/s buf

以字符流的形式来查看 buf

(gdb)x/32xw buf

以十六进制方式查看

(gdb)x/10b buf

以十进制查看

以上的方式够用了

还有一种方式是利用

(gdb)print (value)形式来

比如

(gdb)print buf

这样来查看变量,其实还可以设置变量等,这里就不一一列举了

三、使用VIM

安装:sudo apt-get install vim

查看教程vimtutor

Ubuntu学习使用

具体使用查看:

https://segmentfault.com/a/1190000011466454

四、安装PWNTOOLS

pwntools是一个ctf框架和漏洞利用开发库,用Python开发,由rapid设计,旨在让使用者简单快速的编写exploit。

安装:pip installpwntools

安装完成:

Ubuntu学习使用

五、安装Zsh

Zsh是一个Linux用户很少使用的shell,这是由于大多数Linux产品安装,以及默认使用bash shell。几乎每一款Linux产品都包含有zsh,通常可以用apt-get、urpmi或yum等包管理器进行安装。

先看下你的Ubuntu支持哪些shell:

输入命令:

echo SHELL

cat /etc/shells

结果是这样的:

Ubuntu学习使用

安装Zsh:

sudo apt-get install zsh

输入命令后发现持续报错:

Ubuntu学习使用

解决方案:

其实这是因为有另外一个程序在运行,导致锁不可用。原因可能是上次运行更新或安装没有正常完成。解决办法是杀死此进程
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

重新进行安装:

Ubuntu学习使用

安装完成。查看zsh版本

Ubuntu学习使用

已经成功安装。

安装 oh-my-zsh(这个过程可能会有点慢,或者需要重试几次):wgethttps://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh

继续用zsh取代bash,输入以下两个命令中的任意一个:

sudo usermod -s /bin/zsh yzh (username)或者

chsh -s /bin/zshchsh -s `whichzsh

重启后可以看到如下的画面:

Ubuntu学习使用

Ubuntu学习使用

Zsh已经成功安装。

相应使用教程参见知乎:https://www.zhihu.com/question/21418449

六、安装PWNGDB

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

cd pwndbg

./setup.sh

Ubuntu学习使用

由于下载源不对导致下载速度过慢,修改下载源为清华:

$ sudo gedit /etc/apt/sources.list

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse

# deb-srchttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universemultiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse

# deb-srchttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricteduniverse multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

# deb-srchttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricteduniverse multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# deb-srchttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricteduniverse multiverse

 

# 预发布软件源,不建议启用

# debhttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricteduniverse multiverse

# deb-srchttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricteduniverse multiverse

修改完毕后,

sudo apt-get update

update source list 使其生效。

重新进行安装。

 

 

 

 

上述部分内容参考CSDN博客:

https://blog.csdn.net/smalosnail/article/details/53149426

https://www.cnblogs.com/hanframe/p/3585622.html