资源描述
Kali Linux使用手册 155 / 155
Kali Linux
使用手册
作者:白河·愁
©2014,
版本变更
版本
日期
变更内容
修订人
审核人
V 0.1
2014.4.23
初稿
白河·愁
目录
Kali Linux 1
1 Linux的常用命令 8
1.1 系统 8
1.1.1 内核和系统信息 8
1.1.2 硬件信息 8
1.1.3 加载状态和消息 9
1.1.4 用户 9
1.1.5 限制 10
1.1.6 运行级别 10
1.1.7 重设root密码 11
1.1.8 内核模块 11
1.1.9 编译内核 11
1.1.10 修复grub 12
1.2 进程 12
1.2.1 列进程 12
1.2.2 优先级 12
1.2.3 前端/后端 12
1.2.4 Signals/Kill 13
1.3 文件系统 13
1.3.1 权限 13
1.3.2 磁盘信息 14
1.3.3 系统挂载/磁盘使用 14
1.3.4 谁打开了哪个文件? 14
1.3.5 挂载/卸载文件系统 15
1.4 网络 15
1.4.1 网络调试 15
1.4.2 路由 15
1.4.3 配置IP地址 16
1.4.4 变更MAC地址 16
1.4.5 端口 16
1.4.6 防火墙 17
1.4.7 IP路由转发 17
1.4.8 NAT网络地址映射 17
1.4.9 DNS 17
1.4.10 传输协议分析 18
1.4.11 netcat(nc) 19
1.5 SSH / SCP 20
1.6 rsync 20
1.7 sudo 21
1.8 常用工具 22
1.8.1 less 22
1.8.2 vim 22
1.8.3 mail 23
1.8.4 tar 23
1.8.5 dd 23
1.8.6 find 25
1.9 软件安装 26
1.10 数据库 26
1.10.1 PostgreSQL 26
2 安装后的个性化定制 29
2.1 修改默认编码 29
2.2 输入法安装 29
2.3 安装32位框架 29
2.4 升级iceweasel 30
2.5 安装Flash Player 30
2.6 安装Chrome浏览器 30
2.7 安装WPS Office 31
2.8 修改Gnome主题 31
2.9 保存声音设置 32
2.10 安装显卡驱动 32
2.11 QQ方案 33
2.12 其他合适的程序 34
2.12.1 音乐播放器 34
2.12.2 思维导图 34
2.12.3 项目管理软件 35
2.12.4 下载工具 35
2.12.5 多窗口终端 35
2.12.6 yEd 35
2.12.7 Adobe Reader 35
2.12.8 更新和安装thunderbird 35
2.13 编程 35
2.13.1 Web编辑器 35
2.13.2 Sublime Text 36
2.14 编译安装最新版的wine 37
3 渗透测试流程 39
3.1 常规渗透测试流程 39
3.1.1 OSSTMM测试过程 39
3.1.2 PTES标准 46
3.2 Web应用渗透测试 46
3.3 渗透测试报告 46
4 渗透工具 47
4.1 信息收集 47
4.1.1 DNS分析 47
4.1.2 IDS/IPS识别 73
4.1.3 SMB分析 76
4.1.4 SMTP分析 76
4.1.5 SSL分析 77
4.1.6 Voip分析 77
4.1.7 VPN分析 77
4.1.8 存活主机识别 77
4.1.9 电话分析 77
4.1.10 服务指纹识别 77
4.1.11 流量分析 77
4.1.12 路由分析 77
4.1.13 情报分析 77
4.1.14 网络扫描 77
4.1.15 系统指纹识别 77
4.2 漏洞分析 77
4.2.1 Cisco工具集 77
4.2.2 Fuzzing工具集 77
4.2.3 OpenVAS 78
4.2.4 开源评估软件 84
4.2.5 扫描工具集 84
4.2.6 数据库评估软件 84
4.3 Web程序 142
4.3.1 CMS识别 142
4.3.2 IDS/IPS识别 145
4.3.3 Web漏洞扫描 145
4.3.4 Web爬行 145
4.3.5 Web应用代理 145
4.3.6 数据库漏洞利用 147
4.4 密码攻击 147
4.5 无线攻击 147
4.6 漏洞利用工具集 147
4.6.1 BeEF XSS Framework 147
4.6.2 Cisco攻击 148
4.6.3 Exploit Database 148
4.6.4 Exploit Development Tools 149
4.6.5 Metasploit 149
4.6.6 Social Engineering Toolkit 153
4.6.7 网络漏洞利用 153
4.7 嗅探/欺骗 153
4.8 权限维持 153
4.9 逆向工程 153
4.10 压力测试 154
4.11 硬件Hacking 154
4.12 数字取证 154
4.13 报告工具集 154
4.14 系统服务 154
5 其他工具 155
srw- 白河·愁 版本 1.0
1 Linux的常用命令
参考:
1.1 系统
1.1.1 内核和系统信息
uname -a
查看系统内核信息
lsb_release -a
显示所有LINUX基础信息
cat /etc/debian_version
查看Debian版本
cat /etc/issue
查看发行版本
uptime
查看系统运行时间
hostname
查看机器名
hostname -i
查看IP地址
man hier
查看文件系统目录说明
last reboot
查看系统重启时间
1.1.2 硬件信息
dmesg
查看硬件信息
lsdev
查看安装的硬件
dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
查看BIOS信息
cat /proc/cpuinfo
查看CPU信息
grep MemTotal /proc/meminfo
查看内存大小
watch -n1 'cat /proc/interrupts'
查看中断
free -m
查看内存缓存使用率
cat /proc/devices
查看设备配置
lspci -tv
查看PCI设备信息
lsusb -tv
查看USB设备信息
lshal
查看所有硬件配置信息
dmidecode
查看DMI/SMBIOS
1.1.3 加载状态和消息
top
显示和更新CUP信息
ipcs -a
tail -n 500 /var/log/messages
查看系统最后500条日志
1.1.4 用户
id
显示用户的id和组id
last
显示最后用户登录信息
who
查看用户信息
groupadd admin
增加admin用户组
useradd -c "Colin Barschel" -g admin -m colin
增加Colin Barschel用户,属于admin组,密码colin
usermod -a -G <group><user>
修改一个现存的用户到指定用户组
userdel colin
删除colin用户
echo "Sorry no login now" > /etc/nologin
1.1.5 限制
ulimit -a
查看用户限制(shell)
cat /etc/security/limits.conf
查看用户限制(用户、进程)
sysctl -a
查看用户限制(系统)
sysctl fs.file-max
查看最大打开文件数量
sysctl fs.file-max=102400
修改最大打开文件数量为102400
echo "1024 50000" > /proc/sys/net/ipv4/ip_local_port_range
修改端口范围
cat /etc/sysctl.conf
cat /proc/sys/fs/file-nr
查看系统文件设置
1.1.6 运行级别
grep default: /etc/inittab
查看默认运行级别
init 5
修改默认级别5,包
0 关机和挂起
1 单用户模式
2 多用户模式无望罗
3 多用户模式有网络
5 多用户模式图形界面
6 重启
update-rc.d sshd defaults
修改SSH服务到默认运行级别
update-rc.d -f sshd remove
删除SSH服务
shutdown -h now (or # poweroff)
关机
1.1.7 重设root密码
方法一:
在grub启动界面,进入单用户模式,输入
# init=/bin/sh
使用passwd命令修改密码,重启后root分区变为只读,用以下命令回复
# mount -o remount,rw /
# passwd # 或者删除passwd (/etc/shadow)
# sync; mount -o remount,ro / # sync before to remount read only
# reboot
方法二:
使用live盘
# mount -o rw /dev/ad4s3a /mnt
# chroot /mnt # chroot into /mnt
# passwd
# reboot
1.1.8 内核模块
lsmod
列出所有内核加载的模块
modprobe isdn
加载isdn模块
1.1.9 编译内核
# cd /usr/src/linux
# make mrproper # Clean everything, including config files
# make oldconfig # Reuse the old .config if existent
# make menuconfig # or xconfig (Qt) or gconfig (GTK)
# make # Create a compressed kernel image
# make modules # Compile the modules
# make modules_install # Install the modules
# make install # Install the kernel
# reboot
1.1.10 修复grub
使用live盘启动,使用fdisk命令查看linux分区,加载proc和dev分区,安装grub。
# mount /dev/sda6 /mnt # mount the linux partition on /mnt
# mount --bind /proc /mnt/proc # mount the proc subsystem into /mnt
# mount --bind /dev /mnt/dev # mount the devices into /mnt
# chroot /mnt # change root to the linux partition
# grub-install /dev/sda # reinstall grub with your old settings
1.2 进程
1.2.1 列进程
ps auxefw
查看所有进程
ps aux | grep 'ss[h]'
查看除grep外的所有ssh进程
pgrep -l ssh
用进程名字查找PID号
echo $$
shell的进程号
fuser -va 22/tcp
查看使用22端口的用户
pmap PID
查看PID对应的内存映射
fuser -va /home
列出所有访问home分区的用户
1.2.2 优先级
renice
nice
ionice
1.2.3 前端/后端
bg
将一个进程放在后台运行
jobs -l
列出后台运行的进程
nohup ping -i 60 > ping.log &
放后台运行
1.2.4 Signals/Kill
kill -s TERM 4712
杀死pid为4712的进程
killall -1 httpd
杀死httpd进程
pkill -9 http
杀死http进程
pkill -TERM -u www
杀死所有www用户的进程
fuser -k -TERM -m /home
杀死所有访问/home目录的进程
重要的代码
1 HUP (hang up)
2 INT (interrupt)
3 QUIT (quit)
9 KILL (non-catchable, non-ignorable kill)
15 TERM (software termination signal)
1.3 文件系统
1.3.1 权限
关于文件权限的含义
1 --x execute # Mode 764 = exec/read/write | read/write | read
2 -w- write # For: |-- Owner --| |- Group-| |Oth|
4 r-- read
ugo=a u=user, g=group, o=others, a=everyone
chmod [OPTION] MODE[,MODE] FILE
修改文件权限
chmod 640 /var/log/maillog
修改maillog文件权限为-rw-r-----
chmod u=rw,g=r,o= /var/log/maillog
效果同上
chmod -R o-r /home/*
删除/home目录的可读权限
chmod u+s /path/to/prog
设置SUID可执行
chown user:group /path/to/file
变更文件的用户和组
chgrp group /path/to/file
变更文件所有组
chmod 640 `find ./ -type f -print`
变更当前目录下所有文件的权限为640
chmod 751 `find ./ -type d -print`
变更当前目录下的所有目录为751
1.3.2 磁盘信息
hdparm -I /dev/sda
查看硬盘信息
fdisk
smartctl -a /dev/sda
显示磁盘SMART信息
1.3.3 系统挂载/磁盘使用
mount | column -t
显示所有系统挂载文件分区
df
显示文件分区信息
cat /proc/partitions
显示分区信息
du -sh *
显示当前目录下个文件大小
du -csh
显示当前目录总大小
du -ks * | sort -n -r
显示当前目录下文件大小并排序
ls -lSr
1.3.4 谁打开了哪个文件?
首先卸载/home目录,系统会提示不能卸载
# umount /home/
# fuser -m /home # 列出所有访问/home目录的进程
# lsof /home
相关应用
ps ax | grep Xorg | awk '{print $1}'
3324
# lsof -p 3324
单个文件
# lsof /var/log/Xorg.0.log
1.3.5 挂载/卸载文件系统
mount -t auto /dev/cdrom /mnt/cdrom
加载
1.4 网络
1.4.1 网络调试
ethtool eth0
查看eth0接口的配置
ethtool -s eth0 speed 100 duplex full
配置eth0全双工工作
ethtool -s eth0 autoneg off
禁止eth0网口自动谈判协议
ethtool -p eth1
闪烁eth1网口
ip link show
显示所有接口
ip link set eth0 up
类似ifconfig eth0 up
ip addr show
显示所有IP接口
ip neigh show
类似arp -a
arping 192.168.16.254
在ethernet上ping
tcptraceroute -f 5 cb.vu
使用tcp协议判断路由
1.4.2 路由
route -n
显示路由表
netstat -an
显示端口状态
route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.16.254
增加路由
ip route add 192.168.20.0/24 via 192.168.16.254
增加路由,同上
# route add -net 192.168.20.0 netmask 255.255.255.0 dev eth0
# route add default gw 192.168.51.254
# ip route add default via 192.168.51.254 dev eth0
route delete -net 192.168.20.0 netmask 255.255.255.0
删除路由
1.4.3 配置IP地址
ifconfig eth0 192.168.50.254 netmask 255.255.255.0
配置第一个地址
ifconfig eth0:0 192.168.51.254 netmask 255.255.255.0
配置接口第二个地址
ip addr add 192.168.50.254/24 dev eth0
ip addr add 192.168.51.254/24 dev eth0 label eth0:1
1.4.4 变更MAC地址
# ifconfig eth0 down
# ifconfig eth0 hw ether 00:01:02:03:04:0
1.4.5 端口
netstat -an | grep LISTEN
查看处于监听状态的端口
lsof -i
列出所有的连接
netstat -anp --udp --tcp | grep LISTEN
查看TCP/UDP连接
netstat -tup
列出活动的连接
netstat -tupl
列出活动的连接和监听端口
netstat -ano
列出端口和进程路径
1.4.6 防火墙
iptables -L -n -v
列出端口过滤状态
iptables -P INPUT ACCEPT
允许进入端口
iptables -P FORWARD ACCEPT
允许转发端口
iptables -P OUTPUT ACCEPT
允许输出端口
iptables -Z
屏蔽所有端口
iptables -F
iptables -X
1.4.7 IP路由转发
步骤:
# cat /proc/sys/net/ipv4/ip_forward # Check IP forward 0=off, 1=on
# echo 1 > /proc/sys/net/ipv4/ip_forward
1.4.8 NAT网络地址映射
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
激活一个映射
iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 --dport 20022 -j DNAT --to 192.168.16.44:22
内网ssh端口映射到公网20022端口
iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 --dport 993:995 -j DNAT --to 192.168.16.254:993-99
端口映射范围993-995
ip route flush cache
iptables -L -t nat
查看端口映射
netstat -nat -n
查看连接nat的地址
1.4.9 DNS
Kali的DNS配置文件在/etc/resolv.conf,可以针对相应示例进行修改。
dig
查看DNS解析
dig @127.0.0.1 NS
测试本地服务
dig @204.97.212.10 NS MX heise.de
指定DNS服务器查询一个存在的域名
dig AXFR @ns1.xname.org cb.vu
指定DNS服务器查询域名所有记录
host -t MX cb.vu
获得Mail服务器地址
host -t NS -T
使用TCP连接获得NS的记录
host -a
获得所有记录
# dig -x 78.31.70.238
# host 78.31.70.238
# nslookup 78.31.70.238
反向查询
1.4.10 传输协议分析
tcpdump
tcpdump -nl -i bge0 not port ssh and src \(192.168.16.121 or 192.168.16.54\)
tcpdump -n -i eth1 net 192.168.16.121
使用IP过滤
tcpdump -n -i eth1 net 192.168.16.0/24
使用网段过滤
tcpdump -l > dump && tail -f dump
输出到dump文件中并查看
tcpdump -i rl0 -w traffic.rl0
以二进制形式显示传输文件头
tcpdump -i rl0 -s 0 -w traffic.rl0
输出文件
tcpdump -r traffic.rl0
读文件
tcpdump port 80
tcpdump host
1.4.11. 传输控制(QoS)
限制上传
tc qdisc add dev eth0 root tbf rate 480kbit latency 50ms burst 1540
tc -s qdisc ls dev eth0
tc qdisc del dev eth0 root
tc qdisc change dev eth0 root tbf rate 220kbit latency 50ms burst 1540
QoS
tc qdisc add dev eth0 root handle 1: prio priomap 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 0
tc qdisc add dev eth0 parent 1:1 handle 10: sfq
tc qdisc add dev eth0 parent 1:2 handle 20: sfq
tc qdisc add dev eth0 parent 1:3 handle 30: sfq
tc filter add dev eth0 protocol ip parent 1: prio 1 u32 \
match ip dport 10000 0x3C00 flowid 1:1 # use server port range
match ip dst 123.23.0.1 flowid 1:1 # or/and use server IP
tc -s qdisc ls dev eth0
查询状态
tc qdisc del dev eth0 root
删除所有QoS
1.4.11 netcat(nc)
server# tar -cf - -C VIDEO_TS . | nc -l -p 4444
client# nc 192.168.1.1 4444 | tar xpf - -C VIDEO_TS
# Serve tar folder on port 4444
# Pull the file on port 4444
server# cat largefile | nc -l 5678
client# nc 192.168.1.1 5678 > largefile
# Server a single file
# Pull the single file
server# dd if=/dev/da0 | nc -l 4444
client# nc 192.168.1.1 4444 | dd of=/dev/da0
client# nc 192.168.1.1 4444 | dd of=da0.img
# Server partition image
# Pull partition to clone
# Pull partition to file
nc -lp 4444 -e /bin/bash
生成一个远程shell
nc -lp 4444 -e cmd.exe
windows远程shell
1.5 SSH / SCP
使用ssh-keygen生成一对密钥,~/.ssh/id_dsa 是私钥,~/.ssh/id_dsa.pub是公钥
文件传输
scp file.txt host-two:/tmp
scp joe@host-two:/www/*.html /www/tmp
scp -r joe@host-two:/www /www/tmp
自动开启SSH的脚本
#!/bin/sh
COMMAND="ssh -N -f -g -R 3022:localhost:22 colin@cb.vu"
pgrep -f -x "$COMMAND" > /dev/null 2>&1 || $COMMAND
exit 0
1 * * * * colin /home/colin/port_forward.sh # crontab entry (here hourly)
1.6 rsync
可以用来代替cp和scp的工具
rsync -a /home/colin/ /backup/colin/
使用archive模式复制
rsync -aR --delete-during /home/user/ /backup/
/opt/local/bin/rsync -azv --iconv=UTF-8-MAC,UTF-8 ~/Music/flac/ me@server:/dst/
rsync -axSRzv /home/user/ user@server:/backup/user/
远程复制
rsync -a 'user@server:My\ Documents' My\ Document
rsync -azR --exclude=tmp/ /home/user/ user@server:/backup/
rsync -az -e 'ssh -p 20022' /home/colin/ user@server:/backup/colin/
使用20022端口建立ssh连接
rsync -axSRz ruser@hostname::rmodule/backup/ /home/
从远程向本地复制
一些重要参数:
-a, --archive archive mode; same as -rlptgoD (no -H)
-r, --recursive recurse into directories
-R, --relative use relative path names
-H, --hard-links preserve hard links
-S, --sparse handle sparse files efficiently
-x, --one-file-system don't cross file system boundaries
--exclude=PATTERN exclude files matching PATTERN
--delete-during receiver deletes during xfer, not before
--delete-after receiver deletes after transfer, not before
自动备份脚本
@ECHO OFF
REM rsync the directory My Documents
SETLOCAL
SET CWRSYNCHOME=C:\PROGRAM FILES\CWRSYNC
SET CYGWIN=nontsec
SET CWOLDPATH=%PATH%
REM uncomment the next line when using cygwin
SET PATH=%CWRSYNCHOME%\BIN;%PATH%
echo Press Control-C to abort
rsync -av "/cygdrive/c/Documents and Settings/%USERNAME%/My Documents/" \
'user@server:My\ Documents/'
pause
1.7 sudo
sudo /etc/init.d/dhcpd restart
使用root账户运行脚本
sudo -u sysadmin whoami
使用sysadmin运行脚本
相关配置文件在/etc/sudoers
1.8 常用工具
1.8.1 less
在控制台界面显示文本内容
一些常用参数
h H good help on display
f ^F ^V SPACE Forward one window (or N lines).
b ^B ESC-v Backward one window (or N lines).
F Forward forever; like "tail -f".
/pattern Search forward for (N-th) matching line.
?pattern Search backward for (N-th) matching line.
n Repeat previous search (for N-th occurrence).
N Repeat previous search in reverse direction.
q quit
1.8.2 vim
控制台界面文本编辑器
常用参数
离开
:w newfilename save the file to newfilename
:wq or :x save and quit
:q! quit without saving
查找
/string Search forward for string
?string Search back for string
n Search for next instance of string
N Search for previous instance of string
{ Move a paragraph back
} Move a paragraph forward
1G Move to the first line of the file
nG Move to the n th line of the file
G Move to the last line of the file
:%s/OLD/NEW/g Search and replace every occurrence
删除或复制
dd (dw) Cut current line (word)
D Cut to the end of the line
x Delete (cut) character
yy (yw) Copy line (word) after cursor
P Paste after cursor
u
展开阅读全文