Fixing checksum uri generator again.

This time, it's ensured that generate_uri_checksum(sum) will succeed,
provided the sum is an even number between 80 and 100 (tested)

It's still not great for arbitrary checksum targets, but that's because
there are lots of strings that cannot satisfy the requirement. I kind of
think this is the fault of Rex.
unstable
Tod Beardsley 2012-03-27 08:32:47 -05:00
parent 5f9000efb3
commit a0f0aadad3
2 changed files with 13 additions and 7 deletions

View File

@ -65,9 +65,12 @@ module ReverseHttp
# Create a URI that matches a given checksum
#
def generate_uri_checksum(sum)
chk = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
32.times do
uri = Rex::Text.rand_text_alphanumeric(3)
("a".."z").sort_by {rand}.each do |x|
return(uri + x) if Rex::Text.checksum8(uri + x)
chk.sort_by {rand}.each do |x|
return(uri + x) if Rex::Text.checksum8(uri + x) == sum
end
end
raise RuntimeError, "Unable to generate a string with checksum #{sum}"
end

View File

@ -66,9 +66,12 @@ module ReverseHttps
# Create a URI that matches a given checksum
#
def generate_uri_checksum(sum)
chk = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
32.times do
uri = Rex::Text.rand_text_alphanumeric(3)
("a".."z").sort_by {rand}.each do |x|
return(uri + x) if Rex::Text.checksum8(uri + x)
chk.sort_by {rand}.each do |x|
return(uri + x) if Rex::Text.checksum8(uri + x) == sum
end
end
raise RuntimeError, "Unable to generate a string with checksum #{sum}"
end