some fixes
This commit is contained in:
parent
37fdb5016f
commit
31712d00ee
|
@ -108,13 +108,15 @@
|
||||||
<Compile Include="Helper\ApkManifestExtractor.cs" />
|
<Compile Include="Helper\ApkManifestExtractor.cs" />
|
||||||
<Compile Include="Helper\FileHasher.cs" />
|
<Compile Include="Helper\FileHasher.cs" />
|
||||||
<Compile Include="Helper\FileExtensionDB.cs" />
|
<Compile Include="Helper\FileExtensionDB.cs" />
|
||||||
<Compile Include="Helper\FileCompany.cs" />
|
<Compile Include="Helper\PeOrganizationExtractor.cs" />
|
||||||
<Compile Include="Helper\FileMagic.cs" />
|
<Compile Include="Helper\FileMagic.cs" />
|
||||||
<Compile Include="Helper\LinkExtractor.cs" />
|
<Compile Include="Helper\LinkExtractor.cs" />
|
||||||
<Compile Include="Helper\ImpHash.cs" />
|
<Compile Include="Helper\ImpHash.cs" />
|
||||||
|
<Compile Include="Helper\ExifTagExtractor.cs" />
|
||||||
<Compile Include="Helper\OpenXMLExtractor.cs" />
|
<Compile Include="Helper\OpenXMLExtractor.cs" />
|
||||||
<Compile Include="Helper\Timeline.cs" />
|
<Compile Include="Helper\Timeline.cs" />
|
||||||
<Compile Include="Model\AndroidPermission.cs" />
|
<Compile Include="Model\AndroidPermission.cs" />
|
||||||
|
<Compile Include="Model\ExifTag.cs" />
|
||||||
<Compile Include="Model\FileHash.cs" />
|
<Compile Include="Model\FileHash.cs" />
|
||||||
<Compile Include="Model\Indicator.cs" />
|
<Compile Include="Model\Indicator.cs" />
|
||||||
<Compile Include="Model\OpenXMLMetadata.cs" />
|
<Compile Include="Model\OpenXMLMetadata.cs" />
|
||||||
|
@ -194,5 +196,8 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\link-symbol_icon-icons.com_56927.png" />
|
<None Include="Resources\link-symbol_icon-icons.com_56927.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\tags_icon-icons.com_73382.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
44
Catswords.DataType.Client/Helper/ExifTagExtractor.cs
Normal file
44
Catswords.DataType.Client/Helper/ExifTagExtractor.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using Catswords.DataType.Client.Model;
|
||||||
|
using MetadataExtractor;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Catswords.DataType.Client.Helper
|
||||||
|
{
|
||||||
|
class ExifTagExtractor
|
||||||
|
{
|
||||||
|
private string FilePath;
|
||||||
|
|
||||||
|
public ExifTagExtractor(string filePath)
|
||||||
|
{
|
||||||
|
FilePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExifTag> GetTags()
|
||||||
|
{
|
||||||
|
List<ExifTag> tags = new List<ExifTag>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
IEnumerable<Directory> directories = ImageMetadataReader.ReadMetadata(FilePath);
|
||||||
|
foreach (var directory in directories)
|
||||||
|
{
|
||||||
|
foreach (var tag in directory.Tags)
|
||||||
|
{
|
||||||
|
tags.Add(new ExifTag
|
||||||
|
{
|
||||||
|
Section = directory.Name,
|
||||||
|
Name = tag.Name,
|
||||||
|
Description = tag.Description.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,7 +73,7 @@ namespace Catswords.DataType.Client.Helper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetStrings()
|
public List<string> GetStrings()
|
||||||
{
|
{
|
||||||
List<string> results = new List<string>();
|
List<string> results = new List<string>();
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace Catswords.DataType.Client.Helper
|
||||||
MessageBox.Show($"An error occurred: {ex.Message}");
|
MessageBox.Show($"An error occurred: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.ToArray();
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
103
Catswords.DataType.Client/Helper/PeOrganizationExtractor.cs
Normal file
103
Catswords.DataType.Client/Helper/PeOrganizationExtractor.cs
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
|
namespace Catswords.DataType.Client.Helper
|
||||||
|
{
|
||||||
|
class PeOrganizationExtractor
|
||||||
|
{
|
||||||
|
private string FilePath;
|
||||||
|
|
||||||
|
public PeOrganizationExtractor(string filePath)
|
||||||
|
{
|
||||||
|
FilePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetString()
|
||||||
|
{
|
||||||
|
// 회사 정보 추출
|
||||||
|
string[] companies = new string[] { GetCompanyInfo(), GetProductName(), GetCopyrightInfo(), GetOrganization() };
|
||||||
|
foreach (string company in companies)
|
||||||
|
{
|
||||||
|
if (company != null && !company.Equals(string.Empty))
|
||||||
|
{
|
||||||
|
return company;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOrganization()
|
||||||
|
{
|
||||||
|
string organization = string.Empty;
|
||||||
|
|
||||||
|
// 서명된 파일인 경우 인증서 정보 추출
|
||||||
|
X509Certificate2 certificate = GetCertificateInfo();
|
||||||
|
if (certificate != null)
|
||||||
|
{
|
||||||
|
// Subject 필드에서 O (Organization) 값을 찾아 회사 정보 추출
|
||||||
|
string[] fields = certificate.Subject.Split(',');
|
||||||
|
|
||||||
|
foreach (string field in fields)
|
||||||
|
{
|
||||||
|
string[] keyValue = field.Trim().Split('=');
|
||||||
|
|
||||||
|
if (keyValue.Length == 2 && keyValue[0].Trim().Equals("O", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
organization = keyValue[1].Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return organization;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCompanyInfo()
|
||||||
|
{
|
||||||
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(FilePath);
|
||||||
|
return versionInfo.CompanyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetProductName()
|
||||||
|
{
|
||||||
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(FilePath);
|
||||||
|
return versionInfo.ProductName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCopyrightInfo()
|
||||||
|
{
|
||||||
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(FilePath);
|
||||||
|
return versionInfo.LegalCopyright;
|
||||||
|
}
|
||||||
|
|
||||||
|
private X509Certificate2 GetCertificateInfo()
|
||||||
|
{
|
||||||
|
// GetCertificateInfo 구현
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 파일에 디지털 서명이 있는지 확인
|
||||||
|
Assembly assembly = Assembly.LoadFile(FilePath);
|
||||||
|
X509Certificate2 certificate = new X509Certificate2(assembly.Location);
|
||||||
|
|
||||||
|
// 서명이 유효한지 확인 (옵션)
|
||||||
|
X509Chain chain = new X509Chain();
|
||||||
|
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; // 여러 인증서를 사용하는 경우 인증서 연쇄를 무시할 수 있습니다.
|
||||||
|
|
||||||
|
if (chain.Build(certificate))
|
||||||
|
{
|
||||||
|
return certificate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
Catswords.DataType.Client/Model/ExifTag.cs
Normal file
9
Catswords.DataType.Client/Model/ExifTag.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Catswords.DataType.Client.Model
|
||||||
|
{
|
||||||
|
class ExifTag
|
||||||
|
{
|
||||||
|
public string Section { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -139,5 +139,15 @@ namespace Catswords.DataType.Client.Properties {
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tags_icon_icons_com_73382 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tags_icon_icons_com_73382", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,9 @@
|
||||||
<data name="office_18907" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="office_18907" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\office_18907.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\office_18907.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="tags_icon_icons_com_73382" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\tags_icon-icons.com_73382.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="_2333410_android_os_smartphone_85588" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="_2333410_android_os_smartphone_85588" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\2333410-android-os-smartphone_85588.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\2333410-android-os-smartphone_85588.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -1,11 +1,8 @@
|
||||||
using Catswords.DataType.Client.Helper;
|
using Catswords.DataType.Client.Helper;
|
||||||
using Catswords.DataType.Client.Model;
|
using Catswords.DataType.Client.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Design;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Catswords.DataType.Client
|
namespace Catswords.DataType.Client
|
||||||
|
@ -29,6 +26,7 @@ namespace Catswords.DataType.Client
|
||||||
imageList.Images.Add(Properties.Resources._2333410_android_os_smartphone_85588);
|
imageList.Images.Add(Properties.Resources._2333410_android_os_smartphone_85588);
|
||||||
imageList.Images.Add(Properties.Resources.office_18907);
|
imageList.Images.Add(Properties.Resources.office_18907);
|
||||||
imageList.Images.Add(Properties.Resources.link_symbol_icon_icons_com_56927);
|
imageList.Images.Add(Properties.Resources.link_symbol_icon_icons_com_56927);
|
||||||
|
imageList.Images.Add(Properties.Resources.tags_icon_icons_com_73382);
|
||||||
|
|
||||||
// set image list
|
// set image list
|
||||||
listView1.SmallImageList = imageList;
|
listView1.SmallImageList = imageList;
|
||||||
|
@ -77,8 +75,11 @@ namespace Catswords.DataType.Client
|
||||||
// Get data from timeline
|
// Get data from timeline
|
||||||
FetchFromTimeline();
|
FetchFromTimeline();
|
||||||
|
|
||||||
// Get links from file binary
|
// Get links from file
|
||||||
ExtractLink();
|
ExtractLink();
|
||||||
|
|
||||||
|
// Get EXIF tags from file
|
||||||
|
ExtractExif();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FetchFromFileExtensionDB()
|
private void FetchFromFileExtensionDB()
|
||||||
|
@ -107,10 +108,11 @@ namespace Catswords.DataType.Client
|
||||||
string imphash = ImpHash.Calculate(filePath);
|
string imphash = ImpHash.Calculate(filePath);
|
||||||
search.Fetch(imphash);
|
search.Fetch(imphash);
|
||||||
|
|
||||||
string companyInfo = FileCompany.Read(filePath);
|
string organization = (new PeOrganizationExtractor(filePath)).GetString();
|
||||||
search.Fetch(companyInfo);
|
search.Fetch(organization);
|
||||||
|
listView1.Items.Add(new ListViewItem(new string[] { DateTime.Now.ToString(), "This file are distributed by " + organization }, 4));
|
||||||
|
|
||||||
textBox1.Text = "ImpHash=" + imphash + "; CompanyInfo=" + companyInfo;
|
textBox1.Text = "ImpHash=" + imphash + "; Organization=" + organization;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -190,10 +192,20 @@ namespace Catswords.DataType.Client
|
||||||
private void ExtractLink()
|
private void ExtractLink()
|
||||||
{
|
{
|
||||||
var extractor = new LinkExtractor(filePath);
|
var extractor = new LinkExtractor(filePath);
|
||||||
string[] links = extractor.GetStrings();
|
var strings = extractor.GetStrings();
|
||||||
foreach (string link in links)
|
foreach (string str in strings)
|
||||||
{
|
{
|
||||||
listView1.Items.Add(new ListViewItem(new string[] { DateTime.Now.ToString(), link }, 4));
|
listView1.Items.Add(new ListViewItem(new string[] { DateTime.Now.ToString(), str }, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtractExif()
|
||||||
|
{
|
||||||
|
var extractor = new ExifTagExtractor(filePath);
|
||||||
|
var tags = extractor.GetTags();
|
||||||
|
foreach (ExifTag tag in tags)
|
||||||
|
{
|
||||||
|
listView1.Items.Add(new ListViewItem(new string[] { DateTime.Now.ToString(), $"{tag.Name} ({tag.Section}): {tag.Description}" }, 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user