0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

20230918

Last updated at Posted at 2023-09-18

3-1

info.cs
using System;
using System.Diagnostics;
using System.Net;

namespace RedTeamDevelop
{
    class GeneralInfo
    {
        public string oSystem; //string variable for storing operating system
        public string uName; //string variable for storing username
        public string cDirectory; //string variable for storing current directory
        public string pName; //string variable for storing process name
        public string ePath; //string variable for executable path
        public string ipv4address; //string variable for ipv4adress
	    public string hostName;
        public int pId; //int variable for process id
        public bool isAdmin; //bool variable for check if user is admin

        public GeneralInfo(){

            oSystem = Environment.OSVersion.ToString();
            uName = Environment.UserName;
            cDirectory = Environment.CurrentDirectory;
            pName = Process.GetCurrentProcess().ProcessName;
            pId = Process.GetCurrentProcess().Id;
            ePath = Process.GetCurrentProcess().MainModule.FileName;
            hostName = Dns.GetHostName();
            ipv4address = Dns.GetHostByName(hostName).AddressList[1].ToString();
            using var identity = System.Security.Principal.WindowsIdentity.GetCurrent();
            var principal = new System.Security.Principal.WindowsPrincipal(identity);
            isAdmin = principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
        }
    }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?