asp.NetはコンピュータMACアドレスによって1台あたり1回のアカウントしか受け取れないことを制限します
4263 ワード
次から始めましょう.
まず簡単なフロントコードを書きます.
まず簡単なフロントコードを書きます.
もう1つのバックグラウンドコードを書いて、注釈はすでにはっきり言って、ここは多く言いません!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using System.Diagnostics;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
labName.Text = labPass.Text = "";
}
protected void getNamePass_Click(object sender, EventArgs e)
{
// IP
string IP = Request.UserHostAddress;
//
string dirResults = "";
// ProcessStartInfo
ProcessStartInfo psi = new ProcessStartInfo();
// Process
Process proc = new Process();
//
psi.FileName = "nbtstat";
// Process.StandardInput
psi.RedirectStandardInput = false;
// Process.StandardOutput
psi.RedirectStandardOutput = true;
//
psi.Arguments = "-A " + IP;
//
psi.UseShellExecute = false;
//
proc = Process.Start(psi);
// StandardOutput
dirResults = proc.StandardOutput.ReadToEnd();
// Process
proc.WaitForExit();
// StandardOutput "/r,/n,/t"
dirResults = dirResults.Replace("\r", "").Replace("
", "").Replace("\t", "");
//
Regex reg = new Regex("MAC[ ]{0,}Address[ ]{0,}=[ ]{0,}(?((.)*?))MAC", RegexOptions.IgnoreCase | RegexOptions.Compiled);
// StandardOutput "MAC"
dirResults = dirResults + "MAC";
// Cookie
HttpCookie oldCookie = Request.Cookies["netCard"];
//
Match mc = reg.Match(dirResults);
// “-”
string networkCard = mc.Groups["key"].Value.Replace("-", "");
// Cookie
if (oldCookie == null)
{
//
if (mc.Success)
{
//
labName.Text = " :" + networkCard;
//
labPass.Text = " :1234";
// Cookie
HttpCookie newCookie = new HttpCookie("netCard");
// Cookie
newCookie.Expires = DateTime.MaxValue;
// Cookie
newCookie.Values.Add("numberCard", networkCard);
// Cookie Cookie
Response.Cookies.Add(newCookie);
}
else
{
RegisterStartupScript("", "alert(' !'); ");
}
}
else
{
// Cookie
string numberCard = oldCookie.Values["numberCard"];
// Cookie
if (numberCard.Trim() == networkCard.Trim())
{
RegisterStartupScript("", "alert(' ! 。') ");
}
else
{
//
if (mc.Success)
{
//
labName.Text = " :" + networkCard;
//
labPass.Text = " :1234";
// Cookie
oldCookie.Values.Set("numberCard", networkCard);
// Cookie Cookie
Response.Cookies.Add(oldCookie);
}
else
{
RegisterStartupScript("", "alert(' !'); ");
}
}
}
}
}