Unix/Linux Go Back    


Security Discuss UNIX and Linux computer and network security, cyber security, cyber attacks, IT security, and more.

learn unix and linux commands

swordfish --- a password generator

Security


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-18-2004
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 8 August 2015, 12:06 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 454 Times in 266 Posts
swordfish --- a password generator

Here is my new password generation script. The attachment, swordfish.txt, is in dos format. Remember that you need to use dos2unix or flip or something to get it into unix format.

The script is self documenting. It has an extensive help system built-in. And you can run:
swordfish "set LineLength=75" "help user_guide"
to get a complete user guide.

Here is a sample run to show some of the features:
Code:
$ ./swordfish
>>}###@>---- format +s +x 10
password statistics are on
password expansions are on
10 passwords will be generated per template

>>}###@>---- CvccEnnn
Template EEEEEEEE has 2,992,179,271,065,856 possibilities
Template CvccEnnn has 3,982,230,000 possibilities
YisdG633     YANKEE india sierra delta GOLF six three three
DehtK503     DELTA echo hotel tango KILO five zero three
Hickt465     HOTEL india charlie kilo tango four six five
SeydP384     SIERRA echo yankee delta PAPA three eight four
Fakt0554     FOXTROT alpha kilo tango zero five five four
FexrS395     FOXTROT echo x-ray romeo SIERRA three nine five
Bamwv220     BRAVO alpha mike whiskey victor two two zero
XumtF501     X-RAY uniform mike tango FOXTROT five zero one
HilbS790     HOTEL india lima bravo SIERRA seven nine zero
Xijsw021     X-RAY india juliet sierra whiskey zero two one

>>}###@>----

Attached Files
File Type: txt swordfish.txt (74.7 KB, 156 views)

Last edited by Perderabo; 03-22-2011 at 03:00 PM..
Sponsored Links
    #2  
Old Unix and Linux 12-18-2004
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 8 August 2015, 12:06 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 454 Times in 266 Posts
If I do this:
Code:
$ ./swordfish
>>}###@>---- define X=(n{ABCDEF})
>>}###@>---- XXXXXX
0F5C7E
9833F3
9713BE
1EBE49
195969

>>}###@>----

I can generate random hexadecimal numbers. Password generators are very close to being random number generators. So it is fair to ask a password generator to pass tests intended for a random number generator. I did this:
Code:
$ ./swordfish "define X=(n{ABCDEF})" "format 1000000" "X<80>" > hex.txt
This command took 13711 seconds.
$

At that point I had one million lines of hexadecimal numbers, each 80 characters in length. This is exactly the input format needed by the asc2bin program of the diehard test suite. I ran diehard on the data file, selecting all 15 tests. The data passes all 15 tests. The results are attached.
Attached Files
File Type: txt diehard.txt (56.2 KB, 190 views)

Last edited by Perderabo; 07-06-2005 at 09:41 AM.. Reason: Fix typo
Sponsored Links
    #3  
Old Unix and Linux 07-25-2006
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 16 December 2015, 6:12 PM EST
Location: Bangalore
Posts: 304
Thanks: 10
Thanked 1 Time in 1 Post
need help. when i tried running the sworfish from the same folder that it is residing i could get the passwords working perfectly fine. However, when i tried running it from a different path by giving the absolute path i get the below mentioned warning message. i also tried running it through the shell scripts i tried a cd to the folder and then launched using the command ./swordfish.txt some times this works and some times it fails can some one help me understand why is it failing some times?

Quote:
../utl/swordfish.txt
********************************
* *
* Warning: Entropy is zero! *
* *
********************************
generating weak entropy...
scribe[108]: linecount=linecount+1: bad number
Starts = 1
Period = 9,194,221,792,649,674,751
Total Calls = 0

Carry = 0
X0 = 1099
X1 = 8139
X2 = 26893
X3 = 23965
Entropy = BC928C58A6531E5E95BCB2ECE62EFD56F1D74717
>>}###@>----
    #4  
Old Unix and Linux 07-25-2006
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 8 August 2015, 12:06 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 454 Times in 266 Posts
I will post a new copy of swordfish making these changes:

Code:
In the weak_start_tigershark function: the line in green is new.

function weak_start_tigershark
{
        typeset -i  i final duration
        ((final=SECONDS+2))

        while((SECONDS < final)) ; do
                i=$RANDOM
        done

        ((Carry=0))
        ((X0=$$))
        ((X1=RANDOM))
        ((X2=RANDOM))
        ((X3=RANDOM))
        ((DEBUG)) && echo weakstart X3=$X3 X2=$X2 X1=$X1 X0=$X0 Carry=$Carry
        Sum=0
        ((Stigershark=Stigershark+1))
        return 0
}


In the Main section: The lines in red go away:

if [[ $Entropy = $ZeroEntropy ]] ; then
                echo "********************************" >&2
                echo "*                              *" >&2
                echo "*  Warning:  Entropy is zero!  *" >&2
                echo "*                              *" >&2
                echo "********************************" >&2
                echo generating weak entropy... >&2
                weak_start_tigershark
                status_tigershark
                entropy_generator 1 array
                echo  Entropy = ${Entropy}
                NeedMoreEntropy=1
fi

It is too early in the program to call status_tigershark since linecount has not be initialized and also it is sending unsolicted output to stdout. And that "echo Entropy" should have been directed to stderr as well. The remaining error message should be enough to call attention to the fact that swordfish is not operating in an optimum manner. And the user can always turn on debug mode for more output.

Yes, my intent is that swordfish be invoked always in the same directory. swordfish maintains an entropy file which is random data used to initialize the internal random number generator. But the first time the random number generator is called, there won't be an entropy file. So swordfish will initialize the RNG from /dev/urandom or /dev/random. If neither of those is available then swordfish is stuck with no decent source of initial random numbers. So it invokes the internal ksh RANDOM routine to get a few random numbers and it uses its current PID for one more random number. It first spends a couple of seconds burning off some of KSH's random numbers so it is not as bad as it might otherwise be. But it still complains about the situation. This is what is happening to you. Even HP-UX finally implemented /dev/random in 11.23. What OS are you using without a /dev/random?

If you really want to call swordfish from arbitrary directories, you could change the line:
ENTROPYFILE=swordfish.ent
to be an obsolute path to your entropy file. But remember, if other people can read your entropy file, they might be able to predict the passwords it
will generate.
Sponsored Links
    #5  
Old Unix and Linux 09-14-2007
ArcAngel ArcAngel is offline
Registered User
 
Join Date: Jun 2007
Last Activity: 17 October 2011, 4:41 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
swordfish error

Hi,

I use your tool on Solaris 10, only i get this error.

[machine:user]$ ./swordfish
>>}###@>---- format +s +x 10
./swordfish[39]: !X0 && !X1 && !X2 && !X3 && !X4 && !Carry : bad number
password statistics are on
password expansions are on
10 passwords will be generated per template
Sponsored Links
    #6  
Old Unix and Linux 03-22-2011
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 8 August 2015, 12:06 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 454 Times in 266 Posts
Quote:
Originally Posted by ArcAngel View Post
Hi,

I use your tool on Solaris 10, only i get this error.

[machine:user]$ ./swordfish
>>}###@>---- format +s +x 10
./swordfish[39]: !X0 && !X1 && !X2 && !X3 && !X4 && !Carry : bad number
password statistics are on
password expansions are on
10 passwords will be generated per template

Opps! Sorry ArcAngel, I had not noticed your report before. Better late than never I guess. Linux There is no X4, it only goes up to X3. The fix was to remove "!X4 && " from that line. Actually, it's odd that the script ran everywhere else.

I have recently been ordered to use 12 character randomly generated passwords that meet strong complexity requirements. That is why I have dusted off this old script. I need it badly right now. Ironically, I want to to run on Solaris just like ArcAngel. I also tested it on RedHat and it broke on the latest ksh. I had to change my character slicing technique to get it work. I used to do stuff like this:
Code:
first=${x%${x#?}}

to get the first character. That breaks depening on the contents of the field. That had always been the case but it breaks more easily with today's ksh. I switched to
Code:
        first=$x
        while ((${#first} > 1 )) ; do
               first=${first%?}
        done

which works all the time and it much faster than it looks. I upgraded the help system a little, corrected spelling errors, etc. I had to reverse engineer my own code so I upgraded the comments quite a bit as well. It saved me from needed to memorize a string of garbage from a lesser password generator. I hope others can use it as well.
Sponsored Links
    #7  
Old Unix and Linux 05-13-2011
okhawaja okhawaja is offline
Registered User
 
Join Date: May 2011
Last Activity: 16 May 2011, 1:24 PM EDT
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
im getting sum random errors and im running ubuntu...wll screeny the errors
Sponsored Links
Closed Linux or Unix Question


Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
time generator hernand Shell Programming and Scripting 7 06-02-2011 06:23 AM
Password Generator Perderabo Security 13 10-02-2004 11:34 AM
Load Generator for Web momo UNIX for Advanced & Expert Users 1 05-15-2002 06:40 PM



All times are GMT -4. The time now is 02:12 PM.