using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Http;
using System.IO;
using System.Net.NetworkInformation;
using System.Threading;
namespace FinAutoLogin
{
class Program
{
static void Main(string[] args)
{
var ok = ShowNetworkInterfaces();
if (ok)
{
Console.WriteLine("æ¬å°ç½ç»è®¾å¤æ£æ¥å®æï¼");
}
else
{
Console.WriteLine("æ¬å°ç½ç»æªå°±ç»ªï¼è¯·æ£æ¥ç½å¡æç½çº¿æ¯å¦æ£å¸¸ï¼");
Console.Read();
return;
}
Console.WriteLine();
System.Net.ServicePointManager.Expect100Continue = false;
Console.WriteLine("æ£å¨è¯·æ±ç½å
³éªè¯æå¡...");
CookieContainer cc = new CookieContainer();
string postData = "username=XXXX&userpwd=XXXX&login=åæ°å¼å
¶ä»";
byte[] byteArray = Encoding.UTF8.GetBytes(postData); // 转å
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("
http://172.16.10.252/cgi-bin/ace_web_auth.cgi"));
request.CookieContainer = cc;
request.Method = "POST";
request.Referer = "
http://172.16.100.252/login.php";
request.Accept = "text/html, application/xhtml+xml, */*";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko";
request.AllowAutoRedirect = true;
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream newStream = request.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //åå
¥åæ°
newStream.Close();
Console.WriteLine("æ£å¨è§£æç½å
³ååº...");
HttpWebResponse response2 = (HttpWebResponse)request.GetResponse();
StreamReader sr2 = new StreamReader(response2.GetResponseStream(), Encoding.Default);
string text2 = sr2.ReadToEnd();
if (text2.IndexOf("window.location") > -1)
{
Console.WriteLine("ç½å
³æ³¨åæåï¼");
}
else
{
Console.WriteLine(text2);
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("æä»»æé®å
³éçªå£ï¼");
Console.ReadKey();
}
Console.WriteLine("ä¸ç§åç³»ç»èªå¨éåï¼");
Thread.Sleep(3000);
}
public static bool ShowNetworkInterfaces()
{
bool isFoundNetWork = false;
Console.WriteLine("æ£å¨æ£æ¥æ¬å°ç½ç»ä¿¡æ¯...");
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces().Where(p=>p.NetworkInterfaceType== NetworkInterfaceType.Ethernet || p.NetworkInterfaceType== NetworkInterfaceType.Wireless80211).ToArray();
Console.WriteLine("{0}.{1} çç½ç»æ¥å£ä¿¡æ¯ï¼ ",computerProperties.HostName, computerProperties.DomainName);
if (nics == null || nics.Length < 1)
{
Console.WriteLine(" æªåç°ç½ç»æ¥å£è®¾å¤.");
return false;
}
Console.WriteLine(" åç°ç½ç»æ¥å£è®¾å¤.................... : {0} 个", nics.Length);
foreach (NetworkInterface adapter in nics)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
Console.WriteLine();
Console.WriteLine(adapter.Name+"---"+adapter.Description);
Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, '='));
Console.WriteLine(" æ¥å£ç±»å .......................... : {0}", adapter.NetworkInterfaceType);
Console.WriteLine(" ç©çå°å .......................... : {0}", adapter.GetPhysicalAddress().ToString());
Console.WriteLine(" 设å¤ç¶æ .......................... : {0}", adapter.OperationalStatus);
if(adapter.OperationalStatus== OperationalStatus.Up)
{
isFoundNetWork = true;
}
string versions = "";
// Create a display string for the supported IP versions.
if (adapter.Supports(NetworkInterfaceComponent.IPv4))
{
versions = "IPv4";
}
if (adapter.Supports(NetworkInterfaceComponent.IPv6))
{
if (versions.Length > 0)
{
versions += " ";
}
versions += "IPv6";
}
Console.WriteLine(" IP version .......................... : {0}", versions);
// ShowIPAddresses(properties);
// The following information is not useful for loopback adapters.
// if (adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback || adapter.NetworkInterfaceType== NetworkInterfaceType.Tunnel)
// {
// continue;
// }
Console.WriteLine(" DNS suffix .............................. : {0}",
properties.DnsSuffix);
string label;
if (adapter.Supports(NetworkInterfaceComponent.IPv4))
{
IPv4InterfaceProperties ipv4 = properties.GetIPv4Properties();
Console.WriteLine(" MTU.................................. : {0}", ipv4.Mtu);
if (ipv4.UsesWins)
{
IPAddressCollection winsServers = properties.WinsServersAddresses;
if (winsServers.Count > 0)
{
label = " WINS Servers ......................... :";
// ShowIPAddresses(label, winsServers);
}
}
}
Console.WriteLine(" DNS enabled .......................... : {0}",
properties.IsDnsEnabled);
Console.WriteLine(" Dynamically configured DNS ........... : {0}",
properties.IsDynamicDnsEnabled);
Console.WriteLine(" Receive Only ......................... : {0}",
adapter.IsReceiveOnly);
Console.WriteLine(" Multicast ............................ : {0}",
adapter.SupportsMulticast);
// ShowInterfaceStatistics(adapter);
}
return isFoundNetWork;
}
}
}
追é®
æ¯å¦è¿ä¸ªç»éæ¡ï¼ææ³ä¼ éç¨æ·ååå¯ç å°æå¡å¨ï¼phpæ件ï¼ä¸ï¼ç¶åæå¡å¨å¤æç¨æ·ååå¯ç æ¯å¦æ£ç¡®ï¼è¿åä¸ä¸ªåæ°ãæ³ç¥éè¿ä¸ªä»£ç ï¼ä¸ç¨åé£ä¹å¤æï¼è½ä¸è½å¸®æç®åä¸ç¹ï¼åªåä¸ªä¼ éå°æå¡å¨å°±å¥½ã
追çSystem.Net.ServicePointManager.Expect100Continue = false;
å°
Console.WriteLine("ç½å
³æ³¨åæåï¼"); ä¹é´ç代ç æ¯å¿
éçã
åå¤ä¸äºï¼è¯´åæ°éå¶ï¼åªè½ä¸é¢ç®åç¹