├── docs └── clamshell_logo.png ├── ClamShell ├── config.json ├── Properties │ └── launchSettings.json ├── Services │ ├── Interfaces │ │ ├── IScanService.cs │ │ └── IMessageHandler.cs │ ├── ScanService.cs │ └── MessageHandler.cs ├── Helpers │ ├── UrlExtractor.cs │ └── EmbedHelper.cs ├── ClamShell.Bot.csproj └── Program.cs ├── ClamShell.ClamServer ├── config.json ├── appsettings.json ├── appsettings.Development.json ├── Properties │ └── launchSettings.json ├── Helpers │ └── ConfigExtractor.cs ├── Program.cs ├── ClamShell.ClamServer.csproj ├── Services │ └── HasherService.cs └── Worker.cs ├── ClamShell.MessageBus ├── Models │ ├── Enums │ │ ├── ScanType.cs │ │ └── Status.cs │ ├── TransferModel.cs │ └── Payloads │ │ ├── ScanRequestData.cs │ │ └── DiscordMessageData.cs ├── ClamShell.MessageBus.csproj ├── Publisher.cs └── Consumer.cs ├── .dockerignore ├── Dockerfile ├── ClamShell.sln ├── .gitattributes ├── README.md └── .gitignore /docs/clamshell_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qolors/Clam-Shell/HEAD/docs/clamshell_logo.png -------------------------------------------------------------------------------- /ClamShell/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Settings": { 3 | "BOT_TOKEN": "", 4 | "WEBHOOK_URL": "", 5 | "USE_LOGS": true, 6 | "USE_REACTIONS": true 7 | } 8 | } -------------------------------------------------------------------------------- /ClamShell.ClamServer/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Settings": { 3 | "BOT_TOKEN": "", 4 | "WEBHOOK_URL": "", 5 | "USE_LOGS": true, 6 | "USE_REACTIONS": true 7 | } 8 | } -------------------------------------------------------------------------------- /ClamShell.ClamServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ClamShell/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "ClamShell": { 4 | "commandName": "Project" 5 | }, 6 | "Docker": { 7 | "commandName": "Docker" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /ClamShell.MessageBus/Models/Enums/ScanType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClamShell.MessageBus.Models.Enums 8 | { 9 | public enum ScanType 10 | { 11 | File, 12 | URL 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ClamShell/Services/Interfaces/IScanService.cs: -------------------------------------------------------------------------------- 1 | namespace ClamShell.Bot.Services.Interfaces 2 | { 3 | public interface IScanService 4 | { 5 | void ScanUrl(byte[] url, ulong channelId, ulong messageId, string channelName); 6 | void ScanFile(byte[] file, ulong channelId, ulong messageId, string channelName); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ClamShell/Services/Interfaces/IMessageHandler.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus.Models.Payloads; 2 | using ClamShell.MessageBus.Models; 3 | using Discord.WebSocket; 4 | 5 | namespace ClamShell.Bot.Services.Interfaces 6 | { 7 | public interface IMessageHandler 8 | { 9 | Task HandleMessageAsync(SocketMessage message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ClamShell.MessageBus/Models/Enums/Status.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClamShell.MessageBus.Models.Enums 8 | { 9 | public enum Status 10 | { 11 | Clean, 12 | Infected, 13 | Error 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "ClamShell.ClamServer": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "DOTNET_ENVIRONMENT": "Development" 7 | }, 8 | "dotnetRunMessages": true 9 | }, 10 | "Docker": { 11 | "commandName": "Docker" 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /ClamShell.MessageBus/Models/TransferModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using ClamShell.MessageBus.Models.Enums; 7 | 8 | namespace ClamShell.MessageBus.Models 9 | { 10 | public class TransferModel 11 | { 12 | public T Data { get; set;} 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /ClamShell.MessageBus/Models/Payloads/ScanRequestData.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus.Models.Enums; 2 | 3 | namespace ClamShell.MessageBus.Models.Payloads 4 | { 5 | public class ScanRequestData 6 | { 7 | public ScanType ScanType { get; set; } 8 | public byte[] Data { get; set; } 9 | public ulong ChannelId { get; set; } 10 | public ulong MessageId { get; set; } 11 | public string ChannelName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ClamShell.MessageBus/ClamShell.MessageBus.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ClamShell.MessageBus/Models/Payloads/DiscordMessageData.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus.Models.Enums; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ClamShell.MessageBus.Models.Payloads 9 | { 10 | public class DiscordMessageData 11 | { 12 | public string ChannelName { get; set; } 13 | public ulong ChannelId { get; set; } 14 | public ulong MessageId { get; set; } 15 | public Status Status { get; set; } 16 | public ScanType ScanType { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/Helpers/ConfigExtractor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClamShell.ClamServer.Helpers 8 | { 9 | public class ConfigExtractor 10 | { 11 | public static IConfiguration GetConfiguration() 12 | { 13 | return new ConfigurationBuilder() 14 | .SetBasePath(Directory.GetCurrentDirectory()) 15 | .AddJsonFile("config.json", optional: false, reloadOnChange: true) 16 | .Build(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/Program.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.ClamServer; 2 | using ClamShell.ClamServer.Services; 3 | using ClamShell.MessageBus.Models.Payloads; 4 | using ClamShell.MessageBus; 5 | using ClamShell.ClamServer.Helpers; 6 | using nClam; 7 | 8 | IHost host = Host.CreateDefaultBuilder(args) 9 | .ConfigureServices(services => 10 | { 11 | services 12 | .AddHostedService() 13 | .AddSingleton(ConfigExtractor.GetConfiguration()) 14 | .AddSingleton(new Consumer("scan_request")) 15 | .AddSingleton(new ClamClient(@"clamshell_server", 3310)) 16 | .AddSingleton(); 17 | }) 18 | .Build(); 19 | 20 | await host.RunAsync(); 21 | -------------------------------------------------------------------------------- /ClamShell/Helpers/UrlExtractor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClamShell.Bot.Helpers 8 | { 9 | public static class UrlExtractor 10 | { 11 | public static string? ExtractUrl(string message) 12 | { 13 | string[] words = message.Split(' '); 14 | 15 | foreach (var word in words) 16 | { 17 | if (Uri.TryCreate(word, UriKind.Absolute, out var uriResult) && 18 | (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)) 19 | { 20 | return word; 21 | } 22 | } 23 | 24 | return null; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base 4 | WORKDIR /app 5 | 6 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 7 | WORKDIR /src 8 | COPY ["ClamShell/ClamShell.Bot.csproj", "ClamShell/"] 9 | # Ensure the file exists before copying 10 | COPY ["ClamShell.MessageBus/ClamShell.MessageBus.csproj", "ClamShell.MessageBus/"] 11 | RUN dotnet restore "ClamShell/ClamShell.Bot.csproj" 12 | COPY . . 13 | WORKDIR "/src/ClamShell" 14 | RUN dotnet build "ClamShell.Bot.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "ClamShell.Bot.csproj" -c Release -o /app/publish /p:UseAppHost=false 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "ClamShell.Bot.dll"] 23 | 24 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/ClamShell.ClamServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | dotnet-ClamShell.ClamServer-85814c37-e646-47ca-becb-d4faf4483f00 8 | Linux 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | PreserveNewest 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ClamShell/ClamShell.Bot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | Linux 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | PreserveNewest 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /ClamShell/Services/ScanService.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.Bot.Services.Interfaces; 2 | using ClamShell.MessageBus; 3 | using ClamShell.MessageBus.Models; 4 | using ClamShell.MessageBus.Models.Enums; 5 | using ClamShell.MessageBus.Models.Payloads; 6 | using System.Text; 7 | using System; 8 | 9 | namespace ClamShell.Bot.Services 10 | { 11 | public class ScanService : IScanService 12 | { 13 | public void ScanFile(byte[] fileData, ulong channelId, ulong messageId, string channelName) 14 | { 15 | using var publisher = new Publisher("scan_request"); 16 | 17 | TransferModel transferModel = new TransferModel 18 | { 19 | Data = new ScanRequestData 20 | { 21 | Data = fileData, 22 | ScanType = ScanType.File, 23 | ChannelId = channelId, 24 | MessageId = messageId, 25 | ChannelName = channelName 26 | } 27 | }; 28 | 29 | publisher.Publish(transferModel); 30 | } 31 | 32 | public void ScanUrl(byte[] requestUrl, ulong channelId, ulong messageId, string channelName) 33 | { 34 | using var publisher = new Publisher("scan_request"); 35 | 36 | TransferModel transferModel = new TransferModel 37 | { 38 | Data = new ScanRequestData 39 | { 40 | Data = requestUrl, 41 | ScanType = ScanType.URL, 42 | ChannelId = channelId, 43 | MessageId = messageId, 44 | ChannelName = channelName 45 | } 46 | }; 47 | 48 | publisher.Publish(transferModel); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ClamShell/Helpers/EmbedHelper.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus.Models.Enums; 2 | using Discord; 3 | 4 | namespace ClamShell.Bot.Helpers 5 | { 6 | public static class EmbedHelper 7 | { 8 | public static Embed Build(string content, string author, ScanType scanType) 9 | { 10 | 11 | string description = scanType switch 12 | { 13 | ScanType.File => "The file you uploaded has been detected as a virus and has been removed.", 14 | ScanType.URL => "The URL you shared has been reported as a Phishing site and has been removed.", 15 | _ => "The content you uploaded has been detected as a virus and has been removed." 16 | }; 17 | 18 | string title = scanType switch 19 | { 20 | ScanType.File => "Virus Detected", 21 | ScanType.URL => "Phishing Site Detected", 22 | _ => "Virus Detected" 23 | }; 24 | 25 | string userSummary = scanType switch 26 | { 27 | ScanType.File => "User that uploaded this file", 28 | ScanType.URL => "User that shared this URL", 29 | _ => "User that uploaded this content" 30 | }; 31 | 32 | return new EmbedBuilder() 33 | .WithTitle(title) 34 | .WithDescription(description) 35 | .WithFields(new EmbedFieldBuilder[] { 36 | new EmbedFieldBuilder() 37 | .WithName("Original Message") 38 | .WithValue(string.IsNullOrEmpty(content) ? "_No message was with attachment.._" : "\"" + content + "\"") 39 | .WithIsInline(true), 40 | new EmbedFieldBuilder() 41 | .WithName(userSummary) 42 | .WithValue(author) 43 | .WithIsInline(false) 44 | }) 45 | .WithColor(Color.DarkRed) 46 | .Build(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ClamShell.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34221.43 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClamShell.Bot", "ClamShell\ClamShell.Bot.csproj", "{3273AF8F-2F12-4288-9733-BB449A1432BB}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClamShell.MessageBus", "ClamShell.MessageBus\ClamShell.MessageBus.csproj", "{8B77A07D-3A63-4417-BBF1-3AA2014D8B95}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClamShell.ClamServer", "ClamShell.ClamServer\ClamShell.ClamServer.csproj", "{4E248017-7CE1-4B7E-A51A-F77270DB6478}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {3273AF8F-2F12-4288-9733-BB449A1432BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {3273AF8F-2F12-4288-9733-BB449A1432BB}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {3273AF8F-2F12-4288-9733-BB449A1432BB}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {3273AF8F-2F12-4288-9733-BB449A1432BB}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {8B77A07D-3A63-4417-BBF1-3AA2014D8B95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {8B77A07D-3A63-4417-BBF1-3AA2014D8B95}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {8B77A07D-3A63-4417-BBF1-3AA2014D8B95}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {8B77A07D-3A63-4417-BBF1-3AA2014D8B95}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {4E248017-7CE1-4B7E-A51A-F77270DB6478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {4E248017-7CE1-4B7E-A51A-F77270DB6478}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {4E248017-7CE1-4B7E-A51A-F77270DB6478}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {4E248017-7CE1-4B7E-A51A-F77270DB6478}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9489DB9-106A-4298-AB65-C6B5D9FE59D4} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /ClamShell.MessageBus/Publisher.cs: -------------------------------------------------------------------------------- 1 | using RabbitMQ.Client; 2 | using System.Text.Json; 3 | using System.Text; 4 | using ClamShell.MessageBus.Models; 5 | 6 | namespace ClamShell.MessageBus 7 | { 8 | public class Publisher : IDisposable 9 | { 10 | private const int maxAttempts = 10; 11 | private const int delayMilliseconds = 2000; 12 | private readonly IConnection _connection; 13 | private readonly IModel _channel; 14 | private readonly string _queue; 15 | 16 | public Publisher(string queue) 17 | { 18 | var factory = new ConnectionFactory() { HostName = "rabbitmq" }; 19 | for (int attempt = 1; attempt <= maxAttempts; attempt++) 20 | { 21 | try 22 | { 23 | _connection = factory.CreateConnection(); 24 | break; // Exit the loop if the connection is successful 25 | } 26 | catch (Exception ex) 27 | { 28 | if (attempt == maxAttempts) 29 | { 30 | throw; // Rethrow the exception if the maximum number of attempts is reached 31 | } 32 | Console.WriteLine($"Attempt {attempt} failed: {ex.Message}"); 33 | Console.WriteLine($"Retrying in {delayMilliseconds / 1000} seconds..."); 34 | Thread.Sleep(delayMilliseconds); // Wait before retrying 35 | } 36 | } 37 | _connection = factory.CreateConnection(); 38 | _channel = _connection.CreateModel(); 39 | _queue = queue; 40 | 41 | _channel.QueueDeclare( 42 | queue: _queue, 43 | durable: true, 44 | exclusive: false, 45 | autoDelete: false, 46 | arguments: null); 47 | } 48 | 49 | public void Publish(TransferModel data) 50 | { 51 | var body = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(data)); 52 | 53 | _channel.BasicPublish( 54 | exchange: "", 55 | routingKey: _queue, 56 | basicProperties: null, 57 | body: body); 58 | 59 | System.Console.WriteLine($"Sent message to queue '{_queue}'"); 60 | } 61 | 62 | public void Dispose() 63 | { 64 | _connection?.Dispose(); 65 | _channel?.Dispose(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ClamShell/Program.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.Bot.Services; 2 | using ClamShell.Bot.Services.Interfaces; 3 | using ClamShell.MessageBus; 4 | using ClamShell.MessageBus.Models.Payloads; 5 | using Discord; 6 | using Discord.WebSocket; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Configuration; 9 | 10 | namespace ClamShell.Bot 11 | { 12 | public class Program 13 | { 14 | private static IServiceProvider _services; 15 | public static async Task Main(string[] args) 16 | { 17 | _services = ConfigureServices(); 18 | 19 | var client = _services.GetRequiredService(); 20 | var messageHandler = _services.GetRequiredService(); 21 | 22 | client.Log += LogAsync; 23 | client.Ready += OnReadyAsync; 24 | client.MessageReceived += messageHandler.HandleMessageAsync; 25 | 26 | await client.LoginAsync(TokenType.Bot, _services.GetRequiredService()["Settings:BOT_TOKEN"]); 27 | await client.StartAsync(); 28 | 29 | await Task.Delay(-1); 30 | } 31 | 32 | private static IServiceProvider ConfigureServices() 33 | { 34 | return new ServiceCollection() 35 | .AddSingleton(new DiscordSocketClient(new DiscordSocketConfig 36 | { 37 | LogLevel = LogSeverity.Info, 38 | MessageCacheSize = 50, 39 | GatewayIntents = GatewayIntents.Guilds | GatewayIntents.GuildMessages | GatewayIntents.MessageContent 40 | })) 41 | .AddSingleton() 42 | .AddSingleton() 43 | .AddSingleton(new Consumer("scan_result")) 44 | .AddSingleton(GetConfiguration()) 45 | .BuildServiceProvider(); 46 | } 47 | 48 | private static Task LogAsync(LogMessage log) 49 | { 50 | Console.WriteLine(log.ToString()); 51 | return Task.CompletedTask; 52 | } 53 | 54 | private static Task OnReadyAsync() 55 | { 56 | Console.WriteLine("Clam Shell Running.."); 57 | 58 | return Task.CompletedTask; 59 | } 60 | 61 | private static IConfiguration GetConfiguration() 62 | { 63 | return new ConfigurationBuilder() 64 | .SetBasePath(Directory.GetCurrentDirectory()) 65 | .AddJsonFile("config.json", optional: false, reloadOnChange: true) 66 | .Build(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /ClamShell.MessageBus/Consumer.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus.Models; 2 | using RabbitMQ.Client; 3 | using RabbitMQ.Client.Events; 4 | 5 | namespace ClamShell.MessageBus 6 | { 7 | public class Consumer : IDisposable 8 | { 9 | private const int maxAttempts = 10; 10 | private const int delayMilliseconds = 2000; 11 | private readonly IConnection _connection; 12 | private readonly IModel _channel; 13 | private string _queue; 14 | 15 | public event EventHandler> MessageReceived; 16 | 17 | public Consumer(string queue) 18 | { 19 | var factory = new ConnectionFactory() { HostName = "rabbitmq" }; 20 | for (int attempt = 1; attempt <= maxAttempts; attempt++) 21 | { 22 | try 23 | { 24 | _connection = factory.CreateConnection(); 25 | break; // Exit the loop if the connection is successful 26 | } 27 | catch (Exception ex) 28 | { 29 | if (attempt == maxAttempts) 30 | { 31 | throw; // Rethrow the exception if the maximum number of attempts is reached 32 | } 33 | Console.WriteLine($"Attempt {attempt} failed: {ex.Message}"); 34 | Console.WriteLine($"Retrying in {delayMilliseconds / 1000} seconds..."); 35 | Thread.Sleep(delayMilliseconds); // Wait before retrying 36 | } 37 | } 38 | _connection = factory.CreateConnection(); 39 | _channel = _connection.CreateModel(); 40 | _queue = queue; 41 | 42 | _channel.QueueDeclare(queue: _queue, 43 | durable: true, 44 | exclusive: false, 45 | autoDelete: false, 46 | arguments: null); 47 | 48 | var consumer = new EventingBasicConsumer(_channel); 49 | 50 | consumer.Received += (model, ea) => 51 | { 52 | var body = ea.Body.ToArray(); 53 | var message = System.Text.Encoding.UTF8.GetString(body); 54 | var transferModel = Newtonsoft.Json.JsonConvert.DeserializeObject>(message); 55 | 56 | OnMessageReceived(transferModel); 57 | }; 58 | 59 | _channel.BasicConsume(queue: _queue, 60 | autoAck: true, 61 | consumer: consumer); 62 | } 63 | protected virtual void OnMessageReceived(TransferModel e) 64 | { 65 | MessageReceived?.Invoke(this, e); 66 | } 67 | 68 | public void Dispose() 69 | { 70 | _channel?.Dispose(); 71 | _connection?.Dispose(); 72 | } 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ClamShell/Services/MessageHandler.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.Bot.Helpers; 2 | using ClamShell.Bot.Services.Interfaces; 3 | using ClamShell.MessageBus; 4 | using ClamShell.MessageBus.Models; 5 | using ClamShell.MessageBus.Models.Enums; 6 | using ClamShell.MessageBus.Models.Payloads; 7 | using Discord; 8 | using Discord.WebSocket; 9 | using Microsoft.Extensions.Configuration; 10 | using System.Text; 11 | 12 | namespace ClamShell.Bot.Services 13 | { 14 | public class MessageHandler : IMessageHandler 15 | { 16 | private readonly IScanService _scanService; 17 | private readonly Consumer _consumer; 18 | private readonly DiscordSocketClient _client; 19 | private readonly bool _addReactions; 20 | 21 | public MessageHandler(IScanService scanService, Consumer consumer, DiscordSocketClient client, IConfiguration configuration) 22 | { 23 | _scanService = scanService; 24 | _consumer = consumer; 25 | _client = client; 26 | _addReactions = bool.Parse(configuration["Settings:USE_REACTIONS"]); 27 | 28 | _consumer.MessageReceived += HandleClamNotificationAsync; 29 | } 30 | public async Task HandleMessageAsync(SocketMessage arg) 31 | { 32 | if (arg is not SocketUserMessage message) { return; } 33 | 34 | if (message.Author.Id == _client.CurrentUser.Id || message.Author.IsBot) { return; } 35 | 36 | string? extractedUrl = UrlExtractor.ExtractUrl(message.Content); 37 | 38 | if (extractedUrl is not null) 39 | { 40 | byte[] urlBytes = Encoding.UTF8.GetBytes(extractedUrl); 41 | _scanService.ScanUrl(urlBytes, message.Channel.Id, message.Id, message.Channel.Name); 42 | } 43 | 44 | if (message.Attachments.Count == 0) 45 | { 46 | return; 47 | } 48 | 49 | foreach (IAttachment attachment in message.Attachments) 50 | { 51 | try 52 | { 53 | using (var httpClient = new HttpClient()) 54 | { 55 | byte[] attachmentContent = await httpClient.GetByteArrayAsync(attachment.Url); 56 | 57 | _scanService.ScanFile(attachmentContent, message.Channel.Id, message.Id, message.Channel.Name); 58 | } 59 | } 60 | catch (Exception) 61 | { 62 | Console.WriteLine("Error downloading file"); 63 | } 64 | 65 | } 66 | } 67 | 68 | private async void HandleClamNotificationAsync(object? sender, TransferModel e) 69 | { 70 | if (e is null) { Console.WriteLine("Received null message"); return; } 71 | 72 | var channel = _client.GetChannel(e.Data.ChannelId) as IMessageChannel; 73 | 74 | IMessage? msg = await channel.GetMessageAsync(e.Data.MessageId); 75 | 76 | SocketUserMessage? message = msg as SocketUserMessage; 77 | 78 | if (e.Data.Status == Status.Clean && _addReactions) 79 | { 80 | await msg.AddReactionAsync(new Emoji("✅")); 81 | } 82 | else if (e.Data.Status == Status.Infected) 83 | { 84 | try 85 | { 86 | await message.ReplyAsync(embed: EmbedHelper.Build(msg.Content, msg.Author.GlobalName, e.Data.ScanType)); 87 | 88 | await msg.DeleteAsync(); 89 | } 90 | catch (Discord.Net.HttpException) 91 | { 92 | Console.WriteLine("Message not found - Assuming Deletion Previously"); 93 | } 94 | catch (Exception) 95 | { 96 | Console.WriteLine("Error replying to message"); 97 | } 98 | 99 | } 100 | else if (e.Data.Status == Status.Error && _addReactions) 101 | { 102 | await msg.AddReactionAsync(new Emoji("❓")); 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/Services/HasherService.cs: -------------------------------------------------------------------------------- 1 | using System.IO.Compression; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | using Timer = System.Timers.Timer; 5 | 6 | namespace ClamShell.ClamServer.Services 7 | { 8 | public class HasherService 9 | { 10 | private const string Url = "https://raw.githubusercontent.com/mitchellkrogza/Phishing.Database/master/ALL-phishing-domains.tar.gz"; 11 | private const double Interval = 12 * 60 * 60 * 1000; 12 | private HashSet urlHashes = new HashSet(); 13 | private string currentHash = string.Empty; 14 | private Timer _timer; 15 | private ILogger _logger; 16 | 17 | public HasherService(ILogger logger) 18 | { 19 | _timer = new Timer(Interval); 20 | _timer.Elapsed += async (sender, e) => await UpdatePhishingDomains(); 21 | _timer.AutoReset = true; 22 | _logger = logger; 23 | } 24 | 25 | public void Start() 26 | { 27 | _timer.Start(); 28 | Task.Run(UpdatePhishingDomains); 29 | } 30 | 31 | private async Task UpdatePhishingDomains() 32 | { 33 | _logger.LogInformation("Updating phishing domains..."); 34 | 35 | HashSet newHashes = new HashSet(); 36 | 37 | try 38 | { 39 | using (var httpClient = new HttpClient()) 40 | { 41 | var response = await httpClient.GetAsync(Url); 42 | response.EnsureSuccessStatusCode(); 43 | 44 | // Read the response content into a memory stream 45 | using (var responseStream = await response.Content.ReadAsStreamAsync()) 46 | using (var memoryStream = new MemoryStream()) 47 | { 48 | await responseStream.CopyToAsync(memoryStream); 49 | memoryStream.Position = 0; 50 | 51 | // Compute the hash of the decompressed stream 52 | string streamHash; 53 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress, leaveOpen: true)) 54 | using (var sha256 = SHA256.Create()) 55 | { 56 | var hashBytes = sha256.ComputeHash(gzipStream); 57 | streamHash = BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant(); 58 | } 59 | 60 | if (streamHash == currentHash) 61 | { 62 | _logger.LogInformation("Phishing domains are up to date."); 63 | return; 64 | } 65 | 66 | currentHash = streamHash; 67 | 68 | // Read the content again for processing 69 | memoryStream.Position = 0; 70 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) 71 | using (var reader = new StreamReader(gzipStream)) 72 | { 73 | string line; 74 | while ((line = await reader.ReadLineAsync()) != null) 75 | { 76 | newHashes.Add(ComputeHash(line)); 77 | } 78 | 79 | urlHashes = newHashes; 80 | } 81 | } 82 | } 83 | } 84 | catch (Exception ex) 85 | { 86 | _logger.LogError("Failed to update phishing domains: {ex.Message}", ex.Message); 87 | } 88 | 89 | } 90 | 91 | private string ComputeHash(string input) 92 | { 93 | using (var sha256 = SHA256.Create()) 94 | { 95 | byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(input)); 96 | return BitConverter.ToString(bytes).Replace("-", "").ToLower(); 97 | } 98 | } 99 | 100 | public bool IsPhishing(string url) 101 | { 102 | Uri uri = new Uri(url); 103 | 104 | string host = uri.Host; 105 | 106 | if (string.IsNullOrEmpty(host)) 107 | { 108 | _logger.LogError("Failed to parse host from URL: {url}.. Unable to determine URL Safety", url); 109 | return false; 110 | } 111 | 112 | string hash = ComputeHash(host); 113 | 114 | return urlHashes.Contains(hash); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /ClamShell.ClamServer/Worker.cs: -------------------------------------------------------------------------------- 1 | using ClamShell.MessageBus; 2 | using ClamShell.MessageBus.Models; 3 | using ClamShell.MessageBus.Models.Payloads; 4 | using ClamShell.MessageBus.Models.Enums; 5 | using nClam; 6 | using System.Text.Json; 7 | using System.Text; 8 | using ClamShell.ClamServer.Services; 9 | using Microsoft.Extensions.Options; 10 | 11 | namespace ClamShell.ClamServer 12 | { 13 | public class Worker : BackgroundService 14 | { 15 | private readonly ILogger _logger; 16 | private readonly Consumer _consumer; 17 | private readonly HasherService _hasherService; 18 | private readonly ClamClient _clam; 19 | private readonly Publisher _publisher; 20 | private readonly HttpClient _httpClient; 21 | private readonly string _webhookUrl; 22 | private readonly bool _useLogs; 23 | 24 | public Worker(ILogger logger, Consumer consumer, ClamClient clam, HasherService hasherService, IConfiguration options) 25 | { 26 | _logger = logger; 27 | _consumer = consumer; 28 | _hasherService = hasherService; 29 | _clam = clam; 30 | _publisher = new Publisher("scan_result"); 31 | _httpClient = new HttpClient(); 32 | _webhookUrl = options["Settings:WEBHOOK_URL"]; 33 | _useLogs = bool.Parse(options["Settings:USE_LOGS"]); 34 | 35 | _hasherService.Start(); 36 | _consumer.MessageReceived += Consumer_MessageReceived; 37 | } 38 | 39 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 40 | { 41 | while (!stoppingToken.IsCancellationRequested) 42 | { 43 | _logger.LogInformation("Clam Server Worker running at: {time}", DateTimeOffset.Now); 44 | await Task.Delay(10000, stoppingToken); 45 | } 46 | } 47 | 48 | private async void Consumer_MessageReceived(object sender, TransferModel e) 49 | { 50 | _logger.LogInformation("Received message from Message Queue at: {time}", DateTimeOffset.Now); 51 | 52 | Status status = Status.Error; 53 | bool isUrl = e.Data.ScanType == ScanType.URL; 54 | 55 | if (e.Data.ScanType == ScanType.URL) 56 | { 57 | status = _hasherService.IsPhishing(Encoding.UTF8.GetString(e.Data.Data)) ? 58 | Status.Infected : 59 | Status.Clean; 60 | } 61 | else if (e.Data.ScanType == ScanType.File) 62 | { 63 | var result = await _clam.SendAndScanFileAsync(e.Data.Data); 64 | 65 | if (result is null) 66 | { 67 | _logger.LogError("Error scanning file.."); 68 | return; 69 | } 70 | 71 | status = result.Result switch 72 | { 73 | ClamScanResults.Clean => Status.Clean, 74 | ClamScanResults.VirusDetected => Status.Infected, 75 | _ => Status.Error 76 | }; 77 | } 78 | 79 | _logger.LogInformation("Sending processed request to Message Queue"); 80 | 81 | Task.Run(() => _publisher.Publish(new TransferModel 82 | { 83 | Data = new DiscordMessageData 84 | { 85 | ChannelId = e.Data.ChannelId, 86 | MessageId = e.Data.MessageId, 87 | Status = status, 88 | ChannelName = e.Data.ChannelName, 89 | ScanType = e.Data.ScanType 90 | } 91 | })); 92 | 93 | if (_useLogs) 94 | Task.Run(() => PublishToLogs(status, e.Data.ChannelName, isUrl)); 95 | } 96 | 97 | private async Task PublishToLogs(Status status, string channelName, bool isUrl) 98 | { 99 | string processType = isUrl ? "URL" : "File"; 100 | object data = status switch 101 | { 102 | Status.Clean => new { content = $"**{DateTime.UtcNow}**: Processed a `{processType}` in `{channelName}` with result `CLEAN`" }, 103 | Status.Infected => new 104 | { 105 | embeds = new[] 106 | { 107 | new 108 | { 109 | title = "Virus Detected", 110 | description = $"Clam Shell has detected a `{processType}` with malicious intent resulted `INFECTED`. It was deleted in `{channelName}` at {DateTime.UtcNow}", 111 | color = 16711680 112 | } 113 | } 114 | }, 115 | _ => new { content = $"**{DateTime.UtcNow}**: ClamShell has encountered an error processing a `{processType}` in `{channelName}`" } 116 | }; 117 | 118 | var payloadJson = JsonSerializer.Serialize(data); 119 | var content = new StringContent(payloadJson, Encoding.UTF8, "application/json"); 120 | 121 | await _httpClient.PostAsync(_webhookUrl, content); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clam Shell 2 | 3 | ![Clam Shell Banner](https://github.com/Qolors/Clam-Shell/blob/main/docs/clamshell_logo.png) 4 | 5 | Clam Shell is a self-hosted anti-virus engine for Discord servers, powered by the open-source ClamAV engine. It provides real-time scanning of files and URLs shared within your Discord server, ensuring a safe and secure environment for your community. Clam Shell also features phishing detection by referencing a list of phishing URLs, which is automatically updated every 12 hours. Additionally, it supports posting logs to a designated Discord channel for easy monitoring if desired. 6 | 7 | ## Features 8 | 9 | - **Discord Bot Integration:** Monitors your Discord server for file and URL sharing, and queues them for scanning. 10 | - **ClamAV Engine:** Utilizes the powerful and open-source [ClamAV](https://www.clamav.net/) engine for virus scanning. 11 | - **Phishing Detection:** Detects phishing URLs by referencing an up-to-date list, ensuring protection against online threats. 12 | - **Automatic Updates:** The phishing URL list is automatically updated every 12 hours to keep your server protected against new threats. 13 | - **Discord Logging:** Posts logs to a designated Discord channel for easy monitoring. 14 | - **Automated Safety:** Deletes, removes, reports messages that are sending infected attachment/urls. 15 | 16 | ## Todo List as of v0.9.0 17 | 18 | - Improve Phishing bank ( currently this is only pulling from [Phishing Database](https://github.com/mitchellkrogza/Phishing.Database) ) 19 | - Improve Discord Bot message formatting 20 | - Add other malicious URL type processing & checks 21 | - Add editing configurations through Discord Bot 22 | 23 | ## Support 24 | 25 | If you find any of my work useful and want to help support Development 26 | 27 | Buy Me A Coffee 28 | 29 | ## Prerequisites 30 | 31 | - Before you begin, ensure you have Docker and Docker Compose installed on your system. 32 | - According to [ClamAV Docs](https://docs.clamav.net/manual/Installing/Docker.html#memory-ram-requirements), the av server recommends having **4GiB** of available RAM, with a minimum of **3GiB** 33 | 34 | ## Installation 35 | 36 | 1. **Obtain the Docker Compose file and the configuration template:** 37 | 38 | - Create a `docker-compose.yaml` file: 39 | ```md 40 | version: '3.8' 41 | 42 | services: 43 | 44 | clamshell_server: 45 | image: clamav/clamav:latest 46 | container_name: clamshell_server 47 | networks: 48 | - clamshell_network 49 | 50 | rabbitmq: 51 | image: rabbitmq:3-management 52 | ports: 53 | - "5672:5672" 54 | - "15672:15672" # For RabbitMQ management interface 55 | networks: 56 | - clamshell_network 57 | 58 | clamshell_worker: 59 | image: qolors/clamshell_worker:latest 60 | container_name: clamshell_worker 61 | volumes: 62 | - ./config.json:/app/config.json 63 | networks: 64 | - clamshell_network 65 | 66 | clamshell_bot: 67 | image: qolors/clamshell_bot:latest 68 | container_name: clamshell_bot 69 | volumes: 70 | - ./config.json:/app/config.json 71 | networks: 72 | - clamshell_network 73 | 74 | networks: 75 | clamshell_network: 76 | ``` 77 | - Create a `config.json` file: 78 | 79 | ```json 80 | { 81 | "Settings": { 82 | "BOT_TOKEN": "YOUR_BOT_TOKEN", 83 | "WEBHOOK_URL": "YOUR_WEBHOOK_URL", 84 | "USE_LOGS": true, 85 | "USE_REACTIONS": true 86 | } 87 | } 88 | ``` 89 | 90 | 2. **Configure Clam Shell:** 91 | - Edit `config.json` to set your Discord bot token, webhook URL for logging, and other configuration options 92 | - If your `config.json` file is not in the same location as your `docker-compose.yaml`, update the volumes path 93 | 94 | 3. **Start Clam Shell:** 95 | ```bash 96 | docker-compose up -d 97 | ``` 98 | ### Configuration File Properties Explained 99 | 100 | - **"BOT_TOKEN":** Required Bot Token. If unfamiliar take a look [here](https://discord.com/developers/docs/getting-started) 101 | - **"WEBHOOK_URL":"** This is required if you desire to log the bot's messages. If unfamiliar take a look [here](https://github.com/Qolors/FeedCord?tab=readme-ov-file#quick-setup-docker) 102 | - **"USE_LOGS":** If you do not want to enable the logging, set this to false otherwise keep true 103 | - **"USE_REACTIONS":** If enabled, the bot will react to all files it processes with a ✅ to let you know it's been verified 104 | 105 | ## Usage 106 | 107 | Once Clam Shell is up and running, it will automatically start monitoring your Discord server for file and URL sharing. If a file or URL is detected, it will be queued for scanning by the ClamAV engine. Detected threats and logs will be reported in the designated Discord channel. 108 | 109 | ## Updating 110 | 111 | To update Clam Shell, pull the latest Docker images and restart the services: 112 | 113 | ```bash 114 | docker-compose pull 115 | docker-compose down 116 | docker-compose up -d 117 | ``` 118 | 119 | ## Contributing 120 | 121 | Contributions are welcome! Please feel free to submit pull requests or open issues to improve the software. 122 | 123 | ## Libraries Utilized 124 | - [Discord.Net](https://discordnet.dev/index.html) 125 | - [RabbitMQ](https://rabbitmq.com/) 126 | - [nClam](https://github.com/tekmaven/nClam) 127 | 128 | ## License 129 | 130 | Clam Shell is released under the [MIT License](LICENSE). 131 | 132 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd --------------------------------------------------------------------------------