EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


paswdgen

By: toast  -  Date Submitted: 2009-04-04 04:31:24

  1. #!/bin/bash
  2. # random password generator by typedeaF
  3. # This program has no "real" value other than introducing some bash concepts and putting them to use.
  4. # to strip the comments: cat this.file | grep -v '^# '
  5.  
  6.  
  7. # Sets the maximum size of the password the script will generate
  8. MAXSIZE=50
  9.  
  10. # Holds valid password characters.
  11. # Put the non alph-numeric in single quotes so the program knows that it is part of the array and not a seperate part of the program.
  12. # Example if the # is not in a set of single or double quotes it will comment out any part of the line after the # symbol and will not reconize the characters as part of the array.
  13. array0=(
  14. q w e r t y u i o p a s d f g h j k l z x c v b n m Q W E R T Y U I O P A S D F
  15. G H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 0 '!' '@' '$' '%' '^' '&' '#' '*' '('
  16. ')' '+' '-' '=' '|' '/' '<' '>' '~' '`' ':' ';' '[' ']' '{' '}' '|' ',' '.' '?'
  17. '_')
  18.  
  19. # Used in conjunction with modulus to keep random numbers in range of the array size
  20. MODNUM=${#array0[*]}
  21.  
  22. # Keeps track of the number characters in the password we have generated
  23. pwd_len=0
  24.  
  25. # Bash's command substitution syntax to store the results of the tput command
  26. term_clear=$(tput clear)
  27.  
  28. # Stores the number of lines or rows on the terminal display
  29. max_lines=$(tput lines)
  30.  
  31. # Stores the number of columns on the terminal display
  32. max_cols=$(tput cols)
  33.  
  34. # Finds the appropriate spot to indent for horizontally centered output
  35. indent=$(( ((max_cols / 2)) - ((MAXSIZE / 2)) ))
  36.  
  37. # Finds the vertical center of the terminal.
  38. line_num=$(( max_lines / 2 ))
  39.  
  40. # Clear the screen
  41. echo $term_clear
  42.  
  43. # The outer while loop starts at 0 and loops till MAXSIZE, creating a passwd char each iteration.
  44. # The shells $RANDOM variable creates a semi-random unsigned number. This is our entropy. =x
  45. # x simply holds some random unsigned int that will be used to make the character scramble.
  46. # 500 was choosen for speed and nothing else. Leave out the mod 500 if you want or change it.
  47. # The inner loop displays the password characters. Tput keeps the cursor in the proper position.
  48. # Mod MODNUM keeps the random number inside the size of the array so it doesnt over index.
  49. while [ $pwd_len -lt $MAXSIZE ]
  50. do
  51. x=$(($RANDOM%500))
  52. y=0
  53. while [ $y -lt $x ]
  54. do
  55. ((y++))
  56. index=$(($RANDOM%$MODNUM))
  57. tput cup $line_num $(( indent + pwd_len ))
  58. echo -n "${array0[$index]}"
  59. done
  60. ((pwd_len++))
  61. done
  62.  
  63. # Place the cursor at the bottom of the screen --where is usually at.
  64. tput cup $max_lines 0
  65.  
  66. exit 0
Return to bash category list

Who's Online

487 Guests, 100 Users
ckryptix, TheRetech, Diznablo, Nicid1, Ios, viper0i0, rabbidmind, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019