daily pastebin goal
62%
SHARE
TWEET

convert.c

wtfbbq Nov 1st, 2018 (edited) 415 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top