WebClient wc = new WebClient();
wc.Encoding = Encoding.Utf8;
for(int i=0;i<500;i++)
{
string flag = wc.DownloadString("http://xxxx/xxx.aspx?TextBox1=admin+"&TextBox2="+i+");
if(flag.Contains("true"))
{
Console.Write("密码是:"+i);
}
}
//暴力注册
在页面中使用WebBrowser控件,执行注册页面,然后注册
WebBrowser1.Document.GetElementById("TextBox1").SetAttribute("Value","aaa");
WebBrowser1.Document.GetElementById("TextBox2").SetAttribute("Value","bbb");
WebBrowser1.Document.GetElementById("Button1").InvokeMember("Click");
防止注册机器人的办法:
1、加注册验证码
2、有限次数的登录锁定
Session登录验证
public class XXX:IHttpHandler,IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/JPEG";
using(Bitmap bitmap = new Bitmap(100,50))
{
using(Graphics g = Graphics.FromImage(bitmap))
{
Random rd = new Random();
int code = rd.Next();
string strCode = code.ToString();
g.DrawString(strCode,new Font("Arial",20),Brushes.Green,new PointF(0,0));
//保存到Session中,需要实现IRequiresSessionState接口
HttpContext.Current.Session["Code"] = strCode;
//可以画一些折线
g.DrawEllipse(Pens.Red,new Rectangle(10,10,10,10));
bitmap.Save(context.Response.OutputStream,ImageFormat.Jpeg);
}
}
}
}
在页面中放一个Image控件来显示该图片,然后通过比较输入的验证码和Session中保存的值进行比较判断。
<img src="xxx.ashx" onclick="this.src=xxx.ashx?tag='+new Date() "/>
通用json解析方法:http://www.cnblogs.com/loalongblogs/archive/2011/09/03/2165406.html
C# Socket通信(聊天程序):http://www.cnblogs.com/guoyiqi/archive/2011/07/26/2139181.html
string fullpath = op.FileName; // 一行代码就可以读取全部字节数据 byte[] imagebytes = File.ReadAllBytes(fullpath); // sql 中添加参数 boperate.getcommand("update OrphanInfo set Images=@images where OID='" + textID.Text.Trim() + "'"); // 创建一个 sql 参数实例 SqlParameter sp = new SqlParameter(); sp.ParameterName = "@images"; sp.SqlDbType = SqlDbType.Binary; sp.Value = imagebytes; // 在后面的代码中通过 SqlCommand.Parameters.Add(sp) 添加参数,再执行 ExecuteNonQuery
信息提示
<!--这个是html代码-->
<div id="div1" style="display: none; width:300px; position: absolute">
<table border="0" style="border:2px solid green" cellpadding="0">
<tr>
<td id="td_N" align="center" height="20px" style="color:#004080;background:ECF5FF">
<strong>提示信息</strong>
</td>
</tr>
<tr>
<td id="td1" height="25px" style="color: black;background:white;">
</td>
</tr>
</table>
</div>
<!--下面的则是js的显示隐藏方法-->
function Show(content) {
document.getElementById("td1").innerText = "" + content;
x = event.clientX + document.body.scrollLeft;
y = event.clientY + document.body.scrollTop + 30;
div1.style.display = "block";
div1.style.left = x;
div1.style.top = y;
}
function Hide() {
div1.style.display = "none";
}