前言

模块适配

lib/msf/core/post/common.rb
lib/msf/core/post/file.rb
lib/msf/core/post/process.rb
函数名 功能描述
clear_screen 清屏,在模块编写中没啥作用
rhost 获取目标IP地址
rport 获取目标端口
peer 获取IP地址和端口组合
函数名 功能描述
cmd_exec 执行命令
cmd_exec_get_pid 执行命令返回pid,只支持meterpreter
get_env 获取环境变量
get_envs 获取多个环境变量,以字典的形式返回
command_exists 判断命令是否存在
cmd_exec_with_result 执行命令读取结果
函数名 功能描述
cd 改变会话当前目录
pwd 返回会话当前目录
dir 获取指定目录下的文件和目录
mkdir 创建目录
directory 判断指定路径是否为目录
expand_path 拼接存在环境变量的字符串为完整路径
file 判断指定路径是否为文件
setuid 判断指定路径是否为setuid文件
executable 判断指定路径是否为可执行文件,不支持window系统
writable 判断指定路径是否为可写行文件,支持powershell,不支持shell会话
immutable 判断指定路径是否为不可变文件,不支持window系统
readable 判断指定路径是否为可读行文件,支持powershell,不支持shell会话
exist 判断指定路径是否存在,文件和文件夹都行
attributes 获取指定路径的属性
file_local_write 写数据到本地文件
file_remote_digestmd5 获取指定路径的md5
file_remote_digestsha1 获取指定路径的sha1
file_remote_digestsha2 获取指定路径的sha2
read_file 读指定路径的文件
write_file 写文件
append_file 在指定文件后面追加数据
upload_file 上传文件,原理是读本地文件再调用上面的写文件
upload_and_chmodx 上传完文件再设置属性
chmod 设置属性,不支持window
exploit_data 二进制读取exploit目录下的文件
exploit_source 读取exploit源码文件
rm_f 删除文件
rm_rf 删除文件夹
rename_file 重命名文件
copy_file 复制文件
函数名 功能描述
pidof 回去进程pid
has_pid 判断是否存在指定pid
kill_process 杀死指定进程

代码编写

def initialize(info = {})
  super(
    update_info(
      info,
      'Name' => 'Gather Dbeaver Passwords',
      'Description' => %q{
        This module will determine if Dbeaver is installed on the target system and, if it is, it will try to
        dump all saved session information from the target. The passwords for these saved sessions will then be decrypted
        where possible.
      },
      'License' => MSF_LICENSE,
      'References' => [
        [ 'URL', '<https://blog.kali-team.cn/Metasploit-dbeaver-9f42e26241c94ba785dce5f1e69697aa>' ]
      ],
      'Author' => ['Kali-Team <kali-team[at]qq.com>'],
      'Platform' => [ 'linux', 'win', 'osx', 'unix'],
      'SessionTypes' => [ 'meterpreter', 'shell', 'powershell' ],
      'Notes' => {
        'Stability' => [],
        'Reliability' => [],
        'SideEffects' => []
      }
    )
  )
  register_options(
    [
      OptString.new('XML_FILE_PATH', [ false, 'Specifies the .dbeaver-data-sources.xml file path for Dbeaver']),
      OptString.new('JSON_DIR_PATH', [ false, 'Specifies the json directory path for Dbeaver']),
    ]
  )
end

总结

参考

https://github.com/rapid7/metasploit-framework/pull/17341

https://github.com/rapid7/metasploit-framework/pull/17337

Powered by Kali-Team