using System;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
namespace CTO
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
Console.Write(Get1() + ":" + Get2() + "\t Press Enter to exit.");
Console.ReadLine();
}
private static string Get1()
{
string localIP;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))
{
socket.Connect("8.8.8.8", 65530);
IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
using (SHA256 sha = new SHA256CryptoServiceProvider())
{
localIP = BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(endPoint.Address.ToString()))).Replace("-", string.Empty);
}
}
return localIP;
}
private static string Get2()
{
var mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
string id = "";
foreach (ManagementObject mo in mbsList)
{
id = mo["ProcessorId"].ToString();
break;
}
return id;
}
static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
string batchCommands = string.Empty;
string exeFileName = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty).Replace("/", "\\");
batchCommands += "@
echo OFF\n";
batchCommands += "echo j | del /F ";
batchCommands += exeFileName + "\n";
batchCommands += "echo j | del deleteMyProgram.bat";
File.WriteAllText("SelfDelete.bat", batchCommands);
Process.Start("SelfDelete.bat");
}
}
}