Update the android manifest related feature

This commit is contained in:
Namhyeon Go 2024-04-12 18:24:02 +09:00
parent 52ed5fe3ea
commit 7d846847f6
12 changed files with 102 additions and 38 deletions

View File

@ -190,10 +190,17 @@
<None Include="Resources\document_paperclip_list_paper_icon_219544.png" /> <None Include="Resources\document_paperclip_list_paper_icon_219544.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\OneDrive\문서\GitHub\androidxmldotnet\AndroidXml\AndroidXml.csproj">
<Project>{607eeb2c-6b7c-409e-959e-3b458a109426}</Project>
<Name>AndroidXml</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\OneDrive\문서\GitHub\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj"> <ProjectReference Include="..\..\..\..\OneDrive\문서\GitHub\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj">
<Project>{b1244c5a-cdeb-4d1d-8807-bf40251abcab}</Project> <Project>{b1244c5a-cdeb-4d1d-8807-bf40251abcab}</Project>
<Name>SsdeepNET</Name> <Name>SsdeepNET</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\2333410-android-os-smartphone_85588.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,9 +1,15 @@
using Catswords.DataType.Client.Model; using AndroidXml;
using Catswords.DataType.Client.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Xml.Linq;
namespace Catswords.DataType.Client.Helper namespace Catswords.DataType.Client.Helper
{ {
@ -48,21 +54,30 @@ namespace Catswords.DataType.Client.Helper
{ {
List<AndroidPermission> permissions = new List<AndroidPermission>(); List<AndroidPermission> permissions = new List<AndroidPermission>();
// Read the AndroidManifest.xml file using (FileStream stream = File.OpenRead(ManifestPath))
XmlDocument doc = new XmlDocument();
doc.Load(ManifestPath);
// Find all <uses-permission> elements
XmlNodeList permissionNodes = doc.GetElementsByTagName("uses-permission");
foreach (XmlNode node in permissionNodes)
{ {
// Extract permissions // Read the AndroidManifest.xml file
permissions.Add(new AndroidPermission var reader = new AndroidXmlReader(stream);
XDocument doc = XDocument.Load(reader);
// Find all <uses-permission> elements
var permissionNodes = doc.Descendants().Where(e => e.Name.LocalName == "uses-permission");
foreach (var node in permissionNodes)
{ {
Name = node.Attributes["android:name"].Value, foreach (var attr in node.Attributes())
Description = "", {
Severity = 0 if (attr.Name.LocalName == "name")
}); {
permissions.Add(new AndroidPermission
{
Name = attr.Value,
Description = "",
Severity = 0,
CreatedAt = DateTime.Now
});
}
}
}
} }
return permissions; return permissions;

View File

@ -41,7 +41,7 @@ namespace Catswords.DataType.Client.Helper
Indicators.Add(new Indicator() Indicators.Add(new Indicator()
{ {
Id = itemNode.SelectSingleNode("id").InnerText, Id = itemNode.SelectSingleNode("id").InnerText,
CreatedAt = FormatDateTime(itemNode.SelectSingleNode("datetime").InnerText), CreatedAt = GetDateTimeFromString(itemNode.SelectSingleNode("datetime").InnerText),
Content = itemNode.SelectSingleNode("description").InnerText, Content = itemNode.SelectSingleNode("description").InnerText,
Url = "" Url = ""
}); });
@ -54,16 +54,22 @@ namespace Catswords.DataType.Client.Helper
} }
} }
public string FormatDateTime(string dateString) public static DateTime GetDateTimeFromString(string dateString)
{ {
string formattedDateTime = ""; DateTime parsedDateTime;
if (DateTime.TryParseExact(dateString, "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out DateTime parsedDateTime)) if (DateTime.TryParseExact(dateString, "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out parsedDateTime))
{ {
formattedDateTime = parsedDateTime.ToString(); return parsedDateTime;
}
else
{
parsedDateTime = DateTime.Now;
} }
return formattedDateTime; return parsedDateTime;
} }
} }
} }

View File

@ -33,21 +33,22 @@ namespace Catswords.DataType.Client.Helper
return result; return result;
} }
public static string FormatDateTime(string dateString) public static DateTime GetDateTimeFromString(string dateString)
{ {
string formattedDateTime = ""; DateTime localTime;
// 날짜와 시간을 파싱 // 날짜와 시간을 파싱
if (DateTime.TryParseExact(dateString, "MM/dd/yyyy HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out DateTime parsedDateTime)) if (DateTime.TryParseExact(dateString, "MM/dd/yyyy HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out DateTime parsedDateTime))
{ {
// UTC에서 로컬 시간으로 변환 // UTC에서 로컬 시간으로 변환
DateTime localTime = parsedDateTime.ToLocalTime(); localTime = parsedDateTime.ToLocalTime();
}
// 현재 스레드의 문화권에 따라 날짜와 시간 출력 else
formattedDateTime = localTime.ToString(); {
localTime = DateTime.Now;
} }
return formattedDateTime; return localTime;
} }
public void Fetch(string q) public void Fetch(string q)
@ -78,7 +79,7 @@ namespace Catswords.DataType.Client.Helper
Indicators.Add(new Indicator Indicators.Add(new Indicator
{ {
CreatedAt = FormatDateTime(createdAt), CreatedAt = GetDateTimeFromString(createdAt),
Content = RemoveHtmlTags(content) Content = RemoveHtmlTags(content)
}); });
} }

View File

@ -1,9 +1,12 @@
namespace Catswords.DataType.Client.Model using System;
namespace Catswords.DataType.Client.Model
{ {
class AndroidPermission class AndroidPermission
{ {
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public int Severity { get; set; } public int Severity { get; set; }
public DateTime CreatedAt { get; set; }
} }
} }

View File

@ -1,10 +1,12 @@
namespace Catswords.DataType.Client.Model using System;
namespace Catswords.DataType.Client.Model
{ {
public class Indicator public class Indicator
{ {
public string Id { get; set; } public string Id { get; set; }
public string Content { get; set; } public string Content { get; set; }
public string Url { get; set; } public string Url { get; set; }
public string CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
} }
} }

View File

@ -60,6 +60,16 @@ namespace Catswords.DataType.Client.Properties {
} }
} }
/// <summary>
/// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
/// </summary>
internal static System.Drawing.Bitmap _2333410_android_os_smartphone_85588 {
get {
object obj = ResourceManager.GetObject("_2333410_android_os_smartphone_85588", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다. /// System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
/// </summary> /// </summary>

View File

@ -133,4 +133,7 @@
<data name="message_bubble_conversation_speech_communication_talk_chat_icon_219299" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="message_bubble_conversation_speech_communication_talk_chat_icon_219299" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\message_bubble_conversation_speech_communication_talk_chat_icon_219299.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\message_bubble_conversation_speech_communication_talk_chat_icon_219299.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<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>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -58,7 +58,7 @@
// //
// columnHeader2 // columnHeader2
// //
this.columnHeader2.Text = "Opinion"; this.columnHeader2.Text = "Description";
this.columnHeader2.Width = 200; this.columnHeader2.Width = 200;
// //
// label1 // label1

View File

@ -30,6 +30,7 @@ namespace Catswords.DataType.Client
// Set image size // Set image size
imageList.Images.Add(Properties.Resources.data_database_icon_177024); imageList.Images.Add(Properties.Resources.data_database_icon_177024);
imageList.Images.Add(Properties.Resources.message_bubble_conversation_speech_communication_talk_chat_icon_219299); imageList.Images.Add(Properties.Resources.message_bubble_conversation_speech_communication_talk_chat_icon_219299);
imageList.Images.Add(Properties.Resources._2333410_android_os_smartphone_85588);
// set image list // set image list
listView1.SmallImageList = imageList; listView1.SmallImageList = imageList;
@ -72,11 +73,11 @@ namespace Catswords.DataType.Client
// Get data from file extension database // Get data from file extension database
FetchFromFileExtensionDB(); FetchFromFileExtensionDB();
// Get data from timeline
FetchFromTimeline();
// Get data from Android manifest // Get data from Android manifest
FetchFromAndroidManifest(); FetchFromAndroidManifest();
// Get data from timeline
FetchFromTimeline();
} }
private void FetchFromFileExtensionDB() private void FetchFromFileExtensionDB()
@ -85,7 +86,7 @@ namespace Catswords.DataType.Client
search.Fetch(fileExtension); search.Fetch(fileExtension);
foreach (Indicator ind in search.Indicators) foreach (Indicator ind in search.Indicators)
{ {
listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt, ind.Content }, 0)); listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 0));
} }
} }
@ -143,7 +144,7 @@ namespace Catswords.DataType.Client
// Show the timeline // Show the timeline
foreach (Indicator ind in search.Indicators) foreach (Indicator ind in search.Indicators)
{ {
listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt, ind.Content }, 1)); listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 1));
} }
} }
@ -152,10 +153,12 @@ namespace Catswords.DataType.Client
if (fileExtension == "apk") if (fileExtension == "apk")
{ {
var extractor = new ApkManifestExtractor(filePath); var extractor = new ApkManifestExtractor(filePath);
extractor.Open();
foreach (AndroidPermission perm in extractor.GetPermissions()) foreach (AndroidPermission perm in extractor.GetPermissions())
{ {
listView1.Items.Add(new ListViewItem(new string[] { perm.Name, perm.Description })); listView1.Items.Add(new ListViewItem(new string[] { perm.CreatedAt.ToString(), perm.Name + ' ' + perm.Description }, 2));
} }
extractor.Close();
} }
} }

View File

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Catswords.DataType.Client",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SsdeepNET", "..\..\..\OneDrive\문서\GitHub\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj", "{B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SsdeepNET", "..\..\..\OneDrive\문서\GitHub\SsdeepNET\Source\SsdeepNET\SsdeepNET.csproj", "{B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AndroidXml", "..\..\..\OneDrive\문서\GitHub\androidxmldotnet\AndroidXml\AndroidXml.csproj", "{607EEB2C-6B7C-409E-959E-3B458A109426}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -41,6 +43,18 @@ Global
{B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x64.Build.0 = Release|Any CPU {B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x64.Build.0 = Release|Any CPU
{B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x86.ActiveCfg = Release|Any CPU {B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x86.ActiveCfg = Release|Any CPU
{B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x86.Build.0 = Release|Any CPU {B1244C5A-CDEB-4D1D-8807-BF40251ABCAB}.Release|x86.Build.0 = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|Any CPU.Build.0 = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|x64.ActiveCfg = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|x64.Build.0 = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|x86.ActiveCfg = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Debug|x86.Build.0 = Debug|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|Any CPU.ActiveCfg = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|Any CPU.Build.0 = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|x64.ActiveCfg = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|x64.Build.0 = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|x86.ActiveCfg = Release|Any CPU
{607EEB2C-6B7C-409E-959E-3B458A109426}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE