miraip0ts

convert

Mar 16th, 2019
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //tiny c to convert binary to elf code
  2.  
  3. #include <stdio.h>
  4. #include <stdint.h>
  5.  
  6. static void hacks(char *file)
  7. {
  8.     FILE *ihacku;
  9.     char buffer[128 / 3 - 3];
  10.     int n = 0;
  11.     int next = 0;
  12.     if((ihacku = fopen(file, "r")) == NULL)
  13.     return;
  14.     while((n = fread(buffer, sizeof(char), 128 / 3 - 3, ihacku)) != 0)
  15.     {
  16.         int i =0;
  17.         for(i = 0; i < n; i++)
  18.             printf("\\x%02x", (uint8_t)buffer[i]);
  19.     }
  20.     printf("\n");
  21.     return;
  22. }
  23.  
  24. int main(int argc, char **args)
  25. {
  26.     if(argc < 2){
  27.         printf("./filename binary\n");
  28.         return;
  29.     }
  30.     hacks(args[1]);
  31. }
Add Comment
Please, Sign In to add comment