Lets the keylogger to repeat previous requests.
The keylogger now saves queries to a temporary file, which the new repeat.c will now draw from.
This commit is contained in:
33
capture.c
33
capture.c
@@ -6,11 +6,29 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
int msleep(long time)
|
||||||
|
{
|
||||||
|
struct timespec timeDet;
|
||||||
|
int res;
|
||||||
|
timeDet.tv_sec = time / 1000;
|
||||||
|
timeDet.tv_nsec = (time % 1000) * 1000000;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
res = nanosleep(&timeDet, &timeDet);
|
||||||
|
}
|
||||||
|
while (res && errno == EINTR);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int callSound(char* path)
|
int callSound(char* path)
|
||||||
{
|
{
|
||||||
int child = fork();
|
int child = fork();
|
||||||
@@ -243,7 +261,7 @@ int main(int argc, char **argv)
|
|||||||
* Waits for a split second to let any keystrokes that triggered the program
|
* Waits for a split second to let any keystrokes that triggered the program
|
||||||
* (i.e. the enter key used to execute the terminal command) to be processed)
|
* (i.e. the enter key used to execute the terminal command) to be processed)
|
||||||
*/
|
*/
|
||||||
sleep(1);
|
msleep(250);
|
||||||
|
|
||||||
int grabCode = ioctl(fd, EVIOCGRAB, 1);
|
int grabCode = ioctl(fd, EVIOCGRAB, 1);
|
||||||
if (grabCode < 0)
|
if (grabCode < 0)
|
||||||
@@ -316,9 +334,22 @@ int main(int argc, char **argv)
|
|||||||
callSound("triggerDeactivate.wav");
|
callSound("triggerDeactivate.wav");
|
||||||
|
|
||||||
printf("Running args: ");
|
printf("Running args: ");
|
||||||
|
FILE* store = fopen("/tmp/play_args.txt", "w");
|
||||||
|
if (store < 0)
|
||||||
|
{
|
||||||
|
printf("Could not record arguments");
|
||||||
|
}
|
||||||
for (int i = 0; i <= numArgs; i++)
|
for (int i = 0; i <= numArgs; i++)
|
||||||
{
|
{
|
||||||
printf("'%s' ", ARGS[i]);
|
printf("'%s' ", ARGS[i]);
|
||||||
|
if (store >= 0 && i > 0 && ARGS[i] != NULL)
|
||||||
|
{
|
||||||
|
fprintf(store, "%s ", ARGS[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (store >= 0)
|
||||||
|
{
|
||||||
|
fclose(store);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
|||||||
131
repeat.c
Normal file
131
repeat.c
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
#include <linux/input.h>
|
||||||
|
#include <linux/input-event-codes.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
int msleep(long time)
|
||||||
|
{
|
||||||
|
struct timespec timeDet;
|
||||||
|
int res;
|
||||||
|
timeDet.tv_sec = time / 1000;
|
||||||
|
timeDet.tv_nsec = (time % 1000) * 1000000;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
res = nanosleep(&timeDet, &timeDet);
|
||||||
|
}
|
||||||
|
while (res && errno == EINTR);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int callSound(char* path)
|
||||||
|
{
|
||||||
|
int child = fork();
|
||||||
|
if (child == 0)
|
||||||
|
{
|
||||||
|
char finalPath[60];
|
||||||
|
strcpy(finalPath, getenv("HOME"));
|
||||||
|
strcat(finalPath, "/.local/share/sounds/");
|
||||||
|
strcat(finalPath, path);
|
||||||
|
|
||||||
|
execlp("ffmpeg", "ffmpeg", "-loglevel", "error", "-i", finalPath, "-f", "alsa", "default", NULL);
|
||||||
|
}
|
||||||
|
else if (child < 0)
|
||||||
|
{
|
||||||
|
printf("Could not generate sound %s\n", path);
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void callErrorSound(int code)
|
||||||
|
{
|
||||||
|
int returnCode = callSound("error.wav");
|
||||||
|
wait(NULL);
|
||||||
|
for (int i = 0; i < code; i++)
|
||||||
|
{
|
||||||
|
returnCode = callSound("bit.wav");
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
const int BUFFER_LENGTH = 120;
|
||||||
|
const int ARG_LENGTH = 20;
|
||||||
|
const int MAX_ARGS = 20;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need this command for when we trigger the app from the command line,
|
||||||
|
* because otherwise the upstroke on the enter key will kill the app.
|
||||||
|
*/
|
||||||
|
int waitEnter = 0;
|
||||||
|
char* ARGS[MAX_ARGS];
|
||||||
|
int numArgs = 0;
|
||||||
|
ARGS[numArgs++] = "play";
|
||||||
|
//ARGS[numArgs++] = "--directory=/home/markil3/.local/share/lollypop";
|
||||||
|
char* BUFFER = (char*) calloc(ARG_LENGTH, sizeof(char));
|
||||||
|
int index = 0;
|
||||||
|
BUFFER[index] = '\0';
|
||||||
|
FILE* fd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
fd = fopen("/tmp/play_args.txt", "r");
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
callErrorSound(1);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
len = fscanf(fd, "%s", BUFFER);
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGS[numArgs++] = BUFFER;
|
||||||
|
BUFFER = (char*) calloc(ARG_LENGTH, sizeof(char));
|
||||||
|
}
|
||||||
|
while (len >= 0);
|
||||||
|
|
||||||
|
fclose(fd);
|
||||||
|
ARGS[numArgs] = NULL;
|
||||||
|
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* If index was not reset, then we canceled.
|
||||||
|
*/
|
||||||
|
callSound("end.wav");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
callSound("triggerDeactivate.wav");
|
||||||
|
|
||||||
|
printf("Running args: ");
|
||||||
|
for (int i = 0; i <= numArgs; i++)
|
||||||
|
{
|
||||||
|
printf("'%s' ", ARGS[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
execvp(ARGS[0], ARGS);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user