-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
528 additions
and
521 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using System; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace MultiMiner.Engine.Helpers | ||
{ | ||
public class Fingerprint | ||
{ | ||
private static string fingerPrint = String.Empty; | ||
|
||
public static string Value() | ||
{ | ||
if (String.IsNullOrEmpty(fingerPrint)) | ||
{ | ||
fingerPrint = GetHash( | ||
"CPU >> " + GetProcessorID() + | ||
"\nBIOS >> " + GetBIOSID() + | ||
"\nBASE >> " + GetBaseBoardID() + | ||
"\nDISK >> " + GetDiskDriveID() + | ||
"\nVIDEO >> " + GetVideoControllerID() + | ||
"\nMAC >> " + GetMACAddressID() | ||
); | ||
} | ||
return fingerPrint; | ||
} | ||
|
||
private static string GetHash(string s) | ||
{ | ||
MD5 sec = new MD5CryptoServiceProvider(); | ||
ASCIIEncoding enc = new ASCIIEncoding(); | ||
byte[] bt = enc.GetBytes(s); | ||
return GetHexString(sec.ComputeHash(bt)); | ||
} | ||
|
||
private static string GetHexString(byte[] bt) | ||
{ | ||
Guid guid = new Guid(bt); | ||
return guid.ToString(); | ||
} | ||
|
||
//Return a hardware identifier | ||
private static string GetWMIIdentifier(string wmiClass, string wmiProperty, string wmiMustBeTrue) | ||
{ | ||
System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); | ||
System.Management.ManagementObjectCollection moc = mc.GetInstances(); | ||
foreach (System.Management.ManagementObject mo in moc) | ||
{ | ||
if (mo[wmiMustBeTrue].ToString() == "True") | ||
{ | ||
object propVal = mo[wmiProperty]; | ||
if (propVal != null) | ||
{ | ||
return propVal.ToString(); | ||
} | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
//Return a hardware identifier | ||
private static string GetWMIIdentifier(string wmiClass, string wmiProperty) | ||
{ | ||
System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); | ||
System.Management.ManagementObjectCollection moc = mc.GetInstances(); | ||
foreach (System.Management.ManagementObject mo in moc) | ||
{ | ||
object propVal = mo[wmiProperty]; | ||
if (propVal != null) | ||
{ | ||
return propVal.ToString(); | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
private static string GetProcessorID() | ||
{ | ||
//Uses first CPU identifier available in order of preference | ||
//Don't get all identifiers, as it is very time consuming | ||
string retVal = GetWMIIdentifier("Win32_Processor", "UniqueId"); | ||
|
||
if (retVal == "") //If no UniqueID, use ProcessorID | ||
{ | ||
retVal = GetWMIIdentifier("Win32_Processor", "ProcessorId"); | ||
} | ||
|
||
if (retVal == "") //If no ProcessorId, use Name | ||
{ | ||
retVal = GetWMIIdentifier("Win32_Processor", "Name"); | ||
} | ||
|
||
if (retVal == "") //If no Name, use Manufacturer | ||
{ | ||
retVal = GetWMIIdentifier("Win32_Processor", "Manufacturer"); | ||
} | ||
|
||
//Add clock speed for extra security | ||
retVal += GetWMIIdentifier("Win32_Processor", "MaxClockSpeed"); | ||
|
||
return retVal; | ||
} | ||
|
||
//BIOS Identifier | ||
private static string GetBIOSID() | ||
{ | ||
return GetWMIIdentifier("Win32_BIOS", "Manufacturer") | ||
+ GetWMIIdentifier("Win32_BIOS", "SMBIOSBIOSVersion") | ||
+ GetWMIIdentifier("Win32_BIOS", "IdentificationCode") | ||
+ GetWMIIdentifier("Win32_BIOS", "SerialNumber") | ||
+ GetWMIIdentifier("Win32_BIOS", "ReleaseDate") | ||
+ GetWMIIdentifier("Win32_BIOS", "Version"); | ||
} | ||
|
||
//Main physical hard drive ID | ||
private static string GetDiskDriveID() | ||
{ | ||
return GetWMIIdentifier("Win32_DiskDrive", "Model") | ||
+ GetWMIIdentifier("Win32_DiskDrive", "Manufacturer") | ||
+ GetWMIIdentifier("Win32_DiskDrive", "Signature") | ||
+ GetWMIIdentifier("Win32_DiskDrive", "TotalHeads"); | ||
} | ||
|
||
//Motherboard ID | ||
private static string GetBaseBoardID() | ||
{ | ||
return GetWMIIdentifier("Win32_BaseBoard", "Model") | ||
+ GetWMIIdentifier("Win32_BaseBoard", "Manufacturer") | ||
+ GetWMIIdentifier("Win32_BaseBoard", "Name") | ||
+ GetWMIIdentifier("Win32_BaseBoard", "SerialNumber"); | ||
} | ||
|
||
//Primary video controller ID | ||
private static string GetVideoControllerID() | ||
{ | ||
return GetWMIIdentifier("Win32_VideoController", "DriverVersion") | ||
+ GetWMIIdentifier("Win32_VideoController", "Name"); | ||
} | ||
|
||
//First enabled network card ID | ||
private static string GetMACAddressID() | ||
{ | ||
return GetWMIIdentifier("Win32_NetworkAdapterConfiguration", | ||
"MACAddress", "IPEnabled"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{4409DA1A-D1C3-4AE9-9AAC-D87C2F84AAA8}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>MultiMiner.PoolChecker</RootNamespace> | ||
<AssemblyName>MultiMiner.PoolChecker</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\MultiMiner.Engine\MultiMiner.Engine.csproj"> | ||
<Project>{845687bb-ec47-46d3-ac9d-6fcfb63de8f5}</Project> | ||
<Name>MultiMiner.Engine</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\MultiMiner.Xgminer\MultiMiner.Xgminer.csproj"> | ||
<Project>{0DBEF993-1B34-4D80-AB6A-F662604325DC}</Project> | ||
<Name>MultiMiner.Xgminer</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using MultiMiner.Xgminer.Data; | ||
using MultiMiner.Engine.Helpers; | ||
using MultiMiner.Engine.Data.Configuration; | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Net.Sockets; | ||
|
||
namespace MultiMiner.PoolChecker | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
TimeSpan timeout = new TimeSpan(0, 0, 5); | ||
List<Coin> configurations = new List<Coin>(); ; | ||
DonationPools.Seed(configurations); | ||
foreach (Coin coin in configurations) | ||
{ | ||
foreach (MiningPool pool in coin.Pools) | ||
{ | ||
Uri uri = new Uri(pool.Host); | ||
|
||
if (!IsPortOpen(uri.Host, pool.Port, timeout)) | ||
{ | ||
Console.WriteLine(String.Format("{0} pool {1} (port {2}) is defunct.", coin.PoolGroup.Id, pool.Host, pool.Port)); | ||
} | ||
|
||
} | ||
} | ||
Console.WriteLine("Press any key to exit..."); | ||
Console.ReadKey(); | ||
} | ||
|
||
private static bool IsPortOpen(string host, int port, TimeSpan timeout) | ||
{ | ||
try | ||
{ | ||
using (var client = new TcpClient()) | ||
{ | ||
var result = client.BeginConnect(host, port, null, null); | ||
var success = result.AsyncWaitHandle.WaitOne(timeout); | ||
if (!success) | ||
{ | ||
return false; | ||
} | ||
|
||
client.EndConnect(result); | ||
} | ||
|
||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("MultiMiner.PoolChecker")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("MultiMiner.PoolChecker")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("4409da1a-d1c3-4ae9-9aac-d87c2f84aaa8")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.