Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Crypto :: pan_rar.txt

How to recover a RAR key in Linux






   R A R B   A N D   P A N   U L T I M A T E



--- UNIX LINUX WIN PASSWORD GENERATOR IN C ---



/**************************************************
PAN by ad / 2006 - 2009

The program generates passwords and has many
functions to generate them. It also can generate
octal and hexal passwords now. It includes a pseudo
urandom function and a random keypad function too,
one random function generates a file with a given
size in bytes and one sends the values to stdout.

PAN creates a *.out file with x passwords with a
length of y. The program runs under unix, linux &
windows. We use registers for a faster program.

tested on: FreeBSD 6.2 and Debian 2.6
compiled with: gcc 4.1.2
compile with: cc -o pan pan.c
or just type "make"
start with: ./pan

This is the ultimate version - *NO* more updates.
New urandom function for urandom values to stdout
added, and some more generations in the mix and
also the whole ascii & ansii table if you need it.

This project is closed.
***************************************************/

// libraries
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// library for random values
#include <time.h>

// some info
#define VERSION "ultimate"
#define UPDATE "2006 - 2009"
#define AUTHOR "ad"

// output files
char file[] = "pan.out";

// generator function
void gen( register int a, register int b, register int c );
// keypad function
void keypad();
// pseudo urandom functions
void urandom();
void urandom2();
// wisdom and ascii function
void wisdom();
void ascii();

// global variables
int x, y, z;

// main function
int main(void)
{	// main screen
	printf("PAN %s # %s by %s\n", VERSION, UPDATE, AUTHOR);
	puts("\n\t 0) numbers\t 1) signs\t 2) upper chars\n\t 3) lower \
chars\t 4) mix chars \t 5) chars and numbers\n\t 6) mix all\t 7) octal \
\t 8) hexal\n \t 9) urandom \t10) keypad \t11) help \n\t12) exit \t13) urandom 2 \
\t14) num & signs\n\t15) num & lower\t16) num & upper\t17) wisdom\n\t18) ascii & ansii");
	printf("\nenter a number: ");
	// get input
	scanf("%d", &x);
	// handle input
	switch( x )
	{	case 0:
			break;
		case 1:
			break;
		case 2:
			break;
		case 3:
			break;
		case 4:
			break;
		case 5:
			break;
		case 6:
			break;
		case 7:
			break;
		case 8:
			break;
		case 9:
			// call function urandom
			urandom();
			// exit
			return 0;
		case 10:
			// call function keypad
			keypad();
			// exit
			return 0;
		case 11:
			// help function
			puts("\nselect a number then enter:");
			puts("syntax:\n\tlength passwords\nexample:\n\t12 500\n");
			return 0;
		case 12:
			// exit
			puts("Good bye.");
			return 0;
		case 13:
			// call function urandom 2 -> stdout
			urandom2();
			// exit
			return 0;
		case 14:
			break;
		case 15:
			break;
		case 16:
			break;
		case 17:
			// call function wisdom
			wisdom();
			// exit
			return 0;
		case 18:
			// call ascii function
			ascii();
			// exit
			return 0;
		// if wrong input do exit
		default:
			puts("Wrong input, quit.");
			return 1;
	}
	// input screen
	printf("[length] [passwords]: ");
	// get input
	scanf("%d %d", &y, &z);
	// exec generation function
	gen( x, y, z );
	// exit
	return 0;
}

// keypad function
void keypad()
{	// make a values
	srand( (int)time( NULL ) );
	int n, both;
	// some stuff we need
	char pass_both, s;
	int blah = 0;
	// file pointer
	FILE *fp;
	// create the NEW empty file
	fp = fopen(file, "w");
	// close file
	fclose(fp);
	// create all signs
	for( n = 0; n < 94; n++ )
	{	s = 0;
		while(1)
		{	// create a random sign
			both = rand() % 1000;
			// if wrong input do nothing
			if( both > 126 && both < 33)
				;
			if( both <= 126 && both >= 33 )
			{	// open file
				fp = fopen(file, "a+");
				// read and check file if the sign is inside
				while( s != EOF )
				{	s = fgetc(fp);
					// sign is in the file
					if( both == s )
					{	blah = 0;
						break;
					}
					// sign is not in the file ..
					if( both != s )
					{	blah = 1;
						continue;
					}
				}
				// write the sign into the file
				if( blah == 1 )
				{	pass_both = both;
					fprintf(fp, " %c ", pass_both);
					// every 10 signs make a \n\n
					if( n == 9 || n == 19 || n == 29 \
|| n == 39 || n == 49 || n == 59 || n == 69 || n == 79 || n == 89 )
						fprintf(fp, "\n\n");
					blah = 2;
					// close file
					fclose(fp);
					// next loop
					break;
				}
			}
		}
	}
	// write a stamp
	fp = fopen(file, "a+");
	// write some info
	fprintf(fp, "\n\n secure pan random keypad\n\n");
	// close file
	fclose(fp);
	// done
	printf("keypad file %s is written\n", file);
}

// pseudo urandom function
void urandom()
{	// make a values
	srand( (int)time( NULL ) );
	// some stuff we need
	int both, n;
	int o;
	// question for how many bytes we want
	printf("how many bytes: ");
	scanf("%d", &o);
	// more stuff we need
	char pass_both;
	// file pointer
	FILE *fp;
	// create the file
	fp = fopen(file, "w");
	// generate $x bytes of urandom from 0 - 255
	for( n = 0; n < o; n++ )
	{	while(1)
		{	both = rand() % 1000;
			if( both >= 0 && both <= 255)
			{	pass_both = both;
				break;
			}
		}
		// write into file
		fprintf(fp, "%c", pass_both );
		// do we need this ?
//		fprintf(stderr, "%c", pass_both );
	}
	// close file
	fclose(fp);
	// done
	printf("urandom file %s is written, %d bytes \n", file, o);
}

// urandom function #2 -> send random values to stdout
void urandom2()
{	// make a values
	srand( (int)time( NULL ) );
	// some stuff we need
	int both;
	// more stuff we need
	char pass_both;
	// generate bytes of urandom from 0 - 255
	while(1)
	{	both = rand() % 1000;
		if( both >= 0 && both <= 255)
		{	pass_both = both;
		// write to stdout - use ./pan > file
		fprintf(stdout, "%c", pass_both );
		}
	}
}

// some wisdom ...
void wisdom()
{	puts("\n The internet is full of liars and false vipers, take care. \n");
}

// print the whole ascii & ansii table
void ascii()
{	// print ascii & ansii table ( textfiles.com is for your ascii files )
	// file pointer
	FILE *fp;
	// open the file or create it
	fp = fopen(file, "a+");
	int n;
	// from 0 to 127 is ascii
	fprintf(fp, "\n\n ASCII \n\n" );
	for( n = 0; n <= 127; n++ )
	{	fprintf(fp, "decimal: %d - hexal: %x - octal: %o - ascii: %c \n", n,n,n,n );
	}
	// from 128 to 255 is ansii
	fprintf(fp, "\n\n ANSII \n\n" );
	for( n = 128; n <= 255; n++ )
	{	fprintf(fp, "decimal: %d - hexal: %x - octal: %o - ansii: %c \n", n,n,n,n );
	}
	fprintf(fp, "\n\nPAN generated ASCII & ANSII table\n\ntextfiles.com is ASCII love \n\n" );
	// close file
	fclose(fp);
	printf("ascii table is written to %s \n", file);
}

// generator function - use register for speed
void gen( register int a, register int b, register int c )
{	// stuff we need
	int pass_numb[ y ], m, n;
	char pass_char[ y ];
	char pass_both[ y ];
	// more stuff
	int numb;
	int cha;
	int both;
	// make a value
	srand( (int)time( NULL ) );
	// file pointer
	FILE *fp;
	// open the file or create it
	fp = fopen(file, "a+");
	// numbers
	if( x == 0 )
	{	// how many passwords
		for( n = 0; n < z; n++ )
		{	// loop for the length of the passwords
			for( m = 0; m < y; m++ )
			{	numb = rand() % 10;
				pass_numb[m] = numb;
				// write data
				fprintf(fp, "%d", pass_numb[m] );
			}
			// write new line
			fprintf(fp, "\n" );
		}
	}
	// signs
	if( x == 1 )
	{	// how many passwords
		for( n = 0; n < z; n++ )
		{	// how many signs for the password
			for( m = 0; m < y; m++ )
			{	while(1)
				{	cha = rand() % 1000;
					if( cha > 47 && cha < 33 || cha < 64 \
&& cha > 58 || cha < 96 && cha > 91 || cha > 126 && cha < 123 )
						;
					if( cha <= 47 && cha >= 33 || cha <= 64 \
&& cha >= 58 || cha <= 96 && cha >= 91 || cha <= 126 && cha >= 123 )
					{	pass_char[m] = cha;
						break;
					}
				}
				fprintf(fp, "%c", pass_char[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// upper chars
	if( x == 2 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	cha = rand() % 1000;
					if( cha > 90 && cha < 65)
						;
					if( cha <= 90 && cha >= 65)
					{	pass_char[m] = cha;
						break;
					}
				}
				fprintf(fp, "%c", pass_char[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// lower chars
	if( x == 3 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	cha = rand() % 1000;
					if( cha > 122 && cha < 97)
						;
					if( cha <= 122 && cha >= 97)
					{	pass_char[m] = cha;
						break;
					}
				}
				fprintf(fp, "%c", pass_char[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// all chars
	if( x == 4 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	cha = rand() % 1000;
					if( cha > 122 && cha < 97 || cha > 90 \
&& cha < 65 )
						;
					if( cha <= 122 && cha >= 97 || cha <= 90 \
&& cha >= 65 )
					{	pass_char[m] = cha;
						break;
					}
				}
				fprintf(fp, "%c", pass_char[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// chars & numbers
	if( x == 5 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 57 && both < 48 || both > 90 \
&& both < 65 || both > 122 && both < 97 )
						;
					if( both <= 57 && both >= 48 || both <= 90 \
&& both >=65 || both <= 122 && both >= 97 )
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// mix all
	if( x == 6 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 126 && both < 33)
						;
					if( both <= 126 && both >= 33)
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// octal
	if( x == 7 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	numb = rand() % 10;
					if( numb <= 7 )
					{
						pass_numb[m] = numb;
						break;
					}
				}
				fprintf(fp, "%d", pass_numb[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// hexal
	if( x == 8 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 57 && both < 48 || both > 70 \
&& both < 65 || both > 102 && both < 97 )
						;
					if( both <= 57 && both >= 48 || both <= 70 \
&& both >=65 || both <= 102 && both >= 97 )
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// numbers and signs
	if( x == 14 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 57 && both < 48 || both > 47 && both < 33 \
 || both < 64 && both > 58 || both < 96 && both > 91 || both > 126 && both < 123 )
						;
					if( both <= 57 && both >= 48 || both <= 47 && both >= 33 \
|| both <= 64 && both >= 58 || both <= 96 && both >= 91 || both <= 126 && both >= 123 )
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// numbers and lower chars
	if( x == 15 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 57 && both < 48 || both > 122 && both < 97 )
						;
					if( both <= 57 && both >= 48 || both <= 122 && both >= 97 )
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// numbers and upper chars
	if( x == 16 )
	{	for( n = 0; n < z; n++ )
		{	for( m = 0; m < y; m++ )
			{	while(1)
				{	both = rand() % 1000;
					if( both > 57 && both < 48 || both > 90 && both < 65 )
						;
					if( both <= 57 && both >= 48 || both <= 90 && both >= 65 )
					{	pass_both[m] = both;
						break;
					}
				}
				fprintf(fp, "%c", pass_both[m] );
			}
			fprintf(fp, "\n" );
		}
	}
	// close file
	fclose(fp);
	// done
	printf("pw file %s is written, %d lines, length %d \n", file, z, y);
}
// EOF - End Of File




--- LINUX UNIX RAR AND ZIP KEY RECOVERY SHELL SCRIPT ---



#!/bin/sh
#
# RARB by ad
# 
# Rar & Zip brute force shell script.
#
# Can be used with "rar", "unrar" or "unzip" or what ever for rar
# and zip files.
#
# Tested on Damin Small Linux ( i686 2.4.26 )

# version
vers="v.1.1"
# autor
auth="ad"
# update
#upd="update: 02.04.07"
# help
if [ $# -lt 2 ] ; then
	echo "RARB - $vers # 2006 - 2007"
#	echo "$upd"
	echo "by $auth "
	echo
	echo " usage: "
	echo -e "  $0 <*.rar | *.zip> -n | -N number"
	echo -e "  $0 <*.rar | *.zip> -d | -D wordlist.txt "
	echo
	echo "Option -N and -D are for a faster speed without"
	echo "status checking. You must EDIT this script first."
	echo
	exit 1
fi
# wordlist
dict=$3
# for numbers
number=$2
# rar file
file=$1
num=0
num1=1
# lines of the wordlist
lines=`sed -n -e '$=' "$dict" 2>/dev/null`
# add 1
lines=`expr "$lines" + 1 2>/dev/null`
# if we use "-d"
if [ "$number" = "-d" ] ; then
	#try all words in the wordlist
	echo
	echo " trying keyword: "
	while [ "$lines" -gt "$num1" ] ; do
		# test actual wordlist line
		line=`head -"$num1" "$dict" | tail -1`
		# decryption try
		testing=`rar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unzip
#		testing=`unrar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unrar
#		testing=`unzip -P"$line" "$file" 1>/dev/null 2>/dev/null`
		# test status
		testing2=`echo $?`
		# we got the key
		if [ "$testing2" = 0 ] ; then
			echo
			echo " file "$file" is successfully broken"
			echo " the used keyword is: $line"
			echo
			echo -ne '\a'
			exit 0
		fi
		# increment the key
		num1=`expr $num1 + 1`
		# print actual wordlist line
		echo -e " \t\t $line "
	done
fi
# if we use "-D" (fast)
if [ "$number" = "-D" ] ; then
	#try all words in the wordlist
	echo
	echo " trying keyword: "
	while [ "$lines" -gt "$num1" ] ; do
		# test actual wordlist line
		line=`head -"$num1" "$dict" | tail -1`
		# decryption try
		testing=`rar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unzip
#		testing=`unrar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unrar
#		testing=`unzip -P"$line" "$file" 1>/dev/null 2>/dev/null`
		# increment the key
		num1=`expr $num1 + 1`
		# print actual wordlist line
		echo -e " \t\t $line "
	done
fi
# if we use "-n"
if [ "$number" = "-n" ] ; then
	# loop for numbers
	echo
	while [ ! "$num" -gt "$3" ] ; do
		# test actual number
		test=`rar x -p"$num" "$file" 1>/dev/null 2>/dev/null`
		# for unzip
#		test=`unrar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unrar
#		test=`unzip -P"$line" "$file" 1>/dev/null 2>/dev/null`
		# test status
		test2=`echo $?`
		# we got the key
		if [ "$test2" = 0 ] ; then
			echo
			echo " file "$file" is successfully broken"
			echo " the used key is: $num"
			echo
			echo -ne '\a'
			exit 0
		fi
		# increment key
		num=`expr $num + 1`
		# print actual key number
		echo -ne " "trying key: $num '\r'
	done
fi
# if we use "-N" (fast)
if [ "$number" = "-N" ] ; then
	# loop for numbers
	echo
	while [ ! "$num" -gt "$3" ] ; do
		# test actual number
		test=`rar x -p"$num" "$file" 1>/dev/null 2>/dev/null`
		# for unzip
#		test=`unrar x -p"$line" "$file" 1>/dev/null 2>/dev/null`
		# for unrar
#		test=`unzip -P"$line" "$file" 1>/dev/null 2>/dev/null`
		# increment key
		num=`expr $num + 1`
		# print actual key number
		echo -ne " "trying key: $num '\r'
	done
fi
# no key
echo
echo " Can't decrypt "$file" with this input."
echo
# exit
exit 0

# EOF


TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH