Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Delphi, .NET, Asm (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   Капча турбобит (https://forum.antichat.xyz/showthread.php?t=208831)

IgrikX 03.06.2010 13:38

Капча турбобит
 
Пытаюсь написать скачивалку для turbobit. Выдираю капчу, но при вводе капчи, пишет мол не верно распознано, как решить проблему.?
PHP код:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;

namespace 
turbobit
{
    public 
partial class Form1 Form
    
{
//-----------------------------------------------------------------------
        
private string turbobit_get(string urlstring user_agentstring reffer)
        {

            
HttpWebRequest url_turbobit = (HttpWebRequest)WebRequest.Create(url);
            
url_turbobit.CookieContainer cookies;
            
url_turbobit.Referer reffer;
            
url_turbobit.UserAgent user_agent;
            
HttpWebResponse res_turbobit = (HttpWebResponse)url_turbobit.GetResponse();
            
cookies url_turbobit.CookieContainer;
            
Stream stream_turbobit res_turbobit.GetResponseStream();
            
StreamReader read_stream_turbobit = new StreamReader(stream_turbobit);
            
string str_turbobit read_stream_turbobit.ReadToEnd();
            return 
str_turbobit;
        }

        private 
string turbobit_post(string urlstring user_agentstring refferstring post)
        {

            
HttpWebRequest url_turbobit = (HttpWebRequest)WebRequest.Create(url);
            
url_turbobit.Referer reffer;
            
url_turbobit.CookieContainer cookies;
            
url_turbobit.UserAgent user_agent;
            
url_turbobit.AllowAutoRedirect true;
            
url_turbobit.Method "POST";
            
byte[] byte_post System.Text.Encoding.ASCII.GetBytes(post);
            
url_turbobit.ContentLength byte_post.Length;
            
Stream stream_turbobit url_turbobit.GetRequestStream();
            
stream_turbobit.Write(byte_post0byte_post.Length);
            
stream_turbobit.Close();
            
HttpWebResponse res_turbobit = (HttpWebResponse)url_turbobit.GetResponse();
            
cookies url_turbobit.CookieContainer;
            
richTextBox1.Text res_turbobit.Cookies[0].ToString();
            
Stream stream_turbobit_2 res_turbobit.GetResponseStream();
            
StreamReader read_stream_turbobit = new StreamReader(stream_turbobit_2);
            
string str_turbobit read_stream_turbobit.ReadToEnd();
            return 
str_turbobit;
        }

        private 
string url "http://turbobit.net/jswesvvba30d.html";
        private 
string user_agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3";
        private 
string reffer "";
        private 
string captcha_response "";// разгадывание капчи
        
private string captcha_type "";// тип капчи
        
private string captcha_subtype "";// допольнительный параметр
        
CookieContainer cookies = new CookieContainer();

//-------------------------------------------------------------------------
        
public Form1()
        {
            
InitializeComponent();
        }

        private 
void Form1_Load(object senderEventArgs e)
        {
        
        }

        private 
void button1_Click(object senderEventArgs e)
        {
            
// строки нужно переинициализовать
            
url "http://turbobit.net/jswesvvba30d.html";
            
user_agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3";
            
reffer "";
            
captcha_response "";// разгадывание капчи
            
captcha_type "";// тип капчи
            
captcha_subtype "";// допольнительный параметр
            //--------------------------------
            
string str_html turbobit_get(url,user_agent,reffer);
            
reffer url;// рефером становиться адрес на который мы перешли
            // выдираем сслку для дальнейшего перехода
            
Match free_url Regex.Match(str_html,"class=\"free\" href=\"(.+?)\"");
            
// установливаем ссылку для дальнейшего перехода
            
url "http://turbobit.net" free_url.Groups[1].Value;
            
// отправляем get запрос
            
str_html turbobit_get(urluser_agentreffer);
            
reffer url;// рефером становиться адрес на который мы перешли
            
url reffer "#"// устанавливаем урл для дальнейшего использования
            
richTextBox1.Text str_html;
            
// выдираем капчу
            
Match captha Regex.Match(str_html"alt=\"Captcha\" src=\"(.+?)\"");
            
string url_captha captha.Groups[1].Value;// url к капче
            //выдираем дополнительтные параметры
            
Match captcha_type_s Regex.Match(str_html"value = '(.+?)' name = 'captcha_type'");
            
captcha_type captcha_type_s.Groups[1].Value;
            
Match captcha_subtype_s Regex.Match(str_html"value = '(.+?)' name = 'captcha_subtype'");
            
captcha_subtype captcha_subtype_s.Groups[1].Value;
            
//----------------------------------
            
try
            {
            
// выводи капчу в imageBox
            
HttpWebRequest url_turbobit = (HttpWebRequest)WebRequest.Create(url_captha);
            
url_turbobit.Referer reffer;
            
url_turbobit.CookieContainer cookies;
            
url_turbobit.UserAgent user_agent;
            
HttpWebResponse res_turbobit = (HttpWebResponse)url_turbobit.GetResponse();
            
Stream stream_turbobit res_turbobit.GetResponseStream();
            
pictureBox1.Image Image.FromStream(stream_turbobit);
            
richTextBox2.Text "Капча найдена!";
            }
            catch (
Exception)
            {
            
richTextBox2.Text "Капча не найдена!";
            }

        }

        private 
void button2_Click(object senderEventArgs e)
        {
            
// POSTDATA=captcha_response=NUPP&captcha_type=securimg&captcha_subtype=9
            
captcha_response textBox1.Text;
            
richTextBox2.Text captcha_type;
            
richTextBox3.Text captcha_subtype;
            
richTextBox4.Text reffer;
            
richTextBox5.Text reffer+"#";
            
string post "captcha_response="+captcha_response+"&captcha_type="+captcha_type+"&captcha_subtype="+captcha_subtype;
            
richTextBox6.Text post;
            
string test turbobit_post(urluser_agentrefferpost);
        }

    }




Время: 03:07