-
-
[原创]2019ctfQ2第六题
-
发表于: 2019-6-11 18:50 2715
-
char aTuvwxtulmnopqr[65] = "tuvwxTUlmnopqrs7YZabcdefghij8yz0123456VWXkABCDEFGHIJKLMNOPQRS9+/"; char __cdecl charEncrypt(int data) { int dataa; // [esp+18h] [ebp+8h] dataa = aTuvwxtulmnopqr[data]; if (dataa > 64 && dataa <= 90) return 155 - dataa; if (dataa > 96 && dataa <= 122) return dataa - 64; if (dataa > 47 && dataa <= 57) return dataa + 50; if (dataa == 43) return 119; if (dataa == 47) dataa = 121; return dataa; } char __cdecl charUnEncrypt(int data) { int i; if (data == 121) { data = 47; } else if (data == 119) { data = 43; } else if (data > 47 + 50 && data <= 57 + 50) { data = data - 50; } else if (data > 96 - 64 && data <= 122 - 64) { data = data + 64; } else if (data >= 155 - 90 && data < 155 - 64) { data = 155 - data; } for (i = 0; i < 64; i++) { if (data == aTuvwxtulmnopqr[i]) return i; } return 254; } int __cdecl base64_decode(char *base64, char *bindata, int binlength) { int t = 0, x = 0, y = 0, i = 0; unsigned char c = 0; int g = 3; while (base64[x] != 0) { // 需要解码的数据对应的ASCII值对应base64_suffix_map的值 c = charUnEncrypt(base64[x]); x++; if (c == 255) return -1;// 对应的值不在转码表中 if (c == 253) continue;// 对应的值是换行或者回车 if (c == 254) { c = 0; g--; }// 对应的值是'=' t = (t << 6) | c; // 将其依次放入一个int型中占3字节 if (++y == 4) { bindata[i++] = (unsigned char)((t >> 16) & 0xff); if (g > 1) bindata[i++] = (unsigned char)((t >> 8) & 0xff); if (g > 2) bindata[i++] = (unsigned char)(t & 0xff); y = t = 0; } } return i; } int __cdecl base64_encode(char *bindata, char *base64, int binlength) { int v3; // eax char *v4; // ebx int v5; // eax int v6; // ST0C_4 char *v7; // ebx int v8; // eax int v9; // eax char *v10; // ebx int v11; // eax int v12; // eax char *v13; // ebx uint8_t current; // [esp+Bh] [ebp-Dh] uint8_t currenta; // [esp+Bh] [ebp-Dh] int j; // [esp+Ch] [ebp-Ch] int ja; // [esp+Ch] [ebp-Ch] int jb; // [esp+Ch] [ebp-Ch] int i; // [esp+10h] [ebp-8h] i = 0; j = 0; while (i < binlength) { v3 = j; ja = j + 1; v4 = &base64[v3]; *v4 = charEncrypt((bindata[i] >> 2) & 0x3F); current = (bindata[i] << 4) & 0x30; if (i + 1 >= binlength) { v5 = ja; v6 = ja + 1; v7 = &base64[v5]; *v7 = charEncrypt(current); base64[v6] = '='; v8 = v6 + 1; j = v6 + 2; base64[v8] = '='; break; } v9 = ja; jb = ja + 1; v10 = &base64[v9]; *v10 = charEncrypt((bindata[i + 1] >> 4) | current); currenta = 4 * bindata[i + 1] & 0x3C; if (i + 2 >= binlength) { base64[jb] = charEncrypt(currenta); v11 = jb + 1; j = jb + 2; base64[v11] = 61; break; } base64[jb] = charEncrypt((bindata[i + 2] >> 6) | currenta); v12 = jb + 1; j = jb + 2; v13 = &base64[v12]; *v13 = charEncrypt(bindata[i + 2] & 0x3F); i += 3; } base64[j] = 0; return j; } extern "C" void init(); int main() { //goto lbtest; int i = 0; char buf[256] = { 0 }; char buf1[256] = { 0 }; wchar_t* code = L"!NGV%,$h1f4S3%2P(hkQ94=="; char* as = wtoc(code); //as = "1"; //base64_encode(as, buf, 1); base64_decode(as, buf1, 16); }
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
- [原创]第一题WP 2032
- [原创]第四题:西部乐园赛题 2494
- [原创]2019ctfQ2第六题 2716
- [原创]Q2第一题wp 2017
看原图
赞赏
雪币:
留言: