2019-03-11 09:00:07 +01:00
|
|
|
|
// /**
|
|
|
|
|
// * File: Program.cs
|
|
|
|
|
// * Author: haraldwolff
|
|
|
|
|
// *
|
|
|
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
|
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
|
|
|
// *
|
|
|
|
|
// *
|
|
|
|
|
// **/
|
|
|
|
|
using System;
|
|
|
|
|
using Renci.SshNet;
|
|
|
|
|
using ln.skyscanner.identify;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using ln.snmp.types;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using ln.snmp;
|
2019-03-11 15:08:25 +01:00
|
|
|
|
using ln.snmp.endpoint;
|
2019-03-11 09:00:07 +01:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using ln.perfdb.storage;
|
|
|
|
|
using ln.logging;
|
2019-03-11 15:08:25 +01:00
|
|
|
|
using System.Security.Cryptography;
|
2019-03-12 00:55:04 +01:00
|
|
|
|
using ln.snmp.asn1;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using ln.types;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using ln.snmp.rfc1213;
|
2019-03-13 08:20:53 +01:00
|
|
|
|
using ln.types.sync;
|
|
|
|
|
using ln.skyscanner.crawl;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Net.NetworkInformation;
|
2019-03-11 09:00:07 +01:00
|
|
|
|
|
|
|
|
|
namespace ln.skyscanner
|
|
|
|
|
{
|
|
|
|
|
class MainClass
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static void DumpPerfValues(PerfValue[] perfValues)
|
|
|
|
|
{
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
|
|
Logging.Log("----------------------------------------------");
|
|
|
|
|
Logging.Log("Dumping {0} perfValues:", perfValues.Length);
|
|
|
|
|
foreach (PerfValue perfValue in perfValues)
|
|
|
|
|
{
|
|
|
|
|
Logging.Log("PerfValue: [{1,6}] {0}", perfValue, n);
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
Logging.Log("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2019-03-18 08:12:54 +01:00
|
|
|
|
FileLogger fileLogger = new FileLogger("skyscanner.log");
|
|
|
|
|
fileLogger.MaxLogLevel = LogLevel.DEBUG;
|
|
|
|
|
Logger.Default.Backends.Add(fileLogger);
|
|
|
|
|
|
|
|
|
|
Logger.ConsoleLogger.MaxLogLevel = LogLevel.INFO;
|
2019-03-11 09:00:07 +01:00
|
|
|
|
|
2019-03-13 14:18:05 +01:00
|
|
|
|
SkyScanner skyScanner = new SkyScanner(args);
|
|
|
|
|
skyScanner.Start();
|
2019-03-12 00:55:04 +01:00
|
|
|
|
|
2019-03-11 09:00:07 +01:00
|
|
|
|
}
|
2019-03-12 00:55:04 +01:00
|
|
|
|
|
|
|
|
|
public static void TestAuthKey(String filename,USMEndpoint v3endpoint)
|
|
|
|
|
{
|
|
|
|
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
|
|
|
|
byte[] source = new byte[fileStream.Length];
|
|
|
|
|
|
|
|
|
|
int nread = fileStream.Read(source, 0, source.Length);
|
|
|
|
|
|
|
|
|
|
fileStream.Close();
|
|
|
|
|
fileStream.Dispose();
|
|
|
|
|
|
|
|
|
|
ASN1Value asn = new ASN1Value(source);
|
|
|
|
|
USMMessage usm = new USMMessage(asn);
|
|
|
|
|
|
|
|
|
|
byte[] repro1 = asn.AsByteArray;
|
|
|
|
|
byte[] repro2 = ((ASN1Value)usm).AsByteArray;
|
|
|
|
|
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Source: {0}", BitConverter.ToString(source));
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Repro1: {0}", BitConverter.ToString(repro1));
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Repro2: {0}", BitConverter.ToString(repro2));
|
|
|
|
|
|
|
|
|
|
if (!source.SequenceEqual(repro1))
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro1 does not match!");
|
|
|
|
|
else
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro1 matches!");
|
|
|
|
|
|
|
|
|
|
if (!source.SequenceEqual(repro2))
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro2 does not match!");
|
|
|
|
|
else
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro2 matches!");
|
|
|
|
|
|
|
|
|
|
if (!repro1.SequenceEqual(repro2))
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro1 != Repro2!");
|
|
|
|
|
else
|
|
|
|
|
Logging.Log(LogLevel.ERROR, "Repro1/2 match!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
usm.Dump();
|
|
|
|
|
usm.SecurityParameters.Dump();
|
|
|
|
|
|
|
|
|
|
byte[] auth1 = usm.SecurityParameters.msgAuthenticationParameters.Bytes;
|
|
|
|
|
|
|
|
|
|
usm.SecurityParameters.msgAuthenticationParameters.Bytes = new byte[12];
|
|
|
|
|
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Source: {0}", BitConverter.ToString(source));
|
|
|
|
|
|
|
|
|
|
v3endpoint.RemoteEngineID = usm.SecurityParameters.msgAuthoritativeEngineID;
|
|
|
|
|
v3endpoint.CacheAuthoritativeEngineTime = usm.SecurityParameters.msgAuthoritativeEngineTime;
|
|
|
|
|
v3endpoint.CacheAuthoritativeEngineBoots = usm.SecurityParameters.msgAuthoritativeEngineBoots;
|
|
|
|
|
|
|
|
|
|
v3endpoint.LocalizeKeys();
|
|
|
|
|
|
|
|
|
|
v3endpoint.AuthenticateMessage(usm);
|
|
|
|
|
|
|
|
|
|
byte[] auth2 = usm.SecurityParameters.msgAuthenticationParameters.Bytes;
|
|
|
|
|
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Authenticated: {0}", BitConverter.ToString(((ASN1Value)usm).AsByteArray));
|
|
|
|
|
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Original Auth Token: {0}", BitConverter.ToString(auth1));
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Calculated Auth Token: {0}", BitConverter.ToString(auth2));
|
|
|
|
|
|
|
|
|
|
if (auth1.SequenceEqual(auth2))
|
|
|
|
|
{
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "MATCH");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "NO MATCH");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 09:00:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|