Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean references and update packages #99

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 79 additions & 75 deletions FOCA/Analysis/FingerPrinting/DNS.cs
Original file line number Diff line number Diff line change
@@ -1,98 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FOCA.ModifiedComponents;

namespace FOCA.Analysis.FingerPrinting
{
[Serializable]
public class DNS : FingerPrinting
{

public override event EventHandler FingerPrintingFinished; // salta cuando se finaliza la conexion y el analisis
public override event EventHandler FingerPrintingError; // salta cuando se produce un error en la conexion
public override event EventHandler FingerPrintingFinished; // salta cuando se finaliza la conexion y el analisis
public override event EventHandler FingerPrintingError; // salta cuando se produce un error en la conexion

public DNS()
{
}
public DNS()
{
}

public DNS(string host) : base(host, 53) { }
public DNS(string host) : base(host, 53) { }

public override void GetVersion()
public override void GetVersion()
{
try
{
try
{
System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(Host);
System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(Host);

if (ips.Length == 0)
return;
if (ips.Length == 0)
return;

// Hace la query como 'TXT'. Es mejor hacerla como 'ALL', pero no veo la opción en la lista de QTypes. ¿Quizas ANY?
Heijden.DNS.Resolver r = new Heijden.DNS.Resolver(ips[0], base.Port);
r.TimeOut = 1000;
Heijden.DNS.Response response = r.Query("version.bind", Heijden.DNS.QType.TXT, Heijden.DNS.QClass.CH);
if (response.RecordsTXT.Length > 0)
{
Version = response.RecordsTXT[0].TXT;
this.os = AnalyzeBanner(Version);
}
if (this.FingerPrintingFinished != null)
FingerPrintingFinished(this, null);
}
catch
Heijden.DNS.Resolver r = new Heijden.DNS.Resolver(ips[0], base.Port);
r.TimeOut = 10;
Heijden.DNS.Response response = r.Query("version.bind", Heijden.DNS.QType.TXT, Heijden.DNS.QClass.CH);
if (response.RecordsTXT.Length > 0)
{
if (FingerPrintingError != null)
FingerPrintingError(this, null);
OperatingSystem.OS os = OperatingSystem.OS.Unknown;
Version = response.RecordsTXT.SelectMany(p => p.TXT.Where(q => !String.IsNullOrEmpty(q)))
.FirstOrDefault(p =>
{
os = AnalyzeBanner(p);
return os != OperatingSystem.OS.Unknown;
}
);

this.os = os;
}
if (this.FingerPrintingFinished != null)
FingerPrintingFinished(this, null);
}
catch
{
if (FingerPrintingError != null)
FingerPrintingError(this, null);
}
}

private OperatingSystem.OS AnalyzeBanner(string banner)
{
if (this.os != OperatingSystem.OS.Unknown)
return this.os; // Si ya tiene OS no se re-analiza...
private OperatingSystem.OS AnalyzeBanner(string banner)
{
if (this.os != OperatingSystem.OS.Unknown)
return this.os; // Si ya tiene OS no se re-analiza...

// Familia Windows
if (banner.ToLower().Contains("win32"))
return OperatingSystem.OS.Windows;
else if (banner.ToLower().Contains("macos"))
return OperatingSystem.OS.MacOS;
else if (banner.ToLower().Contains("mac os"))
return OperatingSystem.OS.MacOS;
// Familia BSD
else if (banner.ToLower().Contains("freebsd"))
return OperatingSystem.OS.FreeBSD;
else if (banner.ToLower().Contains("openbsd"))
return OperatingSystem.OS.OpenBSD;
// Familia *nix
else if (banner.ToLower().Contains("centos"))
return OperatingSystem.OS.CentOS;
else if (banner.ToLower().Contains("solaris"))
return OperatingSystem.OS.Solaris;
// Familia Linux
else if (banner.ToLower().Contains("red hat"))
return OperatingSystem.OS.LinuxRedHat;
else if (banner.ToLower().Contains("redhat"))
return OperatingSystem.OS.LinuxRedHat;
else if (banner.ToLower().Contains("ubuntu"))
return OperatingSystem.OS.LinuxUbuntu;
else if (banner.ToLower().Contains("debian"))
return OperatingSystem.OS.LinuxDebian;
else if (banner.ToLower().Contains("fedora"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("mandrake"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("mandriva"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("suse"))
return OperatingSystem.OS.LinuxSuse;
else if (banner.ToLower().Contains("linux"))
return OperatingSystem.OS.Linux;
else if (banner.ToLower().Contains("unix"))
return OperatingSystem.OS.Linux;
else
return OperatingSystem.OS.Unknown;
}
// Familia Windows
if (banner.ToLower().Contains("win32"))
return OperatingSystem.OS.Windows;
else if (banner.ToLower().Contains("macos"))
return OperatingSystem.OS.MacOS;
else if (banner.ToLower().Contains("mac os"))
return OperatingSystem.OS.MacOS;
// Familia BSD
else if (banner.ToLower().Contains("freebsd"))
return OperatingSystem.OS.FreeBSD;
else if (banner.ToLower().Contains("openbsd"))
return OperatingSystem.OS.OpenBSD;
// Familia *nix
else if (banner.ToLower().Contains("centos"))
return OperatingSystem.OS.CentOS;
else if (banner.ToLower().Contains("solaris"))
return OperatingSystem.OS.Solaris;
// Familia Linux
else if (banner.ToLower().Contains("red hat"))
return OperatingSystem.OS.LinuxRedHat;
else if (banner.ToLower().Contains("redhat"))
return OperatingSystem.OS.LinuxRedHat;
else if (banner.ToLower().Contains("ubuntu"))
return OperatingSystem.OS.LinuxUbuntu;
else if (banner.ToLower().Contains("debian"))
return OperatingSystem.OS.LinuxDebian;
else if (banner.ToLower().Contains("fedora"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("mandrake"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("mandriva"))
return OperatingSystem.OS.LinuxFedora;
else if (banner.ToLower().Contains("suse"))
return OperatingSystem.OS.LinuxSuse;
else if (banner.ToLower().Contains("linux"))
return OperatingSystem.OS.Linux;
else if (banner.ToLower().Contains("unix"))
return OperatingSystem.OS.Linux;
else
return OperatingSystem.OS.Unknown;
}

}
}
36 changes: 5 additions & 31 deletions FOCA/FOCA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>..\lib\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="DNSLibrary">
<HintPath>..\lib\DNSLibrary.dll</HintPath>
</Reference>
<Reference Include="PluginsAPI, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Plugins Release\PluginsAPI.dll</HintPath>
Expand All @@ -98,31 +92,8 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceModel.Web">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -866,14 +837,17 @@
<PackageReference Include="EntityFramework">
<Version>6.4.0</Version>
</PackageReference>
<PackageReference Include="Heijden.Dns">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.17</Version>
<Version>1.11.23</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="NLog.Config">
<Version>4.6.8</Version>
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="ParallelExtensionsExtras">
<Version>1.2.0</Version>
Expand Down
3 changes: 1 addition & 2 deletions FOCA/PanelDNSSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ private void PanelDNSSearch_Load(object sender, EventArgs e)
if (Program.DesignMode()) return;
Resolve = new Resolver
{
TimeOut = 1000,
SearchWithAllDNS = Program.cfgCurrent.UseAllDns
TimeOut = 1000
};

Program.data.SetResolver(Resolve);
Expand Down
12 changes: 6 additions & 6 deletions MetadataExtractCore/Metadata/OpenOfficeDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override FileMetadata AnalyzeFile()
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFile, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
AnalizeFileMeta(stmXML);
}
Expand All @@ -49,7 +49,7 @@ public override FileMetadata AnalyzeFile()
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFile, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
analizeFileSettings(stmXML);
}
Expand All @@ -59,7 +59,7 @@ public override FileMetadata AnalyzeFile()
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFile, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
AnalizeFileContent(stmXML);
}
Expand All @@ -69,7 +69,7 @@ public override FileMetadata AnalyzeFile()
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFile, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
AnalizeFileVersionList(stmXML, zip);
}
Expand All @@ -84,7 +84,7 @@ public override FileMetadata AnalyzeFile()
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFileName, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
using (EXIFDocument eDoc = new EXIFDocument(stmXML))
{
Expand Down Expand Up @@ -425,7 +425,7 @@ private void AnalizeFileVersionList(Stream stm, ZipFile zip)
{
using (Stream stmXML = new MemoryStream())
{
zip.Extract(strFile, stmXML);
zip[strFile].Extract(stmXML);
stmXML.Seek(0, SeekOrigin.Begin);
using (OpenOfficeDocument ooDoc = new OpenOfficeDocument(stmXML, strExtlo))
{
Expand Down
26 changes: 3 additions & 23 deletions MetadataExtractCore/MetadataExtractCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,10 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ionic.Zip, Version=1.7.2.12, Culture=neutral, PublicKeyToken=f1a302b3881c2619, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
Expand Down Expand Up @@ -152,18 +139,11 @@
<EmbeddedResource Include="resources\SonyMarkernote.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="..\lib\Ionic.Zip.dll" />
<Content Include="..\lib\PdfSharp.dll" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.17</Version>
<PackageReference Include="DotNetZip">
<Version>1.13.7</Version>
</PackageReference>
<PackageReference Include="MetadataExtractor">
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
<Version>2.3.0</Version>
</PackageReference>
<PackageReference Include="PdfSharp">
<Version>1.50.5147</Version>
Expand Down
36 changes: 0 additions & 36 deletions SearcherCore/SearcherCore/Properties/Settings.Designer.cs

This file was deleted.

Loading