CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/core/auxiliary/sms.rb
Views: 1904
1
# -*- coding: binary -*-
2
3
###
4
#
5
# The Msf::Auxiliary::Sms mixin allows you to send a text message to
6
# multiple phones of the same carrier. A valid SMTP server is needed.
7
#
8
##
9
10
module Msf
11
module Auxiliary::Sms
12
13
def initialize(info={})
14
super
15
16
register_options(
17
[
18
OptString.new('SMTPFROM', [false, 'The FROM field for SMTP', '']),
19
OptString.new('SMTPADDRESS', [ true, 'The SMTP server to use to send the text messages']),
20
OptPort.new('SMTPPORT', [true, 'The SMTP port to use to send the text messages', 25]),
21
OptString.new('SMTPUSERNAME', [true, 'The SMTP account to use to send the text messages']),
22
OptString.new('SMTPPASSWORD', [true, 'The SMTP password to use to send the text messages']),
23
OptEnum.new('SMSCARRIER', [true, 'The targeted SMS service provider', nil,Rex::Proto::Sms::Model::GATEWAYS.keys.collect { |k| k.to_s }]),
24
OptString.new('CELLNUMBERS', [true, 'The phone numbers to send to']),
25
OptString.new('SMSMESSAGE', [true, 'The text message to send']),
26
OptString.new('SMSSUBJECT', [false, 'The text subject', ''])
27
], Auxiliary::Sms)
28
29
register_advanced_options(
30
[
31
OptEnum.new('SmtpLoginType', [true, 'The SMTP login type', 'login', ['plain', 'login', 'cram_md5']]),
32
OptString.new('HeloDdomain', [false, 'The domain to use for HELO', ''])
33
], Auxiliary::Sms)
34
end
35
36
37
# Sends a text message to multiple numbers of the same service provider (carrier).
38
#
39
# @example This sends a text via Gmail
40
# smtp = Rex::Proto::Sms::Model::Smtp.new(address: 'smtp.gmail.com', port: 587, username: user, password: pass)
41
# sms = Rex::Proto::Sms::Client.new(carrier: :verizon, smtp_server: smtp)
42
# numbers = ['1112223333']
43
# sms.send_text_to_phones(numbers, 'Hello from Gmail')
44
#
45
# @param phone_numbers [<String>Array] An array of numbers of try (of the same carrier)
46
# @param subject [String] The text subject
47
# @param message [String] The text to send.
48
#
49
# @return [void]
50
def send_text(phone_numbers, subject, message)
51
smtp = Rex::Proto::Sms::Model::Smtp.new(
52
address: datastore['SMTPADDRESS'],
53
port: datastore['SMTPPORT'],
54
username: datastore['SMTPUSERNAME'],
55
password: datastore['SMTPPASSWORD'],
56
login_type: datastore['SmtpLoginType'].to_sym,
57
from: datastore['SMTPFROM']
58
)
59
60
carrier = datastore['SMSCARRIER'].to_sym
61
sms = Rex::Proto::Sms::Client.new(carrier: carrier, smtp_server: smtp)
62
sms.send_text_to_phones(phone_numbers, subject, message)
63
end
64
65
end
66
end
67
68