From 97b5e1e93b59edbec68ab4a826535e2b418aed6b Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sun, 17 Feb 2019 13:08:18 -0500 Subject: [PATCH 1/2] updated to include namespace information for version 3 --- GrokAssembly/GrokAssembly.csproj | 8 ++++---- GrokAssembly/Program.cs | 21 +++++++++++++++++++ README.md | 35 ++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/GrokAssembly/GrokAssembly.csproj b/GrokAssembly/GrokAssembly.csproj index 5b1980e..2250761 100644 --- a/GrokAssembly/GrokAssembly.csproj +++ b/GrokAssembly/GrokAssembly.csproj @@ -10,11 +10,11 @@ Inspects a .NET Assembly to determine Company, Product, and Version information Inspects a .NET Assembly to determine Company, Product, and Version information OWASP Foundation - Copyright © 2018, OWASP Foundation. All Rights Reserved - 2.0.0.0 - 2.0.0.0 + Copyright © 2019, OWASP Foundation. All Rights Reserved + 3.0.0.0 + 3.0.0.0 GrokAssembly - 2.0.0.0 + 3.0.0.0 OWASP Contributors https://www.apache.org/licenses/LICENSE-2.0 diff --git a/GrokAssembly/Program.cs b/GrokAssembly/Program.cs index 3b0a006..d2fafa6 100644 --- a/GrokAssembly/Program.cs +++ b/GrokAssembly/Program.cs @@ -77,6 +77,27 @@ public static int Main(string[] args) AssemblyName assemblyName = AssemblyName.GetAssemblyName(Path.GetFullPath(args[0])); writeNode(writer, "fullname", assemblyName.FullName); + writer.WriteStartElement("namespaces"); + try + { + Assembly assembly = Assembly.LoadFile(Path.GetFullPath(args[0])); + HashSet nspaces = new HashSet(); + foreach (Type t in assembly.GetTypes()) + { + string ns = t.GetTypeInfo().Namespace; + if (!nspaces.Contains(ns)) + { + writeNode(writer, "namespace", ns); + nspaces.Add(ns); + } + } + } + catch (Exception ex) + { + writeNode(writer, "warning", ex.Message); + } + writer.WriteEndElement(); + } catch (BadImageFormatException) { diff --git a/README.md b/README.md index ccaaa3e..fb17944 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,39 @@ GrokAssembly ============ -GrokAssembly is a simple .NET/mono project used for getting name and version -information out of an assembly. It is primarily used for the -[OWASP Dependency Check][dependencycheck] project to identify company, product, -and version information. +GrokAssembly is a simple .NET core project used for extracting extended properties +information, such as company, product name, and version, from an assembly. The tool +is primarily used within the [OWASP Dependency Check][dependencycheck] project to +identify Common Platform Identifiers (CPE) and report on known vulnerabilities. Usage: ------ -```cmd -$ GrokAssembly +```bash +$ dotnet GrokAssembly.dll ``` -or - +### Example Output ```bash -$ mono GrokAssembly.exe +$ dotnet GrokAssembly.dll GrokAssembly.dll +``` +```xml + + + OWASP Contributors + GrokAssembly + 3.0.0.0 + Inspects a .NET Assembly to determine Company, Product, and Version information + GrokAssembly + /Users/jeremy/Projects/GrokAssembly/GrokAssembly/bin/Release/netcoreapp2.0/GrokAssembly.dll + 3.0.0.0 + GrokAssembly.exe + GrokAssembly.exe + GrokAssembly, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null + + GrokAssembly + + ``` [dependencycheck]: https://github.com/jeremylong/DependencyCheck From 990ceec23576ba68cd483afdb9a4cba1c14cf0d9 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sun, 24 Feb 2019 07:27:01 -0500 Subject: [PATCH 2/2] minor fixes --- GrokAssembly/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GrokAssembly/Program.cs b/GrokAssembly/Program.cs index d2fafa6..c44bea8 100644 --- a/GrokAssembly/Program.cs +++ b/GrokAssembly/Program.cs @@ -80,7 +80,7 @@ public static int Main(string[] args) writer.WriteStartElement("namespaces"); try { - Assembly assembly = Assembly.LoadFile(Path.GetFullPath(args[0])); + Assembly assembly = Assembly.LoadFrom(Path.GetFullPath(args[0])); HashSet nspaces = new HashSet(); foreach (Type t in assembly.GetTypes()) { @@ -91,12 +91,14 @@ public static int Main(string[] args) nspaces.Add(ns); } } + writer.WriteEndElement(); } catch (Exception ex) { + writer.WriteEndElement(); writeNode(writer, "warning", ex.Message); } - writer.WriteEndElement(); + } catch (BadImageFormatException)