下载下来是一个pyc文件,用uncompyle2反编译一下,得到代码:
def encrypt(key, seed, string):
rst = []
for v in string:
rst.append((ord(v) + seed ^ ord(key[seed])) % 255)
seed = (seed + 1) % len(key)
return rst
if __name__ == '__main__':
print 'Welcome to idf\'s python crackme'
flag = input('Enter the Flag: ')
KEY1 = 'Maybe you are good at decryptint Byte Code, have a try!'
KEY2 = [124, 48, 52, 59, 164, 50, 37, 62, 67, 52, 48, 6, 1, 122, 3, 22, 72, 1, 1, 14, 46, 27, 232]
en_out = encrypt(KEY1, 5, flag)
if KEY2 == en_out:
print 'You Win'
else:
print 'Try Again !'
好了,源代码已经看见了,加密算法是(ord(v) + seed ^ ord(key[seed])) % 255
看来这种加密逆向不好推,直接暴力破解吧,由于本人不是很懂python,用C#写了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestDecode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string KEY1 = "Maybe you are good at decryptint Byte Code, have a try!";
int[] KEY2 = { 124, 48, 52, 59, 164, 50, 37, 62, 67, 52, 48, 6, 1, 122, 3, 22, 72, 1, 1, 14, 46, 27, 232 };
for(int i = 0; i < KEY2.Length; i++)
{
for(int j=0;j<255;j++)
if (encrypt(KEY1, i + 5, (char)j) == KEY2[i])
{
textBox1.Text += (char)j;
break;
}
}
}
private int encrypt(string key, int seed, char v)
{
return ((int)v + seed ^ (int)key[seed]) % 255;
}
}
}
OK,结果出来了,WCTF{ILOVEPYTHONSOMUCH},提交,通过!