说明,网上转的。
这段淘宝秒杀真的很火,掌故的拿几个宝物配备布置成低价限时来促销,就被那一些有秒杀器的家伙0秒下单了,是在是受没完也看不下于去,也测验考试的去写个秒杀器,探索的几天几夜,终于有点小成就,但还不完善,要是碰到有证验码 就死翘翘。
但据说有人的秒杀器就能绕过证验码,还切当不移,我也中文搜索网站GG 几天几夜,没找到谜底,但至少有了点端倪,就是什么cookies强制逾期法,来让证验码掉效,可以提早输入证验码。
我懂患上园子儿里许多天才。可以点拨点拨,配合进修进修,有兴趣的可以完善下,同时也学学深奥的破解证验码的技能。
要是你真的绕过证验码了,那去年9月26日,淘宝1元包邮秒杀条记本就是你的了。哈哈哈。。。。
代码都贴在这了,但代码中socket获取页面的时候有时获取的不全,需要调解线程sleep时间什么的的工具,代码里的工具多的很从网上copy下来到,作者也不不懂患上是谁了,我就用了,请多多海涵。
待会截个前台的图,好让没有接触过秒杀的伴侣有个大要的相识,有兴趣的可以加我QQ(278113569 注:博客园)。
二话不说了,截图。
先输入淘宝的账户以及暗码,之后贴上宝物的地址 点击检验测定并抢购。
全数源代码 1 using System;
2 using System.Collections;
3 using System.Configuration;
4 using System.Data;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.HtmlControls;
9 using System.Web.UI.WebControls;
10 using System.Net;
11 using System.Net.Sockets;
12 using System.Text;
13 using System.Threading;
14 using System.IO;
15 using System.Text.RegularExpressions;
16
17 public partial class MiaoSha : System.Web.UI.Page
18 {
19 string strServer = string.Empty;
20 string strPath = string.Empty;
21
22 protected void Page_Load(object sender, EventArgs e)
23 {
24
25 }
26
27 public static String Recv(Socket sock, Encoding encode)
28 {
29 Byte[] buffer = new Byte[8192];
30 StringBuilder sb = new StringBuilder();
31
32 Thread.Sleep(50);//根据页面相应时间举行微调
33 Int32 len = sock.Receive(buffer);
34 sb.Append(encode.GetString(buffer, 0, len));
35
36 w你好le (sock.Available > 0)
37 {
38 Thread.Sleep(300);//也可以视环境微调
39 Array.Clear(buffer, 0, buffer.Length);
40 len = sock.Receive(buffer);
41 sb.Append(encode.GetString(buffer, 0, len));
42 string ss = encode.GetString(buffer, 0, len);
43 }
44 sock.Close();
45 return sb.ToString();
46 }
47
48 /// <summary>
49 /// Socket获取页面HTML同时归回头信息
50 /// </summary>
51 /// <param name="server">服务器地址或者主机名</param>
52 /// <param name="url">哀求的页面</param>
53 /// <param name="method">post or get</param>
54 /// <param name="data">提交处理的数值</param>
55 /// <param name="Cookies">Cookies</param>
56 /// <returns>归回页面的HTML</returns>
57 public string GetHtml(string server, string url, string method, string data, string Cookies)
58 {
59 string _method = method.ToUpper();
60 string _url = string.Empty;
61 if (url == "")
62 {
63 _url = "/";
64 }
65 else if (url.Substring(0, 1) != "/")
66 {
67 _url = "/" url;
68 }
69 else
70 {
71 _url = url;
72 }
73 string formatString = string.Empty;
74 string sendString = string.Empty;
75 Encoding ASCII = Encoding.Default;
76
77 //以下是拼接的HTTP头信息
78 if (_method == "GET")
79 {
80 formatString = "";
81 formatString = "{0} {1} HTTP/1.1\r\n";
82 formatString = "Host: {2}\r\n";
83 formatString = "User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n";
84 formatString = "Accept: text/html\r\n";
85 formatString = "Keep-Alive: 300\r\n";
86 formatString = "Cookies:{3}\r\n";
87 formatString = "Connection: keep-alive\r\n\r\n";
88 sendString = string.Format(formatString, _method, _url, server, Cookies);
89 }
90 else
91 {
92 formatString = "";
93 formatString = "{0} {1} HTTP/1.1\r\n";
94 formatString = "Host: {2}\r\n";
95 formatString = "User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n";
96 formatString = "Accept:text/html\r\n";
97 formatString = "Content-Type:application/x-www-form-urlencoded\r\n";
98 formatString = "Content-Length:{3}\r\n";
99 formatString = "Referer:http://buy.taobao.com/auction/buy_now.jhtml";
100 formatString = "Keep-Alive:300\r\n";
101 formatString = "Cookies:{4}\r\n";
102 formatString = "Connection: keep-alive\r\n\r\n";
103 formatString = "{5}\r\n";
104 sendString = string.Format(formatString, _method, _url, server, Encoding.Default.GetByteCount(data), Cookies, data);
105 }
106
107 Byte[] ByteGet = ASCII.GetBytes(sendString);
108 Byte[] RecvBytes = new Byte[1024];
109 String strRetPage = null;
110 IPAddress hostadd = Dns.Resolve(server).AddressList[0];
111 IPEndPoint EPhost = new IPEndPoint(hostadd, 80);
112 Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
113 s.Connect(EPhost);
114 if (!s.Connected)
115 {
116 strRetPage = "链接主机掉败";
117 return strRetPage;
118 }
119 s.Send(ByteGet, ByteGet.Length, SocketFlags.None);
120
121 strRetPage = Recv(s, ASCII);
122
123 return strRetPage;
124 }
125
126 protected void btnLogin_Click(object sender, EventArgs e)
127 {
128 string u = t你好s.txtUserName.Text.Trim();
129 string p = t你好s.txtPwd.Text.Trim();
130 DateTime st = DateTime.Now;
131
132 //淘宝登录需要post的数值串
133 string sendData = "TPL_username=" u "&TPL_password=" Server.UrlEncode(p) "&actionForStable=enable_post_user_action&action=Authenticator&mi_uid=&mcheck=&TPL_redirect_url=http://item.taobao.com/auction/item_detail-0db1-3036113cf5455bd74047f1a581ba4be7.htm&_oooo_=http://item.taobao.com/auction/item_detail-0db1-3036113cf5455bd74047f1a581ba4be7.htm&event_submit_do_login=anyt你好ng&abtest=&pstrong=3&from=&yparam=&done=&loginType=3&tid=&support=000001&CtrlVersion=1,0,0,7";
134
135 string s = GetHtml("login.taobao.com", "/member/login.jhtml", "post", sendData, "");
136 Session["Cookies"] = GetCookies(s); //从归回的源码中提取cookies,抓取登录后的页面需要附上该cookies
137
138 }
139 protected void btnBuy_Click(object sender, EventArgs e)
140 {
141 string strURL = t你好s.txtURL.Text.Trim();
142 getServerAndPath(strURL);
143
144 string s = GetHtml(strServer, strPath, "get", "", Session["Cookies"].ToString());
145 //Response.Write(s);
146 if (s.IndexOf("当即采办") > 0)
147 {
148 string item_id = strURL.Split('-')[2].Split('.')[0].ToString();
149 string x_id = strURL.Split('-')[1].ToString();
150
151 s = GetHtml("buy.taobao.com", "/auction/buy.htm?from=itemDetail&item_id=" item_id "&x_id=" x_id, "get", "", Session["Cookies"].ToString());
152 //Response.Write(s);
153 using (StreamWriter sw = new StreamWriter(Server.MapPath("debug1.html")))
154 {
155 sw.Write(s);
156 }
157
158 if (s.IndexOf("明确承认提交处理订单") > 0)
159 {
160 Session["Cookies"] = GetCookies(s);
161 string postData = getPostData(s);
162 string r = GetHtml("buy.taobao.com", "/auction/buy_now.htm", "post", postData, Session["Cookies"].ToString());
163 if (r.IndexOf("302") > 0)
164 {
165 using (StreamWriter sw = new StreamWriter(Server.MapPath("debug2.html")))
166 {
167 sw.Write(r);
168 }
169 }
170 else
171 {
172 ////
173 }
174 using (StreamWriter sw = new StreamWriter(Server.MapPath("debug2.html")))
175 {
176 sw.Write(r);
177 }
178 }
179 }
180 else if (s.IndexOf("btn-wait") > 0)//该宝物还处于按时上架的状况
181 {
182
183 }
184
185 }
186
187
188 /// <summary>
189 /// 从归回的源代码中提取cookies
190 /// </summary>
191 /// <param name="s"></param>
192 /// <returns></returns>
193 private string GetCookies(string s)
194 {
195 StringBuilder sbCookies = new StringBuilder();
196
197 string[] arr = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
198 foreach (string str in arr)
199 {
200 if (str.StartsWith("Set-Cookie: "))
201 {
202 int intStart = str.IndexOf(";");
203 string strCookie = str.Substring(12, intStart - 11);
204 sbCookies.Append(strCookie);
205 }
206 }
207 return sbCookies.ToString();
208 }
209
210 private string GetLocationURL(string s)
211 {
212
213 string RtnString = string.Empty;
214 StringBuilder sbCookies = new StringBuilder();
215
216 string[] arr = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
217 foreach (string str in arr)
218 {
219 if (str.StartsWith("Location: "))
220 {
221 RtnString = str.Substring(11, str.Length - 11);
222 }
223 }
224 return RtnString;
225 }
226
227
228
229 private void getServerAndPath(string strURL)
230 {
231 if (strURL != "" && strURL.IndexOf("/") > 0)
232 {
233 int SlashPos = strURL.Substring(7).IndexOf("/");
234 strServer = strURL.Substring(7, SlashPos);
235 strPath = strURL.Substring(SlashPos 7);
236 }
237 else
238 return;
239 }
240
241
242
243 /// <summary>
244 /// 从最后明确承认采办页面的源代码中提取表奇数值的数值
245 /// </summary>
246 /// <param name="html"></param>
247 /// <returns></returns>
248 private string getPostData(string html)
249 {
250 string postStr = "";
251 string pat = "<input .*?name.{0,1}=.{0,1}\"(.*?)\".*? value.{0,1}=\"(.*?)\".*?>";
252 Regex regex = new Regex(pat, RegexOptions.Multiline | RegexOptions.IgnoreCase);
253 MatchCollection mcollection = regex.Matches(html);
254
255 foreach (Match m in mcollection)
256 {
257 GroupCollection gcollection = m.Groups;
258 if (m.ToString().IndexOf("_fma.b._0.s") > 0) { continue; }
259 if (m.ToString().IndexOf("_fma.b._0.c") > 0) { continue; }
260 if (m.ToString().IndexOf("isCheckCode") > 0 && gcollection[2].Value.ToLower() == "true")
261 {
262 //isCheckCode = true;
263 }
264 postStr = gcollection[1].Value; postStr = "=";
265 postStr = Server.UrlEncode(gcollection[2].Value);
266 postStr = "&";
267 }
268 postStr = "n_prov=370000&n_city=370500&n_area=370522&_fma.b._0.w=quicky&_fma.b._0.ac=250&consignment=10&_fma.b._0.au=5&_fma.b._0.c=8888";
269 postStr = postStr.Replace("quantity=0", "quantity=1").Replace("_fma.b._0.d=您没必要重复省-市-区信息;至少五个字", "_fma.b._0.d=" Server.UrlEncode("收货人的具体地址")).Replace("_fma.b._0.po=", "_fma.b._0.po=230031").Replace("_fma.b._0.de=", "_fma.b._0.de=" Server.UrlEncode("啊峰")).Replace("_fma.b._0.u=", "_fma.b._0.u=0").Replace("_fma.b._0.di=1", "_fma.b._0.di=370522").Replace("_fma.b._0.deli=", "_fma.b._0.deli=139XXXX");
270 postStr = "&_fma.b._0.s=2";
271 //postStr = Server.UrlEncode(postStr);
272
273 return postStr;
274 }
275 }
个人签名
-------------------------------------