Lý do share :
- 1. Lười , không muốn tự code 1 mình
- 2. Muốn nhận thêm vài em lập trình viên làm đệ tử. Chỉ nhận em nào nhận ra rằng cố gắng học để đi làm thì sẽ tốt hơn là ôm máy tính MMO suốt ngày.
Vui lòng không ném đá mình.
Code phân từng đoạn
Code giao diện
Code thân chuơng trình .
Trên chỉ là phần code. có thể dựa vào nó để làm ra 1 auto.
ai muốn lấy source thì PM vantin_it
Xong !. ai có câu hỏi gì nào ?
- 1. Lười , không muốn tự code 1 mình
- 2. Muốn nhận thêm vài em lập trình viên làm đệ tử. Chỉ nhận em nào nhận ra rằng cố gắng học để đi làm thì sẽ tốt hơn là ôm máy tính MMO suốt ngày.
Vui lòng không ném đá mình.
Code phân từng đoạn
Code giao diện
Code:
private void InitializeComponent()
{
this.txtCap = new System.Windows.Forms.TextBox();
this.pic0 = new System.Windows.Forms.PictureBox();
this.pic1 = new System.Windows.Forms.PictureBox();
this.pic2 = new System.Windows.Forms.PictureBox();
this.pic3 = new System.Windows.Forms.PictureBox();
this.pic4 = new System.Windows.Forms.PictureBox();
this.lbStatus = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.checkAuto = new System.Windows.Forms.CheckBox();
this.lbCong = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pic0)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pic4)).BeginInit();
this.SuspendLayout();
//
// txtCap
//
this.txtCap.Location = new System.Drawing.Point(162, 41);
this.txtCap.Multiline = true;
this.txtCap.Name = "txtCap";
this.txtCap.Size = new System.Drawing.Size(188, 44);
this.txtCap.TabIndex = 1;
//
// pic0
//
this.pic0.BackColor = System.Drawing.SystemColors.Control;
this.pic0.Location = new System.Drawing.Point(45, 41);
this.pic0.Name = "pic0";
this.pic0.Size = new System.Drawing.Size(111, 44);
this.pic0.TabIndex = 2;
this.pic0.TabStop = false;
//
// pic1
//
this.pic1.BackColor = System.Drawing.SystemColors.Control;
this.pic1.Location = new System.Drawing.Point(45, 91);
this.pic1.Name = "pic1";
this.pic1.Size = new System.Drawing.Size(53, 44);
this.pic1.TabIndex = 2;
this.pic1.TabStop = false;
//
// pic2
//
this.pic2.BackColor = System.Drawing.SystemColors.Control;
this.pic2.Location = new System.Drawing.Point(129, 91);
this.pic2.Name = "pic2";
this.pic2.Size = new System.Drawing.Size(53, 44);
this.pic2.TabIndex = 2;
this.pic2.TabStop = false;
//
// pic3
//
this.pic3.BackColor = System.Drawing.SystemColors.Control;
this.pic3.Location = new System.Drawing.Point(213, 91);
this.pic3.Name = "pic3";
this.pic3.Size = new System.Drawing.Size(53, 44);
this.pic3.TabIndex = 2;
this.pic3.TabStop = false;
//
// pic4
//
this.pic4.BackColor = System.Drawing.SystemColors.Control;
this.pic4.Location = new System.Drawing.Point(297, 91);
this.pic4.Name = "pic4";
this.pic4.Size = new System.Drawing.Size(53, 44);
this.pic4.TabIndex = 2;
this.pic4.TabStop = false;
//
// lbStatus
//
this.lbStatus.AutoSize = true;
this.lbStatus.Location = new System.Drawing.Point(91, 18);
this.lbStatus.Name = "lbStatus";
this.lbStatus.Size = new System.Drawing.Size(37, 13);
this.lbStatus.TabIndex = 3;
this.lbStatus.Text = "Status";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(42, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(43, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Status :";
//
// checkAuto
//
this.checkAuto.AutoSize = true;
this.checkAuto.Location = new System.Drawing.Point(356, 68);
this.checkAuto.Name = "checkAuto";
this.checkAuto.Size = new System.Drawing.Size(48, 17);
this.checkAuto.TabIndex = 4;
this.checkAuto.Text = "Auto";
this.checkAuto.UseVisualStyleBackColor = true;
//
// lbCong
//
this.lbCong.AutoSize = true;
this.lbCong.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbCong.Location = new System.Drawing.Point(103, 102);
this.lbCong.Name = "lbCong";
this.lbCong.Size = new System.Drawing.Size(19, 20);
this.lbCong.TabIndex = 5;
this.lbCong.Text = "+";
//
// BH
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(487, 384);
this.Controls.Add(this.lbCong);
this.Controls.Add(this.checkAuto);
this.Controls.Add(this.label1);
this.Controls.Add(this.lbStatus);
this.Controls.Add(this.pic4);
this.Controls.Add(this.pic3);
this.Controls.Add(this.pic2);
this.Controls.Add(this.pic1);
this.Controls.Add(this.pic0);
this.Controls.Add(this.txtCap);
this.Name = "BH";
this.Text = "BH";
((System.ComponentModel.ISupportInitialize)(this.pic0)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pic4)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
Code thân chuơng trình .
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace BuxHost
{
public partial class BH : Form
{
HtmlElementCollection htmlcode;
string strHeader = string.Empty;
HttpWebRequest request;
HttpWebResponse response;
Stream st;
StreamReader strd;
StreamWriter stwt;
CookieContainer ck = new CookieContainer();
string strCK = string.Empty;
string strCap = string.Empty;
List<Ads> listAds = new List<Ads>();
string strCurrAds = string.Empty;
int iCurrAds = 1;
int iTask = 0;
string strLinkRequest = string.Empty;
string strContentSite = string.Empty;
BackgroundWorker bg = new BackgroundWorker();
string strReport = string.Empty;
List<string> listCap = new List<string>();
string strURL = "http://www.buxsecure.com";
WebBrowser wb = new WebBrowser();
bool bDisable = true;
public BH()
{
InitializeComponent();
this.Load += new EventHandler(BH_Load);
}
void BH_Load(object sender, EventArgs e)
{
// txtCap.Enabled = false;
Disable();
wb.Navigate(strURL+"/pages/login");
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
txtCap.KeyUp += new KeyEventHandler(txtCap_KeyUp);
bg.DoWork += new DoWorkEventHandler(bglogin_DoWork);
bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bglogin_RunWorkerCompleted);
bg.ProgressChanged += new ProgressChangedEventHandler(bg_ProgressChanged);
bg.WorkerReportsProgress = true;
bg.WorkerSupportsCancellation = true;
}
void bg_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
if (iTask == 1)
{
lbStatus.Text = strReport;
txtCap.Enabled = true;
if (listCap.Count == 2)
lbCong.Visible = true;
}
if (iTask == 2)
{
if (strContentSite.Contains("Your balance has been credited"))
{
lbStatus.Text = "Your balance has been credited";
}
}
}
void txtCap_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (wb != null&&iTask==0)
{
if (wb.Url.ToString().Contains("login"))
{
Login();
txtCap.Text = "";
//Disable();
}
}
else if (iTask == 1)
{
txtCap.Enabled = false;
strLinkRequest = strLinkRequest + txtCap.Text.Trim();
iTask = 2;
bg.RunWorkerAsync();
}
}
}
void Login()
{
bool blogin=false;
do
{
try
{
htmlcode = wb.Document.GetElementsByTagName("input");
htmlcode[0].SetAttribute("value", "user");
htmlcode[1].SetAttribute("value", "password");
htmlcode[3].SetAttribute("checked", "true");
htmlcode[4].SetAttribute("checked", "true");
try
{
wb.Document.GetElementById("captcha").SetAttribute("value", txtCap.Text);
}
catch { }
wb.Document.GetElementById("submitbutton").InvokeMember("click");
blogin = true;
}
catch { blogin = false; }
}
while (!blogin);
}
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (wb.Url.ToString().Contains("login"))
{
if (wb.ReadyState.Equals(WebBrowserReadyState.Complete))
{
strCK = wb.Document.Cookie;
htmlcode = wb.Document.Images;
foreach (HtmlElement el in htmlcode)
{
if (el.OuterHtml.Contains("captcha?t=s"))
{
int dau = el.OuterHtml.IndexOf("h=") + 2;
int cuoi = el.OuterHtml.IndexOf("this.on") - 3;
strCap = el.OuterHtml.Substring(dau, cuoi - dau);
goto F1;
}
}
F1: ;
//wb.Stop();
if (strCap != string.Empty)
{
lbStatus.Text = "Loading captcha login";
iTask = 0;
if (!bg.IsBusy)
bg.RunWorkerAsync();
}
else Login();
}
}
else if (wb.Url.ToString().Contains("clickads"))
{
if (wb.ReadyState.Equals(WebBrowserReadyState.Interactive))
{
lbStatus.Text = "Find ads ...";
System.Threading.Thread.Sleep(500);
strCK = wb.Document.Cookie;
listAds = new List<Ads>();
htmlcode = wb.Document.GetElementsByTagName("tr");
string id = string.Empty;
double db = 0;
foreach (HtmlElement el in htmlcode)
{
if (el.OuterHtml.Contains("openad("))
{
HtmlElementCollection htmlcodediv = el.GetElementsByTagName("div");
foreach (HtmlElement eldiv in htmlcodediv)
{
if (eldiv.OuterHtml.Contains("openad("))
{
//int dau = eldiv.OuterHtml.IndexOf(""
int dau=eldiv.OuterHtml.IndexOf("openad(")+8;
int cuoi = eldiv.OuterHtml.IndexOf("\");");
id = eldiv.OuterHtml.Substring(dau, cuoi - dau);
}
else if (eldiv.GetAttribute("classname").Equals("strike"))
{
db = double.Parse(eldiv.InnerText.Replace("$", ""));
}
}
listAds.Add(new Ads(id, db));
}
}
if (listAds.Count > 0)
{
lbStatus.Text = "List Ads done ! Number Ads :" + listAds.Count;
wb.Dispose();
SortList();
ReadAds();
}
lbStatus.Text = "List Ads done ! Number Ads :" + listAds.Count;
System.Threading.Thread.Sleep(500);
}
}
}
void SortList()
{
for (int i = 0; i < listAds.Count-1; i++)
{
for (int j = i; j < listAds.Count; j++)
{
if (listAds[j].Earn > listAds[i].Earn)
{
Ads t = new Ads(listAds[j].IdAds, listAds[j].Earn);
listAds[j] = listAds[i];
listAds[i] = t;
}
}
}
}
void bglogin_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (iTask == 0)
{
txtCap.Enabled = true;
lbStatus.Text = "Load captcha done !";
}
else if (iTask == 2)
{
if (strContentSite.Contains("Your balance has been credited"))
{
ReadAds();
}
else if (strContentSite.Contains("right number"))
{
lbStatus.Text = "Wrong captcha.";
txtCap.Enabled = true;
}
else if (strContentSite.Contains("maximum"))
{
lbStatus.Text = "You have clicked maximum ads to day !Press F7 to next site";
txtCap.Enabled = true;
}
}
}
void bglogin_DoWork(object sender, DoWorkEventArgs e)
{
if (iTask == 0)
{
bg.ReportProgress(0);
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages/captcha?t=s&s=standard&h=" + strCap);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic0.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
}
#region itask =1
else if (iTask == 1)
{
//bDisable = true;
strReport = string.Format("Request Ads {0}", iCurrAds);
bg.ReportProgress(0);
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages/clickadsproc?h=" + strCurrAds);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
string[] t = (new StreamReader(response.GetResponseStream())).ReadToEnd().Split('\'');
request.Abort();
response.Close();
strLinkRequest = string.Empty;
foreach (string t2 in t)
{
if (t2.Contains("docaptcha=1&rnd="))
{
strLinkRequest = t2;
goto B1;
}
}
B1: ;
if (!checkAuto.Checked)
{
strReport = string.Format("Request Ads {0} Done . Loading Captcha...", iCurrAds);
bg.ReportProgress(0);
listCap = new List<string>();
foreach (string t2 in t)
{
if (t2.Contains("captcha_ads.php"))
{
listCap.Add(t2);
}
}
if (listCap.Count == 1)
{
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[0]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic0.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
strReport = "Load captcha done. Plz input valid number";
bg.ReportProgress(0);
}
else if (listCap.Count == 2)
{
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[0]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic1.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[1]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic2.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
strReport = "Load captcha done. Plz input count of two number";
bg.ReportProgress(0);
}
else if (listCap.Count == 5)
{
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[0]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic0.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[1]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic1.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[2]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic2.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[3]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic3.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages" + listCap[4]);
request.Headers.Add("Cookie", strCK);
response = (HttpWebResponse)request.GetResponse();
pic4.Image = Image.FromStream(response.GetResponseStream());
request.Abort();
response.Close();
strReport = "Load captcha done. Plz input order of correct number";
bg.ReportProgress(0);
}
}
}
#endregion
else if (iTask == 2)
{
strReport = "Sending captcha";
bg.ReportProgress(0);
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(strLinkRequest);
request = (HttpWebRequest)HttpWebRequest.Create(strURL+"/pages/clickadsproc");
request.Headers.Add("Cookie", strCK);
request.Method = "POST";
//request.Connection = "Close";
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
st = request.GetRequestStream();
st.Write(data, 0, data.Length);
response = (HttpWebResponse)request.GetResponse();
request.Abort();
response.Close();
System.Threading.Thread.Sleep(500);
request = (HttpWebRequest)HttpWebRequest.Create(strURL + "/pages/clickadsproc");
request.Headers.Add("Cookie", strCK);
request.Method = "POST";
//request.Connection = "Close";
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
st = request.GetRequestStream();
st.Write(data, 0, data.Length);
response = (HttpWebResponse)request.GetResponse();
strContentSite = (new StreamReader(response.GetResponseStream())).ReadToEnd();
request.Abort();
response.Close();
strReport = strContentSite;
bg.ReportProgress(0);
System.Threading.Thread.Sleep(1000);
}
}
void Disable()
{
txtCap.Enabled = false;
lbCong.Visible = false;
pic0.Image = null;
pic1.Image = null;
pic2.Image = null;
pic3.Image = null;
pic4.Image = null;
}
void ReadAds()
{
if (listAds.Count == 0)
{
lbStatus.Text = "Clicked All Ads. Press F7 to move next";
}
else
{
Disable();
iTask = 1;
strCurrAds = listAds[0].IdAds;
listAds.RemoveAt(0);
bg.RunWorkerAsync();
}
}
}
public class Ads
{
public string IdAds;
public double Earn;
public Ads(string id,double db)
{
IdAds = id;
Earn = db;
}
}
}
ai muốn lấy source thì PM vantin_it
Xong !. ai có câu hỏi gì nào ?