2024. Március 29, Péntek, Auguszta
Főoldal | Hardver | Szoftver | Tudástár | Árlista | Partnerek | Kapcsolat

Tudástár
 

Az alábbi program tök ingyen lefordíható Microsoft Visual C# 2005 Express-el. A program lényege, hogy egy adott elérési úton szereplő progit indít el másik felhasználó nevében. Ez akkor hasznos, ha a felhasználó le van korlátozva (nincs telepítési joga, stb. ), viszont egy fránya progi meg csak admin jogokkal hajlandó futni.

Arra figyeljünk, hogy az így futtatott programból indított alprogram is admin jogokkal fog futni!

A progi NEM FUT CSAK HELYI MEREVLEMEZES MEGHAJTÓRÓL. .NET 2.0 framework biztonság rulez


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.AccessControl;

namespace junk1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Yes, this text is held insecurely in memory
            string TEXTDATA = "P4ssw0rd";

            using (System.Security.SecureString secretString = new System.Security.SecureString())
            {
                // Add the text from our insecure string into our SecureString
                // Normally, you WOULD NOT keep a string in memory for this purpose but it makes this
                // Demo a little shorter and easier to read.
                foreach (char c in TEXTDATA)
                    secretString.AppendChar(c);
                // Marshall the secure string to a BSTR pointer
                IntPtr ptr = Marshal.SecureStringToBSTR(secretString);
                try
                {
                    byte b = 1;
                    int i = 0;
                    // Loop through until we hit the string terminator '\0'
                    while (((char)b) != '\0')
                    {
                        b = Marshal.ReadByte(ptr, i);
                        //Console.Write((char)b);
                        i = i + 2;  // BSTR is unicode and occupies 2 bytes
                    }

                    //System.Diagnostics.Process.Start("\\\\fserver\\shared\\frissit\\allianz\\allianz.bat", "Us3rn4me", secretString, "d0m41n");
                    System.Diagnostics.Process.Start("C:\\\\Program Files\\FrontEnd.NET\\FrontEndNET.exe", "Us3rn4me", secretString, "d0m41n");

                }
                finally
                {
                    // Free AND ZERO OUT our marshalled BSTR pointer to our securetext
                    Marshal.ZeroFreeBSTR(ptr);
                }
            }
            //Console.ReadLine();
        }
    }
}