Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- # define IS_PRINTABLE(c) ((c >= ' ' && c <= '~'))
- int main(int argc, char **argv)
- {
- int fd;
- int i;
- int j;
- char buffer[1024];
- int n;
- j = 0;
- i = 1;
- if (argc != 2)
- {
- printf("Usage : %s <filetobrute>\n", argv[0]);
- return (1);
- }
- if ((fd = open(argv[1], O_RDONLY)) == -1)
- {
- printf("Can't open file : '%s'\n", argv[1]);
- perror("open");
- return (1);
- }
- while ((n = read(fd, buffer, 1023)) > 0)
- buffer[n] = 0;
- /* premier test */
- while (i != 20)
- {
- printf("[+%d] ", i);
- while (buffer[j])
- {
- if (IS_PRINTABLE(buffer[j] + i))
- printf("%c", buffer[j] + i);
- else
- printf(" ");
- j++;
- }
- printf("\n");
- j = 0;
- i++;
- }
- i = 0;
- /* second test */
- while (i != -20)
- {
- printf("[-%d] ", i);
- while (buffer[j])
- {
- if (IS_PRINTABLE(buffer[j] - i))
- printf("%c", buffer[j] - i);
- else
- printf(" ");
- j++;
- }
- printf("\n");
- j = 0;
- i--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment