[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[comp.unix.programmer] Re: reversing compiled programs



------- Start of forwarded message -------
Newsgroups: comp.unix.programmer
From: [email protected] (!@?*$%)
Subject: Re: reversing compiled programs
Message-ID: <[email protected]>
Organization: The Programmer formerly known as S M Ryan
References: <[email protected]>
Date: Wed, 23 Oct 1996 03:03:10 GMT

> Could someone tell me how to reverse compiled C or C++ programs in
> UNIX?  The compiler would be either CC or g++.

This should reverse compiled programs, uncompiled programs, or any other
file you have.

#include <stdio.h>

int main(int N,char **P) {
  long i=0,j,k; int a,b;
  FILE *f = fopen(P[1],"r+");
  for (;;) {
    fseek(f,i,0); a = fgetc(f); if (a==EOF) break; j = ftell(f);
    fseek(f,-i-1,2); k = ftell(f); b = fgetc(f); if (b==EOF) break;
    if (j>k) break;
    fseek(f,i,0); fputc(b,f);
    fseek(f,-i-1,2) fputc(a,f);
  }
  return 0;
}

- -- 
The winter ceased its weary grip    | [email protected]  PO Box 1563
when soft and sudden sunbeams slip  |          Cupertino, California
and etch away the ice and gray,     | (xxx)xxx-xxxx            95015
with life to soul and song to lip.  |         I don't use no smileys
------- End of forwarded message -------

-- 
This message comes to you as a service of the mph-humor list.  No
claims of real or perceived humor are offered.
Sumbissions:  [email protected] 
Information:  http://mph124.rh.psu.edu/~hunt/mph-humor.html