📄 wnstorm.c
字号:
/**************************************************************************\
* *
* White Noise Storm *
* *
* *
* SOURCE CODE REVISION BETA-940512-01:18 EST *
* *
* Compiled with Borland C 3.1, Large Model. *
* *
*==========================================================================*
* *
* Copyright (C) 1992,1993,1994 by Ray (Arsen) Arachelian, *
* All Rights Reserved, General Technical Data Restricted. *
* *
*==========================================================================*
* *
* WARNING: This source code is the sole property of the author and is *
* to be treated as such. The use of this source code is subject to *
* certain limitations stated in the documentation. Use of this source *
* code is subject to the conditions stated therein. Using this source *
* code signifies acceptance to the terms listed in the documentation. *
* *
* The ideas/algorithms of this software MAY not be patented by other *
* parties. *
* *
* Ray (Arsen) Arachelian is the author and sole owner of WNINJECT(tm) and *
* WNSTORM(tm) and maintains exclusive proprietary interests and exclusive *
* copyright for these forementioned programs. *
* *
* WNINJECT and WNSTORM are trademarks of the author *
* *
* WARANTY: There ain't none. Due to the nature of this software, the *
* author disclaims all warranties whether express or implied. The *
* software distributed in this package is distributed "AS IS" and *
* all consequences arising from its use are the solely the user's *
* responsability. Neither the author, nor his associates may be *
* held liable for any damage/consequnces arising from the use of *
* this software. Some states do not allow the exclusion of *
* warranties, so your rights may vary. *
* *
* Don't bother suing me. I'm not rich. *
* *
* *
* LICENSE: *
* *
* This is published proprietary source code of the author, and may be *
* freely distributed and copied as long as this and any other copyright, *
* trademark, and ownership notices are not altered in any way shape or form*
* *
* This software is hereby deemed freeware and may not be sold. A small *
* duplication charge (less than $5.00 US) may be made as compensation for *
* the specific distribution of this software. This software may be included*
* on any CD-ROM collection of shareware and or freeware. Please feel free*
* to give out copies of this software to your friends. *
* *
* You may not distribute modified copies of this software without the *
* written consent of the author. *
* *
* Usage of this software indicates an agreement to the above license. *
* *
* Should any statement in this license be deemed invalid, only that *
* statement shall be revoked, leaving the rest of this license valid. *
* *
* This license terminates when the user destroys all copies of this *
* software from all media on which it resides. *
* *
\**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h> /* for getch() prototype only */
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <values.h>
short int stealth=0; /* No header flag */
short int statson=0; /* do statistics flag */
short int bitfix=0; /* statistical bit fix flag */
short int trace=0; /* Trace mode flag */
unsigned long fsize; /* Input file size, needed by thermo fn */
long rsize; /* Random input device file size */
FILE *infile; /* Input file name handle */
FILE *outfile; /* Output file name handle */
FILE *rndfile=NULL; /* input of random numbers */
unsigned long insize; /* Size of input file */
unsigned int limitchnl; /* Max number of channels, user defined */
int maxchnl; /* Size of bytes in the current window */
unsigned int command; /* command byte index */
int oldmode=0;
long rndread=0;
unsigned int passkey; /* Password elementry encryption key.
This is used as part of the password
encryption so as to make every
encryption very sensitive to even 1
bit of change, and thus produce
garbage between two very similar
passwords (diffusion) */
unsigned char oldxor; /* Previous data char. Used by encrypt
and decrypt for recursive encryption
with the previous pass's charachter.
Thus if ANY char is decrypted the
wrong way, all further chars will
also be decrypted the wrong way. */
unsigned char password[151]; /* Password passkey. This isn't really
limited to 150 chars, you can have more,
but then you can't get'em from the
command line. */
int DataBit[8]; /* Array of data bit values. What bit of
the data window is our bit in? */
int DataByte[8]; /* Data bit byte pointers. Which byte
of the window is our bit in? */
/* Define maximum stream size */
#define MAXSTREAM 32
unsigned char
stream[MAXSTREAM]; /* Encryption Stream buffer */
unsigned char
xstream[MAXSTREAM]; /* Bit fix Stream */
char junk[129]; /* Junk buffer used for version check. */
char *header="Encrypted by WNSTORM Rel 1.2 V2.1 940517\n\r\0x04\0x1A ";
/*
DO NOT CHANGE THIS PORTION OF
THE HEADER LINE!!!!!!!!!!!!!!!
If you do, the modified program
won't be able to decrypt what
was written by other copies of
it except in stealth mode.
*/
/* Version 1.01 compatibility header - doesn't have size block */
char *v101header="Encrypted by White Noise Storm. V2.0 940322\n\r\0x04\0x1A ";
/*-----------------------------------------------------------------------
Define byte to start data file from. Should be greater than size
of the header line, plus 3 other bytes for EOF's for DOS & Unix.
If you customize this program, thus making it incompatible with the
normal version, you should also change the header line to include
your company name as well, so that standard versions will not
be confused and attempt to decrypt something it can't. You should
however LEAVE the "Encrypted by White Noise Storm." portion of the
header in the text. Also change the size of the junk[] buffer
declared above to be slightly greater than your possible header
line, and the STARTBYTE as well.
There was a weaker beta version of this program created in Sep 92
which didn't split the data up into 8 separate bits, but rather
worked as nibbles (4 low bytes, and 4 high bytes.) That version
has the same signature as this program, but is incompatible. Hey,
that's what you get for using a beta test version.
This version should be four times as secure as the previous beta
as it not only swaps the bits randomly around, but also swaps the
bytes in which they reside.
------------------------------------------------------------------------*/
#define STARTBYTE 100
/*-------------------- Function Prototypes ------------------------------*/
void help(void);
void victimbit(int *, int *, int, int);
void statbitfix (void);
unsigned char lrotate (char in, int times);
unsigned char rrotate (char in, int times);
unsigned char prexor (char in, int index);
void seedpassword (void);
void nextpasscommand (int index);
void encrypt (void);
void decrypt (void);
void thermometer (void);
/* Debugging code */
void traceout(void);
int vlx (int, int);
void collision(int line);
/*----------------------------------------------------------------------*/
/*-------------------------------------------------------------------*\
| FUNCTION: traceout |
| ------------------------------------------------------------------- |
| |
| Written by: Ray Arachelian on 04/09/1994 |
| Modified by: on |
| Reason for modification: |
| |
| ------------------------------------------------------------------- |
| |
| PURPOSE: Display a trace of the random number window and |
| the data channels. |
| |
| PARAMS: none |
| |
| RETURNS: nothing. |
| |
| |
\*-------------------------------------------------------------------*/
void traceout(void)
{
int i,b;
if (!trace) return;
printf("[%d] ",maxchnl);
for (i=0; i<=7; i++)
{
switch (DataBit[i])
{
case 1: b=0; break;
case 2: b=1; break;
case 4: b=2; break;
case 8: b=3; break;
case 16: b=4; break;
case 32: b=5; break;
case 64: b=6; break;
case 128: b=7; break;
default: b=-1; break;
}
printf("%d:%d ",DataByte[i],b);
}
printf(" pos=%6ld/%-6ld :",ftell(infile),fsize);
for (i=0; i<=maxchnl; i++)
printf("%02x",stream[i]);
puts("");
}
/*-------------------------------------------------------------------*\
| FUNCTION: vlx |
| ------------------------------------------------------------------- |
| |
| Written by: Ray Arachelian on 04/09/1994 |
| Modified by: on |
| Reason for modification: |
| |
| ------------------------------------------------------------------- |
| |
| PURPOSE: Check for array overflows. Used for debugging |
| |
| |
| PARAMS: value of index, line number |
| |
| RETURNS: nothing |
| |
| |
\*-------------------------------------------------------------------*/
int vlx(int x,int y)
{
if (limitchnl<2 || limitchnl>32)
{
printf("limitchnl out of range in line %d (max=%d, lim=%d)\n",
y,maxchnl,limitchnl);
}
if (x<0 || x>7)
{
printf("Array out of bounds (%d) at line %d\n\r",x,y);
exit(0);
}
return(x);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -