From a1bd640eff9ea91f424d4432adc24f60b073dff3 Mon Sep 17 00:00:00 2001 From: William Vu Date: Fri, 1 Jul 2016 09:05:03 -0500 Subject: [PATCH 1/2] Fix hashrocket alignment --- .../exploits/windows/local/payload_inject.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/exploits/windows/local/payload_inject.rb b/modules/exploits/windows/local/payload_inject.rb index 32df9a790d..59f9fd37b6 100644 --- a/modules/exploits/windows/local/payload_inject.rb +++ b/modules/exploits/windows/local/payload_inject.rb @@ -14,29 +14,29 @@ class MetasploitModule < Msf::Exploit::Local def initialize(info={}) super( update_info( info, - 'Name' => 'Windows Manage Memory Payload Injection', - 'Description' => %q{ + 'Name' => 'Windows Manage Memory Payload Injection', + 'Description' => %q{ This module will inject a payload into memory of a process. If a payload isn't selected, then it'll default to a reverse x86 TCP meterpreter. If the PID datastore option isn't specified, then it'll inject into notepad.exe instead. }, - 'License' => MSF_LICENSE, - 'Author' => + 'License' => MSF_LICENSE, + 'Author' => [ 'Carlos Perez ', 'sinn3r' ], - 'Platform' => [ 'win' ], - 'Arch' => [ ARCH_X86, ARCH_X86_64 ], - 'SessionTypes' => [ 'meterpreter' ], - 'Targets' => [ [ 'Windows', {} ] ], + 'Platform' => [ 'win' ], + 'Arch' => [ ARCH_X86, ARCH_X86_64 ], + 'SessionTypes' => [ 'meterpreter' ], + 'Targets' => [ [ 'Windows', {} ] ], 'Payload' => { 'Space' => 4096, 'DisableNops' => true }, - 'DefaultTarget' => 0, - 'DisclosureDate'=> "Oct 12 2011" + 'DefaultTarget' => 0, + 'DisclosureDate' => "Oct 12 2011" )) register_options( From 4b01213fb57456d7ba3f175f98693a70e3aec115 Mon Sep 17 00:00:00 2001 From: William Vu Date: Fri, 1 Jul 2016 09:15:42 -0500 Subject: [PATCH 2/2] Rewrite the logic to be positive unless is the devil. unless/else doubly so. --- lib/msf/core/payload/linux/bind_tcp.rb | 2 +- lib/msf/core/payload/linux/reverse_tcp.rb | 2 +- lib/msf/core/payload/windows/bind_tcp.rb | 2 +- lib/msf/core/payload/windows/bind_tcp_rc4.rb | 2 +- lib/msf/core/payload/windows/reverse_http.rb | 2 +- lib/msf/core/payload/windows/reverse_tcp.rb | 2 +- lib/msf/core/payload/windows/reverse_tcp_dns.rb | 2 +- lib/msf/core/payload/windows/reverse_tcp_rc4.rb | 2 +- lib/msf/core/payload/windows/reverse_tcp_rc4_dns.rb | 2 +- lib/msf/core/payload/windows/reverse_winhttp.rb | 2 +- lib/msf/core/payload/windows/x64/bind_tcp.rb | 2 +- lib/msf/core/payload/windows/x64/reverse_http.rb | 2 +- lib/msf/core/payload/windows/x64/reverse_tcp.rb | 2 +- lib/msf/core/payload/windows/x64/reverse_winhttp.rb | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/msf/core/payload/linux/bind_tcp.rb b/lib/msf/core/payload/linux/bind_tcp.rb index a8de052bc6..aa7537da12 100644 --- a/lib/msf/core/payload/linux/bind_tcp.rb +++ b/lib/msf/core/payload/linux/bind_tcp.rb @@ -30,7 +30,7 @@ module Payload::Linux::BindTcp } # Generate the more advanced stager if we have the space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'], conf[:reliable] = true end diff --git a/lib/msf/core/payload/linux/reverse_tcp.rb b/lib/msf/core/payload/linux/reverse_tcp.rb index bad961c820..ad719b7fb4 100644 --- a/lib/msf/core/payload/linux/reverse_tcp.rb +++ b/lib/msf/core/payload/linux/reverse_tcp.rb @@ -33,7 +33,7 @@ module Payload::Linux::ReverseTcp } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/bind_tcp.rb b/lib/msf/core/payload/windows/bind_tcp.rb index 23d8aa6de1..4c34ea21ba 100644 --- a/lib/msf/core/payload/windows/bind_tcp.rb +++ b/lib/msf/core/payload/windows/bind_tcp.rb @@ -34,7 +34,7 @@ module Payload::Windows::BindTcp } # Generate the more advanced stager if we have the space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'], conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/bind_tcp_rc4.rb b/lib/msf/core/payload/windows/bind_tcp_rc4.rb index 065b725c5f..315a1b0afc 100644 --- a/lib/msf/core/payload/windows/bind_tcp_rc4.rb +++ b/lib/msf/core/payload/windows/bind_tcp_rc4.rb @@ -32,7 +32,7 @@ module Payload::Windows::BindTcpRc4 } # Generate the more advanced stager if we have the space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'], conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/reverse_http.rb b/lib/msf/core/payload/windows/reverse_http.rb index 65c4267a05..fbff122bb4 100644 --- a/lib/msf/core/payload/windows/reverse_http.rb +++ b/lib/msf/core/payload/windows/reverse_http.rb @@ -50,7 +50,7 @@ module Payload::Windows::ReverseHttp } # Add extra options if we have enough space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:url] = luri + generate_uri conf[:exitfunk] = datastore['EXITFUNC'] conf[:ua] = datastore['MeterpreterUserAgent'] diff --git a/lib/msf/core/payload/windows/reverse_tcp.rb b/lib/msf/core/payload/windows/reverse_tcp.rb index 8109cc7182..dd7ed1e166 100644 --- a/lib/msf/core/payload/windows/reverse_tcp.rb +++ b/lib/msf/core/payload/windows/reverse_tcp.rb @@ -34,7 +34,7 @@ module Payload::Windows::ReverseTcp } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/reverse_tcp_dns.rb b/lib/msf/core/payload/windows/reverse_tcp_dns.rb index c73c8d8b40..d834c5a353 100644 --- a/lib/msf/core/payload/windows/reverse_tcp_dns.rb +++ b/lib/msf/core/payload/windows/reverse_tcp_dns.rb @@ -38,7 +38,7 @@ module Payload::Windows::ReverseTcpDns } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/reverse_tcp_rc4.rb b/lib/msf/core/payload/windows/reverse_tcp_rc4.rb index 4835fa27ff..0f78ff96d5 100644 --- a/lib/msf/core/payload/windows/reverse_tcp_rc4.rb +++ b/lib/msf/core/payload/windows/reverse_tcp_rc4.rb @@ -34,7 +34,7 @@ module Payload::Windows::ReverseTcpRc4 } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/reverse_tcp_rc4_dns.rb b/lib/msf/core/payload/windows/reverse_tcp_rc4_dns.rb index 2eb4c0a000..5ced87e1a8 100644 --- a/lib/msf/core/payload/windows/reverse_tcp_rc4_dns.rb +++ b/lib/msf/core/payload/windows/reverse_tcp_rc4_dns.rb @@ -34,7 +34,7 @@ module Payload::Windows::ReverseTcpRc4Dns } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/reverse_winhttp.rb b/lib/msf/core/payload/windows/reverse_winhttp.rb index be1c5e95b7..23ee66695c 100644 --- a/lib/msf/core/payload/windows/reverse_winhttp.rb +++ b/lib/msf/core/payload/windows/reverse_winhttp.rb @@ -36,7 +36,7 @@ module Payload::Windows::ReverseWinHttp } # Add extra options if we have enough space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:uri] = generate_uri conf[:exitfunk] = datastore['EXITFUNC'] conf[:verify_cert_hash] = opts[:verify_cert_hash] diff --git a/lib/msf/core/payload/windows/x64/bind_tcp.rb b/lib/msf/core/payload/windows/x64/bind_tcp.rb index 33f57b220e..053143d640 100644 --- a/lib/msf/core/payload/windows/x64/bind_tcp.rb +++ b/lib/msf/core/payload/windows/x64/bind_tcp.rb @@ -32,7 +32,7 @@ module Payload::Windows::BindTcp_x64 } # Generate the more advanced stager if we have the space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'], conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/x64/reverse_http.rb b/lib/msf/core/payload/windows/x64/reverse_http.rb index 83d0379409..d4118896e8 100644 --- a/lib/msf/core/payload/windows/x64/reverse_http.rb +++ b/lib/msf/core/payload/windows/x64/reverse_http.rb @@ -54,7 +54,7 @@ module Payload::Windows::ReverseHttp_x64 } # add extended options if we do have enough space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:url] = luri + generate_uri conf[:exitfunk] = datastore['EXITFUNC'] conf[:ua] = datastore['MeterpreterUserAgent'] diff --git a/lib/msf/core/payload/windows/x64/reverse_tcp.rb b/lib/msf/core/payload/windows/x64/reverse_tcp.rb index 3de55bd891..8c4c66b228 100644 --- a/lib/msf/core/payload/windows/x64/reverse_tcp.rb +++ b/lib/msf/core/payload/windows/x64/reverse_tcp.rb @@ -41,7 +41,7 @@ module Payload::Windows::ReverseTcp_x64 } # Generate the advanced stager if we have space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end diff --git a/lib/msf/core/payload/windows/x64/reverse_winhttp.rb b/lib/msf/core/payload/windows/x64/reverse_winhttp.rb index 8c31863621..5a17196667 100644 --- a/lib/msf/core/payload/windows/x64/reverse_winhttp.rb +++ b/lib/msf/core/payload/windows/x64/reverse_winhttp.rb @@ -37,7 +37,7 @@ module Payload::Windows::ReverseWinHttp_x64 } # Add extra options if we have enough space - unless self.available_space.nil? || required_space > self.available_space + if self.available_space && required_space < self.available_space conf[:uri] = generate_uri conf[:exitfunk] = datastore['EXITFUNC'] conf[:verify_cert_hash] = opts[:verify_cert_hash]