Skip to content

Instantly share code, notes, and snippets.

@AlbertoMonteiro
Created August 2, 2012 14:32
Show Gist options
  • Save AlbertoMonteiro/3237491 to your computer and use it in GitHub Desktop.
Save AlbertoMonteiro/3237491 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Net;
namespace ConsoleApplication9
{
class Program
{
static string str = @"------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""fw_username""
TEU
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""fw_password""
TEU
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""fw_domain""
Active Directory
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""submit""
Login
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""action""
fw_logon
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""style""
fw_logon_progress.xsl
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
Content-Disposition: form-data; name=""fw_logon_type""
logon
------WebKitFormBoundaryoCMA9W1hTtsLzZ8e--";
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
ServicePointManager.Expect100Continue = false;
var webRequest = (HttpWebRequest)HttpWebRequest.Create("https://10.1.254.250:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=logout");
webRequest.Method = "POST";
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
webRequest.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
webRequest.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
webRequest.Headers.Add("Accept-Language", "pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4");
webRequest.Headers.Add("Cache-Control", "max-age=0");
webRequest.ContentType = "multipart/form-data; boundary=----WebKitFormBoundaryoCMA9W1hTtsLzZ8e";
webRequest.Headers.Add("Cookie", "domain=Active Directory; username=albertomonteiro");
webRequest.Headers.Add("Origin", "https://10.1.254.250:4100");
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11";
using(var stream = new StreamWriter(webRequest.GetRequestStream()))
stream.Write(str);
var webResponse = webRequest.GetResponse();
using(var strR = new StreamReader(webResponse.GetResponseStream()))
Console.WriteLine(strR.ReadToEnd());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment