Linksys路由器自动重启加流量

解决方法完整代码

 

代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using Pucome.com;

namespace Linksys路由器自动重启加流量
{
    
public partial class Form1 : Form
    {
        
public Form1()
        {
            InitializeComponent();
        }
        HttpRequest http
=new HttpRequest();
        
private void Form1_Load(object sender, EventArgs e)
        {
            
            
//http.Referer = "http://192.168.15.1/";
            SetAllowUnsafeHeaderParsing();
            http.OpenRequest(
"http://192.168.15.1/","");
            textBox1.Text 
= http.HtmlDocument;
        }

        
private void button1_Click(object sender, EventArgs e)
        {
            http.OpenRequest(
"http://192.168.15.1/cgi-bin/webcm""http://192.168.15.1/cgi-bin/webcm?getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html",
                             
"security%3Acommand%2Flogout=&getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fhome.html&errorpage=%2Fusr%2Fwww_safe%2Findex.html&var%3Apagename=home&login%3Acommand%2Fusername_ja=admin&login%3Acommand%2Fpassword_ja=admin&var%3Arequestfrom=");
            textBox1.Text 
= http.HtmlDocument;
        }

        
private void button2_Click(object sender, EventArgs e)
        {
            http.OpenRequest(
                
"http://192.168.15.1/cgi-bin/webcm?getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html""");
            textBox1.Text 
= http.HtmlDocument;
        }

        
private void button3_Click(object sender, EventArgs e)
        {
            http.OpenRequest(
"http://192.168.15.1/cgi-bin/webcm""",
                             
"getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html&errorpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html&var%3Apagename=pppoe&var%3Aerrorpagename=&connection0%3Apppoe%3Acommand%2Fstop=1&var%3Aconnect=0");
            textBox1.Text 
= http.HtmlDocument;
        }

        
private void button4_Click(object sender, EventArgs e)
        {
            http.OpenRequest(
"http://192.168.15.1/cgi-bin/webcm""",
                 
"getpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html&errorpage=%2Fusr%2Fwww_safe%2Fhtml%2Fstatus%2FRouter.html&var%3Apagename=pppoe&var%3Aerrorpagename=&connection0%3Apppoe%3Acommand%2Fstart=1&var%3Aconnect=1");
            textBox1.Text 
= http.HtmlDocument;
        }

        
public static bool SetAllowUnsafeHeaderParsing()
        {
            
//Get the assembly thatConfiguration contains the internal class
            Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection));
            
if (aNetAssembly != null)
            {
                
//Use the assembly in order to get the internal type for                 
                
// the internal class                 
                Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal");
                
if (aSettingsType != null)
                {
                    
//Use the internal static property to get an instance                     
                    
// of the internal settings class. If the static instance                     
                    
// isn't created allready the property will create it for us.                     
                    object anInstance = aSettingsType.InvokeMember("Section",
                        BindingFlags.Static 
| BindingFlags.GetProperty | BindingFlags.NonPublic, nullnullnew object[] { });
                    
if (anInstance != null)
                    {
                        
//Locate the private bool field that tells the                         
                        
// framework is unsafe header parsing should be                         
                        
// allowed or not                         
                        FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance); if (aUseUnsafeHeaderParsing != null) { aUseUnsafeHeaderParsing.SetValue(anInstance, true); return true; }
                    }
                }
            } 
return false;
        }
    }
}

 

 

posted on 2010-05-02 00:16  welcomesay  阅读(1054)  评论(0编辑  收藏  举报

导航