地址:
ctf.idf.cn/index.php?g=game&m=article&a=index&id=43
题目:
http://ctf.idf.cn/game/web/43/index.php
和上篇差不多,直接查看源代码,发现
function pseudoHash(string, method)
{ // Default method is encryption
if (!('ENCRYPT' == method || 'DECRYPT' == method))
{ method = 'ENCRYPT'; } // Run algorithm with the right method
if ('ENCRYPT' == method)
{ // Variable for output string
var output = ''; // Algorithm to encrypt
for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x)
{
charCode = string.charCodeAt(x);
if (128 > charCode)
{ charCode += 128; }
else if (127 < charCode)
{ charCode -= 128; }
charCode = 255 - charCode;
hexCode = charCode.toString(16);
if (2 > hexCode.length) { hexCode = '0' + hexCode; } output += hexCode;
} // Return output
return output;
}
else if ('DECRYPT' == method)
{ // DECODE MISS // Return ASCII value of character
var output = ''
return string;
}
}
#document.getElementById('password').value = pseudoHash('4e4f484f4c4f1c1e49474a4f48491c4f1a1b4a1a4f4a4b1a4d1c4c1a1b464b4f', 'DECRYPT');
这段代码只有密文和加密部分,没有解密部分(自己编写好了),写C 程序:
#include<stdio.h>
#include<string.h>
void main(void)
{
int str[64]={0x4a,0x49,0x1a,0x4d,0x1c,0x1e,0x1c,0x1a,0x1a,0x4c,0x4f,0x4e,0x4c,0x1b,0x49,0x4a,0x47,0x46,0x46,0x19,0x46,0x1b,0x4f,0x4a,0x4d,0x4d,0x1e,0x47,0x46,0x4c,0x19,0x47};
char output[64]="";
int x=0;
int charCode;
for (;str[x]!=0; ++x)
{
charCode= str[x];
charCode = 255 - charCode;
if (128 > charCode)
{ charCode -= 128; }
else if (127 < charCode)
{ charCode += 128; }
output[x]= (char)charCode;
} // Return output
printf("\n%s\n",output);
return 0;
}
将结果提交,显示flag.
ctf.idf.cn/index.php?g=game&m=article&a=index&id=43
题目:
http://ctf.idf.cn/game/web/43/index.php
和上篇差不多,直接查看源代码,发现
function pseudoHash(string, method)
{ // Default method is encryption
if (!('ENCRYPT' == method || 'DECRYPT' == method))
{ method = 'ENCRYPT'; } // Run algorithm with the right method
if ('ENCRYPT' == method)
{ // Variable for output string
var output = ''; // Algorithm to encrypt
for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x)
{
charCode = string.charCodeAt(x);
if (128 > charCode)
{ charCode += 128; }
else if (127 < charCode)
{ charCode -= 128; }
charCode = 255 - charCode;
hexCode = charCode.toString(16);
if (2 > hexCode.length) { hexCode = '0' + hexCode; } output += hexCode;
} // Return output
return output;
}
else if ('DECRYPT' == method)
{ // DECODE MISS // Return ASCII value of character
var output = ''
return string;
}
}
#document.getElementById('password').value = pseudoHash('4e4f484f4c4f1c1e49474a4f48491c4f1a1b4a1a4f4a4b1a4d1c4c1a1b464b4f', 'DECRYPT');
这段代码只有密文和加密部分,没有解密部分(自己编写好了),写C 程序:
#include<stdio.h>
#include<string.h>
void main(void)
{
int str[64]={0x4a,0x49,0x1a,0x4d,0x1c,0x1e,0x1c,0x1a,0x1a,0x4c,0x4f,0x4e,0x4c,0x1b,0x49,0x4a,0x47,0x46,0x46,0x19,0x46,0x1b,0x4f,0x4a,0x4d,0x4d,0x1e,0x47,0x46,0x4c,0x19,0x47};
char output[64]="";
int x=0;
int charCode;
for (;str[x]!=0; ++x)
{
charCode= str[x];
charCode = 255 - charCode;
if (128 > charCode)
{ charCode -= 128; }
else if (127 < charCode)
{ charCode += 128; }
output[x]= (char)charCode;
} // Return output
printf("\n%s\n",output);
return 0;
}
将结果提交,显示flag.