asp.net 小偷程序实现的原理和源码
今天看了网上关于小偷程序的介绍自己做了分析。
下面就是实现的原理:
通过请求别人的服务器,通过得到的服务器的返回的数据进行 自己组装和拆分的到自己想要的内容 显示在页面上的下面是一个例子。
string strURL = "其他网站的地址";
HttpWebRequest request= (HttpWebRequest)WebRequest.Create(strURL);
request.Method="POST";
request.ContentType="application/x-www-form-urlencoded";
string paraUrl = HttpUtility.UrlEncode("请求的参数");
paraUrl = paraUrl + "=" + HttpUtility.UrlEncode(city, Encoding.GetEncoding("GB2312"));
byte[] paraByte= Encoding.GetEncoding("GB2312").GetBytes(paraUrl);
request.ContentLength = paraByte.Length;
Stream writer = request.GetRequestStream();
writer.Write(paraByte,0,paraByte.Length);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s= response.GetResponseStream();
StreamReader objReader = new StreamReader(s,Encoding.GetEncoding("GB2312"));
string strHTML = "";
string strLine = "";
int i = 0;
while (strLine!=null)
{
i++;
strLine = objReader.ReadLine();
if (strLine!=null)
strHTML += strLine;
}
strHTML = strHTML .Replace("<","<");
strHTML = strHTML .Replace(">",">");
这里的strHTML就是这个得到的html内容 然后进行字符串操作 就可以得到自己想要的信息了
下面就是实现的原理:
通过请求别人的服务器,通过得到的服务器的返回的数据进行 自己组装和拆分的到自己想要的内容 显示在页面上的下面是一个例子。
string strURL = "其他网站的地址";
HttpWebRequest request= (HttpWebRequest)WebRequest.Create(strURL);
request.Method="POST";
request.ContentType="application/x-www-form-urlencoded";
string paraUrl = HttpUtility.UrlEncode("请求的参数");
paraUrl = paraUrl + "=" + HttpUtility.UrlEncode(city, Encoding.GetEncoding("GB2312"));
byte[] paraByte= Encoding.GetEncoding("GB2312").GetBytes(paraUrl);
request.ContentLength = paraByte.Length;
Stream writer = request.GetRequestStream();
writer.Write(paraByte,0,paraByte.Length);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s= response.GetResponseStream();
StreamReader objReader = new StreamReader(s,Encoding.GetEncoding("GB2312"));
string strHTML = "";
string strLine = "";
int i = 0;
while (strLine!=null)
{
i++;
strLine = objReader.ReadLine();
if (strLine!=null)
strHTML += strLine;
}
strHTML = strHTML .Replace("<","<");
strHTML = strHTML .Replace(">",">");
这里的strHTML就是这个得到的html内容 然后进行字符串操作 就可以得到自己想要的信息了