-
-
Save key-moon/3d7cc6dc23203938fe87bd7e32e561d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
//自製TCP接続ライブラリの初期化(接続) | |
var stream = new TCPStream("2018shell2.picoctf.com", 14390, Encoding.UTF8); | |
while (true) | |
{ | |
//問題文を表示 | |
Console.WriteLine(stream.ReadToEnd()); | |
//使うbaseを入力 | |
int b = int.Parse(Console.ReadLine()); | |
//結果を計算 | |
string res = Console.ReadLine().Split().Select(x => GetChar(x, b)).Aggregate((x, y) => x + y); | |
//コンソールに出す | |
Console.WriteLine(res); | |
//TCPで送信 | |
stream.WriteLine(res); | |
} | |
} | |
//bsaeを使ってbitsをデコード | |
static string GetChar(string bits,int b) | |
{ | |
//Hex(b=16)の時だけ特殊処理 | |
if (b == 16) | |
{ | |
string res = ""; | |
for (int i = 0; i < bits.Length; i += 2) | |
{ | |
res += char.ConvertFromUtf32(Convert.ToInt32(bits.Substring(i, 2), b)); | |
} | |
return res; | |
} | |
return char.ConvertFromUtf32(Convert.ToInt32(bits,b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment