Пример #1
0
        static void Main(String[] args)
        {
            PrintBanner();

            if (args.Length == 0)
            {
                PrintUseage();
                return;
            }

            if (WhoWasI.IsAdmin == false)
            {
                Console.WriteLine("\n## ERROR ## - You Are Not An Admin.. You need Admin Privs!");
                PrintUseage();
                return;
            }

            //we already have the last two arguments
            for (Int32 i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower().Trim())
                {
                    case "-la": WhoWasI.PrintActiveAccountsToConsole();
                                return;
                    case "-pp":
                                Int32 _PID;

                                //try and parse the next argument, this should be a process ID and so numerical
                                if (!Int32.TryParse(args[i + 1], out _PID))
                                {
                                    Console.WriteLine("## ERROR ## - Invalid Process ID '{0}' Specified, Unable To Dump Process Privilages...\n");
                                    PrintUseage();
                                    Environment.Exit(0);
                                }//end of  if (!UInt32.TryParse(args[i + 1], out _PID))

                                WhoWasI.PrintProcessPrivsToConsole(_PID);
                                Environment.Exit(0);

                        return;
                }//end of switch
            }//end of  for (Int32 i = 0; i < args.Length -2; i++)

            if (args.Length < 2)
            {
                Console.WriteLine("## ERROR ## - Not Enough Command Line Args, Aborting..n");
                return;
            }

            //We want the penultimate paramiter as the account
            String _InputtedAccount = args[args.Length - 2];

            Int32 _InputtedProcessID;
            Boolean _UseProcessIDAsAccountHandle = false;

            //the following checks are used to determine whether a string (account) or number (processID) has been specified
            if (Int32.TryParse(_InputtedAccount, out _InputtedProcessID)) { _UseProcessIDAsAccountHandle = true; }

            //Last paramiter is the command to run
            String _CommandToRun = args[args.Length - 1];

            if (String.IsNullOrEmpty(_InputtedAccount))
            {
                Console.WriteLine("## ERROR ## - Account Name Is NULL/Empty, Aborting..n");
                PrintUseage();
                return;
            }//end of if (String.IsNullOrEmpty(_InputtedAccount))

            if (String.IsNullOrEmpty(_CommandToRun))
            {
                Console.WriteLine("## ERROR ## - Command Is NULL/Empty, Aborting..\n");
                PrintUseage();
                return;
            }//end of if (String.IsNullOrEmpty(_CommandToRun))

            ProcessEntry _ProcessIdToUse;

            if (_UseProcessIDAsAccountHandle)
            {
                _ProcessIdToUse = new ProcessEntry()
                {
                    Name = "ASDF",
                    PID = _InputtedProcessID
                };
            }
            else
            {
                _ProcessIdToUse = WhoWasI.GetProcessIDForAccount(_InputtedAccount);
            }

            //do we have a valid process?
            if (_ProcessIdToUse.PID == -1)
            {
                Console.WriteLine("## ERROR ## - No Processes Found For Account '{0}', Aborting..\n", _InputtedAccount);
                PrintUseage();
                return;
            }//end of if (_ProcessIdToUse == -1)

            Console.WriteLine("[+] Using Process '[{0}] - {1}' With Owner '{2}'..", _ProcessIdToUse.Name, _ProcessIdToUse.PID, _InputtedAccount);

            WhoWasI.ImpersonateAndExecute(_ProcessIdToUse.PID, _CommandToRun);
        }
Пример #2
0
        static void Main(String[] args)
        {
            PrintBanner();

            if (args.Length == 0)
            {
                PrintUseage();
                return;
            }

            if (WhoWasI.IsAdmin == false)
            {
                Console.WriteLine("\n## ERROR ## - You Are Not An Admin.. You need Admin Privs!");
                PrintUseage();
                return;
            }



            //we already have the last two arguments
            for (Int32 i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower().Trim())
                {
                case "-la": WhoWasI.PrintActiveAccountsToConsole();
                    return;

                case "-pp":
                    Int32 _PID;

                    //try and parse the next argument, this should be a process ID and so numerical
                    if (!Int32.TryParse(args[i + 1], out _PID))
                    {
                        Console.WriteLine("## ERROR ## - Invalid Process ID '{0}' Specified, Unable To Dump Process Privilages...\n");
                        PrintUseage();
                        Environment.Exit(0);
                    }            //end of  if (!UInt32.TryParse(args[i + 1], out _PID))

                    WhoWasI.PrintProcessPrivsToConsole(_PID);
                    Environment.Exit(0);

                    return;
                } //end of switch
            }     //end of  for (Int32 i = 0; i < args.Length -2; i++)


            if (args.Length < 2)
            {
                Console.WriteLine("## ERROR ## - Not Enough Command Line Args, Aborting..n");
                return;
            }

            //We want the penultimate paramiter as the account
            String _InputtedAccount = args[args.Length - 2];


            Int32   _InputtedProcessID;
            Boolean _UseProcessIDAsAccountHandle = false;

            //the following checks are used to determine whether a string (account) or number (processID) has been specified
            if (Int32.TryParse(_InputtedAccount, out _InputtedProcessID))
            {
                _UseProcessIDAsAccountHandle = true;
            }


            //Last paramiter is the command to run
            String _CommandToRun = args[args.Length - 1];

            if (String.IsNullOrEmpty(_InputtedAccount))
            {
                Console.WriteLine("## ERROR ## - Account Name Is NULL/Empty, Aborting..n");
                PrintUseage();
                return;
            }//end of if (String.IsNullOrEmpty(_InputtedAccount))

            if (String.IsNullOrEmpty(_CommandToRun))
            {
                Console.WriteLine("## ERROR ## - Command Is NULL/Empty, Aborting..\n");
                PrintUseage();
                return;
            }//end of if (String.IsNullOrEmpty(_CommandToRun))

            ProcessEntry _ProcessIdToUse;


            if (_UseProcessIDAsAccountHandle)
            {
                _ProcessIdToUse = new ProcessEntry()
                {
                    Name = "ASDF",
                    PID  = _InputtedProcessID
                };
            }
            else
            {
                _ProcessIdToUse = WhoWasI.GetProcessIDForAccount(_InputtedAccount);
            }

            //do we have a valid process?
            if (_ProcessIdToUse.PID == -1)
            {
                Console.WriteLine("## ERROR ## - No Processes Found For Account '{0}', Aborting..\n", _InputtedAccount);
                PrintUseage();
                return;
            }//end of if (_ProcessIdToUse == -1)

            Console.WriteLine("[+] Using Process '[{0}] - {1}' With Owner '{2}'..", _ProcessIdToUse.Name, _ProcessIdToUse.PID, _InputtedAccount);

            WhoWasI.ImpersonateAndExecute(_ProcessIdToUse.PID, _CommandToRun);
        }