fread
// from the linux programmer's manual, fread(3)
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp = fopen("/bin/sh", "rb");
if (!fp) {
perror("fopen");
return EXIT_FAILURE;
}
unsigned char buffer[4];
size_t ret = fread(buffer, 4, 1, fp);
if (ret != sizeof(*buffer)) {
fprintf(stderr, "fread() failed: %zu\n", ret);
exit(EXIT_FAILURE);
}
printf("ELF magic: %#04x%02x%02x%02x\n", buffer[0], buffer[1],
buffer[2], buffer[3]);
fclose(fp);
return 0;
}
Also in C:
- C %d
- what is i686 vs x86_64
- arduino server read
- default password raspberry pi
- how to run a update comand in linux
- rakshabandhan 2020
- if statement shorthand c
- ruby find object in array by attribute
- arduino keypad wait for key
- c fork wait for child
- c \b
- Print the number 0 using write()
- run a command in cmd with c
- 32bit or 64bit
- ecole de chien d'aveugles paris
- cannot update windows 10
- switch c
- invalid operands to binary expression ('int *' and 'int *')
- c isdigit function
- what is x:Name Xamarin forms
- fread
- cmd command with c
- how to combine strings in c
- putting value of struct in runtme