k
async static Task Main(string[] args)
{
if(args.Contains("-v")) verbose = true;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var cookieContainer = new CookieContainer();
handler = new HttpClientHandler
{
// Proxy = new WebProxy("http://127.0.0.1:8080"),
CookieContainer = cookieContainer,
};
httpClient = new HttpClient(new HttpLogger(handler));
httpClient.DefaultRequestHeaders.Accept.ParseAdd(accept);
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(uagent);
string input;
string exitcmd = "exit||quit";
string authcmd = "auth||login";
string helpcmd = "help||?";
string execcmd = "exec(.*?)";
for (; ; )
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("VkHacks> ");
Console.ForegroundColor = ConsoleColor.Gray;
input = Console.ReadLine();
if (exitcmd.Contains(input.ToLower().Trim())) break;
if (authcmd.Contains(input.ToLower().Trim()))
{
if (logged)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Already authorized!");
continue;
}
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Enter your e-mail or phone: ");
Console.ForegroundColor = ConsoleColor.Gray;
string log = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Enter your password: ");
Console.ForegroundColor = ConsoleColor.Gray;
string pass = Console.ReadLine();
await Login(log, pass);
continue;
}
if (helpcmd.Contains(input.ToLower().Trim()))
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("VkHacks v1.0 - Help:\n");
string[] col1 = { "auth/login", "exit/quit", "exec(param=value)" },
col2 = { "Login at vk.com", "Exit", "Request to API. Required parameters: scope, can only be messages. Example: exec(scope=messages) " };
var offset = col1.OrderByDescending(s => s.Length).First().Length;
for (var i = 0; i < col1.Length; i++)
{
Console.Write(col1[i]);
Console.CursorLeft = offset + 5;
Console.WriteLine(col2[i]);
}
continue;
}
if (Regex.IsMatch(input.Trim().ToLower(), execcmd))
{
if (!logged) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Login at first!"); continue; }
var regex = Regex.Matches(input.Trim().ToLower().Replace("exec(", ""), "((.*?)=(.*?)[,)])");
Dictionary<string, string> list = new Dictionary<string, string>();
foreach (Match match in regex)
{
list[match.Groups[2].Value.Trim()] = match.Groups[3].Value.Trim();
}
Console.WriteLine(await Exec(list));
}
}