Skip to content

Instantly share code, notes, and snippets.

@CWKSC
Last active December 5, 2020 14:51
Show Gist options
  • Save CWKSC/dcf3796ab3ac49ce59cc3677e2d5c0d4 to your computer and use it in GitHub Desktop.
Save CWKSC/dcf3796ab3ac49ce59cc3677e2d5c0d4 to your computer and use it in GitHub Desktop.
CTF - Reversing.Kr
int[] flag = { 0x43, 0x6B, 0x66, 0x6B, 0x62, 0x75, 0x6C, 0x69, 0x4C, 0x45, 0x5C, 0x45, 0x5F, 0x5A, 0x7E, 0x1C, 0x07, 0x25, 0x25, 0x29, 0x70, 0x17, 0x34, 0x39, 0x01, 0x16, 0x49, 0x4C, 0x20, 0x15, 0x0B, 0x0F, 0xF7, 0xEB, 0xFA, 0xE8, 0xB0, 0xFD, 0xEB, 0xBC, 0xF4, 0xCC, 0xDA, 0x9F, 0xF5, 0xF0, 0xE8, 0xCE, 0xF0, 0xA9 };
for (int i = 0; i < flag.Length; i++)
{
((char)(flag[i] ^ i * 4)).Print();
}
// CongratulationF Game Clear! Password is Thr3EDPr0m
/*
if ( input1 != '1' ) return 0;
input0 ^= 0x34u;
input2 ^= 0x32u;
input3 ^= 0x88u;
if ( input4 != 'X' ) return 0;
if ( input5 ) return 0;
if ( input2 != ('|') ) return 0;
if ( input0 == 'x' ) return input3 == 0xDDu;
*/
string input = "x1|\xDDX";
((char)(input[0] ^ 0x34)).Print();
input[1].Print();
((char)(input[2] ^ 0x32)).Print();
((char)(input[3] ^ 0x88)).Print();
input[4].Print();
// L1NUX
string flag = "";
int[] outputhex = { 0x5B, 0x13, 0x49, 0x77, 0x13, 0x5E, 0x7D, 0x13 };
int[] key = { 0x10, 0x20, 0x30 };
int[] index = { 0, 1, 2, 0, 1, 2, 0, 1 };
for (int i = outputhex.Length - 1; i >= 0; i--)
{
flag = (char)(outputhex[i] ^ key[index[i]]) + flag;
}
flag.Println(); // K3yg3nm3
string serial = "76876-77776";
((int)'a', (int)'z').Loop(i =>
{
((int)'a', (int)'z').Loop(j =>
{
((int)'a', (int)'z').Loop(k =>
{
string input = "" + (char)i + (char)j + (char)k +"p";
char input0 = input[0];
var v7 = (input0 & 1) + 5;
var v48 = ((input0 >> 4) & 1) + 5;
var v42 = ((input0 >> 1) & 1) + 5;
var v44 = ((input0 >> 2) & 1) + 5;
var v46 = ((input0 >> 3) & 1) + 5;
var input1 = input[1];
var v34 = (input1 & 1) + 1;
var v40 = ((input1 >> 4) & 1) + 1;
var v36 = ((input1 >> 1) & 1) + 1;
var v9 = ((input1 >> 2) & 1) + 1;
var v38 = ((input1 >> 3) & 1) + 1;
if (serial[0] == (v7 + v9).ToString()[0] &&
serial[1] == (v46 + v38).ToString()[0] &&
serial[2] == (v42 + v40).ToString()[0] &&
serial[3] == (v44 + v34).ToString()[0] &&
serial[4] == (v48 + v36).ToString()[0])
{
char input2 = input[2];
var v21 = (input2 & 1) + 5;
var v49 = ((input2 >> 4) & 1) + 5;
var v43 = ((input2 >> 1) & 1) + 5;
var v45 = ((input2 >> 2) & 1) + 5;
var v47 = ((input2 >> 3) & 1) + 5;
char input3 = input[3];
var v35 = (input3 & 1) + 1;
var v41 = ((input3 >> 4) & 1) + 1;
var v37 = ((input3 >> 1) & 1) + 1;
var v23 = ((input3 >> 2) & 1) + 1;
var v39 = ((input3 >> 3) & 1) + 1;
if (serial[6] == (v21 + v23).ToString()[0] &&
serial[7] == (v47 + v39).ToString()[0] &&
serial[8] == (v43 + v41).ToString()[0] &&
serial[9] == (v45 + v35).ToString()[0] &&
serial[10] == (v49 + v37).ToString()[0])
{
("input : " + input).Println();
}
}
});
});
});
// input : bump
// input : cqmp
// input : ftmp
// input : gpmp
byte[] file = { 0xC7, 0xF2, 0xE2, 0xFF, 0xAF, 0xE3, 0xEC, 0xE9, 0xFB, 0xE5, 0xFB, 0xE1, 0xAC, 0xF0, 0xFB, 0xE5, 0xE2, 0xE0, 0xE7, 0xBE, 0xE4, 0xF9, 0xB7, 0xE8, 0xF9, 0xE2, 0xB3, 0xF3, 0xE5, 0xAC, 0xCB, 0xDC, 0xCD, 0xA6, 0xF1, 0xF8, 0xFE, 0xE9 };
byte[] normal = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F, 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20, 0x6D, 0x6F, 0x64, 0x65 };
for (int i = 0; i < file.Length; i++)
{
((char)(file[i] ^ 0xff ^ normal[i])).Print();
}
// key = letsplaychess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment