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/tools/modules/generate_mettle_payloads.rb
Views: 11767
1
#!/usr/bin/env ruby
2
3
#
4
# This script generates Mettle payload wrappers
5
#
6
7
require 'erb'
8
9
schemes = [
10
'tcp',
11
'http',
12
'https'
13
]
14
15
arches = [
16
['aarch64', 'Linux', 'aarch64-linux-musl'],
17
['armbe', 'Linux', 'armv5b-linux-musleabi'],
18
['armle', 'Linux', 'armv5l-linux-musleabi'],
19
['mips64', 'Linux', 'mips64-linux-muslsf'],
20
['mipsbe', 'Linux', 'mips-linux-muslsf'],
21
['mipsle', 'Linux', 'mipsel-linux-muslsf'],
22
['ppc', 'Linux', 'powerpc-linux-muslsf'],
23
['ppce500v2', 'Linux', 'powerpc-e500v2-linux-musl'],
24
['ppc64le', 'Linux', 'powerpc64le-linux-musl'],
25
['x64', 'Linux', 'x86_64-linux-musl'],
26
['x86', 'Linux', 'i486-linux-musl'],
27
['zarch', 'Linux', 's390x-linux-musl'],
28
['x64', 'OSX', 'x86_64-apple-darwin'],
29
['aarch64', 'OSX', 'aarch64-apple-darwin'],
30
['aarch64', 'Apple_iOS', 'aarch64-iphone-darwin'],
31
['armle', 'Apple_iOS', 'arm-iphone-darwin'],
32
]
33
34
arch = ''
35
payload = ''
36
platform = ''
37
scheme = ''
38
cwd = File::dirname(__FILE__)
39
40
arches.each do |a, pl, pa|
41
schemes.each do |s|
42
arch = a
43
platform = pl
44
payload = pa
45
scheme = s
46
47
template = File::read(File::join(cwd, "meterpreter_reverse.erb"))
48
renderer = ERB.new(template)
49
filename = File::join('modules', 'payloads', 'singles', platform.downcase, arch, "meterpreter_reverse_#{scheme}.rb")
50
File::write(filename, renderer.result())
51
end
52
end
53
54
`bundle exec #{File::join(cwd, 'update_payload_cached_sizes.rb')}`
55
56