public static List <string> GetMcAfeeSitelistFiles() { //From SharpUP List <string> results = new List <string>(); try { string drive = System.Environment.GetEnvironmentVariable("SystemDrive"); string[] SearchLocations = { String.Format("{0}\\Program Files\\", drive), String.Format("{0}\\Program Files (x86)\\", drive), String.Format("{0}\\Documents and Settings\\", drive), String.Format("{0}\\Users\\", drive) }; foreach (string SearchLocation in SearchLocations) { List <string> files = MyUtils.FindFiles(SearchLocation, "SiteList.xml"); foreach (string file in files) { results.Add(file); } } } catch (Exception ex) { Console.WriteLine(String.Format(" [X] Exception: {0}", ex.Message)); } return(results); }
public static List <string> ListUsersDocs() { List <string> results = new List <string>(); try { // returns files (w/ modification dates) that match the given pattern below string patterns = "*diagram*;*.pdf;*.vsd;*.doc;*docx;*.xls;*.xlsx"; if (MyUtils.IsHighIntegrity()) { string searchPath = String.Format("{0}\\Users\\", Environment.GetEnvironmentVariable("SystemDrive")); List <string> files = MyUtils.FindFiles(searchPath, patterns); foreach (string file in files) { DateTime lastAccessed = System.IO.File.GetLastAccessTime(file); DateTime lastModified = System.IO.File.GetLastWriteTime(file); results.Add(file); } } else { string searchPath = Environment.GetEnvironmentVariable("USERPROFILE"); List <string> files = MyUtils.FindFiles(searchPath, patterns); foreach (string file in files) { DateTime lastAccessed = System.IO.File.GetLastAccessTime(file); DateTime lastModified = System.IO.File.GetLastWriteTime(file); results.Add(file); } } } catch (Exception ex) { Beaprint.GrayPrint("Error: " + ex); } return(results); }
public static Dictionary <string, Dictionary <string, string> > GetCachedGPPPassword() { //From SharpUP Dictionary <string, Dictionary <string, string> > results = new Dictionary <string, Dictionary <string, string> >(); try { string allUsers = System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE"); if (!allUsers.Contains("ProgramData")) { // Before Windows Vista, the default value of AllUsersProfile was "C:\Documents and Settings\All Users" // And after, "C:\ProgramData" allUsers += "\\Application Data"; } allUsers += "\\Microsoft\\Group Policy\\History"; // look only in the GPO cache folder List <String> files = MyUtils.FindFiles(allUsers, "*.xml"); // files will contain all XML files foreach (string file in files) { if (!(file.Contains("Groups.xml") || file.Contains("Services.xml") || file.Contains("Scheduledtasks.xml") || file.Contains("DataSources.xml") || file.Contains("Printers.xml") || file.Contains("Drives.xml"))) { continue; // uninteresting XML files, move to next } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file); if (!xmlDoc.InnerXml.Contains("cpassword")) { continue; // no "cpassword" => no interesting content, move to next } Console.WriteLine("\r\n{0}", file); string cPassword = ""; string UserName = ""; string NewName = ""; string Changed = ""; if (file.Contains("Groups.xml")) { XmlNode a = xmlDoc.SelectSingleNode("/Groups/User/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/Groups/User"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("userName")) { UserName = attr.Value; } if (attr.Name.Equals("newName")) { NewName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } //Console.WriteLine("\r\nA{0}", a.Attributes[0].Value); } else if (file.Contains("Services.xml")) { XmlNode a = xmlDoc.SelectSingleNode("/NTServices/NTService/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/NTServices/NTService"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("accountName")) { UserName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } } else if (file.Contains("Scheduledtasks.xml")) { XmlNode a = xmlDoc.SelectSingleNode("/ScheduledTasks/Task/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/ScheduledTasks/Task"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("runAs")) { UserName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } } else if (file.Contains("DataSources.xml")) { XmlNode a = xmlDoc.SelectSingleNode("/DataSources/DataSource/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/DataSources/DataSource"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("username")) { UserName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } } else if (file.Contains("Printers.xml")) { XmlNode a = xmlDoc.SelectSingleNode("/Printers/SharedPrinter/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/Printers/SharedPrinter"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("username")) { UserName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } } else { // Drives.xml XmlNode a = xmlDoc.SelectSingleNode("/Drives/Drive/Properties"); XmlNode b = xmlDoc.SelectSingleNode("/Drives/Drive"); foreach (XmlAttribute attr in a.Attributes) { if (attr.Name.Equals("cpassword")) { cPassword = attr.Value; } if (attr.Name.Equals("username")) { UserName = attr.Value; } } foreach (XmlAttribute attr in b.Attributes) { if (attr.Name.Equals("changed")) { Changed = attr.Value; } } } if (UserName.Equals("")) { UserName = "******"; } if (NewName.Equals("")) { NewName = "[BLANK]"; } if (cPassword.Equals("")) { cPassword = "******"; } else { cPassword = DecryptGPP(cPassword); } if (Changed.Equals("")) { Changed = "[BLANK]"; } results[file] = new Dictionary <string, string>(); results[file]["UserName"] = UserName; results[file]["NewName"] = NewName; results[file]["cPassword"] = cPassword; results[file]["Changed"] = Changed; } } catch (Exception ex) { Console.WriteLine(String.Format(" [X] Exception: {0}", ex.Message)); } return(results); }