Skip to content

Add stdin support for modules #21591

Description

@vognik

Summary

Sometimes static values from datastore are not enough.
For example, when target services enforces 2FA.

It can be useful to add a function for user input at runtime.

Basic example

Ghost CMS enforces 2FA by default, and you cannot log in without a code from an email #21234

In code, it could be useful to use a function that asks the user for a 2FA code at runtime.

res = ghost_request_cgi('POST', 'session', data: {
  username: datastore['USERNAME'],
  password: datastore['PASSWORD']
})

if res&.code == 201
  print_good('Session established via password.')

elsif res&.body =~ /2FA_NEW_DEVICE_DETECTED/
  print_warning('Ghost CMS requires a 6-digit verification code from your email.')

  verification_code = input('[*] Enter the 6-digit verification code: ', format: '[0-9]{6}') // <= a new function for user input

  print_status("Verifying session with code: #{verification_code}...")
  res_verify = ghost_request_cgi('PUT', 'session/verify', data: {
    token: verification_code
  })

end

Motivation

Metasploit does not support runtime input, and because of this, you cannot create exploits for some systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions