由于本人最近正在深入学习PHP的各种奇葩属性,碰巧在乌云上看到了一篇讲解php无字母数字编程的教程,然而文章是因为,而小编我的英文着实让人捉急,于是拜托我的小伙伴翻译供大家查阅。
PHP非字母数字编程
我的第一份关于PHP非字母数字代码的工作很短暂,沉浸在此项发现的激动之中,我没能将其程序深入细化。我决定写一个教程,希望能够为想要学习或改进这项技术的人更好地解释该程序。
PHP非字母数字代码的基础是利用这样的一个事实:当用于字符串的环境下时,PHP能够将阵列(Arrays)自动转化为字符串“阵列”。举一个简单的例子:
$x = array(1,2,3);
echo $x;//输出阵列
$x 在这里就是字符串“阵列”。但你会发现,如果使用非字母数字字符,我们还可以不使用数组()来构建一个阵列,如下例:
$_=””;
$_[+””]=”;
echo $_;//输出阵列
第一部分构建了一个变量“$_”,第二部分通过在一个空格串前使用前缀运算符来转换成0进而引入了0,此赋值就构建了阵列。这是我第一次写它,也是我对设计一个阵列的程序的初次尝试,但你还可以使用所有的方法和窍门,比如不使用“0”的部分。
$_=””;
$_[+$_]++;
echo $_;//输出阵列
我会让你去试验以寻求构建阵列的方法,但你首先要明白这一概念。我们有了字符“A”、“r”、“r”等等,现在我们需要做的是将他们接入,幸运的是 就这一方面来说PHP与“Java描述语言”十分相似。第一步是通过用空白字符串串接阵列,将阵列强行置码成为实际的字符串,像这样:
$_=$_.””;//$_ 包含了我们先前的阵列,并将其强行置码成为一个字符串
下一步是实际接入一个字母,PHP为我们提供了与Java描述语言相同的相当便利的接入方法。为此我们需要0,正如我在前面所指出的,使用一个空格串和前缀运算符就可以转换成0,也就如Java描述语言。
1 |
echo + "" ; // 输入0 |
使用0我们现在就可以接入转化后的阵列中的字母“A”。
1 |
echo $_ [+ "" ] // 输出 "A" |
现在由于我也是才在研究这一技术,我在多字符问题上进行了一些疯狂的数学运算来得到除阵列之外的其他字符,但据Stefan Esser所指出的这并不必要:你可以很简单地增加或减少字符串。但不管怎么说我还是得出了字母结果,通过嵌套来使所有字符循环的方法。如果之后我还能得 到这种描述语言,我就会把它公布。但就目前,我们只能简单增加或减少所需的字符。下面我先告诉你怎么得到字母“B”。
$_=””;//开始我们需要一个空白字符串
$_[+$_]++;//接入部分字符串来转化为一个阵列
$_=$_.””;//将阵列转化为一个字符串“阵列”
$_=$_[+””];//接入这一字符串“阵列”的0索引,就是字母“A”
echo ++$_;//增加“A”到“B”
这就是它运作的基本原理,我们只需要建立一个字符串来调用诸如“chr”或手动产生字符的功能,然后用一个字符串宏指令基础功能来调用我们的代码。 最初的公示使用的是GET,但由于那早已经有文件记录了所以我想告诉你怎样生成不同的代码。我们讲使用PHP功能“判断提示”,因为它可以评估代码并且它 可以在字符串引用其名称时被允许调用。例如:
$_=”assert”;
$_(“print 1+1;”)//输出 2
因此我们需要生成“判断提示”和我们要调用的代码。使用来自于先前我们生成的“阵列”的模板,我们可以很容易地构建新的引用,增加我们所需的字符。
$_=””;//开始我们需要一个空白字符串
$_[+$_]++;//接入部分字符串来转化为一个阵列
$_=$_.””;//将阵列转化为一个字符串“阵列”
$__=+””;//生成0
$__++;//增加到1
$___=$_[+””];//接入这一字符串“阵列”的0索引,就是字母“A”
$____=$____=$_[$__];//接入这一字符串“阵列”的1索引,就是字母“r”
$_____=$____;// 将“r”赋值为一个新的变量
$_____++;//增加到“s”
$______=$___;//新变量为“e”
$______++;$______++;$______++;$______++;//增加到”e”
$_=$___.$_____.$_____.$______.$____.++$_____;//连接字符串以形成“AssErt”
$_(“p”.$____.”in”.$_____.” $__+$__”);//调用输出 1+1
你最后会发现有些缺失的字符,“p”,“i”和“n”是给你来用上面描述的技术来生成的字母。在那之后还有一些挑战,比如你要问自己“要生成非字母 数字代码的最少字符要求是多少?”另一个挑战是“要构建一个非字母数字代码生成器所需的最小字符总数是多少?”希望你会喜欢以上所写,享受用非字母PHP 来创造和寻找新事物!
小编语:本人在经过思考以及询问有关大神后,大致了解了非字母数字代码编程的过程。首先通过空白字符串构造一个数组,再把这个数组类型名,就是 Array,转变成一个字符串,类似于强制转换类型。接着取出这个字符串里的字母,通过累加的方式来获得其它字母,例如A+1 = B,但到达一个值时就会增长位数。也就是说,这样可以构造任意字符串。试想不那么偏执一定非不使用字母数字,要是构造一个for循环就能很快速的达到我们 需要的字符串,领用这种特性来构造后门也是一种不错的技巧。
本着服务大众的想法就有了此文,本来想自己翻译的,不过谷歌字典着实费力,在此再一次感谢自己的小伙伴!顺便祝愿我的小伙伴和她的小先生天天开心!不被现实击倒,好好学习,天天向上!
PHP nonalpha tutorial
Tuesday, 21 August 2012
My first post on PHP non-alpha numeric code was a bit brief, in the excitement of the discovery I failed to detail in depth the process. I’ve decided to follow up with a tutorial and hopefully explain the process better for anyone wanting to learn or improve the technique.
The basis of PHP non-alphanumeric code is to take advantage of the fact that PHP automatically converts Arrays into a string “Array” when using in a string context. A simple example would be:
$x = array(1,2,3);
echo $x;//output Array
$x is now the string “Array”. But you will notice we used alphanumeric characters, we can also create an array without using array() like the following:
$_="";
$_[+""]='';
echo $_;//output Array
The first part creates a variable “$_” the second part references 0 by using the prefix operator on a blank string to convert to 0, the assignment creates the array. This was a first attempt to hack together an array when I first wrote it but all sorts of tricks can be used for example you don’t need the “0″ part.
$_="";
$_[+$_]++;
echo $_;//output Array
I’ll leave you to experiment for ways to create arrays but you get the idea. Right we have the characters “A”, “r”, “r” and so on now we need to access them and fortunately PHP is very similar to JavaScript in that respect. The first step is to force our array into an actual string by concatenating it with a blank string like so:
$_=$_."";//$_ contains our array previously and forces it into a string
The next step is to actually access a letter and PHP conveniently provides the same accessor method as JavaScript. To do that we need zero, as I showed before using the prefix operator with a blank string can convert to zero (also like JavaScript).
echo +"";// output 0
Using the 0 we can now access our letter “A” from the converted array.
echo $_[+""]// output "A"
Now originally because I was just discovering the technique I did some crazy math operations on multiple characters to obtain other characters than Array but this wasn’t necessary as Stefan Esser pointed out you can simply increment/decrement strings. But anyway I figured the letters out by doing nested for loops of all the characters, I’ll post the script if I’ve still got it later. For now though we’ll simply increment/decrement the characters we need. I’ll show you how to get the letter “B” first.
$_="";//we need a blank string to start
$_[+$_]++;//access part of the string to convert to an array
$_=$_."";//convert the array into a string of "Array"
$_=$_[+""];//access the 0 index of the string "Array" which is "A"
echo ++$_;//increment "A" to "B"
That is the basis of how it works, we just need to construct a string that calls a function such as “chr” or generate characters manually and then an eval based function to call our code. The original post used GET but since that is already documented I’ll show you how to generate different code. We’ll use the PHP function “assert” since it evaluates code and it is allowed to be called using string references of it’s name. For example:
$_="assert";
$_("print 1+1;")//output 2
We therefore need to generate “assert” and our code to call. Using the template from before were we generated “Array” we simply create new references and increment the characters we need.
$_="";//we need a blank string to start
$_[+$_]++;//access part of the string to convert to an array
$_=$_."";//convert the array into a string of "Array"
$__=+"";//make zero
$__++;//increment to 1
$___=$_[+""];//access the 0 index of the string "Array" which is "A"
$____=$____=$_[$__];//access the 1 index of the string "Array" which is "r"
$_____=$____;// assign "r" to a new variable
$_____++;//increment to "s"
$______=$___;//new variable for "e"
$______++;$______++;$______++;$______++;//increment to "e"
$_=$___.$_____.$_____.$______.$____.++$_____;//concat the strings to form "AssErt"
$_("p".$____."in".$_____." $__+$__");//call print 1+1
You will notice there are missing characters at the end “p”, “i” and “n” are alpha those are for you to generate using the techniques described. There are separate challenges to do after that for example a question to ask yourself is “How many characters are the minimum required to generate non-alphanumeric code?” another challenge is “What is the smallest amount of characters need to create a generator of non-alphanumeric code. Hope you enjoyed the write up and enjoy creating and finding new things with non-alpha php!
Challenges
1. Complete the “print 1+1″ code at the end of the last example (Basic)
2. Find the minimum number of characters to generate required to generate non-alpha code e.g. using only $_ + etc (Hard).
3. Create a PHP non-alpha generator in the smallest amount of code possible such as: The Hackvertor non-alpha tag (Hard)
Challenge leaderboard
1. @insertScript
Challenge 1 – done
Challenge 2 – done (using $_()[]+=.;)
转载请注明:jinglingshu的博客 » PHP nonalpha tutorial