mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-26 13:25:26 +00:00
f2ac1ece55
add
55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Bmc.Services.RemoteServiceBase
|
|
// Assembly: ticketservice, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: 3DFB8186-7053-43AF-8B45-70866071B1F2
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Trojan.Win32.Patched.mf-fd200e64412b6be5c177c3cfa7b94e83e807ff04211ce324f12e2ffa5537eb36.exe
|
|
|
|
using Bmc.Broker.Config;
|
|
using Bmc.RegistryAccess;
|
|
using System;
|
|
using System.Runtime.Remoting;
|
|
using System.Runtime.Remoting.Channels;
|
|
using System.Runtime.Remoting.Channels.Tcp;
|
|
using System.ServiceProcess;
|
|
|
|
namespace Bmc.Services
|
|
{
|
|
public class RemoteServiceBase : ServiceBase
|
|
{
|
|
private TcpServerChannel channel;
|
|
private static Random portRandom = new Random();
|
|
private static int MAX_PORT_TRIES = 5;
|
|
|
|
private static int randomPort() => RemoteServiceBase.portRandom.Next(0, (int) ushort.MaxValue);
|
|
|
|
protected void OnStart(FIELD portField, string uri, Type server)
|
|
{
|
|
string str = ConfigurationManager.Instance[portField];
|
|
int port = str == null ? RemoteServiceBase.randomPort() : Convert.ToInt32(str);
|
|
for (int index = 0; index < RemoteServiceBase.MAX_PORT_TRIES; ++index)
|
|
{
|
|
try
|
|
{
|
|
this.channel = new TcpServerChannel(port);
|
|
if (port.ToString() != str)
|
|
{
|
|
ConfigurationManager.Instance[portField] = port.ToString();
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
port = RemoteServiceBase.randomPort();
|
|
}
|
|
}
|
|
if (this.channel == null)
|
|
throw new Exception("initialization failed, could not find free port");
|
|
ChannelServices.RegisterChannel((IChannel) this.channel);
|
|
RemotingConfiguration.RegisterWellKnownServiceType(server, uri, WellKnownObjectMode.Singleton);
|
|
}
|
|
|
|
protected override void OnStop() => ChannelServices.UnregisterChannel((IChannel) this.channel);
|
|
}
|
|
}
|