diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1d96e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,405 @@ +# Created by https://www.toptal.com/developers/gitignore/api/visualstudio +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/visualstudio \ No newline at end of file diff --git a/README.md b/README.md index db8c88c..94e331f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # SocialOnTheFile Social on the file - Mastodon integration to Windows File Property Sheet + +## Screenshot +![Screenshot](screenshot.png) + +## Related projects +* github.com/Mastodon/Mastodon +* github.com/dwmkerr/sharpshell +* github.com/gnh1201/CatswordsTab + +## Contact me +- abuse@catswords.net +- ActivityPub [@catswords_oss@catswords.social](https://catswords.social/@catswords_oss) diff --git a/SocialOnTheFile.sln b/SocialOnTheFile.sln new file mode 100644 index 0000000..69071a1 --- /dev/null +++ b/SocialOnTheFile.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34322.80 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocialOnTheFile", "SocialOnTheFile\SocialOnTheFile.csproj", "{35CC3E28-05C8-478B-B5A2-15FCE468CE34}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|x64.ActiveCfg = Debug|x64 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|x64.Build.0 = Debug|x64 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|x86.ActiveCfg = Debug|x86 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Debug|x86.Build.0 = Debug|x86 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|Any CPU.Build.0 = Release|Any CPU + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|x64.ActiveCfg = Release|x64 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|x64.Build.0 = Release|x64 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|x86.ActiveCfg = Release|x86 + {35CC3E28-05C8-478B-B5A2-15FCE468CE34}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {97D36B6E-4D22-4DB6-85CB-F45AD4F4334A} + EndGlobalSection +EndGlobal diff --git a/SocialOnTheFile/Helper/FileMagic.cs b/SocialOnTheFile/Helper/FileMagic.cs new file mode 100644 index 0000000..4ffdfec --- /dev/null +++ b/SocialOnTheFile/Helper/FileMagic.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; + +namespace SocialOnTheFile.Helper +{ + public static class FileMagic + { + public static string Error = string.Empty; + + public static string Read(string filePath) + { + string hexString = ""; + + try + { + // 파일 열기 + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + // 첫 3 바이트 읽기 + byte[] buffer = new byte[3] { 0x00, 0x00, 0x00 }; + int bytesRead = fs.Read(buffer, 0, 3); + + // 16진수로 변환하여 출력 + hexString = BitConverter.ToString(buffer).Replace("-", string.Empty).ToLower(); + } + } + catch (Exception ex) + { + hexString = "000000"; + Error = ex.Message; + } + + return hexString; + } + } +} diff --git a/SocialOnTheFile/Helper/ImpHash.cs b/SocialOnTheFile/Helper/ImpHash.cs new file mode 100644 index 0000000..96c9747 --- /dev/null +++ b/SocialOnTheFile/Helper/ImpHash.cs @@ -0,0 +1,68 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace SocialOnTheFile.Helper +{ + public static class ImpHash + { + public static string Calculate(string filePath) + { + string imphash = ""; + + using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + using (BinaryReader binaryReader = new BinaryReader(fileStream)) + { + // DOS Header 크기만큼 스킵 + binaryReader.BaseStream.Seek(0x3C, SeekOrigin.Begin); + int peHeaderOffset = binaryReader.ReadInt32(); + + // PE Header로 이동 + binaryReader.BaseStream.Seek(peHeaderOffset, SeekOrigin.Begin); + + // Signature 확인 + uint signature = binaryReader.ReadUInt32(); + if (signature != 0x00004550) // "PE\0\0" + { + throw new InvalidOperationException("Invalid PE file"); + } + + // Optional Header에서 Import Table Offset 찾기 + binaryReader.BaseStream.Seek(20, SeekOrigin.Current); // COFF 파일 헤더 크기만큼 스킵 + ushort optionalHeaderSize = binaryReader.ReadUInt16(); + binaryReader.BaseStream.Seek(42, SeekOrigin.Current); // ImageBase 크기만큼 스킵 + + int importTableOffset = peHeaderOffset + 24 + optionalHeaderSize; + binaryReader.BaseStream.Seek(importTableOffset, SeekOrigin.Begin); + + // Import Table에서 imphash 생성 + StringBuilder imphashBuilder = new StringBuilder(); + while (true) + { + uint lookupTableRVA = binaryReader.ReadUInt32(); + if (lookupTableRVA == 0) + { + break; + } + + binaryReader.BaseStream.Seek(12, SeekOrigin.Current); // 다른 필드들을 스킵 + binaryReader.BaseStream.Seek(4, SeekOrigin.Current); // 항상 0인 TimeDateStamp 필드를 스킵 + + imphashBuilder.Append(lookupTableRVA.ToString("X8")); + } + + // MD5 해시 생성 + using (MD5 md5 = MD5.Create()) + { + byte[] hashBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(imphashBuilder.ToString())); + imphash = BitConverter.ToString(hashBytes).Replace("-", string.Empty).ToLower(); + } + } + } + + return imphash; + } + } +} diff --git a/SocialOnTheFile/Helper/Timeline.cs b/SocialOnTheFile/Helper/Timeline.cs new file mode 100644 index 0000000..26cd9d0 --- /dev/null +++ b/SocialOnTheFile/Helper/Timeline.cs @@ -0,0 +1,90 @@ +using Newtonsoft.Json.Linq; +using SocialOnTheFile.Model; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace SocialOnTheFile.Helper +{ + public class Timeline + { + public string ApiBaseUrl; + public string AccessToken; + public List Indicators; + public string ResponseText; + + public Timeline(string host, string access_token) + { + ApiBaseUrl = $"https://{host}/api/v1/timelines/tag"; + AccessToken = access_token; + Indicators = new List(); + } + + public static string RemoveHtmlTags(string input) + { + // 정규 표현식을 사용하여 HTML 태그 제거 + string pattern = "<.*?>"; + string replacement = ""; + Regex regex = new Regex(pattern); + string result = regex.Replace(input, replacement); + + return result; + } + + public static string FormatDateTime(string dateString) + { + string formattedDateTime = ""; + + // 날짜와 시간을 파싱 + if (DateTime.TryParseExact(dateString, "MM/dd/yyyy HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out DateTime parsedDateTime)) + { + // UTC에서 로컬 시간으로 변환 + DateTime localTime = parsedDateTime.ToLocalTime(); + + // 현재 스레드의 문화권에 따라 날짜와 시간 출력 + formattedDateTime = localTime.ToString(); + } + + return formattedDateTime; + } + + public void Fetch(string q) + { + using (HttpClient client = new HttpClient()) + { + client.DefaultRequestHeaders.Add("Authorization", $"Bearer {AccessToken}"); + + try + { + // 데이터 요청 + Task responseTask = client.GetAsync($"{ApiBaseUrl}/{q}"); + responseTask.Wait(); + + // 응답 본문 저장 + HttpResponseMessage response = responseTask.Result; + Task readAsStringTask = response.Content.ReadAsStringAsync(); + readAsStringTask.Wait(); + ResponseText = readAsStringTask.Result; + + // JSON 파싱 + JArray statuses = JArray.Parse(ResponseText); + + foreach (var status in statuses) + { + string createdAt = status["created_at"].Value(); + string content = status["content"].Value(); + + Indicators.Add(new Indicator + { + CreatedAt = FormatDateTime(createdAt), + Content = RemoveHtmlTags(content) + }); + } + } + catch { } + } + } + } +} diff --git a/SocialOnTheFile/Model/Indicator.cs b/SocialOnTheFile/Model/Indicator.cs new file mode 100644 index 0000000..88ff6dc --- /dev/null +++ b/SocialOnTheFile/Model/Indicator.cs @@ -0,0 +1,10 @@ +namespace SocialOnTheFile.Model +{ + public class Indicator + { + public string Id { get; set; } + public string Content { get; set; } + public string Url { get; set; } + public string CreatedAt { get; set; } + } +} diff --git a/SocialOnTheFile/Properties/AssemblyInfo.cs b/SocialOnTheFile/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eb79f9c --- /dev/null +++ b/SocialOnTheFile/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SocialOnTheFile")] +[assembly: AssemblyDescription("SocialOnTheFile")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Catswords Research")] +[assembly: AssemblyProduct("SocialOnTheFile")] +[assembly: AssemblyCopyright("(C) 2023, Catswords Research.")] +[assembly: AssemblyTrademark("SocialOnTheFile")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(true)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("35cc3e28-05c8-478b-b5a2-15fce468ce34")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SocialOnTheFile/Properties/Resources.Designer.cs b/SocialOnTheFile/Properties/Resources.Designer.cs new file mode 100644 index 0000000..629e946 --- /dev/null +++ b/SocialOnTheFile/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace SocialOnTheFile.Properties { + using System; + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SocialOnTheFile.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. + /// + internal static System.Drawing.Bitmap image1 { + get { + object obj = ResourceManager.GetObject("image1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/SocialOnTheFile/Properties/Resources.resx b/SocialOnTheFile/Properties/Resources.resx new file mode 100644 index 0000000..dece6fe --- /dev/null +++ b/SocialOnTheFile/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\image1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/SocialOnTheFile/Resources/image1.png b/SocialOnTheFile/Resources/image1.png new file mode 100644 index 0000000..b22297f Binary files /dev/null and b/SocialOnTheFile/Resources/image1.png differ diff --git a/SocialOnTheFile/SocialOnTheFile.csproj b/SocialOnTheFile/SocialOnTheFile.csproj new file mode 100644 index 0000000..998965b --- /dev/null +++ b/SocialOnTheFile/SocialOnTheFile.csproj @@ -0,0 +1,134 @@ + + + + + Debug + AnyCPU + {35CC3E28-05C8-478B-B5A2-15FCE468CE34} + Library + SocialOnTheFile + SocialOnTheFile + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + + + true + + + signature.snk + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\SharpShell.2.7.2\lib\net40-client\SharpShell.dll + False + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + UserControl + + + SocialOnTheFilePage.cs + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SocialOnTheFilePage.cs + + + + + + + + + + + + \ No newline at end of file diff --git a/SocialOnTheFile/SocialOnTheFilePage.Designer.cs b/SocialOnTheFile/SocialOnTheFilePage.Designer.cs new file mode 100644 index 0000000..084b2ce --- /dev/null +++ b/SocialOnTheFile/SocialOnTheFilePage.Designer.cs @@ -0,0 +1,133 @@ +namespace SocialOnTheFile +{ + partial class SocialOnTheFilePage + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 구성 요소 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.label2 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(123, 63); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(118, 42); + this.label1.TabIndex = 1; + this.label1.Text = "label1"; + // + // listView1 + // + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.listView1.HideSelection = false; + this.listView1.Location = new System.Drawing.Point(13, 126); + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(347, 277); + this.listView1.TabIndex = 3; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "CreatedAt"; + this.columnHeader1.Width = 120; + // + // columnHeader2 + // + this.columnHeader2.Text = "Content"; + this.columnHeader2.Width = 200; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(10, 417); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(122, 13); + this.linkLabel1.TabIndex = 4; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "Write a review to this file"; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(127, 46); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(118, 16); + this.label2.TabIndex = 5; + this.label2.Text = "Conversations with"; + // + // textBox1 + // + this.textBox1.BackColor = System.Drawing.Color.White; + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Location = new System.Drawing.Point(11, 446); + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(349, 13); + this.textBox1.TabIndex = 6; + // + // SocialOnTheFilePage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.BackgroundImage = global::SocialOnTheFile.Properties.Resources.image1; + this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.Controls.Add(this.textBox1); + this.Controls.Add(this.label2); + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.listView1); + this.Controls.Add(this.label1); + this.DoubleBuffered = true; + this.Name = "SocialOnTheFilePage"; + this.Size = new System.Drawing.Size(491, 477); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox textBox1; + } +} diff --git a/SocialOnTheFile/SocialOnTheFilePage.cs b/SocialOnTheFile/SocialOnTheFilePage.cs new file mode 100644 index 0000000..8dc17ef --- /dev/null +++ b/SocialOnTheFile/SocialOnTheFilePage.cs @@ -0,0 +1,148 @@ +using SharpShell.Attributes; +using SharpShell.ServerRegistration; +using SharpShell.SharpPropertySheet; +using SocialOnTheFile.Model; +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace SocialOnTheFile +{ + [ComVisible(true)] + [COMServerAssociation(AssociationType.AllFiles)] + public partial class SocialOnTheFilePage: SharpPropertyPage + { + private string filePath; + private string fileMagic; + private string fileName; + private string fileExtension; + + /// + /// Initializes a new instance of the class. + /// + public SocialOnTheFilePage() + { + InitializeComponent(); + + // Set the page title. + PageTitle = "FileToots"; + + // Note: You can also set the icon to be used: + // PageIcon = Properties.Resources.SomeIcon; + } + + /// + /// Called when the page is initialised. + /// + /// The parent property sheet. + protected override void OnPropertyPageInitialised(SharpPropertySheet parent) + { + // Store the file path. + filePath = parent.SelectedItemPaths.First(); + + // Get first 4 bytes from the file. + fileMagic = Helper.FileMagic.Read(filePath); + + // Show file magic to the label + label1.Text = "#0x" + fileMagic; + if (Helper.FileMagic.Error != string.Empty) + { + textBox1.Text = Helper.FileMagic.Error; + } + + // Get file name and file extension + try + { + fileExtension = Path.GetExtension(filePath); + fileName = Path.GetFileName(filePath); + if (fileExtension.Length > 0 && fileExtension.Substring(0, 1) == ".") + { + fileExtension = fileExtension.Substring(1); + } + } + catch + { + fileExtension = ""; + fileName = ""; + } + + // Request a timeline + var search = new Helper.Timeline("catswords.social", "HDVTEfLswvSJZq5MRpim2tp7DifTcgKbMl0mBM5-uHw"); + + // fetch data by file magic + search.Fetch("0x" + fileMagic); + + // if PE format (ImpHash) + if (fileMagic.StartsWith("4d5a")) + { + try + { + string imphash = Helper.ImpHash.Calculate(filePath); + search.Fetch(imphash); + textBox1.Text = imphash; + } + catch (Exception ex) + { + textBox1.Text = ex.Message; + } + } + + // fetch data by file extension + if (fileExtension.Length > 0) + { + search.Fetch(fileExtension); + + // if Office365 format + if (fileExtension.StartsWith("xls") || fileExtension.StartsWith("ppt") || fileExtension.StartsWith("doc")) + { + search.Fetch("office365"); + } + } + + // if it contains ransomware keywords + if (fileName.ToLower().Contains("readme") || fileName.ToLower().Contains("decrypt")) + { + search.Fetch("ransomware"); + } + + // if IoC (Indicators of Compomise) mode + if (fileMagic == "58354f") // EICAR test file header + { + search.Fetch("ioc"); + } + + // Show the timeline + foreach (Indicator ind in search.Indicators) + { + listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt, ind.Content })); + } + } + + /// + /// Called when apply is pressed on the property sheet, or the property + /// sheet is dismissed with the OK button. + /// + protected override void OnPropertySheetApply() + { + // code here + } + + /// + /// Called when OK is pressed on the property sheet. + /// + protected override void OnPropertySheetOK() + { + // code here + } + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://catswords.social/"); + } + } +} diff --git a/SocialOnTheFile/SocialOnTheFilePage.resx b/SocialOnTheFile/SocialOnTheFilePage.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SocialOnTheFile/SocialOnTheFilePage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SocialOnTheFile/SocialOnTheFileSheet.cs b/SocialOnTheFile/SocialOnTheFileSheet.cs new file mode 100644 index 0000000..76e32dd --- /dev/null +++ b/SocialOnTheFile/SocialOnTheFileSheet.cs @@ -0,0 +1,44 @@ +using SharpShell.Attributes; +using SharpShell.SharpPropertySheet; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; + +namespace SocialOnTheFile +{ + /// + /// The ResourcesPropertySheet is a shell extension to show the managed + /// and unmanaged resources containing in binary files. + /// + [ComVisible(true)] + [COMServerAssociation(AssociationType.AllFiles)] + public class SocialOnTheFileSheet : SharpPropertySheet + { + /// + /// Determines whether this instance can show a shell property sheet, given the specified selected file list. + /// + /// + /// true if this instance should show a shell property sheet for the specified file list; otherwise, false. + /// + protected override bool CanShowSheet() + { + // We will only show the resources pages if we have ONE file selected. + return SelectedItemPaths.Count() == 1; + } + + /// + /// Creates the pages. + /// + /// + /// The property sheet pages. + /// + protected override IEnumerable CreatePages() + { + // Create the property sheet page. + var page = new SocialOnTheFilePage(); + + // Return the pages we've created. + return new[] { page }; + } + } +} diff --git a/SocialOnTheFile/app.config b/SocialOnTheFile/app.config new file mode 100644 index 0000000..25bc80d --- /dev/null +++ b/SocialOnTheFile/app.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/SocialOnTheFile/packages.config b/SocialOnTheFile/packages.config new file mode 100644 index 0000000..39ac2d7 --- /dev/null +++ b/SocialOnTheFile/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/SocialOnTheFile/signature.snk b/SocialOnTheFile/signature.snk new file mode 100644 index 0000000..9434b73 Binary files /dev/null and b/SocialOnTheFile/signature.snk differ diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..a2fee76 Binary files /dev/null and b/screenshot.png differ