├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── CyberSniff.sln ├── CyberSniff ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Classes │ ├── CacheManager.cs │ ├── DiscordPresenceService.cs │ ├── ErrorLogging.cs │ ├── ExportDrawer.cs │ ├── Extensions.cs │ ├── PacketFilter.cs │ ├── Security.cs │ ├── ServerSettings.cs │ ├── TableHandler.cs │ ├── ThemeUtils.cs │ └── Web.cs ├── Converters │ └── InverseBooleanConverter.cs ├── CyberSniff.csproj ├── Globals.cs ├── Interfaces │ ├── ICacheManager.cs │ ├── IDiscordPresenceService.cs │ ├── IErrorLogging.cs │ ├── IExportDrawer.cs │ ├── IPacketFilter.cs │ ├── IServerSettings.cs │ └── IThemeUtils.cs ├── Models │ ├── Adapter.cs │ ├── AddressFamily.cs │ ├── ArpDevice.cs │ ├── CacheConfiguration.cs │ ├── CaptureGrid.cs │ ├── ColorType.cs │ ├── DiscordPresenceConfiguration.cs │ ├── FilterPreset.cs │ ├── GeolocationCache.cs │ ├── GeolocationResponse.cs │ ├── Label.cs │ ├── LogLevel.cs │ ├── MsgBox.cs │ ├── NotificationType.cs │ ├── PacketWrapper.cs │ ├── Settings.cs │ ├── Theme.cs │ └── ThemeExport.cs ├── Properties │ ├── Resources.Designer.cs │ └── Resources.resx ├── Resources │ ├── Fonts │ │ ├── CascadiaCode.ttf │ │ ├── CascadiaCodePL.ttf │ │ ├── CascadiaMono.ttf │ │ ├── CascadiaMonoPL.ttf │ │ ├── gothambold.ttf │ │ ├── gothambolditalic.ttf │ │ ├── gothambook.ttf │ │ ├── gothamlight.ttf │ │ ├── gothamlightitalic.ttf │ │ ├── gothammedium.ttf │ │ ├── gothammediumitalic.ttf │ │ ├── gothamxlight.ttf │ │ └── gothamxlightitalic.ttf │ ├── Images │ │ ├── Flags │ │ │ ├── Abkhazia.png │ │ │ ├── Afghanistan.png │ │ │ ├── Aland.png │ │ │ ├── Albania.png │ │ │ ├── Algeria.png │ │ │ ├── American-Samoa.png │ │ │ ├── Andorra.png │ │ │ ├── Angola.png │ │ │ ├── Anguilla.png │ │ │ ├── Antarctica.png │ │ │ ├── Antigua-and-Barbuda.png │ │ │ ├── Argentina.png │ │ │ ├── Armenia.png │ │ │ ├── Aruba.png │ │ │ ├── Australia.png │ │ │ ├── Austria.png │ │ │ ├── Azerbaijan.png │ │ │ ├── Bahamas.png │ │ │ ├── Bahrain.png │ │ │ ├── Bangladesh.png │ │ │ ├── Barbados.png │ │ │ ├── Basque-Country.png │ │ │ ├── Belarus.png │ │ │ ├── Belgium.png │ │ │ ├── Belize.png │ │ │ ├── Benin.png │ │ │ ├── Bermuda.png │ │ │ ├── Bhutan.png │ │ │ ├── Bolivia.png │ │ │ ├── Bosnia-and-Herzegovina.png │ │ │ ├── Botswana.png │ │ │ ├── Brazil.png │ │ │ ├── British-Antarctic-Territory.png │ │ │ ├── British-Virgin-Islands.png │ │ │ ├── Brunei.png │ │ │ ├── Bulgaria.png │ │ │ ├── Burkina-Faso.png │ │ │ ├── Burundi.png │ │ │ ├── Cambodia.png │ │ │ ├── Cameroon.png │ │ │ ├── Canada.png │ │ │ ├── Canary-Islands.png │ │ │ ├── Cape-Verde.png │ │ │ ├── Catalonia.png │ │ │ ├── Cayman-Islands.png │ │ │ ├── Central-African-Republic.png │ │ │ ├── Chad.png │ │ │ ├── Chile.png │ │ │ ├── China.png │ │ │ ├── Christmas-Island.png │ │ │ ├── Cocos-Keeling-Islands.png │ │ │ ├── Colombia.png │ │ │ ├── Commonwealth.png │ │ │ ├── Comoros.png │ │ │ ├── Cook-Islands.png │ │ │ ├── Costa-Rica.png │ │ │ ├── Cote-dIvoire.png │ │ │ ├── Croatia.png │ │ │ ├── Cuba.png │ │ │ ├── Curacao.png │ │ │ ├── Cyprus.png │ │ │ ├── Czech-Republic.png │ │ │ ├── Democratic-Republic-of-the-Congo.png │ │ │ ├── Denmark.png │ │ │ ├── Djibouti.png │ │ │ ├── Dominica.png │ │ │ ├── Dominican-Republic.png │ │ │ ├── East-Timor.png │ │ │ ├── Ecuador.png │ │ │ ├── Egypt.png │ │ │ ├── El-Salvador.png │ │ │ ├── England.png │ │ │ ├── Equatorial-Guinea.png │ │ │ ├── Eritrea.png │ │ │ ├── Estonia.png │ │ │ ├── Ethiopia.png │ │ │ ├── European-Union.png │ │ │ ├── Falkland-Islands.png │ │ │ ├── Faroes.png │ │ │ ├── Fiji.png │ │ │ ├── Finland.png │ │ │ ├── France.png │ │ │ ├── French-Polynesia.png │ │ │ ├── French-Southern-Territories.png │ │ │ ├── Gabon.png │ │ │ ├── Gambia.png │ │ │ ├── Georgia.png │ │ │ ├── Germany.png │ │ │ ├── Ghana.png │ │ │ ├── Gibraltar.png │ │ │ ├── GoSquared.png │ │ │ ├── Greece.png │ │ │ ├── Greenland.png │ │ │ ├── Grenada.png │ │ │ ├── Guam.png │ │ │ ├── Guatemala.png │ │ │ ├── Guernsey.png │ │ │ ├── Guinea-Bissau.png │ │ │ ├── Guinea.png │ │ │ ├── Guyana.png │ │ │ ├── Haiti.png │ │ │ ├── Honduras.png │ │ │ ├── Hong-Kong.png │ │ │ ├── Hungary.png │ │ │ ├── Iceland.png │ │ │ ├── India.png │ │ │ ├── Indonesia.png │ │ │ ├── Iran.png │ │ │ ├── Iraq.png │ │ │ ├── Ireland.png │ │ │ ├── Isle-of-Man.png │ │ │ ├── Israel.png │ │ │ ├── Italy.png │ │ │ ├── Jamaica.png │ │ │ ├── Japan.png │ │ │ ├── Jersey.png │ │ │ ├── Jordan.png │ │ │ ├── Kazakhstan.png │ │ │ ├── Kenya.png │ │ │ ├── Kiribati.png │ │ │ ├── Kosovo.png │ │ │ ├── Kuwait.png │ │ │ ├── Kyrgyzstan.png │ │ │ ├── Laos.png │ │ │ ├── Latvia.png │ │ │ ├── Lebanon.png │ │ │ ├── Lesotho.png │ │ │ ├── Liberia.png │ │ │ ├── Libya.png │ │ │ ├── Liechtenstein.png │ │ │ ├── Lithuania.png │ │ │ ├── Luxembourg.png │ │ │ ├── Macau.png │ │ │ ├── Macedonia.png │ │ │ ├── Madagascar.png │ │ │ ├── Malawi.png │ │ │ ├── Malaysia.png │ │ │ ├── Maldives.png │ │ │ ├── Mali.png │ │ │ ├── Malta.png │ │ │ ├── Mars.png │ │ │ ├── Marshall-Islands.png │ │ │ ├── Martinique.png │ │ │ ├── Mauritania.png │ │ │ ├── Mauritius.png │ │ │ ├── Mayotte.png │ │ │ ├── Mexico.png │ │ │ ├── Micronesia.png │ │ │ ├── Moldova.png │ │ │ ├── Monaco.png │ │ │ ├── Mongolia.png │ │ │ ├── Montenegro.png │ │ │ ├── Montserrat.png │ │ │ ├── Morocco.png │ │ │ ├── Mozambique.png │ │ │ ├── Myanmar.png │ │ │ ├── NATO.png │ │ │ ├── Nagorno-Karabakh.png │ │ │ ├── Namibia.png │ │ │ ├── Nauru.png │ │ │ ├── Nepal.png │ │ │ ├── Netherlands-Antilles.png │ │ │ ├── Netherlands.png │ │ │ ├── New-Caledonia.png │ │ │ ├── New-Zealand.png │ │ │ ├── Nicaragua.png │ │ │ ├── Niger.png │ │ │ ├── Nigeria.png │ │ │ ├── Niue.png │ │ │ ├── Norfolk-Island.png │ │ │ ├── North-Korea.png │ │ │ ├── Northern-Cyprus.png │ │ │ ├── Northern-Mariana-Islands.png │ │ │ ├── Norway.png │ │ │ ├── Olympics.png │ │ │ ├── Oman.png │ │ │ ├── Pakistan.png │ │ │ ├── Palau.png │ │ │ ├── Palestine.png │ │ │ ├── Panama.png │ │ │ ├── Papua-New-Guinea.png │ │ │ ├── Paraguay.png │ │ │ ├── Peru.png │ │ │ ├── Philippines.png │ │ │ ├── Pitcairn-Islands.png │ │ │ ├── Poland.png │ │ │ ├── Portugal.png │ │ │ ├── Puerto-Rico.png │ │ │ ├── Qatar.png │ │ │ ├── Red-Cross.png │ │ │ ├── Republic-of-the-Congo.png │ │ │ ├── Reunion.png │ │ │ ├── Romania.png │ │ │ ├── Russia.png │ │ │ ├── Rwanda.png │ │ │ ├── Saint-Barthelemy.png │ │ │ ├── Saint-Helena.png │ │ │ ├── Saint-Kitts-and-Nevis.png │ │ │ ├── Saint-Lucia.png │ │ │ ├── Saint-Martin.png │ │ │ ├── Saint-Vincent-and-the-Grenadines.png │ │ │ ├── Samoa.png │ │ │ ├── San-Marino.png │ │ │ ├── Sao-Tome-and-Principe.png │ │ │ ├── Saudi-Arabia.png │ │ │ ├── Scotland.png │ │ │ ├── Senegal.png │ │ │ ├── Serbia.png │ │ │ ├── Seychelles.png │ │ │ ├── Sierra-Leone.png │ │ │ ├── Singapore.png │ │ │ ├── Sint-Maarten.png │ │ │ ├── Slovakia.png │ │ │ ├── Slovenia.png │ │ │ ├── Solomon-Islands.png │ │ │ ├── Somalia.png │ │ │ ├── Somaliland.png │ │ │ ├── South-Africa.png │ │ │ ├── South-Georgia-and-the-South-Sandwich-Islands.png │ │ │ ├── South-Korea.png │ │ │ ├── South-Ossetia.png │ │ │ ├── South-Sudan.png │ │ │ ├── Spain.png │ │ │ ├── Sri-Lanka.png │ │ │ ├── Sudan.png │ │ │ ├── Suriname.png │ │ │ ├── Swaziland.png │ │ │ ├── Sweden.png │ │ │ ├── Switzerland.png │ │ │ ├── Syria.png │ │ │ ├── Taiwan.png │ │ │ ├── Tajikistan.png │ │ │ ├── Tanzania.png │ │ │ ├── Thailand.png │ │ │ ├── Togo.png │ │ │ ├── Tokelau.png │ │ │ ├── Tonga.png │ │ │ ├── Trinidad-and-Tobago.png │ │ │ ├── Tunisia.png │ │ │ ├── Turkey.png │ │ │ ├── Turkmenistan.png │ │ │ ├── Turks-and-Caicos-Islands.png │ │ │ ├── Tuvalu.png │ │ │ ├── US-Virgin-Islands.png │ │ │ ├── Uganda.png │ │ │ ├── Ukraine.png │ │ │ ├── United-Arab-Emirates.png │ │ │ ├── United-Kingdom.png │ │ │ ├── United-Nations.png │ │ │ ├── United-States.png │ │ │ ├── Unknown.png │ │ │ ├── Uruguay.png │ │ │ ├── Uzbekistan.png │ │ │ ├── Vanuatu.png │ │ │ ├── Vatican-City.png │ │ │ ├── Venezuela.png │ │ │ ├── Vietnam.png │ │ │ ├── Wales.png │ │ │ ├── Wallis-And-Futuna.png │ │ │ ├── Western-Sahara.png │ │ │ ├── Yemen.png │ │ │ ├── Zambia.png │ │ │ └── Zimbabwe.png │ │ ├── csniff-128.png │ │ ├── csniff-28.png │ │ ├── csniff-65.png │ │ ├── csniff-box.png │ │ ├── csniff-box100.png │ │ ├── csniff-box96.png │ │ ├── cybersniff-banner.png │ │ ├── cybersniff-w.png │ │ └── cybersniff.png │ └── Style.xaml ├── Views │ ├── AdapterInfo.xaml │ ├── AdapterInfo.xaml.cs │ ├── Arp.xaml │ ├── Arp.xaml.cs │ ├── Filters.xaml │ ├── Filters.xaml.cs │ ├── Locate.xaml │ ├── Locate.xaml.cs │ ├── Nmap.xaml │ ├── Nmap.xaml.cs │ ├── Probe.xaml │ ├── Probe.xaml.cs │ ├── Settings.xaml │ └── Settings.xaml.cs ├── Windows │ ├── ArpWindow.xaml │ ├── ArpWindow.xaml.cs │ ├── BootstrapWindow.xaml │ ├── BootstrapWindow.xaml.cs │ ├── CustomMsgBox.xaml │ ├── CustomMsgBox.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── PacketAnalyserWindow.xaml │ └── PacketAnalyserWindow.xaml.cs └── csniff-box-ico.ico ├── LICENSE ├── README.md └── csniff-box-ico.ico /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: windows-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v2 18 | with: 19 | dotnet-version: 6.0.x 20 | - name: Restore dependencies 21 | run: dotnet restore 22 | - name: Build 23 | run: dotnet build --no-restore 24 | - name: Test 25 | run: dotnet test --no-build --verbosity normal 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.com 2 | *.snk 3 | *.class 4 | *.dll 5 | *.exe 6 | *.pdb 7 | *.dll.config 8 | *.cache 9 | *.suo 10 | !/packages/*/lib/*.dll 11 | !*CommonReferences/*.dll 12 | _UpgradeReport_Files/ 13 | bin/ 14 | obj/ 15 | TestResults/ 16 | *.Publish.xml 17 | /_ReSharper.* 18 | *.ReSharper.* 19 | *.7z 20 | *.dmg 21 | *.gz 22 | *.iso 23 | *.jar 24 | *.rar 25 | *.tar 26 | *.zip 27 | *.log 28 | *.sqlite 29 | .DS_Store? 30 | ehthumbs.db 31 | Icon? 32 | Thumbs.db 33 | *.user 34 | *.userosscache 35 | *.sln.docstates 36 | *.userprefs 37 | [Dd]ebug/ 38 | [Dd]ebugPublic/ 39 | [Rr]elease/ 40 | [Rr]eleases/ 41 | x64/ 42 | x86/ 43 | build/ 44 | bld/ 45 | [Bb]in/ 46 | [Oo]bj/ 47 | .vs/ 48 | [Tt]est[Rr]esult*/ 49 | [Bb]uild[Ll]og.* 50 | *.VisualState.xml 51 | TestResult.xml 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | project.lock.json 56 | artifacts/ 57 | *_i.c 58 | *_p.c 59 | *_i.h 60 | *.ilk 61 | *.meta 62 | *.obj 63 | *.pch 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.vspscc 74 | *.vssscc 75 | .builds 76 | *.pidb 77 | *.svclog 78 | *.scc 79 | _Chutzpah* 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opensdf 84 | *.sdf 85 | *.cachefile 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | $tf/ 90 | *.gpState 91 | _ReSharper*/ 92 | *.[Rr]e[Ss]harper 93 | *.DotSettings.user 94 | .JustCode 95 | _TeamCity* 96 | *.dotCover 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | *.mm.* 100 | AutoTest.Net/ 101 | .sass-cache/ 102 | [Ee]xpress/ 103 | DocProject/buildhelp/ 104 | DocProject/Help/*.HxT 105 | DocProject/Help/*.HxC 106 | DocProject/Help/*.hhc 107 | DocProject/Help/*.hhk 108 | DocProject/Help/*.hhp 109 | DocProject/Help/Html2 110 | DocProject/Help/html 111 | publish/ 112 | *.[Pp]ublish.xml 113 | *.azurePubxml 114 | *.pubxml 115 | *.publishproj 116 | *.nupkg 117 | **/packages/* 118 | **/packages/build/ 119 | csx/ 120 | *.build.csdef 121 | AppPackages/ 122 | *.[Cc]ache 123 | !*.[Cc]ache/ 124 | ClientBin/ 125 | [Ss]tyle[Cc]op.* 126 | ~$* 127 | *~ 128 | *.dbmdl 129 | *.dbproj.schemaview 130 | *.pfx 131 | *.publishsettings 132 | node_modules/ 133 | bower_components/ 134 | orleans.codegen.cs 135 | Generated_Code/ 136 | _UpgradeReport_Files/ 137 | Backup*/ 138 | UpgradeLog*.XML 139 | UpgradeLog*.htm 140 | *.mdf 141 | *.ldf 142 | *.rdl.data 143 | *.bim.layout 144 | *.bim_*.settings 145 | FakesAssemblies/ 146 | .ntvs_analysis.dat 147 | *.plg 148 | *.opt 149 | *.baml -------------------------------------------------------------------------------- /CyberSniff.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30413.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CyberSniff", "CyberSniff\CyberSniff.csproj", "{020F37C2-44B6-462B-80BB-8A4041A2D0AD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {020F37C2-44B6-462B-80BB-8A4041A2D0AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {020F37C2-44B6-462B-80BB-8A4041A2D0AD}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {020F37C2-44B6-462B-80BB-8A4041A2D0AD}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {020F37C2-44B6-462B-80BB-8A4041A2D0AD}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {11548A56-EDC2-4A88-AAD2-5A00E42BEA1A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /CyberSniff/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CyberSniff/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Net.Http; 5 | using System.Reflection; 6 | using System.Windows; 7 | using CyberSniff.Classes; 8 | using CyberSniff.Interfaces; 9 | using CyberSniff.Models; 10 | using SimpleInjector; 11 | 12 | namespace CyberSniff 13 | { 14 | public partial class App : Application 15 | { 16 | public App() 17 | { 18 | Globals.Container.Register(Lifestyle.Singleton); 19 | Globals.Container.Register(Lifestyle.Singleton); 20 | Globals.Container.RegisterSingleton(() => new DiscordPresenceService( 21 | new DiscordPresenceConfiguration 22 | { 23 | ClientId = 992863681488633896, 24 | LargeImageKey = "main", 25 | LargeImageText = $"CyberSniff [version {Assembly.GetExecutingAssembly().GetName().Version} OSS STABLE]" 26 | })); 27 | Globals.Container.Register(Lifestyle.Singleton); 28 | Globals.Container.Register(Lifestyle.Singleton); 29 | Globals.Container.Register(Lifestyle.Singleton); 30 | Globals.Container.RegisterSingleton>>(() => new CacheManager>(new CacheConfiguration 31 | { 32 | FilePath = Path.Combine( 33 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 34 | "CSniffOSS", "geo.bin") 35 | })); 36 | Globals.Container.Register(() => new HttpClient(), Lifestyle.Singleton); 37 | 38 | Globals.Container.Verify(); 39 | 40 | // Gets the settings 41 | Globals.Container.GetInstance().GetSettingsAsync(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /CyberSniff/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, 5 | ResourceDictionaryLocation.SourceAssembly 6 | )] -------------------------------------------------------------------------------- /CyberSniff/Classes/CacheManager.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using CyberSniff.Interfaces; 3 | using CyberSniff.Models; 4 | using Newtonsoft.Json; 5 | 6 | namespace CyberSniff.Classes; 7 | 8 | public class CacheManager : ICacheManager 9 | { 10 | private readonly CacheConfiguration configuration; 11 | private readonly object threadLock = new(); 12 | 13 | public CacheManager(CacheConfiguration configuration) 14 | { 15 | this.configuration = configuration; 16 | } 17 | 18 | public void ClearCache() 19 | { 20 | lock (threadLock) 21 | { 22 | File.Delete(configuration.FilePath); 23 | } 24 | } 25 | 26 | public T GetCache() 27 | { 28 | lock (threadLock) 29 | { 30 | if (!File.Exists(configuration.FilePath)) return default; 31 | 32 | var fileBytes = File.ReadAllText(configuration.FilePath); 33 | var decryptedBytes = Security.Decrypt(fileBytes); 34 | 35 | return JsonConvert.DeserializeObject(decryptedBytes); 36 | } 37 | } 38 | 39 | public void WriteCache(T cache) 40 | { 41 | lock (threadLock) 42 | { 43 | var json = JsonConvert.SerializeObject(cache); 44 | var encryptedJson = Security.Encrypt(json); 45 | 46 | File.WriteAllText(configuration.FilePath, encryptedJson); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/DiscordPresenceService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using CyberSniff.Interfaces; 4 | using CyberSniff.Models; 5 | using DiscordRPC; 6 | using DiscordRPC.Logging; 7 | 8 | namespace CyberSniff.Classes 9 | { 10 | public sealed class DiscordPresenceService : IDiscordPresenceService 11 | { 12 | private readonly DiscordPresenceConfiguration configuration; 13 | private DiscordRpcClient client; 14 | 15 | public DiscordPresenceService(DiscordPresenceConfiguration configuration) 16 | { 17 | this.configuration = configuration; 18 | 19 | if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 20 | "CSniffOSS"))) 21 | { 22 | Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CSniffOSS")); 23 | } 24 | 25 | CreateInstance(); 26 | } 27 | 28 | public RichPresence Presence { get; set; } 29 | 30 | public void CreateInstance() 31 | { 32 | client = new DiscordRpcClient(configuration.ClientId.ToString(), 33 | logger: new FileLogger(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CSniffOSS", "discord.log"))); 34 | 35 | Presence = GetRichPresence(); 36 | client.SetPresence(Presence); 37 | } 38 | 39 | public RichPresence GetRichPresence() 40 | { 41 | return new RichPresence 42 | { 43 | State = "Idle", 44 | Assets = new Assets 45 | { 46 | LargeImageKey = configuration.LargeImageKey, 47 | LargeImageText = configuration.LargeImageText 48 | } 49 | }; 50 | } 51 | 52 | public void ResetPresence() 53 | { 54 | Presence = GetRichPresence(); 55 | } 56 | 57 | public void Dispose() 58 | { 59 | ClearPresence(); 60 | DeInitialize(); 61 | client.Dispose(); 62 | } 63 | 64 | public void ClearPresence() 65 | { 66 | client.ClearPresence(); 67 | } 68 | 69 | public void DeInitialize() 70 | { 71 | if (!client.IsInitialized) return; 72 | 73 | client.Deinitialize(); 74 | client.Dispose(); 75 | } 76 | 77 | public void Initialize() 78 | { 79 | if (!client.IsInitialized || client.IsDisposed) 80 | { 81 | CreateInstance(); 82 | client.Initialize(); 83 | } 84 | 85 | SetPresence(); 86 | } 87 | 88 | public void ResetTimestamps() 89 | { 90 | Presence.WithTimestamps(null); 91 | 92 | SetPresence(); 93 | } 94 | 95 | public void UpdateDetails(string details) 96 | { 97 | Presence.WithDetails(details); 98 | 99 | SetPresence(); 100 | } 101 | 102 | public void UpdateState(string state) 103 | { 104 | Presence.WithState(state); 105 | 106 | SetPresence(); 107 | } 108 | 109 | public void UpdateTimestamps() 110 | { 111 | Presence.WithTimestamps(new Timestamps(DateTime.UtcNow)); 112 | 113 | SetPresence(); 114 | } 115 | 116 | public void SetPresence() 117 | { 118 | if (!client.IsInitialized) return; 119 | 120 | client.SetPresence(Presence); 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/ErrorLogging.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CyberSniff.Interfaces; 7 | using CyberSniff.Models; 8 | using CyberSniff.Properties; 9 | 10 | namespace CyberSniff.Classes 11 | { 12 | public class ErrorLogging : IErrorLogging 13 | { 14 | private readonly string logfile; 15 | 16 | public ErrorLogging() 17 | { 18 | logfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CSniffOSS", 19 | "logfile.log"); 20 | } 21 | 22 | public async Task CreateLogAsync() 23 | { 24 | try 25 | { 26 | if (File.Exists(logfile)) File.Delete(logfile); 27 | 28 | await File.AppendAllTextAsync(logfile, 29 | $"[{DateTime.Now}] [INFO]: CyberSniff-OSS v{Assembly.GetExecutingAssembly().GetCyberSniffVersion()} [{Resources.APP_STAGE}]\r\n[{DateTime.Now}] [INFO]: Created a new log file\r\n", 30 | Encoding.UTF8); 31 | return true; 32 | } 33 | catch (Exception) 34 | { 35 | return false; 36 | } 37 | } 38 | 39 | public async Task WriteToLogAsync(string buffer, LogLevel logType) 40 | { 41 | try 42 | { 43 | if (!File.Exists(logfile)) await CreateLogAsync(); 44 | await File.AppendAllTextAsync(logfile, $"[{DateTime.Now}] [{logType}]: {buffer}\r\n", Encoding.UTF8); 45 | return true; 46 | } 47 | catch (Exception) 48 | { 49 | return false; 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/ExportDrawer.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Interfaces; 2 | using CyberSniff.Models; 3 | using System; 4 | using System.ComponentModel; 5 | using System.IO; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | 9 | namespace CyberSniff.Classes 10 | { 11 | public class ExportDrawer : IExportDrawer 12 | { 13 | public async Task DrawTableForExport(BindingList submittedDataTable, string submittedFilePath) 14 | { 15 | var table = new TableHandler(); 16 | 17 | table.SetHeaders("IP address", "Port", "Country", "City", "State", "ISP"); 18 | 19 | foreach (var row in submittedDataTable) 20 | { 21 | table.AddRow(row.IpAddress.ToString(), row.Port.ToString(), row.Country, row.City, row.State, row.Isp); 22 | } 23 | 24 | await File.WriteAllTextAsync(submittedFilePath, $"CyberSniff-OSS [version {Assembly.GetExecutingAssembly().GetCyberSniffVersionString()} RELEASE OSS] capture results, exported at {DateTime.UtcNow} UTC\nTotal items: {submittedDataTable.Count}\n\n"); 25 | await File.AppendAllTextAsync(submittedFilePath, table.ToString()); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.NetworkInformation; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Media; 10 | using CyberSniff.Interfaces; 11 | using CyberSniff.Models; 12 | using PacketDotNet; 13 | using SharpPcap.Npcap; 14 | 15 | namespace CyberSniff 16 | { 17 | public static class Extensions 18 | { 19 | public static async Task CheckAndForwardPacketAsync(Packet packet, NpcapDevice device, 20 | PhysicalAddress targetPhysicalAddress, PhysicalAddress realGatewayAddress) 21 | { 22 | try 23 | { 24 | if (!device.Opened) 25 | device.Open(); 26 | 27 | var ethPacket = packet.Extract(); 28 | 29 | if (ethPacket == null || device.MacAddress == null) return false; 30 | 31 | if (!ethPacket.SourceHardwareAddress.ToString().Contains(targetPhysicalAddress.ToString())) 32 | return false; 33 | ethPacket.DestinationHardwareAddress = realGatewayAddress; 34 | 35 | return true; 36 | 37 | } 38 | catch (Exception e) 39 | { 40 | await e.AutoDumpExceptionAsync(); 41 | return false; 42 | } 43 | } 44 | 45 | public static bool CheckRemoteAddr(this string remoteAddr) 46 | { 47 | if (IPAddress.TryParse(remoteAddr, out var address)) 48 | return address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork || 49 | address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6; 50 | return false; 51 | } 52 | 53 | public static async void CopyToClipboard(this string text) 54 | { 55 | try 56 | { 57 | Clipboard.SetText(text); 58 | } 59 | catch (Exception ex) 60 | { 61 | await ex.AutoDumpExceptionAsync(); 62 | MessageBox.Show($"Failed to copy to clipboard\n\nWhat happened: {ex.Message}", "CyberSniff", 63 | MessageBoxButton.OK, MessageBoxImage.Warning); 64 | } 65 | } 66 | 67 | public static AddressFamily GetAddressFamily(this NpcapDevice device) 68 | { 69 | string interfaceLocalAddress; 70 | if (device.Addresses.Any()) 71 | { 72 | interfaceLocalAddress = device.Addresses.First().Addr.ToString(); 73 | if (interfaceLocalAddress == "0.0.0.0") return AddressFamily.Null; 74 | } 75 | else 76 | { 77 | return AddressFamily.Null; 78 | } 79 | 80 | if (string.IsNullOrWhiteSpace(interfaceLocalAddress)) return AddressFamily.Null; 81 | return interfaceLocalAddress.Contains(':') ? AddressFamily.IPv6 : AddressFamily.IPv4; 82 | } 83 | 84 | public static Version GetCyberSniffVersion(this Assembly assembly) 85 | { 86 | var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); 87 | return Version.Parse(fvi.FileVersion); 88 | } 89 | 90 | public static string GetCyberSniffVersionString(this Assembly assembly) 91 | { 92 | var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); 93 | return fvi.FileVersion.Replace(".0", ""); 94 | } 95 | 96 | public static async Task AutoDumpExceptionAsync(this Exception exception) 97 | { 98 | return await Globals.Container.GetInstance().WriteToLogAsync( 99 | $"Exception thrown on {exception.Source} at {exception.TargetSite}: {exception.Message}. Trace:\n\n{exception.StackTrace}\r\n", 100 | LogLevel.ERROR); 101 | } 102 | 103 | public static async Task PoisonAsync(this NpcapDevice device, IPAddress targetAddress, 104 | PhysicalAddress targetMac, IPAddress gatewayIpAddress, PhysicalAddress gatewayMacAddress) 105 | { 106 | try 107 | { 108 | if (!device.Opened) 109 | device.Open(); 110 | if (device.MacAddress == null || targetAddress == null || targetMac == null || 111 | gatewayIpAddress == null || gatewayMacAddress == null) return; 112 | ArpPacket arpPacket = new(ArpOperation.Request, targetMac, targetAddress, 113 | device.MacAddress, gatewayIpAddress); 114 | EthernetPacket ethPacket = new(device.MacAddress, targetMac, EthernetType.Arp) 115 | { 116 | PayloadPacket = arpPacket 117 | }; 118 | await Task.Run(() => device.SendPacket(ethPacket)); 119 | } 120 | catch (Exception e) 121 | { 122 | await e.AutoDumpExceptionAsync(); 123 | } 124 | } 125 | 126 | public static async Task ValidateIpAsync(this string ip) 127 | { 128 | try 129 | { 130 | await Dns.GetHostAddressesAsync(ip); 131 | return true; 132 | } 133 | catch 134 | { 135 | return false; 136 | } 137 | } 138 | 139 | public static string ToHex(this Color c) 140 | { 141 | return $"#{c.R:X2}{c.G:X2}{c.B:X2}"; 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/PacketFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using CyberSniff.Interfaces; 4 | using CyberSniff.Models; 5 | using PacketDotNet; 6 | 7 | namespace CyberSniff.Classes 8 | { 9 | public class PacketFilter : IPacketFilter 10 | { 11 | public Task FilterPacketAsync(PacketWrapper packetWrapper) 12 | { 13 | var packet = packetWrapper.Packet.Extract(); 14 | return Task.FromResult(packet is not null); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/Security.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Newtonsoft.Json; 7 | 8 | namespace CyberSniff.Classes 9 | { 10 | public static class Security 11 | { 12 | private const string SettingsKey = 13 | "jRKmBBi1BHzCXHreFmD4VJD4aFBmgbKyVnmQFE6RMqdntR9RL7SbxFkx527yn4vp12PhWDNHHM6iIFf9b7oAr37Cb8427UUbJmGMotSqLkDPLN7amb4kOmxClZKdNtED"; 14 | 15 | public static string Decrypt(string input) 16 | { 17 | try 18 | { 19 | input = input.Replace(" ", "+"); 20 | var cipherBytes = Convert.FromBase64String(input); 21 | using var encryptor = Aes.Create(); 22 | Rfc2898DeriveBytes pdb = new(SettingsKey, 23 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 24 | encryptor.Key = pdb.GetBytes(32); 25 | encryptor.IV = pdb.GetBytes(16); 26 | using MemoryStream ms = new(); 27 | using CryptoStream cs = new(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write); 28 | cs.Write(cipherBytes, 0, cipherBytes.Length); 29 | cs.Close(); 30 | input = Encoding.Unicode.GetString(ms.ToArray()); 31 | return input; 32 | } 33 | catch (Exception e) 34 | { 35 | _ = e.AutoDumpExceptionAsync(); 36 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 37 | } 38 | } 39 | 40 | public static async Task DecryptAsync(string input) 41 | { 42 | try 43 | { 44 | input = input.Replace(" ", "+"); 45 | var cipherBytes = Convert.FromBase64String(input); 46 | using var encryptor = Aes.Create(); 47 | Rfc2898DeriveBytes pdb = new(SettingsKey, 48 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 49 | encryptor.Key = pdb.GetBytes(32); 50 | encryptor.IV = pdb.GetBytes(16); 51 | await using MemoryStream ms = new(); 52 | await using CryptoStream cs = new(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write); 53 | await cs.WriteAsync(cipherBytes.AsMemory(0, cipherBytes.Length)); 54 | cs.Close(); 55 | input = Encoding.Unicode.GetString(ms.ToArray()); 56 | return input; 57 | } 58 | catch (Exception e) 59 | { 60 | await e.AutoDumpExceptionAsync(); 61 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 62 | } 63 | } 64 | 65 | public static async Task DecryptThemeAsync(string input) 66 | { 67 | try 68 | { 69 | input = input.Replace(" ", "+"); 70 | var cipherBytes = Convert.FromBase64String(input); 71 | using var encryptor = Aes.Create(); 72 | const string key = "Kbs8WST6xEenNSZr3Sn22SsDCDHVQbaSAxhUmEPr7H4YQWbgaLpMMN37ZeByegxyYvLAPv8VUhxquZUuZz5n8D8Mm3r4DyFNS9aY9b88fU93VUtadJNz5eAX2WE2XVXG"; 73 | Rfc2898DeriveBytes pdb = new(key, 74 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 75 | encryptor.Key = pdb.GetBytes(32); 76 | encryptor.IV = pdb.GetBytes(16); 77 | await using MemoryStream ms = new(); 78 | await using CryptoStream cs = new(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write); 79 | await cs.WriteAsync(cipherBytes.AsMemory(0, cipherBytes.Length)); 80 | cs.Close(); 81 | input = Encoding.Unicode.GetString(ms.ToArray()); 82 | return input; 83 | } 84 | catch (Exception e) 85 | { 86 | await e.AutoDumpExceptionAsync(); 87 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 88 | } 89 | } 90 | 91 | public static string Encrypt(string input) 92 | { 93 | try 94 | { 95 | var clearBytes = Encoding.Unicode.GetBytes(input); 96 | using var encryptor = Aes.Create(); 97 | Rfc2898DeriveBytes pdb = new(SettingsKey, 98 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 99 | encryptor.Key = pdb.GetBytes(32); 100 | encryptor.IV = pdb.GetBytes(16); 101 | using MemoryStream ms = new(); 102 | using CryptoStream cs = new(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write); 103 | cs.Write(clearBytes, 0, clearBytes.Length); 104 | cs.Close(); 105 | input = Convert.ToBase64String(ms.ToArray()); 106 | return input; 107 | } 108 | catch (Exception e) 109 | { 110 | _ = e.AutoDumpExceptionAsync(); 111 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 112 | } 113 | } 114 | 115 | public static async Task EncryptAsync(string input) 116 | { 117 | try 118 | { 119 | var clearBytes = Encoding.Unicode.GetBytes(input); 120 | using var encryptor = Aes.Create(); 121 | Rfc2898DeriveBytes pdb = new(SettingsKey, 122 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 123 | encryptor.Key = pdb.GetBytes(32); 124 | encryptor.IV = pdb.GetBytes(16); 125 | await using MemoryStream ms = new(); 126 | await using CryptoStream cs = new(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write); 127 | await cs.WriteAsync(clearBytes.AsMemory(0, clearBytes.Length)); 128 | cs.Close(); 129 | input = Convert.ToBase64String(ms.ToArray()); 130 | return input; 131 | } 132 | catch (Exception e) 133 | { 134 | await e.AutoDumpExceptionAsync(); 135 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 136 | } 137 | } 138 | 139 | public static async Task EncryptThemeAsync(string input) 140 | { 141 | try 142 | { 143 | var clearBytes = Encoding.Unicode.GetBytes(input); 144 | using var encryptor = Aes.Create(); 145 | const string key = "Kbs8WST6xEenNSZr3Sn22SsDCDHVQbaSAxhUmEPr7H4YQWbgaLpMMN37ZeByegxyYvLAPv8VUhxquZUuZz5n8D8Mm3r4DyFNS9aY9b88fU93VUtadJNz5eAX2WE2XVXG"; 146 | Rfc2898DeriveBytes pdb = new(key, 147 | new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); 148 | encryptor.Key = pdb.GetBytes(32); 149 | encryptor.IV = pdb.GetBytes(16); 150 | await using MemoryStream ms = new(); 151 | await using CryptoStream cs = new(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write); 152 | cs.Write(clearBytes, 0, clearBytes.Length); 153 | cs.Close(); 154 | input = Convert.ToBase64String(ms.ToArray()); 155 | return input; 156 | } 157 | catch (Exception e) 158 | { 159 | await e.AutoDumpExceptionAsync(); 160 | return JsonConvert.SerializeObject(new {error = "Encryption failed"}); 161 | } 162 | } 163 | } 164 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/ServerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Threading.Tasks; 5 | using CyberSniff.Interfaces; 6 | using CyberSniff.Models; 7 | using Newtonsoft.Json; 8 | 9 | namespace CyberSniff.Classes 10 | { 11 | public class ServerSettings : IServerSettings 12 | { 13 | public async void GetSettingsAsync() 14 | { 15 | var fileLocation = Path.Combine( 16 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CSniffOSS", "settings.bin"); 17 | if (!File.Exists(fileLocation)) 18 | { 19 | if (!Directory.Exists(Path.GetDirectoryName(fileLocation))) 20 | Directory.CreateDirectory(Path.GetDirectoryName(fileLocation)); 21 | 22 | Globals.Settings = new Settings(); 23 | await UpdateSettingsAsync(); 24 | } 25 | 26 | var contents = await File.ReadAllTextAsync(fileLocation); 27 | 28 | var decryptedContents = await Security.DecryptAsync(contents); 29 | 30 | var jsonResp = JsonConvert.DeserializeObject(decryptedContents); 31 | 32 | Globals.Settings = jsonResp; 33 | } 34 | 35 | [Obfuscation(Feature = "virtualization", Exclude = false)] 36 | public async Task UpdateSettingsAsync() 37 | { 38 | var newSettings = new Settings 39 | { 40 | PacketAnalyser = Globals.Settings.PacketAnalyser, 41 | ShowFlags = Globals.Settings.ShowFlags, 42 | AutoShowPanel = Globals.Settings.AutoShowPanel, 43 | DiscordStatus = Globals.Settings.DiscordStatus, 44 | Background = Globals.Settings.Background, 45 | ColorType = Globals.Settings.ColorType, 46 | DynamicRemove = Globals.Settings.DynamicRemove, 47 | EnableLabels = Globals.Settings.EnableLabels, 48 | Filter = Globals.Settings.Filter, 49 | Geolocate = Globals.Settings.Geolocate, 50 | HardwareAccel = Globals.Settings.HardwareAccel, 51 | HexColor = Globals.Settings.HexColor, 52 | HideInterfaces = Globals.Settings.HideInterfaces, 53 | InterfaceName = Globals.Settings.InterfaceName, 54 | Labels = Globals.Settings.Labels, 55 | Ports = Globals.Settings.Ports, 56 | PortsInverse = Globals.Settings.PortsInverse, 57 | RememberInterface = Globals.Settings.RememberInterface, 58 | TopMost = Globals.Settings.TopMost 59 | }; 60 | var json = JsonConvert.SerializeObject(newSettings); 61 | var encryptedJson = await Security.EncryptAsync(json); 62 | 63 | await File.WriteAllTextAsync(Path.Combine( 64 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CSniffOSS", "settings.bin"), 65 | encryptedJson); 66 | 67 | return true; 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/ThemeUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Media; 8 | using System.Windows.Media.Imaging; 9 | using CyberSniff.Interfaces; 10 | using CyberSniff.Models; 11 | using CyberSniff.Properties; 12 | using CyberSniff.Windows; 13 | using MaterialDesignThemes.Wpf; 14 | using Newtonsoft.Json; 15 | using Theme = CyberSniff.Models.Theme; 16 | 17 | namespace CyberSniff.Classes 18 | { 19 | public class ThemeUtils : IThemeUtils 20 | { 21 | public async Task ExportTheme(string path) 22 | { 23 | var obj = new Theme 24 | { 25 | CustomColorBrush = (Color) ColorConverter.ConvertFromString(Globals.Settings.HexColor), DarkMode = true, 26 | PrimaryColor = Globals.Settings.ColorType, SecondaryColor = Globals.Settings.ColorType 27 | }; 28 | 29 | if (Globals.Settings.Background != "None") 30 | { 31 | var wpBytes = 32 | await File.ReadAllBytesAsync( 33 | Path.GetFullPath(Globals.Settings.Background)); // Reads all wallpaper bytes asynchronously 34 | 35 | var expObj1 = JsonConvert.SerializeObject(new ThemeExport 36 | { 37 | ThemeObject = obj, 38 | BackgroundFileName = Path.GetFileName(Globals.Settings.Background), 39 | PictureBytes = wpBytes, 40 | Author = Environment.UserName 41 | }, Formatting.None); 42 | 43 | await File.WriteAllTextAsync(path, await Security.EncryptThemeAsync(expObj1)); 44 | return; 45 | } 46 | 47 | var expObj = JsonConvert.SerializeObject(new ThemeExport 48 | { 49 | ThemeObject = obj, 50 | Author = Environment.UserName 51 | }, Formatting.None); 52 | 53 | await File.WriteAllTextAsync(path, await Security.EncryptThemeAsync(expObj)); 54 | } 55 | 56 | public async Task ImportTheme(string path) 57 | { 58 | var theme = 59 | JsonConvert.DeserializeObject( 60 | await Security.DecryptThemeAsync(await File.ReadAllTextAsync(path))); 61 | Globals.Settings.ColorType = theme.ThemeObject.PrimaryColor; 62 | if (theme.BackgroundFileName != null) 63 | { 64 | var imagePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 65 | "CSniffOSS", "themes", "images", theme.BackgroundFileName); 66 | if (!Directory.Exists(Path.GetDirectoryName(imagePath))) 67 | Directory.CreateDirectory(Path.GetDirectoryName(imagePath)); 68 | if (!File.Exists(imagePath)) await File.WriteAllBytesAsync(imagePath, theme.PictureBytes); 69 | Globals.Settings.Background = imagePath; 70 | } 71 | else 72 | { 73 | Globals.Settings.Background = "None"; 74 | } 75 | 76 | Globals.Settings.HexColor = theme.ThemeObject.CustomColorBrush.ToHex(); 77 | SwitchTheme(new Theme 78 | { 79 | CustomColorBrush = (Color) ColorConverter.ConvertFromString(Globals.Settings.HexColor), DarkMode = true, 80 | PrimaryColor = Globals.Settings.ColorType, SecondaryColor = Globals.Settings.ColorType 81 | }); 82 | } 83 | 84 | public bool IsImage(string filename) 85 | { 86 | try 87 | { 88 | _ = new BitmapImage(new Uri(filename)); 89 | } 90 | catch (NotSupportedException) 91 | { 92 | return false; 93 | } 94 | 95 | return true; 96 | } 97 | 98 | public MsgBox.MsgBoxResult MsgBox(MsgBox m) 99 | { 100 | CustomMsgBox msgBox = null; 101 | var thread = new Thread(() => 102 | { 103 | msgBox = new CustomMsgBox(m); 104 | msgBox.ShowDialog(); 105 | }); 106 | thread.SetApartmentState(ApartmentState.STA); 107 | thread.Start(); 108 | thread.Join(); 109 | return msgBox.Result; 110 | } 111 | 112 | public async void SwitchTheme(Theme colorObject) 113 | { 114 | try 115 | { 116 | var baseTheme = colorObject.DarkMode 117 | ? MaterialDesignThemes.Wpf.Theme.Dark 118 | : MaterialDesignThemes.Wpf.Theme.Light; 119 | switch (colorObject.PrimaryColor) 120 | { 121 | case ColorType.Default: 122 | ITheme defaultTheme3 = MaterialDesignThemes.Wpf.Theme.Create(baseTheme, 123 | Color.FromRgb(255, 87, 34), Color.FromRgb(221, 44, 0)); 124 | Application.Current.Resources.SetTheme(defaultTheme3); 125 | break; 126 | 127 | case ColorType.Accent: 128 | ITheme defaultTheme1 = MaterialDesignThemes.Wpf.Theme.Create(baseTheme, 129 | SystemParameters.WindowGlassColor, SystemParameters.WindowGlassColor); 130 | Application.Current.Resources.SetTheme(defaultTheme1); 131 | break; 132 | 133 | case ColorType.Custom: 134 | ITheme defaultTheme2 = MaterialDesignThemes.Wpf.Theme.Create(baseTheme, 135 | colorObject.CustomColorBrush, colorObject.CustomColorBrush); 136 | Application.Current.Resources.SetTheme(defaultTheme2); 137 | break; 138 | 139 | default: 140 | var pColor = (Color) ColorConverter.ConvertFromString(colorObject.PrimaryColor.ToString()); 141 | var sColor = (Color) ColorConverter.ConvertFromString(colorObject.SecondaryColor.ToString()); 142 | ITheme theme = MaterialDesignThemes.Wpf.Theme.Create(baseTheme, pColor, sColor); 143 | Application.Current.Resources.SetTheme(theme); 144 | break; 145 | } 146 | } 147 | catch (Exception e) 148 | { 149 | await e.AutoDumpExceptionAsync(); 150 | MessageBox.Show($"{Resources.GENERIC_EXCEPTION}\n\nWhat happened: {e.Message}", "CyberSniff", 151 | MessageBoxButton.OK, MessageBoxImage.Warning); 152 | 153 | Environment.Exit(0); 154 | } 155 | } 156 | } 157 | } -------------------------------------------------------------------------------- /CyberSniff/Classes/Web.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Net.Http.Headers; 7 | using System.Reflection; 8 | using System.Threading.Tasks; 9 | using CyberSniff.Interfaces; 10 | using CyberSniff.Models; 11 | using Newtonsoft.Json; 12 | 13 | namespace CyberSniff.Classes 14 | { 15 | public static class Web 16 | { 17 | private static readonly HttpClient Client; 18 | static Web() 19 | { 20 | HttpClientHandler httpClientHandler = new() 21 | { 22 | Proxy = null, 23 | UseProxy = false, 24 | UseCookies = false, 25 | AutomaticDecompression = DecompressionMethods.All, 26 | }; 27 | Client = new HttpClient(httpClientHandler); 28 | Client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("CyberSniff", 29 | Assembly.GetCallingAssembly().GetName().Version?.ToString())); 30 | } 31 | 32 | public static async Task IpLocationAsync(IPAddress ip) 33 | { 34 | try 35 | { 36 | var geoCacheManager = Globals.Container.GetInstance>>(); 37 | var geoCache = geoCacheManager.GetCache() ?? new List(); 38 | 39 | if (geoCache.Any(x => x.IpAddress == ip.ToString())) 40 | return geoCache.FirstOrDefault(x => x.IpAddress == ip.ToString()); 41 | 42 | var response = await Client.GetStringAsync($"http://ip-api.com/json/{ip}?fields=66846719"); 43 | 44 | var json = JsonConvert.DeserializeObject(response); 45 | 46 | // Construct cache from the response 47 | var cache = new GeolocationCache 48 | { 49 | IpAddress = ip.ToString() 50 | }; 51 | cache.ConstructFromGeolocationResponse(json); 52 | 53 | // Add and write to the cache 54 | geoCache.Add(cache); 55 | geoCacheManager.WriteCache(geoCache); 56 | 57 | return json; 58 | } 59 | catch (Exception e) 60 | { 61 | await e.AutoDumpExceptionAsync(); 62 | return null; 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /CyberSniff/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CyberSniff.Converters 6 | { 7 | [ValueConversion(typeof(bool), typeof(bool))] 8 | public class InverseBooleanConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, 11 | CultureInfo culture) 12 | { 13 | if (targetType != typeof(bool)) 14 | throw new InvalidOperationException("The target must be a boolean"); 15 | 16 | return value != null && !(bool) value; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, 20 | CultureInfo culture) 21 | { 22 | throw new NotSupportedException(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /CyberSniff/Globals.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Models; 2 | using SimpleInjector; 3 | 4 | namespace CyberSniff 5 | { 6 | public static class Globals 7 | { 8 | public static readonly Container Container = new(); 9 | 10 | public static Settings Settings; 11 | } 12 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Interfaces; 2 | 3 | public interface ICacheManager 4 | { 5 | void ClearCache(); 6 | T GetCache(); 7 | void WriteCache(T cache); 8 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IDiscordPresenceService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DiscordRPC; 3 | 4 | namespace CyberSniff.Interfaces 5 | { 6 | public interface IDiscordPresenceService 7 | { 8 | RichPresence Presence { get; set; } 9 | void CreateInstance(); 10 | RichPresence GetRichPresence(); 11 | void ResetPresence(); 12 | void Dispose(); 13 | void ClearPresence(); 14 | void DeInitialize(); 15 | void Initialize(); 16 | void ResetTimestamps(); 17 | void UpdateDetails(string details); 18 | void UpdateState(string state); 19 | void UpdateTimestamps(); 20 | void SetPresence(); 21 | } 22 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IErrorLogging.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using CyberSniff.Models; 3 | 4 | namespace CyberSniff.Interfaces 5 | { 6 | internal interface IErrorLogging 7 | { 8 | Task WriteToLogAsync(string buffer, LogLevel logType); 9 | } 10 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IExportDrawer.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Models; 2 | using System.ComponentModel; 3 | using System.Threading.Tasks; 4 | 5 | namespace CyberSniff.Interfaces 6 | { 7 | public interface IExportDrawer 8 | { 9 | Task DrawTableForExport(BindingList submittedDataTable, string submittedFilePath); 10 | } 11 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IPacketFilter.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Models; 2 | using System.Threading.Tasks; 3 | 4 | namespace CyberSniff.Interfaces 5 | { 6 | internal interface IPacketFilter 7 | { 8 | public Task FilterPacketAsync(PacketWrapper wrapper); 9 | } 10 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IServerSettings.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Models; 2 | using System.Threading.Tasks; 3 | 4 | namespace CyberSniff.Interfaces 5 | { 6 | public interface IServerSettings 7 | { 8 | void GetSettingsAsync(); 9 | 10 | Task UpdateSettingsAsync(); 11 | } 12 | } -------------------------------------------------------------------------------- /CyberSniff/Interfaces/IThemeUtils.cs: -------------------------------------------------------------------------------- 1 | using CyberSniff.Models; 2 | using System.Threading.Tasks; 3 | 4 | namespace CyberSniff.Interfaces 5 | { 6 | public interface IThemeUtils 7 | { 8 | Task ExportTheme(string path); 9 | 10 | Task ImportTheme(string path); 11 | 12 | bool IsImage(string filename); 13 | 14 | MsgBox.MsgBoxResult MsgBox(MsgBox m); 15 | 16 | void SwitchTheme(Theme colorObject); 17 | } 18 | } -------------------------------------------------------------------------------- /CyberSniff/Models/Adapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.NetworkInformation; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using CyberSniff.Properties; 8 | using PacketDotNet; 9 | using SharpPcap; 10 | using SharpPcap.Npcap; 11 | 12 | namespace CyberSniff.Models; 13 | 14 | public struct Adapter 15 | { 16 | 17 | public static readonly HashSet Instance = new(); 18 | 19 | public AddressFamily AddressFamily { get; set; } 20 | 21 | public string DisplayName { get; private init; } 22 | 23 | public uint? Flags { get; private init; } 24 | 25 | public string FriendlyName { get; private init; } 26 | 27 | public string GatewayAddress { get; private init; } 28 | 29 | public string IpAddress { get; private init; } 30 | 31 | public ushort? KernelBufferSize { get; private init; } 32 | 33 | public LinkLayers? LinkType { get; private init; } 34 | 35 | public bool? Loopback { get; private init; } 36 | 37 | public PhysicalAddress MacAddress { get; private init; } 38 | 39 | public string Name { get; private init; } 40 | 41 | public IntPtr PcapHandle { get; private init; } 42 | 43 | public static async Task InitAdapters() 44 | { 45 | try 46 | { 47 | Instance.Clear(); 48 | var devices = CaptureDeviceList.Instance.ToList(); 49 | foreach (var dev in devices) 50 | try 51 | { 52 | dev.Open(); 53 | var npcapInterface = (NpcapDevice) dev; 54 | if (string.IsNullOrWhiteSpace(npcapInterface.Name) || 55 | string.IsNullOrWhiteSpace(npcapInterface.Interface.FriendlyName)) continue; 56 | if (Globals.Settings.HideInterfaces && string.IsNullOrWhiteSpace(dev.Description)) continue; 57 | 58 | string interfaceLocalAddress; 59 | 60 | if (npcapInterface.Addresses.Any()) 61 | { 62 | interfaceLocalAddress = npcapInterface.Addresses.First().Addr.ToString(); 63 | if (interfaceLocalAddress == "0.0.0.0") interfaceLocalAddress = "N/A"; 64 | } 65 | else 66 | { 67 | interfaceLocalAddress = "N/A"; 68 | } 69 | 70 | var gatewayAddress = npcapInterface.Interface.GatewayAddresses.Any() 71 | ? npcapInterface.Interface.GatewayAddresses.First().ToString() 72 | : "N/A"; 73 | 74 | if (string.IsNullOrWhiteSpace(interfaceLocalAddress) || 75 | !interfaceLocalAddress.CheckRemoteAddr()) interfaceLocalAddress = "N/A"; 76 | var obj = new Adapter 77 | { 78 | AddressFamily = npcapInterface.GetAddressFamily(), 79 | FriendlyName = npcapInterface.Interface.FriendlyName, 80 | DisplayName = 81 | $"{npcapInterface.Interface.FriendlyName} - {npcapInterface.GetAddressFamily()}: {interfaceLocalAddress}", 82 | Flags = npcapInterface.Flags, GatewayAddress = gatewayAddress, 83 | IpAddress = interfaceLocalAddress, LinkType = npcapInterface.LinkType, 84 | KernelBufferSize = 10240, Loopback = npcapInterface.Loopback, 85 | PcapHandle = npcapInterface.PcapHandle, Name = npcapInterface.Name, 86 | MacAddress = npcapInterface.MacAddress 87 | }; 88 | Instance.Add(obj); 89 | } 90 | catch (Exception ex1) 91 | { 92 | await ex1.AutoDumpExceptionAsync(); 93 | dev.Close(); 94 | MessageBox.Show($"{Resources.ADAPTER_EXCEPTION}\n\nWhat happened: {ex1.Message}", "CyberSniff", 95 | MessageBoxButton.OK, MessageBoxImage.Warning); 96 | } 97 | finally 98 | { 99 | dev.Close(); 100 | } 101 | } 102 | catch (Exception ex) 103 | { 104 | if (ex.Message.ToLower().Contains("unable to load dll")) 105 | { 106 | await ex.AutoDumpExceptionAsync(); 107 | MessageBox.Show( 108 | $"{Resources.ADAPTER_EXCEPTION}\n\nYou will need to install Npcap for CyberSniff to work\n\nNeed help installing Npcap? Follow the setup guide at https://cybersniff.net/support/setup\n\nInstalled Npcap and CyberSniff is still not working?\nReport this to us: failed to load dynamic link library. Npcap capture driver was not found or corrupt.", 109 | "CyberSniff", MessageBoxButton.OK, MessageBoxImage.Warning); 110 | Environment.Exit(0); 111 | return; 112 | } 113 | 114 | await ex.AutoDumpExceptionAsync(); 115 | } 116 | 117 | if (Instance.Count == 0) 118 | { 119 | MessageBox.Show( 120 | $"{Resources.ADAPTER_EXCEPTION}\n\nYou will need to install Npcap for CyberSniff to work\n\nNeed help installing Npcap? Follow the setup guide at https://cybersniff.net/support/setup\n\nInstalled Npcap and CyberSniff is still not working?\nReport this to us: detected 0 adapters from capturedevicelist instance.", 121 | "CyberSniff", MessageBoxButton.OK, MessageBoxImage.Warning); 122 | Environment.Exit(0); 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /CyberSniff/Models/AddressFamily.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public enum AddressFamily 4 | { 5 | IPv4, 6 | IPv6, 7 | Null 8 | } 9 | } -------------------------------------------------------------------------------- /CyberSniff/Models/ArpDevice.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.NetworkInformation; 3 | 4 | namespace CyberSniff.Models; 5 | 6 | public struct ArpDevice 7 | { 8 | public bool IsNullRouted { init; get; } 9 | 10 | public IPAddress SourceLocalAddress { init; get; } 11 | 12 | public PhysicalAddress SourcePhysicalAddress { init; get; } 13 | 14 | public IPAddress TargetLocalAddress { get; init; } 15 | 16 | public PhysicalAddress TargetPhysicalAddress { init; get; } 17 | } -------------------------------------------------------------------------------- /CyberSniff/Models/CacheConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models; 2 | 3 | public class CacheConfiguration 4 | { 5 | public string FilePath { get; set; } 6 | } -------------------------------------------------------------------------------- /CyberSniff/Models/CaptureGrid.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Net; 3 | using MaterialDesignThemes.Wpf; 4 | 5 | namespace CyberSniff.Models; 6 | 7 | public struct CaptureGrid : INotifyPropertyChanged 8 | { 9 | private string city; 10 | 11 | private string country; 12 | 13 | private PackIconKind ddosProtected; 14 | 15 | private string flag; 16 | 17 | private readonly IPAddress ipAddress; 18 | 19 | private string isp; 20 | 21 | private string label; 22 | 23 | private readonly ushort port; 24 | 25 | private string protocol; 26 | 27 | private PackIconKind spoofed; 28 | 29 | private string state; 30 | 31 | public event PropertyChangedEventHandler PropertyChanged; 32 | 33 | public string City 34 | { 35 | get => city; 36 | 37 | set 38 | { 39 | city = value; 40 | OnPropertyChanged(nameof(City)); 41 | } 42 | } 43 | 44 | public string Country 45 | { 46 | get => country; 47 | 48 | set 49 | { 50 | country = value; 51 | OnPropertyChanged(nameof(Country)); 52 | } 53 | } 54 | 55 | public PackIconKind DDoSProtected 56 | { 57 | get => ddosProtected; 58 | 59 | set 60 | { 61 | ddosProtected = value; 62 | OnPropertyChanged(nameof(DDoSProtected)); 63 | } 64 | } 65 | 66 | public string Flag 67 | { 68 | get => flag; 69 | 70 | set 71 | { 72 | flag = value; 73 | OnPropertyChanged(nameof(Flag)); 74 | } 75 | } 76 | 77 | public IPAddress IpAddress 78 | { 79 | get => ipAddress; 80 | 81 | init 82 | { 83 | ipAddress = value; 84 | OnPropertyChanged(nameof(IpAddress)); 85 | } 86 | } 87 | 88 | public string Isp 89 | { 90 | get => isp; 91 | 92 | set 93 | { 94 | isp = value; 95 | OnPropertyChanged(nameof(Isp)); 96 | } 97 | } 98 | 99 | public string Label 100 | { 101 | get => label; 102 | 103 | set 104 | { 105 | label = value; 106 | OnPropertyChanged(nameof(Label)); 107 | } 108 | } 109 | 110 | public ushort Port 111 | { 112 | get => port; 113 | 114 | init 115 | { 116 | port = value; 117 | OnPropertyChanged(nameof(Port)); 118 | } 119 | } 120 | 121 | public string Protocol 122 | { 123 | get => protocol; 124 | 125 | set 126 | { 127 | protocol = value; 128 | OnPropertyChanged(nameof(Protocol)); 129 | } 130 | } 131 | 132 | public PackIconKind Spoofed 133 | { 134 | get => spoofed; 135 | 136 | set 137 | { 138 | spoofed = value; 139 | OnPropertyChanged(nameof(Spoofed)); 140 | } 141 | } 142 | 143 | public string State 144 | { 145 | get => state; 146 | 147 | set 148 | { 149 | state = value; 150 | OnPropertyChanged(nameof(State)); 151 | } 152 | } 153 | 154 | private void OnPropertyChanged(string propertyName) 155 | { 156 | var saved = PropertyChanged; 157 | if (saved == null) return; 158 | 159 | var e = new PropertyChangedEventArgs(propertyName); 160 | saved(this, e); 161 | } 162 | } -------------------------------------------------------------------------------- /CyberSniff/Models/ColorType.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public enum ColorType 4 | { 5 | Default, 6 | 7 | Accent, 8 | 9 | Red, 10 | 11 | Yellow, 12 | 13 | Cyan, 14 | 15 | Blue, 16 | 17 | Teal, 18 | 19 | Pink, 20 | 21 | Custom 22 | } 23 | } -------------------------------------------------------------------------------- /CyberSniff/Models/DiscordPresenceConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public class DiscordPresenceConfiguration 4 | { 5 | public ulong ClientId { get; init; } 6 | public string LargeImageKey { get; init; } 7 | public string LargeImageText { get; init; } 8 | } 9 | } -------------------------------------------------------------------------------- /CyberSniff/Models/FilterPreset.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public enum FilterPreset 4 | { 5 | None, 6 | 7 | TCP, 8 | 9 | UDP, 10 | 11 | GTAVConsole, 12 | 13 | RecRoom, 14 | 15 | RainbowSixSiege, 16 | 17 | Discord, 18 | 19 | ApexLegends, 20 | 21 | RocketLeague, 22 | 23 | PSNParty, 24 | 25 | uTorrent, 26 | 27 | GenericTorrentClient, 28 | 29 | XboxPartyBETA 30 | } 31 | } -------------------------------------------------------------------------------- /CyberSniff/Models/GeolocationCache.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace CyberSniff.Models; 4 | 5 | public class GeolocationCache : GeolocationResponse 6 | { 7 | [JsonProperty("ip_address")] public string IpAddress { get; set; } 8 | 9 | public void ConstructFromGeolocationResponse(GeolocationResponse response) 10 | { 11 | Isp = response.Isp; 12 | Asn = response.Asn; 13 | Hostname = response.Hostname; 14 | Region = response.Region; 15 | Isp = response.Isp; 16 | IsHosting = response.IsHosting; 17 | IsHotspot = response.IsHotspot; 18 | IsProxy = response.IsProxy; 19 | Organization = response.Organization; 20 | Continent = response.Continent; 21 | Country = response.Country; 22 | CountryCode = response.CountryCode; 23 | City = response.City; 24 | Latitude = response.Latitude; 25 | Longitude = response.Longitude; 26 | Zip = response.Zip; 27 | Timezone = response.Timezone; 28 | } 29 | } -------------------------------------------------------------------------------- /CyberSniff/Models/GeolocationResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace CyberSniff.Models 4 | { 5 | public class GeolocationResponse 6 | { 7 | [JsonProperty("as")] public string Asn { get; set; } 8 | 9 | [JsonProperty("city")] public string City { get; set; } 10 | 11 | [JsonProperty("continent")] public string Continent { get; set; } 12 | 13 | [JsonProperty("country")] public string Country { get; set; } 14 | 15 | [JsonProperty("countryCode")] public string CountryCode { get; set; } 16 | 17 | [JsonProperty("reverse")] public string Hostname { get; set; } 18 | 19 | [JsonProperty("hosting")] public bool IsHosting { get; set; } 20 | 21 | [JsonProperty("mobile")] public bool IsHotspot { get; set; } 22 | 23 | [JsonProperty("isp")] public string Isp { get; set; } 24 | 25 | [JsonProperty("proxy")] public bool IsProxy { get; set; } 26 | 27 | [JsonProperty("lat")] public string Latitude { get; set; } 28 | 29 | [JsonProperty("lon")] public string Longitude { get; set; } 30 | 31 | [JsonProperty("org")] public string Organization { get; set; } 32 | 33 | [JsonProperty("regionName")] public string Region { get; set; } 34 | 35 | [JsonProperty("timezone")] public string Timezone { get; set; } 36 | 37 | [JsonProperty("zip")] public string Zip { get; set; } 38 | } 39 | } -------------------------------------------------------------------------------- /CyberSniff/Models/Label.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public struct Label 4 | { 5 | public string IpAddress { get; set; } 6 | 7 | public string Name { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /CyberSniff/Models/LogLevel.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public enum LogLevel 4 | { 5 | INFO, 6 | 7 | NOTICE, 8 | 9 | WARNING, 10 | 11 | ERROR, 12 | 13 | FATAL, 14 | 15 | DEBUG 16 | } 17 | } -------------------------------------------------------------------------------- /CyberSniff/Models/MsgBox.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public struct MsgBox 4 | { 5 | public enum MsgBoxBtn 6 | { 7 | YesNo, 8 | 9 | YesNoCancel, 10 | 11 | Ok, 12 | 13 | OkCancel, 14 | 15 | RetryCancel 16 | } 17 | 18 | public enum MsgBoxIcon 19 | { 20 | Error, 21 | 22 | Warning, 23 | 24 | Information, 25 | 26 | Question, 27 | 28 | Success 29 | } 30 | 31 | public enum MsgBoxResult 32 | { 33 | Yes, 34 | 35 | No, 36 | 37 | Cancel, 38 | 39 | Ok, 40 | 41 | Retry 42 | } 43 | 44 | public MsgBoxBtn Button { set; get; } 45 | 46 | public MsgBoxIcon Icon { set; get; } 47 | 48 | public string Message { set; get; } 49 | } 50 | } -------------------------------------------------------------------------------- /CyberSniff/Models/NotificationType.cs: -------------------------------------------------------------------------------- 1 | namespace CyberSniff.Models 2 | { 3 | public enum NotificationType 4 | { 5 | Info, 6 | 7 | Alert, 8 | 9 | Error 10 | } 11 | } -------------------------------------------------------------------------------- /CyberSniff/Models/PacketWrapper.cs: -------------------------------------------------------------------------------- 1 | using PacketDotNet; 2 | using SharpPcap; 3 | 4 | namespace CyberSniff.Models 5 | { 6 | public struct PacketWrapper 7 | { 8 | public RawCapture p; 9 | 10 | public PacketWrapper(int count, RawCapture p) 11 | { 12 | Count = count; 13 | this.p = p; 14 | } 15 | 16 | public int Count { get; } 17 | 18 | public LinkLayers LinkLayerType => p.LinkLayerType; 19 | 20 | public Packet Packet => Packet.ParsePacket(p.LinkLayerType, p.Data); 21 | 22 | public ProtocolType Protocol 23 | { 24 | get 25 | { 26 | var packet = Packet.ParsePacket(LinkLayerType, p.Data); 27 | var ipPacket = packet.Extract(); 28 | return ipPacket?.Protocol ?? ProtocolType.Reserved254; 29 | } 30 | } 31 | 32 | public PosixTimeval TimeValue => p.Timeval; 33 | } 34 | } -------------------------------------------------------------------------------- /CyberSniff/Models/Settings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace CyberSniff.Models 5 | { 6 | public class Settings 7 | { 8 | [JsonProperty("AutoShowPanel")] public bool AutoShowPanel { get; set; } = true; 9 | 10 | [JsonProperty("Background")] public string Background { get; set; } = "None"; 11 | 12 | [JsonProperty("ColorType")] public ColorType ColorType { get; set; } = ColorType.Default; 13 | 14 | [JsonProperty("DiscordStatus")] public bool DiscordStatus { get; set; } = true; 15 | 16 | [JsonProperty("Dynamic Remove")] public bool DynamicRemove { get; set; } = true; 17 | 18 | [JsonProperty("EnableLabels")] public bool EnableLabels { get; set; } 19 | 20 | [JsonProperty("Filter")] public FilterPreset Filter { get; set; } = FilterPreset.None; 21 | 22 | [JsonProperty("Geolocate")] public bool Geolocate { get; set; } = true; 23 | 24 | [JsonProperty("HardwareAccel")] public bool HardwareAccel { get; set; } = true; 25 | 26 | [JsonProperty("HexColor")] public string HexColor { get; set; } = "#ff5722"; 27 | 28 | [JsonProperty("HideInvalidInterfaces")] 29 | public bool HideInterfaces { get; set; } 30 | 31 | [JsonProperty("InterfaceName")] public string InterfaceName { get; set; } 32 | 33 | [JsonProperty("Labels")] public List