Results 1 to 9 of 9

Thread: (Source Code) Password Generator

  1. #1
    Just burned his ISO
    Join Date
    Nov 2009
    Posts
    3

    Default (Source Code) Password Generator

    Properties :

    Code:
    Begin VB.Form Form1
       BorderStyle     =   1  'Fixed Single
       Caption         =   "Password Generator"
       ClientHeight    =   2745
       ClientLeft      =   150
       ClientTop       =   720
       ClientWidth     =   4695
       LinkTopic       =   "Form1"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       ScaleHeight     =   2745
       ScaleWidth      =   4695
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton Command2
          Caption         =   "Hide Password"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   8.25
             Charset         =   0
             Weight          =   700
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   495
          Left            =   2400
          TabIndex        =   9
          Top             =   2160
          Width           =   1575
       End
       Begin VB.CheckBox Check3
          Caption         =   "Uppercase"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   9.75
             Charset         =   0
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   255
          Left            =   120
          TabIndex        =   6
          Top             =   1080
          Width           =   1335
       End
       Begin VB.CheckBox Check2
          Caption         =   "Lowercase"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   9.75
             Charset         =   0
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   255
          Left            =   120
          TabIndex        =   5
          Top             =   840
          Value           =   1  'Checked
          Width           =   1335
       End
       Begin VB.CheckBox Check1
          Caption         =   "Add Numbers"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   9.75
             Charset         =   0
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   255
          Left            =   120
          TabIndex        =   4
          Top             =   1320
          Width           =   1455
       End
       Begin VB.ComboBox Combo1
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   8.25
             Charset         =   0
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   315
          ItemData        =   "PasswordGen.frx":0000
          Left            =   2520
          List            =   "PasswordGen.frx":0002
          Style           =   2  'Dropdown List
          TabIndex        =   3
          Top             =   1080
          Width           =   2055
       End
       Begin VB.CommandButton Command1
          Caption         =   "Get Password"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   8.25
             Charset         =   0
             Weight          =   700
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   495
          Left            =   720
          TabIndex        =   1
          Top             =   2160
          Width           =   1575
       End
       Begin VB.TextBox Text1
          Height          =   285
          Left            =   0
          Locked          =   -1  'True
          TabIndex        =   0
          Top             =   240
          Width           =   4695
       End
       Begin VB.Frame Frame1
          Caption         =   "Options"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   9.75
             Charset         =   0
             Weight          =   700
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   1095
          Left            =   0
          TabIndex        =   7
          Top             =   600
          Width           =   4695
          Begin VB.Label Label2
             Caption         =   "Select # Of Characters:"
             BeginProperty Font
                Name            =   "Tahoma"
                Size            =   9.75
                Charset         =   0
                Weight          =   400
                Underline       =   0   'False
                Italic          =   0   'False
                Strikethrough   =   0   'False
             EndProperty
             Height          =   255
             Left            =   2520
             TabIndex        =   8
             Top             =   240
             Width           =   2055
          End
       End
       Begin VB.Label Label1
          Caption         =   "Your Password:"
          BeginProperty Font
             Name            =   "Tahoma"
             Size            =   9.75
             Charset         =   0
             Weight          =   700
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          Height          =   255
          Left            =   0
          TabIndex        =   2
          Top             =   0
          Width           =   4695
       End
       Begin VB.Menu Clip
          Caption         =   "Clipboard"
          Begin VB.Menu Copy
             Caption         =   "Copy"
             Shortcut        =   ^C
          End
       End
       Begin VB.Menu About
          Caption         =   "About..."
       End
    End
    script :
    Code:
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Dim PassSet, TextTxt, mylower, myupper
    
    Private Sub About_Click()
    Load Form2
    Form2.Show
    End Sub
    
    Private Sub Command1_Click()
    Text1.Text = ""
    Randomize
    Dim mypass, NumOfChars
    Dim uporlow
    
    
    
    NumOfChars = Combo1.Text
    
    'Checking if Combo1 has value or if value under 3
    If NumOfChars = "" Then
    mynull = MsgBox("Error: Number of characters not selected!", vbExclamation, "Error!")
    Exit Sub
    ElseIf NumOfChars <= 3 Then
    mynull = MsgBox("Error: Number of characters not selected!", vbExclamation, "Error!")
    Exit Sub
    End If
    
    NumOfChars = Int(NumOfChars)
    
    For i = 1 To NumOfChars
    
    
    If Check2.Value And Check3.Value = 1 Then
    
    'Deciding if uppercase or lowercase
    Randomize
    uporlow = Int((Rnd * 2) + 1)
    If uporlow = 1 Then
      myupper = 122
      mylower = 97
     
      Call NumChooser
     
    Else
      myupper = 90
      mylower = 65
     
      Call NumChooser
     
    End If
     
    ElseIf Check3.Value = 1 Then
    myupper = 90
    mylower = 65
    
    Call NumChooser
    
    ElseIf Check2.Value = 1 Then
    myupper = 122
    mylower = 97
    
    Call NumChooser
    
    Else
    mynull = MsgBox("Error: You must select Lowercase or Uppercase!", vbExclamation, "Error!")
    Exit Sub
    End If
    
    mypass = Int((myupper - mylower + 1) * Rnd + mylower)
    Text1.Text = Text1.Text & Chr(mypass)
    Next
    End Sub
    
    Private Sub Command2_Click()
    
    If Text1.Text = "" Then
    Exit Sub
    End If
    
    If PassSet = True Then
    Text1.PasswordChar = ""
    Text1.Text = TextTxt
    Command2.Caption = "Hide Password!"
    PassSet = False
    ElseIf PassSet = False Then
    TextTxt = Text1.Text
    Text1.PasswordChar = "*"
    Command2.Caption = "Unhide Password!"
    PassSet = True
    End If
    End Sub
    
    Private Sub Copy_Click()
    Clipboard.SetText (Text1.Text)
    End Sub
    
    Private Sub Form_Load()
    For i = 4 To 20
    Combo1.AddItem (i)
    Next
    End Sub
    
    Private Sub NumChooser()
    'Adding number if number checkbox is selected and
    'random generator chooses number over characters
    If Check1.Value = 1 Then
    Randomize
    isnumorchar = Int((Rnd * 4) + 1)
    If isnumorchar = 1 Then
    mylower = 48
    myupper = 57
    End If
    End If
    End Sub
    for VB.5

  2. #2
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default

    Howsabout something a bit more useful to a Linux based community? Ripped directly from Bl@ckTo\/\/3r by Brian Hatch but placed here for those who haven't seen it before:
    Code:
    $ cat ~/bin/randpw
    
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    # All printable ascii characters
    my @chars = (32..126);
    my $num_chars = @chars;
    
    # Passwords must be 50 chars long, unless specified otherwise
    my $length=$ARGV[0] || 50;
    
    while (1) {
            my $password;
            foreach (1..$length) {
                    $password .= chr($chars[int(rand($num_chars))]);
            }
    
            # Password must have lower, upper, numeric, and 'other'
            if (    $password =~ /[a-z]/
                and $password =~ /[A-Z]/
                and $password =~ /[0-9]/
                and $password =~ /[^a-zA-Z0-9]/ ) {
                    print $password, "\n";
                    exit;
            }
    }
    
    $ randpw 10
     (8;|vf4>7X
    
    $ randpw
    ]'|ZJ{.iQo3(H4vA&c;Q?[hI8QN9Q@h-^G8$>n^`3I@gQOj/-(
    
    $ randpw
    Q(gUfqqKi2II96Km)kO&hUr,`,oL_Ohi)29v&[' Y^Mx{J-i(]
    If you write one down to begin with and type it a few times you will get to know them. I regularily have 40 char passwords memorised based on that script.
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

  3. #3
    Senior Member fnord0's Avatar
    Join Date
    Jul 2008
    Posts
    144

    Default

    40chars memorized?? wow - thats quite the feat! I have no clue how u do it, I tried it, and I am not getting how u can memorize 40chars@!#

    thanks for the code, and the link gitsnik, I hadn't read that book before, tried the code and I like it. peace
    'see the fnords!'

  4. #4
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default

    Quote Originally Posted by fnord0 View Post
    40chars memorized?? wow - thats quite the feat! I have no clue how u do it, I tried it, and I am not getting how u can memorize 40chars@!#

    thanks for the code, and the link gitsnik, I hadn't read that book before, tried the code and I like it. peace
    Muscle memory more than anything. If I think about it I can't remember them at all (I've been known to boot my truecrypt volumes when asleep - over 200 characters without remembering them). When you type them day after day they tend to stick.

    The books are not half bad for computer novels, definitely grab them from the local bookstore if you can!

    Keeping this on topic (and something for anyone generating a cupp list against me) I usually modify the above code to remove spaces as I hate the sound of that particular key being struck when typing a password - there are tools out there to train themselves to the sound of a keyboard, and it's not hard to pick a space bar!
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

  5. #5
    prowl3r
    Guest

    Default

    Quote Originally Posted by fnord0 View Post
    40chars memorized?? wow - thats quite the feat! I have no clue how u do it, I tried it, and I am not getting how u can memorize 40chars@!#
    Just follow Lecter's method: Develop Perfect Memory With the Memory Palace Technique

  6. #6
    Senior Member streaker69's Avatar
    Join Date
    Jan 2010
    Location
    Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
    Posts
    3,535
    A third party security audit is the IT equivalent of a colonoscopy. It's long, intrusive, very uncomfortable, and when it's done, you'll have seen things you really didn't want to see, and you'll never forget that you've had one.

  7. #7
    Super Moderator Archangel-Amael's Avatar
    Join Date
    Jan 2010
    Location
    Somewhere
    Posts
    8,012

    Default

    Quote Originally Posted by prowl3r View Post
    Nahh that's too much reading. I'll just stick to the minimum password lengths.
    To be successful here you should read all of the following.
    ForumRules
    ForumFAQ
    If you are new to Back|Track
    Back|Track Wiki
    Failure to do so will probably get your threads deleted or worse.

  8. #8
    Senior Member streaker69's Avatar
    Join Date
    Jan 2010
    Location
    Virginville, BlueBall, Bird In Hand, Intercourse, Paradise, PA
    Posts
    3,535

    Default

    Quote Originally Posted by prowl3r View Post
    I did not RTFA, but I hope this method doesn't involve eating someone's liver with some fava beans.
    A third party security audit is the IT equivalent of a colonoscopy. It's long, intrusive, very uncomfortable, and when it's done, you'll have seen things you really didn't want to see, and you'll never forget that you've had one.

  9. #9
    prowl3r
    Guest

    Default

    Quote Originally Posted by streaker69 View Post
    I did not RTFA, but I hope this method doesn't involve eating someone's liver with some fava beans.
    Well, actually you have to do it. But only those of new members who don't make proper use of the s34rch function.

    ... and those of lazy mods.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •