示例#1
0
        public string ReadImage(string filepath, string apiKey)
        {
            string captchaText = string.Empty;

            var api = new ImageToText
            {
                ClientKey = apiKey,
                FilePath  = filepath
            };

            if (!api.CreateTask())
            {
                Console.WriteLine("API v2 send failed. " + api.ErrorMessage ?? "", DebugHelper.Type.Error);
            }
            else if (!api.WaitForResult())
            {
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            }
            else
            {
                captchaText = api.GetTaskSolution();

                DebugHelper.Out("Result: " + captchaText, DebugHelper.Type.Success);
            }

            return(captchaText);
        }
        private async System.Threading.Tasks.Task SetVerificationCode(ValidationData validationData, string picFilePath, string clientKey)
        {
            DebugHelper.VerboseMode = true;

            var api = new ImageToText(NumericOption.NumbersOnly, 0)
            {
                ClientKey = clientKey,
                FilePath  = picFilePath
            };

            if (!api.CreateTask())
            {
                DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
            }
            else if (!api.WaitForResult())
            {
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            }
            else
            {
                var result = api.GetTaskSolution().Text;
                DebugHelper.Out("Result: " + result, DebugHelper.Type.Success);
                validationData.TextBox1 = result;
            }
        }
示例#3
0
        private async Task MessageReceivedAsync(SocketMessage message)
        {
            if (message.Author.Id == _client.CurrentUser.Id)
            {
                return;
            }

            // Check if the message is a captcha request
            if (message.Content.Contains(_CAPTCHA_REQUEST_PATTERN))
            {
                IReadOnlyCollection <Attachment> msgAttachments    = message.Attachments;
                IReadOnlyCollection <SocketUser> msgMentionnedUser = message.MentionedUsers;

                // ID of the user that needs a captcha bypass
                ulong  userId   = msgMentionnedUser.ElementAt(0).Id;
                string userName = msgMentionnedUser.ElementAt(0).Username;

                // Sends bypass request to DB
                wcSendToServer.DownloadString($"http://127.0.0.1/needCaptcha.php?idDiscord={userId}");

                Console.WriteLine($"[Captcha] Captcha Request for User {userName} ({userId})");

                // Getting captcha image link
                string imgUrl = msgAttachments.ElementAt(0).Url;

                // Downloading captcha image
                using (WebClient client = new WebClient())
                {
                    client.DownloadFile(new Uri(imgUrl), System.Environment.CurrentDirectory + $"/toBypass/{userId}.png");
                }

                // Captcha Bypass
                var api = new ImageToText
                {
                    ClientKey = _CAPTCHA_API_KEY,
                    FilePath  = System.Environment.CurrentDirectory + $"/toBypass/{userId}.png"
                };

                if (!api.CreateTask())
                {
                    Console.WriteLine($"[Captcha] API send FAIL -> [{api.ErrorMessage}]");
                }
                else if (!api.WaitForResult())
                {
                    Console.WriteLine($"[Captcha] Couldn't solve captcha...");
                }
                else
                {
                    Console.WriteLine($"[Captcha] Captcha Solved for User {userName} ({userId}) -> [{api.GetTaskSolution().Text}]");

                    string captcha = api.GetTaskSolution().Text;
                    captcha = captcha.Replace("\"", "");

                    wcSendToServer.DownloadString($"http://127.0.0.1/insertCaptcha.php?idDiscord={userId}&captcha={captcha}");

                    await message.Channel.SendMessageAsync("Captcha Result : " + captcha);
                }
            }
        }
示例#4
0
        private void BuscaCaptchaString()
        {
            var text            = wb.Document.GetElementById("cipCaptchaImg");
            var html            = String.Format("{0}{1}{2}", "<table cellpadding=\"0\" cellspacing=\"0\">", text.InnerHtml, "</table>");
            var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();

            // htmlToImageConv.Height = 70;
            htmlToImageConv.Width = 200;
            var jpegBytes = htmlToImageConv.GenerateImage(html, "Png");

            piccaptcha.Image = ByteArrayToImage(jpegBytes);



            Bitmap bitmapImage = new Bitmap(piccaptcha.Image);
            var    ms          = new MemoryStream();

            Image image = piccaptcha.Image;

            image.Save(ms, ImageFormat.Png);
            var bytes = ms.ToArray();

            var imageMemoryStream = new MemoryStream(bytes);

            Image imgFromStream = Image.FromStream(imageMemoryStream);

            imgFromStream.Save("captcha.jpg", ImageFormat.Jpeg);



            DebugHelper.VerboseMode = true;

            var api = new ImageToText
            {
                ClientKey = "ef85f1b1baa494a70b68cf1212727dcd",
                FilePath  = "captcha.jpg"
            };

            if (!api.CreateTask())
            {
                DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
            }
            else if (!api.WaitForResult())
            {
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            }
            else
            {
                DebugHelper.Out("Result: " + api.GetTaskSolution().Text, DebugHelper.Type.Success);
                captcha         = api.GetTaskSolution().Text;
                txtcaptcha.Text = captcha;
            }
        }
示例#5
0
        private static void ExampleImageToText()
        {
            DebugHelper.VerboseMode = true;

            var api = new ImageToText
            {
                ClientKey = "1234567890123456789012",
                FilePath  = "captcha.jpg"
            };

            if (!api.CreateTask())
            {
                DebugHelper.Out("API v2 send failed. " + api.ErrorMessage ?? "", DebugHelper.Type.Error);
            }
            else if (!api.WaitForResult())
            {
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            }
            else
            {
                DebugHelper.Out("Result: " + api.GetTaskSolution(), DebugHelper.Type.Success);
            }
        }
示例#6
0
        private async void btnIniciarConsulta_Click(object sender, EventArgs e)
        {
            do
            {
                //foreach (var consul in layout)
                //{



                wb.Document.GetElementById("aceiteTermoUso").SetAttribute("checked", "true");

                if (!string.IsNullOrEmpty(layout[totalconsultado].CPFCNPJ))
                {
                    txtcpf.Text = layout[totalconsultado].CPFCNPJ;
                    wb.Document.GetElementById("cpfCnpjEmitente").InnerText = txtcpf.Text;
                }


                if (!string.IsNullOrEmpty(layout[totalconsultado].CM7D1))
                {
                    txtd1.Text = layout[totalconsultado].CM7D1;
                    wb.Document.GetElementById("primeiroCampoCmc7").InnerText = txtd1.Text;
                }


                if (!string.IsNullOrEmpty(layout[totalconsultado].CM7D2))
                {
                    txtd2.Text = layout[totalconsultado].CM7D2;
                    wb.Document.GetElementById("segundoCampoCmc7").InnerText = txtd2.Text;
                }


                if (!string.IsNullOrEmpty(layout[totalconsultado].CM7D3))
                {
                    txtd3.Text = layout[totalconsultado].CM7D3;
                    wb.Document.GetElementById("terceiroCampoCmc7").InnerText = txtd3.Text;
                }


                if (!string.IsNullOrEmpty(layout[totalconsultado].CPFINTERESSADO))
                {
                    txtcpfinteressado.Text = layout[totalconsultado].CPFINTERESSADO;
                    wb.Document.GetElementById("cpfCnpjInteressado").InnerText = txtcpfinteressado.Text;
                }



                var text            = wb.Document.GetElementById("cipCaptchaImg");
                var html            = String.Format("{0}{1}{2}", "<table cellpadding=\"0\" cellspacing=\"0\">", text.InnerHtml, "</table>");
                var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();
                // htmlToImageConv.Height = 70;
                htmlToImageConv.Width = 200;
                var jpegBytes = htmlToImageConv.GenerateImage(html, "Png");
                piccaptcha.Image = ByteArrayToImage(jpegBytes);



                Bitmap bitmapImage = new Bitmap(piccaptcha.Image);
                var    ms          = new MemoryStream();

                Image image = piccaptcha.Image;

                image.Save(ms, ImageFormat.Png);
                var bytes = ms.ToArray();

                var imageMemoryStream = new MemoryStream(bytes);

                Image imgFromStream = Image.FromStream(imageMemoryStream);

                imgFromStream.Save("captcha.jpg", ImageFormat.Jpeg);



                DebugHelper.VerboseMode = true;

                var api = new ImageToText
                {
                    ClientKey = "ef85f1b1baa494a70b68cf1212727dcd",
                    FilePath  = "captcha.jpg"
                };

                if (!api.CreateTask())
                {
                    DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
                }
                else if (!api.WaitForResult())
                {
                    DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
                }
                else
                {
                    DebugHelper.Out("Result: " + api.GetTaskSolution().Text, DebugHelper.Type.Success);
                    captcha         = api.GetTaskSolution().Text;
                    txtcaptcha.Text = captcha;
                }

                if (!string.IsNullOrEmpty(captcha))
                {
                    wb.Document.GetElementById("captcha").InnerText = captcha;
                }

                //status.Text = "Aguardar 3 segundos";
                //Thread.Sleep(3000);
                wb.Document.GetElementById("btEnviar").InvokeMember("click");

                //Thread.Sleep(5000);
                var item = wb.Document.GetElementById("errors");
                if (item.InnerHtml != null)
                {
                    if ((item.InnerText.Contains(@"Código da Imagem: Caracteres do captcha não foram preenchidos corretamente ou o tempo máximo para preenchimento foi ultrapassado")) || (item.InnerText.Contains(@"Código da Imagem é um campo obrigatório")))
                    {
                        //MessageBox.Show(@"Código da Imagem: Caracteres do captcha não foram preenchidos corretamente ou o tempo máximo para preenchimento foi ultrapassado");
                        status.Text = @"Código da Imagem: Caracteres do captcha não foram preenchidos corretamente ou o tempo máximo para preenchimento foi ultrapassado";
                        //goto repete;
                    }
                }


                atualizaConsultado();
            } while (totalconsultado < totalConsulta);

            //}
        }
示例#7
0
        private async void btnConsultar_Click(object sender, EventArgs e)
        {
            wb.Document.GetElementById("aceiteTermoUso").SetAttribute("checked", "true");

            if (!string.IsNullOrEmpty(txtcpf.Text))
            {
                wb.Document.GetElementById("cpfCnpjEmitente").InnerText = txtcpf.Text.Trim();
            }

            if (!string.IsNullOrEmpty(txtd1.Text))
            {
                wb.Document.GetElementById("primeiroCampoCmc7").InnerText = txtd1.Text.Trim();
            }

            if (!string.IsNullOrEmpty(txtd2.Text))
            {
                wb.Document.GetElementById("segundoCampoCmc7").InnerText = txtd2.Text.Trim();
            }

            if (!string.IsNullOrEmpty(txtd3.Text))
            {
                wb.Document.GetElementById("terceiroCampoCmc7").InnerText = txtd3.Text.Trim();
            }

            if (!string.IsNullOrEmpty(txtcpfinteressado.Text))
            {
                wb.Document.GetElementById("cpfCnpjInteressado").InnerText = txtcpfinteressado.Text.Trim();
            }


            var text            = wb.Document.GetElementById("cipCaptchaImg");
            var html            = String.Format("{0}{1}{2}", "<table cellpadding=\"0\" cellspacing=\"0\">", text.InnerHtml, "</table>");
            var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();

            // htmlToImageConv.Height = 70;
            htmlToImageConv.Width = 200;
            var jpegBytes = htmlToImageConv.GenerateImage(html, "Png");

            piccaptcha.Image = ByteArrayToImage(jpegBytes);



            Bitmap bitmapImage = new Bitmap(piccaptcha.Image);
            var    ms          = new MemoryStream();

            Image image = piccaptcha.Image;

            image.Save(ms, ImageFormat.Png);
            var bytes = ms.ToArray();

            var imageMemoryStream = new MemoryStream(bytes);

            Image imgFromStream = Image.FromStream(imageMemoryStream);

            imgFromStream.Save("captcha.jpg", ImageFormat.Jpeg);



            DebugHelper.VerboseMode = true;

            var api = new ImageToText
            {
                ClientKey = "ef85f1b1baa494a70b68cf1212727dcd",
                FilePath  = "captcha.jpg"
            };

            if (!api.CreateTask())
            {
                DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
            }
            else if (!api.WaitForResult())
            {
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            }
            else
            {
                DebugHelper.Out("Result: " + api.GetTaskSolution().Text, DebugHelper.Type.Success);
                wb.Document.GetElementById("captcha").InnerText = api.GetTaskSolution().Text;
                txtcaptcha.Text = api.GetTaskSolution().Text;
            }

            if (!string.IsNullOrEmpty(txtcaptcha.Text))
            {
                wb.Document.GetElementById("captcha").InnerText = txtcaptcha.Text.Trim();
            }



            wb.Document.GetElementById("btEnviar").InvokeMember("click");
        }
        public void VkAuth(string login, string password)
        {
            if (sender_Group_ID is null)
            {
                System.Windows.MessageBox.Show("Значение Group ID не было введено! ");
                return;
            }
            System.Windows.Controls.TextBox textbox = (System.Windows.Controls.TextBox)sender_Group_ID;
            GroupID = Convert.ToInt64(textbox.Text);

            Func <string> code = () =>
            {
                string value = Microsoft.VisualBasic.Interaction.InputBox("Please enter code:", "Code Request", "Enter code there");
                //MessageBox.Show(value);
                return(value);
            };

            ulong  appID         = 2890984; // Используем официальное приложение VK для получения access token
            var    vk            = new VkApi();
            long   captchaSid    = 0;
            string captchaAnswer = "";
            long   getuserid     = 0;

            try
            {
                try
                {
                    if (TwoFactorAuthorization == true)
                    {
                        vk.Authorize(new VkNet.Model.ApiAuthParams
                        {
                            ApplicationId          = appID,
                            Login                  = login,
                            Password               = password,
                            Settings               = Settings.All,
                            TwoFactorAuthorization = code,
                            CaptchaKey             = captchaAnswer,
                            CaptchaSid             = captchaSid
                        }
                                     );
                    }
                    else
                    {
                        vk.Authorize(new VkNet.Model.ApiAuthParams
                        {
                            ApplicationId = appID,
                            Login         = login,
                            Password      = password,
                            Settings      = Settings.All,
                            CaptchaKey    = captchaAnswer,
                            CaptchaSid    = captchaSid
                        }
                                     );
                    }
                }
                catch (VkNet.Exception.VkApiException)
                {
                    UnsuccessfulLogin++;
                    System.Windows.MessageBox.Show("Неуспешная авторизация!");
                    return;
                }

                /*
                 * catch (System.InvalidOperationException)
                 * System.Windows.MessageBox.Show("Эта операция не поддерживается для относительных URI-адресов.");
                 */

                try
                {
                    SuccessfulLogin++;
                    var users = vk.Friends.Get(new VkNet.Model.RequestParams.FriendsGetParams
                    {
                    });
                    List <VkNet.Model.User> IDs = users.ToList();
                    foreach (VkNet.Model.User id in IDs)
                    {
                        getuserid = id.Id;
                        vk.Groups.Invite(GroupID, id.Id);
                        SuccessfulInvitesCount++;
                        //System.Threading.Thread.Sleep(5000);
                        //System.Windows.MessageBox.Show(Convert.ToString(id.Id));
                    }
                }
                catch (VkNet.Exception.AccessDeniedException e)
                {
                    System.Windows.MessageBox.Show("Access denied: ");
                    UnsuccessfulInvitesCount++;
                    SuccessfulInvitesCount--;
                }
                catch (VkNet.Exception.CannotBlacklistYourselfException e)
                {
                    System.Windows.MessageBox.Show("Access denied: user should be friend");
                    UnsuccessfulInvitesCount++;
                    SuccessfulInvitesCount--;
                }
            }

            catch (VkNet.Exception.CaptchaNeededException cap)
            {
                captchaSid = cap.Sid;
                if (sender_antigate is null)
                {
                    System.Windows.MessageBox.Show("Значение ключа Antigate не было введено! Не возможно отправить капчу на Antigate! ");
                    return;
                }
                if (GetAntigateBalance() == 0)
                {
                    System.Windows.MessageBox.Show("Нет средств на балансе Antigate");
                    return;
                }

                System.Windows.Controls.TextBox textbox2 = (System.Windows.Controls.TextBox)sender_antigate;
                var api = new ImageToText
                {
                    ClientKey = textbox2.Text,
                    FilePath  = cap.Img.ToString()
                };
                if (!api.CreateTask())
                {
                    System.Windows.MessageBox.Show("API v2 send failed. " + api.ErrorMessage);
                    UnsuccessfulCaptcha++;
                }
                else if (!api.WaitForResult())
                {
                    System.Windows.MessageBox.Show("Could not solve the captcha.");
                    UnsuccessfulCaptcha++;
                }
                else
                {
                    //System.Windows.MessageBox.Show("Result: " + api.GetTaskSolution().Text);
                    captchaAnswer = api.GetTaskSolution().Text;
                    SuccessfulCaptcha++;
                    vk.Groups.Invite(GroupID, getuserid, captchaSid, captchaAnswer);
                }
            }
        }