小宁发现了一个网页,但却一直输不对密码。(Flag格式为 Cyberpeace{xxxxxxxxx} )
进入页面,输入密码试试
得到空白页面,查看源代码试一试,得到一个代码,放入代码格式化网站里得到
function dechiffre(pass_enc) {
var pass = "70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65";
var tab = pass_enc.split(',');
var tab2 = pass.split(',');
var i, j, k, l = 0,
m, n, o, p = "";
i = 0;
j = tab.length;
k = j + (l) + (n = 0);
n = tab2.length;
for (i = (o = 0); i < (k = j = n); i++) {
o = tab[i - l];
p += String.fromCharCode((o = tab2[i]));
if (i == 5) break;
}
for (i = (o = 0); i < (k = j = n); i++) {
o = tab[i - l];
if (i > 5 && i < k - 1)
p += String.fromCharCode((o = tab2[i]));
}
p += String.fromCharCode(tab2[17]);
pass = p;
return pass;
}
String["fromCharCode"](dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30"));
h = window.prompt('Enter password');
alert(dechiffre(h));
我们发现这串js代码和flag没有半毛钱关系,但是最后一段
(dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30"));
引起我们注意,这种编码形式是ASCII码的16进制表示,我们使用C语言进行解码
#include<stdio.h>
int main(void)
{
printf("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30");
return 0;
}
得到解码结果:
55,56,54,79,115,69,114,116,107,49,50
有点ASCII码套娃的意思
在编写一个C程序在进行解码试试,我们将前面的70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65一并放到一个char数组里进行输出,程序代码如下:
#include<stdio.h>
int main(void)
{
char c[] = {70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65,55,56,54,79,115,69,114,116,107,49,50};
int i;
for(i = 0;i < sizeof(c);i++)
putchar(c[i]);
return 0;
}
得到结果:
FAUX PASSWORD HAHA786OsErtk12
根据语义得到flag内容应该是第一次转码得到的ASCII码即786OsErtk12
提交
Cyberpeace{786OsErtk12}