php_code_challenges练习challenge1~3

Challenge1

1wMDEyY2U2YTY0M2NgMTEyZDQyMjAzNWczYjZgMWI4NTt3YWxmY=
<?php
error_reporting(0);
require __DIR__.'/lib.php';

echo base64_encode(hex2bin(strrev(bin2hex($flag)))), '<hr>';

highlight_file(__FILE__);
?>

使用PHP反跑一下编码解密。

challenge2

<?php
error_reporting(0);
require __DIR__.'/lib.php';
if(isset($_GET['time'])){
    if(!is_numeric($_GET['time'])){
        echo 'The time must be number.';
    }else if($_GET['time'] < 60 * 60 * 24 * 30 * 2){
        echo 'This time is too short.';
    }else if($_GET['time'] > 60 * 60 * 24 * 30 * 3){
        echo 'This time is too long.';
    }else{
        sleep((int)$_GET['time']);
        echo $flag;
    }
    echo '<hr>';
}
highlight_file(__FILE__);

本题要求GET请求time,还要求time在60 * 60 * 24 * 30 * 2~60 * 60 * 24 * 30 * 3之间,上传time之后,会等待这个数值时间后才会收到flag,我们不可能真等这么长时间。

看到int强转换,可以考虑科学计数法绕过。

最后的payload:http://47.113.94.15:23112/challenge2.php?time=6e6
等待六秒后得到flag。

challenge3

<?php
error_reporting(0);
echo "<!--challenge3.txt-->";
require __DIR__.'/lib.php';
if(!$_GET['id'])
{
    header('Location: challenge3.php?id=1');
    exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
    echo 'Hahahahahaha';
    return ;
}
$data = @file_get_contents($a,'r');
if($data=="1112 is a nice lab!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
    echo $flag;
}
else
{
    print "work harder!harder!harder!";
}
?>

stripos函数:查找某个字符在字符串出现的位置。

$data = @file_get_contents($a,'r');要求把a写入字符串data中

a–>

  1. 不存在.或者.在开头。
  2. a写入字符串要为1112 is a nice lab!

id–>

  1. $id==0弱等于0成立和!$_GET['id']结果不能为真,即不为0。

b–>

  1. strlen($b)>5要求长度大于5
  2. substr($b,0,1)截取b的第一位和111拼接在和1114匹配(eregi),但是又有一个条件说substr($b,0,1)!=4不能等于4,采取的方法是%00截断

payload:http://47.113.94.15:23113/challenge3.php?id=a&a=php://input&b=%001111121

post:1112 is a nice lab!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
acme.client.ClientV2.answer_challenge() 是一个函数,用于回答一个验证挑战(challenge)。 具体来说,当你向 ACME 服务器申请一个证书时,服务器会向你发送一个或多个验证挑战,以确保你拥有域名的控制权。你需要回答这些挑战,才能得到证书。 该函数的参数如下: - challenge (acme.challenges.Challenge):要回答的验证挑战对象。 - response (Union[acme.challenges.ChallengeResponse, bytes, str]):回答验证挑战的响应。这个参数的类型取决于挑战的类型,可以是 ChallengeResponse 对象、bytes 对象或字符串。 - max_retries (int):最大重试次数。如果回答失败,则会进行重试,最多重试 max_retries 次,默认为 3 次。 该函数的返回值是一个 acme.messages.ChallengeResponse 类型的对象,表示回答挑战的结果。 下面是一个例子,演示如何使用该函数回答 HTTP-01 验证挑战: ```python import acme import acme.client import acme.challenges import acme.messages # 创建 ACME 客户端 client = acme.client.ClientV2('https://acme-staging-v02.api.letsencrypt.org/directory') # 获取 HTTP-01 验证挑战 authzr = client.request_domain_challenges('example.com') http_challenge = [c for c in authzr.body.challenges if isinstance(c.chall, acme.challenges.HTTP01)][0] # 下面的代码需要你在 example.com 的网站根目录下创建一个名为 ".well-known/acme-challenge" 的目录,并将以下内容写入名为 "${http_challenge.token}" 的文件中 response_content = http_challenge.validation.encode('utf-8') response_path = f'.well-known/acme-challenge/{http_challenge.token}' with open(response_path, 'wb') as f: f.write(response_content) # 回答验证挑战 response = acme.challenges.HTTP01Response(validation=http_challenge.validation) result = client.answer_challenge(http_challenge, response) # 删除临时文件 os.remove(response_path) ``` 在这个例子中,我们首先创建了一个 ACME 客户端,并使用它向 ACME 服务器申请 example.com 的证书。服务器返回一个授权对象(Authorization),其中包含一个或多个验证挑战。我们从中找到了 HTTP-01 验证挑战,并将 challenge.validation 的内容写入了一个临时文件中。然后,我们创建了一个 HTTP01Response 对象,将其作为参数传递给 answer_challenge() 函数,回答了验证挑战。最后,我们删除了临时文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值