示例#1
0
        //===========================================================================
        //
        // Public Functions
        //
        //===========================================================================
        //
        // Load(string name, ref NSSKeylogger.ProfileData profile)
        // Attempts to load a profile from a file into a ProfileData structure
        //
        public Boolean Load(string name, ref NSSKeyloggerForm.ProfileData profile)
        {
            Boolean success = false;
            BinaryReader b = null;
            try
            {
                //Open the file
                b = new BinaryReader(File.Open(currentDirectory + "\\" + name + ".nss", FileMode.Open));

                //Check the header
                if (b.ReadString() != "NSS Keylogger Profile")
                {
                    success = false; //header was invalid
                    throw new Exception("File is not a NSS Keylogger profile!");
                }

                //Load the KEYCOMBO structures
                if (!LoadKEYCOMBO(b, ref profile.ActivationKey))
                {
                    success = false;
                    throw new Exception("ActivationKey could not be loaded!");
                }
                if (!LoadKEYCOMBO(b, ref profile.DeactivationKey))
                {
                    success = false;
                    throw new Exception("DeactivationKey could not be loaded!");
                }
                if (!LoadKEYCOMBO(b, ref profile.SubtleModeKey))
                {
                    success = false;
                    throw new Exception("SubtleModeKey could not be loaded!");
                }

                //Load all other profile data
                profile.useDeactivationKey = b.ReadBoolean();
                profile.suppressHotkeys = b.ReadBoolean();
                profile.clearKeylogOnStartup = b.ReadBoolean();
                profile.useSubtleModeKey = b.ReadBoolean();
                profile.startupSubtleMode = b.ReadBoolean();
                profile.subtleMode = b.ReadBoolean();
                profile.keylogSaveLocation = b.ReadString();

                success = true;
            }
            catch
            { //something went wrong
                success = false;
            }
            finally
            {
                if (b != null)
                {
                    b.Close(); //all done with the file
                    b.Dispose();
                }
            }
            return success;
        }
示例#2
0
 //Constructor
 public ProfileManager(ref NSSKeyloggerForm.ProfileData profileData)
 {
     data = profileData;
     InitializeComponent();
     foreach (string file in Directory.GetFiles(currentDirectory, "*.nss"))
     {
         lbProfiles.Items.Add(Path.GetFileNameWithoutExtension(file));
     }
 }
示例#3
0
 //
 // LoadKEYCOMBO(BinaryReader b, ref NSSKeylogger.KEYCOMBO key)
 // Attempts to load a KEYCOMBO structure from a file
 //
 private Boolean LoadKEYCOMBO(BinaryReader b, ref NSSKeyloggerForm.KEYCOMBO key)
 {
     try
     {
         key.valid = b.ReadBoolean();
         if (!key.valid) //key must be valid
             throw new Exception("KEYCOMBO is not valid!");
         key.isKeyboard = b.ReadBoolean();
         key.modifierKeys = GetKey(b.ReadBytes(KeySize));
         key.key = GetKey(b.ReadBytes(KeySize));
         key.keyString = b.ReadString();
         key.cmd = b.ReadString();
         key.mouseButton = b.ReadUInt32();
         key.wheel = b.ReadInt32();
     }
     catch
     {
         return false;
     }
     return true;
 }
示例#4
0
 //
 // SaveKEYCOMBO(BinaryWriter b, NSSKeylogger.KEYCOMBO key)
 // Attempts to save a KEYCOMBO structure to a file
 //
 private Boolean SaveKEYCOMBO(BinaryWriter b, NSSKeyloggerForm.KEYCOMBO key)
 {
     try
     {
         if (!key.valid) //key must be valid
             throw new Exception("KEYCOMBO is not valid!");
         b.Write(key.valid);
         b.Write(key.isKeyboard);
         b.Write(GetBytes(key.modifierKeys));
         b.Write(GetBytes(key.key));
         b.Write(key.keyString);
         b.Write(key.cmd);
         b.Write(key.mouseButton);
         b.Write(key.wheel);
     }
     catch
     {
         return false;
     }
     return true;
 }
示例#5
0
        //
        // Save(string name, ref NSSKeylogger.ProfileData profile)
        // Attempts to save a profile to a file from a ProfileData structure
        //
        public Boolean Save(string name, ref NSSKeyloggerForm.ProfileData profile)
        {
            Boolean success = false;
            BinaryWriter b = null;
            try
            {
                if (!Directory.Exists(currentDirectory)) //make sure the profile directory exists
                    Directory.CreateDirectory(currentDirectory); //if not, create it

                //Open the file
                b = new BinaryWriter(File.Open(currentDirectory + "\\" + name + ".nss", FileMode.OpenOrCreate));

                //Write the header
                b.Write("NSS Keylogger Profile");

                //Save the KEYCOMBO structures
                if (!SaveKEYCOMBO(b, profile.ActivationKey))
                    throw new Exception("ActivationKey could not be saved!");
                if (!SaveKEYCOMBO(b, profile.DeactivationKey))
                    throw new Exception("DeactivationKey could not be saved!");
                if (!SaveKEYCOMBO(b, profile.SubtleModeKey))
                    throw new Exception("SubtleModeKey could not be saved!");

                //Save all other profile data
                b.Write(profile.useDeactivationKey);
                b.Write(profile.suppressHotkeys);
                b.Write(profile.clearKeylogOnStartup);
                b.Write(profile.useSubtleModeKey);
                b.Write(profile.startupSubtleMode);
                b.Write(profile.subtleMode);
                b.Write(profile.keylogSaveLocation);

                success = true;
            }
            catch
            { //something went wrong
                success = false;
            }
            finally
            {
                if (b != null)
                {
                    b.Close(); //all done with the file
                    b.Dispose();
                }
            }
            return success;
        }