NO

Author Topic: Some small silly programs...  (Read 3398 times)

kobold

  • Guest
Some small silly programs...
« on: September 07, 2006, 05:58:10 PM »
I wrote those programs at work to test and bypass our e-mail filter system . (-> evil *gg*)
Our stupid system blocks zip files with more than approx. 2500 files.
This it is very annoying because the mail system does not inform you, when a mail was blocked.

So i wrote a program to generate a large number of empty files for compressing them as a zip file and one to encrypt the zip file.
(Deleting the zip extension does not work.)

The best: It works! :mrgreen: (mail filters suck!)


The first program can create a large number of files - with random file names and variable length:

Code: [Select]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

#define PATH "d:\\temp\\"   // path for the files
#define NUM 1000            // number of files to create


int main( int argc,char *argv[] )
{
int num = 0;


puts("Starting...");
srand( GetTickCount() );

while ( num < NUM )
{
FILE *fp;
char name[14], path[1024];
int i1 = 0;


for ( ; i1 < (rand() %13 + 3); i1++)
{
int data = '\0';

data = rand() %26 + 1;
name[i1] = data + 96;
}
name[i1] = '\0';

printf("%i. > '%s'\n", num, name );

strcpy( path, PATH );
strcat( path, name );
printf( "'%s'\n", path );

fp = fopen( path, "wt" );
fclose( fp );
num++;
}

puts("Work complete!");
return(0);
}



This program is a XOR encryption program. It is able to encrypt and decrypt programs and files with a given password.

The first argument is the sourcefile, you want to encrypt or decrypt, as second argument the destination (the output), an as third and last argument the password.
It is not the ultimate crypto program - so do not use it, if security is important for you!

Code: [Select]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>


void crypt( char *file1, char *file2, char *password )
{
OFSTRUCT stuff;
HFILE   fp1;
long int size = 0;
char *mem;


fp1 = OpenFile( file1, &stuff, OF_READ );
size = GetFileSize( (void *)fp1, NULL );
printf( "file: %s, size1: %i\n", file1, size );
_lclose( fp1 );

FILE *fp2 = NULL;
FILE *fp3 = NULL;

fp2 = fopen( file1, "rb" );
if ( fp2 != NULL )
{
mem = (char *)malloc( size );
fread( mem, 1, size, fp2 );
printf( "%i\n", mem );

fp3 = fopen( file2, "wb" );

for ( int k=0, i=size; i > 0; i-- )  // do some magic encryption...
{
mem[i] ^= (int)password[k];
if ( k < strlen(password) ) k++;
else k = 0;
}

fwrite( mem, 1, size, fp3 );

fflush( fp3 );
free( mem );
fclose( fp2 );
fclose( fp3 );
}
}


int main(int argc,char *argv[])
{
if ( argc == 4 )
crypt( argv[1], argv[2], argv[3] );
return(0);
}