Skip to content

Instantly share code, notes, and snippets.

@HeathHopkins
Last active October 11, 2015 22:48
Show Gist options
  • Save HeathHopkins/3931538 to your computer and use it in GitHub Desktop.
Save HeathHopkins/3931538 to your computer and use it in GitHub Desktop.
APP5 Hidden Meta-game Solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace APP5
{
class Program
{
static void Main(string[] args)
{
Parallel.ForEach(Items, code =>
{
//Console.WriteLine(code);
SubmitAnswer(code);
});
Console.WriteLine("done");
Console.ReadLine();
}
static List<string> c
{
get
{
var l = new List<string>();
l.AddRange(Enumerable.Range(65, 26).Select(o => Char.ConvertFromUtf32(o).ToString()));
l.AddRange(Enumerable.Range(0, 10).Select(o => o.ToString()));
return l;
}
}
static IEnumerable<string> Items
{
get
{
int count = c.Count;
for (int a = 0; a < count; a++)
for (int b = 0; b < count; b++)
for (int z = 0; z < count; z++)
for (int d = 0; d < count; d++)
for (int e = 0; e < count; e++)
for (int f = 0; f < count; f++)
yield return c[a] + c[b] + c[z] + c[d] + c[e] + c[f];
}
}
static void SubmitAnswer(string code)
{
string parameters = "csrfmiddlewaretoken=REDACTED&code=" + code;
string reply;
using (var wc = new App5WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.Encoding = Encoding.UTF8;
reply = wc.UploadString("http://app5.jdabbs.com/solve/", parameters);
}
reply = null;
}
}
class App5WebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address);
var cookies = new CookieContainer();
cookies.Add(new Cookie("sessionid", "REDACTED", "/", "app5.jdabbs.com"));
cookies.Add(new Cookie("csrftoken", "REDACTED", "/", "app5.jdabbs.com"));
if (request is HttpWebRequest)
{
(request as HttpWebRequest).CookieContainer = cookies;
}
return request;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment