一、代码审计error_reporting(0); if (isset($_GET['code'])) { $code = $_GET['code']; if (strlen($code) > 40) { die("This is too Long."); } if (preg_match("/[A-Za-z0-9]+/", $code)) { die("NO."); } @eval($code); } else { highlight_file(__FILE__); }这次的代码很简单,不可以使用可见字符,需要使用不可见字符运算后进行RCE。二、原理PHP的神奇特性,允许变量的值作为变量名或函数名进行调用,且该变量的值允许运算。或绕过将可见字符转换为使用或运算之后才能得到的结果,这样可以使用不可见字符转换为可见字符串。import re import requests import urllib from sys import * impo
一、信息收集扫描目录,发现index.php.swp文件。ob_start(); function get_hash(){ $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-'; $random = $chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)];//Random 5 times $content = uniqid().$random; return sha1($content); } header("Content-Type: text/html;charset=utf-8"); //*** if(isset($_POST['username']) and $_POST['username'] != '' ) { $admin =
Java反序列化Java序列化与反序列化依赖于两个函数writeObject()与readObject(),只要一个类实现了Serializable接口就可以使用这两个函数进行序列化与反序列化。Java反序列化漏洞原理类似PHP反序列化,PHP反序列化时会触发wakeup()函数,而Java中没有这种通用的函数,要实现类似wakeup()函数在反序列化时被触发的功能需要重写readObject()。Java反序列化漏洞需要触发一个被重写的readObject(),这个readObject()调用了一个其他类也有同名的函数,导致非预期的函数被执行。举个例子:原本的程序预期:从接口接到A类对象序列化的字节流调用A类的readObject()进行反序列化A类的readObject()中调用反序列化出来的A类对象中的一个B类对象的F方法完成反序列化传入恶意序列化字节流后:在A类对象中放置B类对象的位置嵌入一个恶意的C类对象,其中B与C有一个共同的F方法从接口接到A类对象序列化的字节流调用A类的readObject()进行反序列化A类的readObject()中调用反序列化出来的A类对象中的C类
一、SSTI简介SSTI就是服务器端模板注入(Server-Side Template Injection),实际上也是一种注入漏洞。由于未对用户输入的数据进行过滤,导致由用户输入的模板引擎渲染标识符中的内容被渲染,导致RCE(任意代码执行)漏洞。二、判断模板引擎最出名的一张图。解释:绿色箭头指成功执行,红色箭头指原样返回或报错。区分Jinja2与Twig通过{{7*'7'}}返回的值。Jinja2:7777777Twig:49三、Smarty1. 简介这是一个基于PHP服务的模板引擎,是为了让前端界面(html)与程序代码(php)分离而产生的一种解决方案,Smarty 的原理是变量替换原则,我们只需要在html文件里写好Smarty的标签即可,如果对用户的输入不加处理直接回显可能会导致SSTI漏洞。2. 漏洞确认POC:{$smarty.version}返回版本号。3. 任意文件读取POC:string:{include file='[file path]'}解释:{include}标签所导致,被该标签引入的文件只会单纯的输出文件内容,就算引入 php 文件也是如此。通过self获
SQL注入原理由于程序员对插入SQL语句的用户输入参数检查不严格,导致的恶意SQL命令被插入语句并执行。例如:原始查询语句为 select * from user where id=$value$value为用户输入变量,由于没有过滤,在用户输入 1 and 1=2时查询语句变为 select * from user where id=1 and 1=2,返回永假页面。SQL数据库重要信息MySQL端口3306默认数据库:information_schemamysql.innodb_table_stats:这个表不储存列,所以看列的时候要另行他路。三个表名:SCHEMATA:所有数据库库名TABLES:所有数据库库名与表名COLUMNS:库名、表名、字段名基础查询语句select * from {table_name}select * from {table_name} where {column_name}={data}select * from {table_name} where {column_name}={data} and {other_column}={data} ...
Equinox
一个乐于分享的网安人