CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/vsploit/malware/dns/dns_query.rb
Views: 11766
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
8
def initialize
9
super(
10
'Name' => 'VSploit DNS Beaconing Emulation',
11
'Description' => 'This module takes a list and emulates malicious DNS beaconing.',
12
'Author' => 'MJC',
13
'License' => MSF_LICENSE
14
)
15
register_options(
16
[
17
OptString.new('DOMAINS', [ true, "Separate Domains by whitespace"]),
18
OptString.new('DNS_SERVER',[false, "Specifies a DNS Server"]),
19
OptInt.new('COUNT', [false, "Number of intervals to loop",2]),
20
OptInt.new('DELAY', [false, "Delay in seconds between intervals",3])
21
])
22
end
23
24
def run
25
@res = Net::DNS::Resolver.new()
26
#@res.retry = 2
27
28
if datastore['DNS_SERVER']
29
@res.nameservers = datastore['DNS_SERVER']
30
end
31
32
count = 0
33
34
while count < datastore['COUNT']
35
36
domain = datastore['DOMAINS'].split(/[\s,]+/)
37
domain.each do |name|
38
query = @res.query(name, "A")
39
time = Time.new
40
time = time.strftime("%Y-%m-%d %H:%M:%S")
41
print_status("#{time} - DNS Query sent for => #{name}")
42
if query.answer.length == 0
43
print_error("#{time} - #{name} => No Record Found")
44
else
45
a = query.answer[0].to_s.split(/[\s,]+/)
46
print_status("#{time} - #{name} => #{a[-1]}")
47
end
48
end
49
unless count == (datastore['COUNT'] - 1)
50
time = Time.new
51
time = time.strftime("%Y-%m-%d %H:%M:%S")
52
print_status("#{time} - Waiting #{datastore['DELAY']} seconds to beacon")
53
select(nil, nil, nil, datastore['DELAY'])
54
end
55
count += 1
56
end
57
end
58
end
59
60