I'm trying to concat a SQL query string and a hex string that should be capitalized. hURL -X -s
takes a string or file and coverts it to hex.
cmd = "/root/Desktop/pentest/tools/hURL/hURL -X -s " +
md5_got.chomp.delete("\n").to_s
md5_tohex = `#{cmd}`
md5_where = md5_tohex.chomp.delete("\n").to_s
At this point, md5_where
is:
1b5b316d34303339613365663766633739653461646236306234336163313038643634381b5b306d
I need this hex capitalized. I did both of these in all permutations including leaving out the to_s
and the !
:
md5_where.upcase!
md5_where.to_s!
I try and combine my query and my hex value:
sql_comp = "SELECT word FROM captcha_rbow WHERE hex(md5) = " + md5_where
puts sql_comp
puts '###
abort()
This is what I get:
1B5B316D653...B306D
Leading spaces equal to the length of the SQL query and the upstring variable printed on the screen with no trace of the SQL query
If I take md5_where
, I get this, which is as it should be:
SELECT word FROM captcha_rbow WHERE hex(md5) =
Why does this clobber the text? Here is full script require 'open-uri' require 'sqlite3'
open('GOT_captcha.png', 'wb') do |file|
file << open('http://192.168.56.101/captcha/example5/captcha.png').read
end
cmd = "/root/Desktop/pentest/tools/hURL/hURL -m -s -f GOT_captcha.png"
md5orig = `#{cmd}`
cmd = "/root/Desktop/pentest/tools/hURL/hURL -X -s " + md5orig.chomp.delete("\n").to_s
puts cmd
md5_tohex = `#{cmd}`
md5_where = md5_tohex.to_s
puts md5_where
sql_comp = "SELECT word FROM captcha_rbow WHERE (hex(md5)) = " + md5_where.upcase
puts sql_comp
#THIS IS WHERE THE PROBLEM IS
begin
db = SQLite3::Database.open( "akad_web2" )
sql_comp = "SELECT word FROM captcha_rbow WHERE hex(md5) = '" + md5_where.upcase + "';"
puts sql_comp
stm = db.prepare sql_comp
rs = stm.execute
row = rs.next
puts row.to_s
rescue SQLite3::Exception => e
puts "Exception occurred"
puts e
ensure
stm.close if stm
db.close if db
end
abort()
NOTE - input is an image file (a captcha generated via RMagick with a known set of possible strings) to generate an MD5 rainbow table.
This is the output:
/root/Desktop/pentest/tools/hURL/hURL -X -s 4039a3ef7fc79e4adb60b43ac108d648
1b5b316d34303339613365663766633739653461646236306234336163313038643634381b5b306d
1B5B316D34303339613365663766633739653461646236306234336163313038643634381B5B306D
1B5B316D34303339613365663766633739653461646236306234336163313038643634381B5B306D';
root@kali:~/Desktop/Akademy_webpentest_2#