_Steganography for DOS Programmers_
by Alan Johnson

Listing One

/* llist.c  */
#include "stdio.h"

main(argc,argv)   /* ....this program lists a file in binary mode; */
                  /*     ALL characters are shown.                 */
     int    argc;
     char  *argv[];
{
  int byte;

  long count=0l;

  FILE *infl;
  if ( argc == 2 )
    {
          infl = fopen(argv[1],"rb");
          if ( infl != NULL )
            {
                while( ( byte = getc(infl) ) != EOF )
                     {
                           count++;
                  /*       if ( byte != 26 ) remove these comment marks to 
                                          avoid display of cntrl-Z. Writing
                                          cntrl-Z to stdout terminates the 
                                          program on some systems.        */
                           putc(byte,stdout);
                     }
                close(infl);
            }
          else
            {
               printf("\n\n...cannot open input file...\n\n");
            }
    }
  else
    {
        printf("\n\n....must supply one file name...\n");
    }
}


Listing Two

/* lappend.c  */
#include "stdio.h"

main(n,params)
  int n;
  char *params[];
{
  FILE *thefile,*thedata;
  int ch=0;
  if ( n == 3 )
    {  
       thefile = fopen( params[1], "ab" );
       thedata = fopen( params[2], "rb" );
       if ( thefile != NULL && thedata != NULL )
         {
           fseek(thefile, 0, 2);
           putc(26,thefile); 
           while ( (ch = getc(thedata)) != EOF ) 

             { 
                    putc(ch,thefile);
             }
         }
       else
         {
           printf("\ncannot open a file..\n");
         }
       fclose(thedata);
       fclose(thefile);
    /*   remove(params[2]);   option to erase the source of the hidden data */
    }
  else
    {
      printf("\nproper format is:\nlappend <file appended to> ");
      printf("<file to append>\n");
    }
}


Listing Three

/*  lsplit.c  */
#include "stdio.h"
#define TEMPFILE "temp.1"

main(n,params)
  int n;
  char *params[];
{
  FILE *thefile,*thedata;
  int ch=0,hiddendata=0;

  if ( n == 2 )
    {  
       thefile = fopen( params[1], "rb" );
       thedata = fopen( TEMPFILE, "wb" );
       if ( thefile != NULL )
         {
           while ( (ch = getc(thefile)) != EOF ) 
             { 
               if (ch == 26 ) hiddendata++;
               if (hiddendata)
                 {
                   while ( (ch = getc(thefile)) != EOF )
                     {
                        putc(ch,thedata);
                     }   
                 }     
             }
         }
       else
         {

           printf("\ncannot open a file..\n");
         }
       fclose(thedata);
       fclose(thefile);
    }
  else
    {
      printf("\nproper format is:\nlsplit <datafile>\n");
      printf("hidden data (if any) will be in temp.1\n");
    }
}


Listing Four

/* lwrite.c  */
#include "stdio.h"

main(n,params)
  int n;
  char *params[];
{
  FILE *thefile;
  int ch=0;

  if ( n == 2 )
    {  
       puts("type control-Z to finnish");
       thefile = fopen( params[1], "ab" );
       if ( thefile != NULL )
         {
           fseek(thefile, 0, 2);
           putc(26,thefile); /*<-add new EOF...*/
           while ( (ch = getc(stdin)) != EOF ) 
             { 
               if ( ch == 10 )
                 putc(13,thefile); /* explicitly add CR.*/
                 putc(ch,thefile);
             }
         }
       else
         {
           printf("\ncannot open file..\n");
         }
       fclose(thefile);
    }
  else
    {
      printf("\nproper format is:\nlwrite <filename>\n");
    }
}

Listing Five


/* findh.c  */
#include "stdio.h"
#include "direct.h"
#include "dos.h"

read_file(filename)
char *filename[];
{
  FILE *readingthis;
  int inbyte=0,stoploop=0;
  long count=0l,filelength=0l;

  readingthis = fopen(filename,"rb");

  fseek(readingthis,0l,2); /*<-find end of file          */
  filelength = ftell(readingthis);/*<-find filelength    */
  fseek(readingthis,0l,0);/*<-return to begining; Rewind!*/  

  while( (inbyte = getc(readingthis) ) != EOF && !stoploop ) 
    {
      count++;
      if (inbyte == 26 && ( count < filelength-1 ) )
        {
          stoploop++;
          printf("\n%s has possible hidden data ", filename);
          printf("  %ld bytes from the begining...",count);
        }
    }
  fclose(readingthis);
}
main(n,params)
int  n;
char *params[];
{
  struct ffblk fldata;
  int c1;
  if ( n >= 2 )
    {
      for(c1=1;c1<n;c1++)
        {
           if (findfirst(params[c1],&fldata,(FA_NORMAL | FA_RDONLY)) != -1)
            {
              read_file(fldata.ff_name);

              while( findnext(&fldata) != -1)
                {
                  read_file(fldata.ff_name);
                }
             }

           else
             {
               printf("\n..no matching file(s) for %s\n",params[c1]);
             }
          }/*endfor*/
    }
  else
    {
       printf("\nproper format is:  findh  filename(s) \n"); 
       printf(" wildcards `*' and `?' may be used.\n"); 
    }
}







