C#做登陆器!

kwanok 2010-11-03 05:48:48
我们学校用的是天翼校园网,每次都要打开网页来登录,那么请问我可以用C#做一个软件来登录吗?包括有自动登录的功能!记住密码功能都可以!(有人用易语言做了一个简单的!但不能自动登录!)
...全文
222 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
huwen7565833 2010-11-04
  • 打赏
  • 举报
回复
关注!!!
  • 打赏
  • 举报
回复
可以,你把用户名和密码存在客户端,当然要加密,就行了
fs_rong123 2010-11-04
  • 打赏
  • 举报
回复
星云飞龙 2010-11-04
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<!-- CSS样式文件 -->
<link id="css" rel="stylesheet" type="text/css" href="/pub/web_green.css">
<link id="css" rel="stylesheet" type="text/css" href="/pub/webui.css">
<link id="css" rel="stylesheet" type="text/css" href="/pub/web.css">
<title>湖南电信业务支撑系统</title>

</head>

<body topmargin="0" leftmargin="0" bgcolor="#D0E0F6" scroll="no"
onkeypress="Enter()">
<form method="POST" target="_parent" name="mainForm"
action="/TCRM/login">

<table border="0" width="100%" cellspacing="0" cellpadding="0"
background="/common/images/dl-topde.jpg"
height="265">
<tr>
<td width="50%" valign="top">
<table border="0" width="100%" height="265" cellspacing="0"
cellpadding="0">
<tr>
<td width="100%" valign="top" height="187"><img border="0"
src="/common/images/dl-top001.jpg"
width="580" height="187"></td>
</tr>
<tr>
<td width="100%" height="78"><img border="0"
src="/common/images/dl-top003.gif"
width="580" height="78" id="log_pic"></td>
</tr>
</table>
</td>
<td width="50%">
<p align="right"><img border="0"
src="/common/images/dl-top02.jpg"
width="407" height="265" onClick="window_close()">
</td>
</tr>
</table>
<table border="0" width="100%" height="477" cellspacing="0"
cellpadding="0">
<tr>
<td width="100%" valign="top">
<div align="center">
<center>
<table border="0" width="367" cellspacing="0" cellpadding="0">
<tr>
<td width="358" colspan="5" height="100"></td>
</tr>

<tr>
<td width="102" valign="top">
<p align="right"><img border="0"
src="/common/images/dl-yyxz.gif"
width="62" height="17">
</td>
<center>
<td width="10" valign="middle"><img border="0"
src="/common/images/dl-dian.gif"
width="7" height="7"></td>
<td width="53" valign="middle"><img border="0"
src="/common/images/dl-english.gif"
width="50" height="17"></td>
<td width="10" valign="middle"><img border="0"
src="/common/images/dl-dian.gif"
width="7" height="7"></td>
<td width="188" valign="middle"><img border="0"
src="/common/images/dl-china.gif"
width="59" height="17"></td>
</tr>
<tr>
<td width="358" colspan="5"><img border="0"
src="/common/images/dl-yhdl.gif"
width="244" height="33"></td>
</tr>
<tr>
<td width="358" colspan="5" valign="top">
<table border="0" width="102%" cellspacing="0" cellpadding="0">
<tr>
<td width="27%">IP</td>
<td width="25%">
<SCRIPT language="JavaScript">
var ipinfo = "134.164.11.34";
document.write(ipinfo);
</SCRIPT>
</td>
</tr>
<tr>
<td width="27%">用户名</td>
<td width="25%">
<input type="hidden" id='submitFlag' name='submitFlag' value="0">
<input type="text" id="j_username" name="j_username" size="14">
</td>
<td width="50%" rowspan="2">
<img border="0" src="/common/images/dl-login.gif"
width="59" height="61" onClick="login_check()" style="cursor:hand">
</td>
</tr>
<tr>
<td width="27%">密  码</td>
<td width="25%">
<input type="password" id="j_password" name="j_password" size="14" onmouseout="">
<SPAN id="message"></SPAN>
</td>
</tr>
<tr>
<td width="27%">验证码</td>
<td width="25%"><script>
document.write("<img border=0 src='/TCRM/image.jsp'>");
</script></td>
</tr>
<tr>
<td width="27%">输认证码</td>
<td width="25%"><input name="rand" maxlength=4 size="20"></td>
</tr>
<tr>
<td colspan=2 align="middle"><input type="radio" name="userAttr"
value=0 checked>本地用户登陆  <input type="radio" name="userAttr"
value=1>域用户登陆</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
<table border="0" width="100%" bgcolor="#FFFFFF" height="1"
cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><img border="0"
src="/common/images/dl-bottom-line.gif"
width="8" height="1"></td>
</tr>
</table>
<table border="0" width="1004" cellspacing="0" cellpadding="0"
bgcolor="#75C4F5" height="26">
<tr>
<td width="561" valign="top"><img border="0"
src="/common/images/dl-bottom.gif"
width="560" height="26"></td>
<td width="268">
<p align="right"><img border="0"
src="/common/images/dl-bottom-logo.gif"
width="70" height="26"></p>
</td>
<td width="189">
<p align="left" style="margin-top: 6">湖南创发天辰科技有限责任公司 
</td>
</tr>
</table>
<SCRIPT language='javascript'>
window_onload();
initpage();
</script> </From>
</body>

</html>
登陆代码(有验证码)如下
private void button5_Click(object sender, EventArgs e)
{
string strText = "";
try{

System.Drawing.Image img = GetRegCodePic(webBrowser1, "", "/TCRM/image.jsp", "");
int width = img.Width * 4;
int height = img.Height * 4;
System.Drawing.Image imgFlax = new System.Drawing.Bitmap(width, height);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(imgFlax);
g.DrawImage(img, new Rectangle(0, 0, width - 1, height - 1));

imgFlax.Save("bmptxt.tif", ImageFormat.Tiff);
img.Dispose();
imgFlax.Dispose();
MODI.Document md = new MODI.Document();
// The Create method grabs the picture from
// disk snd prepares for OCR.
md.Create("bmptxt.tif");
// Do the OCR.
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);

// This string will contain the text.

// Get the first (and only image)
MODI.Image image = (MODI.Image)md.Images[0];
// Get the layout.
MODI.Layout layout = image.Layout;

// Loop through the words.
for (int j = 0; j < layout.Words.Count; j++)
{
// Get this word.
MODI.Word word = (MODI.Word)layout.Words[j];
// Add a blank space to separate words.
if (strText.Length > 0)
{
strText += " ";
}
// Add the word.
strText += word.Text;
}
// Close the MODI.Document object.

md.Close(false);
}
catch
{
strText = "????";
}
HtmlDocument objDoc = webBrowser1.Document;
objDoc.All["j_username"].SetAttribute("value", "734HYS0315");
objDoc.All["j_password"].SetAttribute("value", "aczdsx1234");
objDoc.All["rand"].SetAttribute("value", strText);

objDoc.Images[GetPicIndex(webBrowser1, "/common/images/dl-login.gif", "")].InvokeMember("click");

}
public static Image GetRegCodePic(WebBrowser wbMail, string ImgName, string Src, string Alt)
{
HTMLDocument doc = (HTMLDocument)wbMail.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
IHTMLControlRange rang = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement Img;
if (ImgName == "") //如果没有图片的名字,通过Src或Alt中的关键字来取
{
int ImgNum = GetPicIndex(wbMail, Src, Alt);
if (ImgNum == -1) return null;
Img = (IHTMLControlElement)wbMail.Document.Images[ImgNum].DomElement;
}
else
Img = (IHTMLControlElement)wbMail.Document.All[ImgName].DomElement;

rang.add(Img);
rang.execCommand("Copy", false, null);
Image RegImg = Clipboard.GetImage();
Clipboard.Clear();
return RegImg;
}

public static int GetPicIndex(WebBrowser wbMail, string Src, string Alt)
{
int imgnum = -1;
for (int i = 0; i < wbMail.Document.Images.Count; i++) //获取所有的Image元素
{
IHTMLImgElement img = (IHTMLImgElement)wbMail.Document.Images[i].DomElement;

if (Alt == "")
{
if (img.src.Contains(Src)) return i;
}
else
{
if (!string.IsNullOrEmpty(img.alt))
{
if (img.alt.Contains(Alt)) return i;
}
}
}
return imgnum;
}
a82344626 2010-11-04
  • 打赏
  • 举报
回复
能做!
会POST数据就行了~
http://hi.baidu.com/panyuan1988/blog/item/b1904e955538d46154fb96f7.html
用COOKIE方式来登陆
解密登陆算法!
peng2739956 2010-11-04
  • 打赏
  • 举报
回复
当然可以啊 把你的账号密码保存你写的登录代码块中 你也不需要做什么 花俏的东西 只需要一个按钮
然后 点了之后 通过http服务连接到 校园网的登录的子页 然后将账号密码写入 登录就行了 当然咯你要截取下login的完整地址才行 就像做QQ农场外挂差不多 也是这种模式 不过就是QQ农场外挂用了多线程罢了

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧