Example #1
0
 private void materialRaisedButton1_Click_5(object sender, EventArgs e)
 {
     try
     {
         CurrBalance.Text = VkCaptchaWorks.GetBalance();
     }
     catch (Exception ex)
     {
         Log.Push("[Ошибка запроса баланса]: " + ex.Message);
     }
 }
Example #2
0
 private void materialRaisedButton1_Click_4(object sender, EventArgs e)
 {
     if (ManualCaptBox.Text == "" || currManId == null)
     {
         VkCaptchaWorks.RegisterManual(currManId, ManualCaptBox.Text);
         CaptPic.Image.Dispose();
         CaptPic.Image = null;
         currManId     = null;
         ManualCaptBox.Clear();
     }
 }
Example #3
0
        private void materialRaisedButton1_Click_3(object sender, EventArgs e)
        {
            if (ApiKeyTextBox.Text.Trim() != "")
            {
                string[] array = File.ReadAllText("lastApiKey.txt").Split(new char[]
                {
                    ':'
                });

                if (array.Length != 3)
                {
                    array = new string[]
                    {
                        "1",
                        array[0],
                        ""
                    };
                }

                if (rb_CaptRucaptcha.Checked)
                {
                    VkCaptchaWorks.SetKeyAndProv(CaptchaWorksProvder.rucaptcha, ApiKeyTextBox.Text.Trim());
                    array[0] = "1";
                    array[1] = ApiKeyTextBox.Text.Trim();
                }
                else
                {
                    VkCaptchaWorks.SetKeyAndProv(CaptchaWorksProvder.antiCaptcha, ApiKeyTextBox.Text.Trim());
                    array[0] = "2";
                    array[2] = ApiKeyTextBox.Text.Trim();
                }
                File.WriteAllText("lastApiKey.txt", string.Concat(new string[]
                {
                    array[0],
                    ":",
                    array[1],
                    ":",
                    array[2]
                }));

                VkCaptchaWorks.Enabled = !rb_CaptManual.Checked;
                CaptAns.Visible        = (ManualCaptBox.Visible = (CaptPic.Visible = !VkCaptchaWorks.Enabled));
                label8.Visible         = (CurrBalance.Visible = (ApiKeyTextBox.Visible = (saveCaptcha.Visible = (button1.Visible = VkCaptchaWorks.Enabled))));
            }
        }
Example #4
0
        public int GetToken()
        {
            int num;
            int result;

            if (CheckToken() == 0)
            {
                num = 0;
            }
            else
            {
                CookieContainer cc   = new CookieContainer();
                string          text = Network.GET("https://vk.com/", cc);
                text = StrWrk.GetBetween(text, "action=\"", "\"");
                string url = text;
                text = Network.POST(url, "email=" + login + "&pass="******"_logout"))
                {
                    if (!text.Contains("captcha_img"))
                    {
                        result = -1;
                        return(result);
                    }
                    Log.Push("Капча при получении токена " + login + ", переключитесь на ручной ввод капчи");
                    string text2 = StrWrk.qSubstr(text, "captcha.php", false);
                    text2 = StrWrk.GetBetween(text2, "sid=", "\"");
                    string arg = VkCaptchaWorks.SolveManual("https://m.vk.com/captcha.php?s=0&sid=" + text2, text2);
                    text = Network.POST(url, string.Concat(new string[]
                    {
                        "email=",
                        login,
                        "&pass="******"&captcha_sid={0}&captcha_key={1}", text2, arg)
                    }), cc);

                    if (!text.Contains("_logout"))
                    {
                        result = -1;
                        return(result);
                    }
                }
                string text3;
                text = Network.GET("https://oauth.vk.com/authorize?client_id=2685278&scope=1073737727&redirect_uri=https://api.vk.com/blank.html&display=page&response_type=token&revoke=1')", out text3, cc);                 //Вставить ссылку авторизации

                if (text3 == null)
                {
                    text = StrWrk.GetBetween(text, "form method=\"post\" action=\"", "\"");
                }
                else
                {
                    text = text3;
                }
                Network.GET(text, out text3, cc);

                if (!text3.Contains("access_token="))
                {
                    Log.Push($"[{login}]: Ошибка авторизации, включена двуфакторная авторизация?");
                    num = -1;
                }
                else
                {
                    token        = StrWrk.GetBetween(text3, "access_token=", "&");
                    token_status = true;
                    num          = 0;
                }
            }
            result = num;
            return(result);
        }
Example #5
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            ListControl emotionVO = EmotionVO;
            int         i         = VoiceVO.SelectedIndex = 0;

            emotionVO.SelectedIndex = i;
            turnOffOn.CustomFormat  = "dd.MM.yyyy HH:mm:ss";
            notifyIcon1.Icon        = SystemIcons.Application;
            ni = notifyIcon1;
            CreateFileIfNotExist("accs.txt");
            CreateFileIfNotExist("lastApiKey.txt");
            CreateFileIfNotExist("phrases.txt");
            CreateFileIfNotExist("typerTexts.txt");
            CreateFileIfNotExist("photoComments.txt");
            CreateFileIfNotExist("generatorMessages.txt");
            CreateFileIfNotExist("images.txt");

            if (!Directory.Exists("AccsData"))
            {
                Directory.CreateDirectory("AccsData");
            }

            if (!Directory.Exists("Images"))
            {
                Directory.CreateDirectory("Images");
            }

            string[] files = Directory.GetFiles("Images");
            DataGridViewComboBoxColumn dataGridViewComboBoxColumn = (DataGridViewComboBoxColumn)chatsGrid.Columns[2];

            string[] array = files;
            for (int j = 0; j < array.Length; j++)
            {
                string path = array[j];
                dataGridViewComboBoxColumn.Items.Add(Path.GetFileName(path));
            }
            phrases           = File.ReadAllLines("phrases.txt", Encoding.GetEncoding("windows-1251"));
            images            = File.ReadAllLines("images.txt");
            photoComments     = File.ReadAllLines("photoComments.txt", Encoding.GetEncoding("windows-1251"));
            generatorMessages = File.ReadAllLines("generatorMessages.txt", Encoding.GetEncoding("windows-1251"));
            Log.Push(string.Format($"В /images {files.Length} файлов"));
            Log.Push(string.Format($"В phrases.txt {phrases.Length} строк"));
            Log.Push(string.Format($"В images.txt {images.Length} строк"));
            Log.Push(string.Format($"В photoComments.txt {photoComments.Length} строк"));
            Log.Push(string.Format($"В generatorMessages.txt {generatorMessages.Length} строк"));
            Regex regex = new Regex("photo[0-9]+_[0-9]+");

            for (int k = 0; k < images.Length; k++)
            {
                Match match = regex.Match(images[k]);

                if (!match.Success)
                {
                    Log.Push(string.Format($"Ошибка при обработке \"{images[k]}\""));
                    images[k] = "";
                }
                else
                {
                    images[k] = match.Value;
                }
            }
            string[] array2 = File.ReadAllText("lastApiKey.txt").Split(new char[]
            {
                ':'
            });

            if (array2[0] != "" && array2.Length == 3)
            {
                if (array2[0] == "0")
                {
                    VkCaptchaWorks.Enabled = false;
                    rb_CaptManual.Checked  = true;
                }
                else
                {
                    if (array2[0] == "1")
                    {
                        VkCaptchaWorks.SetKeyAndProv(CaptchaWorksProvder.rucaptcha, array2[1]);
                        rb_CaptRucaptcha.Checked = true;
                        ApiKeyTextBox.Text       = array2[1];
                    }
                    else
                    {
                        VkCaptchaWorks.SetKeyAndProv(CaptchaWorksProvder.antiCaptcha, array2[2]);
                        rb_CaptAnticaptcha.Checked = true;
                        ApiKeyTextBox.Text         = array2[2];
                    }
                }
            }
            else
            {
                File.WriteAllText("lastApiKey.txt", "1:" + array2[0] + ":");
                VkCaptchaWorks.SetKeyAndProv(CaptchaWorksProvder.rucaptcha, array2[0]);
                ApiKeyTextBox.Text       = array2[0];
                rb_CaptRucaptcha.Checked = true;
            }
            string[]      array3        = File.ReadAllLines("accs.txt", Encoding.GetEncoding("windows-1251"));
            string        text          = "";
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Account));

            string[] array4 = array3;
            for (i = 0; i < array4.Length; i++)
            {
                string[] array5 = array4[i].Split(new char[]
                {
                    ':'
                });

                if (array5.Length != 2)
                {
                    Log.Push("Ошибка загрузки аккаунта из accs.txt - неверный формат");
                }
                else
                {
                    Account account;
                    if (!File.Exists("AccsData\\" + array5[0] + ".xml"))
                    {
                        account = new Account(array5[0], array5[1]);
                    }
                    else
                    {
                        FileStream fileStream = new FileStream("AccsData\\" + array5[0] + ".xml", FileMode.Open);
                        XmlReader  xmlReader  = XmlReader.Create(fileStream);
                        account = (Account)xmlSerializer.Deserialize(xmlReader);
                        fileStream.Close();
                    }
                    account.password = array5[1];
                    switch (account.CheckToken())
                    {
                    case -1:
                        text = "Не создан";
                        break;

                    case 0:
                        text = "Ок";
                        break;

                    case 1:
                        text = "Неверен";
                        break;

                    case 2:
                        text = "Неизв. ошибка";
                        break;
                    }
                    foreach (ChatsTarget current in account.chTargets)
                    {
                        if (!File.Exists("Images\\" + current.setPhoto))
                        {
                            current.setPhoto = "Ничего";
                        }
                    }
                    accounts.Add(account);
                    accsTable.Rows.Add(new object[]
                    {
                        account.login,
                        account.password,
                        text
                    });
                    CurrAccComboBox.Items.Add(account.login);
                }
            }

            if (CurrAccComboBox.Items.Count != 0)
            {
                CurrAccComboBox.SelectedIndex = 0;
                materialCombobox1_SelectedIndexChanged(null, null);
            }
            CaptAns.Visible       = (ManualCaptBox.Visible = (CaptPic.Visible = !VkCaptchaWorks.Enabled));
            ApiKeyTextBox.Visible = (saveCaptcha.Visible = (button1.Visible = VkCaptchaWorks.Enabled));
        }
Example #6
0
        public static string APIRequest(string method, string param, string token, string captcha_data = "")
        {
            if (captcha_data == "")
            {
                param = Uri.EscapeDataString(param);
                param = param.Replace("%3D", "=").Replace("%26", "&");
            }

            string text;
            int    randomId;

            while (true)
            {
                Random rnd = new Random();
                randomId = rnd.Next(100000, 1000000000);
                text     = Network.GET(string.Concat(new string[]
                {
                    "https://api.vk.com/method/",
                    method,
                    "?",
                    param,
                    "&access_token=",
                    token,
                    captcha_data,
                    "&v=5.92",
                    "&random_id=",
                    randomId.ToString()
                }), null);
                if (!text.Contains("\"error_code\":6"))
                {
                    break;
                }
                Thread.Sleep(333);
            }
            if (text.Contains("\"error_code\":14"))
            {
                string between = StrWrk.GetBetween(text, "\"captcha_sid\":\"", "\"");
                string url     = StrWrk.GetBetween(text, "\"captcha_img\":\"", "\"").Replace("\\", "");
                string str     = "";
                if (VkCaptchaWorks.Enabled)
                {
                    Log.Push("[captcha]: обработка капчи");
                    try
                    {
                        str = VkCaptchaWorks.Solve(url, between);
                    }
                    catch (RuCaptchaException ex)
                    {
                        Log.Push("[Ошибка обработки captcha]: " + ex.Message);
                    }
                    return(APIRequest(method, param, token, "&captcha_sid=" + between + "&captcha_key=" + str));
                }
                Log.Push("[captcha]: изображение поставлено в очередь на ручной ввод");
                str = VkCaptchaWorks.SolveManual(url, between);
                return(APIRequest(method, param, token, "&captcha_sid=" + between + "&captcha_key=" + str));
            }
            else
            {
                if (text.Contains("\"error_code\""))
                {
                    throw new Exception(StrWrk.GetBetween(text, "\"error_msg\":\"", "\""));
                }
                return(text);
            }
        }