mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2025-01-31 06:17: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: updateservice, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: A6A1FC23-14F7-4CCE-B702-0F9FFD2CD5AC
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Trojan.Win32.Patched.mf-9c4f7eb57e580673b883e57f31931bcbce8bd5d8de1a509a25b8b5a175335d9f.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);
|
|
}
|
|
}
|