Author Topic: (Challenge) Password Generator  (Read 8828 times)

0 Members and 1 Guest are viewing this topic.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: (Challenge) Password Generator
« Reply #15 on: August 30, 2013, 06:34:56 AM »
After some more tinkering (fixed some issues) I want to move on to creating "pronounceable" passwords and using SHA1 like PWGEN (the tool mentioned in the OP). This is fun! :D
What about one which generates a pass phrase for you like the the xkcd comic: http://xkcd.com/936/

That would probably necessitate a dictionary of words to select from. Perhaps splitting them into nouns, verbs, etc. Then generating some random sentences  :laugh: Might come up with really "strange" stuff.

Thereafter you might then use some form of mutation on those words. E.g. extract random letters from them, substituting some letters using numbers or punctuation.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: (Challenge) Password Generator
« Reply #16 on: August 30, 2013, 08:19:08 AM »
Letting someone else do the work...

Code - Auto/Visual Lisp: [Select]
  1. ;; Password Generator  -  Lee Mac
  2. ;; Retrieves a set of random strings from http://www.random.org
  3. ;; num - [int] Number of passwords to generate (1 - 10000)
  4. ;; len - [int] Length of each password (1 - 20)
  5. ;; bit - [int] 1=0-9, 2=A-Z, 4=a-z
  6.  
  7. (defun password ( num len bit / obj rtn )
  8.     (if (and (< 0 num 1e4) (< 0 len 21) (< 0 bit))
  9.         (if (setq obj (vlax-get-or-create-object "winhttp.winhttprequest.5.1"))
  10.             (progn
  11.                 (setq rtn
  12.                     (vl-catch-all-apply
  13.                         (function
  14.                             (lambda ( )
  15.                                 (vlax-invoke-method obj 'open "GET"
  16.                                     (strcat
  17.                                         "http://www.random.org/strings/?num="
  18.                                         (itoa num)
  19.                                         "&len="
  20.                                         (itoa len)
  21.                                         "&digits="
  22.                                         (if (= 1 (logand 1 bit)) "on" "off")
  23.                                         "&upperalpha="
  24.                                         (if (= 2 (logand 2 bit)) "on" "off")
  25.                                         "&loweralpha="
  26.                                         (if (= 4 (logand 4 bit)) "on" "off")
  27.                                         "&unique=on&format=plain&rnd=new"
  28.                                     )
  29.                                     :vlax-false
  30.                                 )
  31.                                 (vlax-invoke-method obj 'send)
  32.                                 (vlax-get-property  obj 'responsebody)
  33.                             )
  34.                         )
  35.                     )
  36.                 )
  37.                 (vlax-release-object obj)
  38.                 (if (vl-catch-all-error-p rtn)
  39.                     (princ (vl-catch-all-error-message rtn))
  40.                     (princ
  41.                         (vl-list->string
  42.                             (mapcar '(lambda ( x ) (lsh (lsh x 24) -24))
  43.                                 (vlax-safearray->list (vlax-variant-value rtn))
  44.                             )
  45.                         )
  46.                     )
  47.                 )
  48.             )
  49.         )
  50.         (princ "\nInvalid arguments.\nnum: integer 1-10,000\nlen: integer 1-20\nbit: 1=0-9, 2=A-Z, 4=a-z")
  51.     )
  52.     (princ)
  53. )

Code - Auto/Visual Lisp: [Select]
  1. _$ (password 5 10 (+ 2 4))
  2. zqldmMHEdy
  3. ktoKijAdNf
  4. YwucronUgI
  5. hsFwudZlns
  6. wAcwxhkHkL

JohnK

  • Administrator
  • Seagull
  • Posts: 10649
Re: (Challenge) Password Generator
« Reply #17 on: August 30, 2013, 08:57:37 AM »
After some more tinkering (fixed some issues) I want to move on to creating "pronounceable" passwords and using SHA1 like PWGEN (the tool mentioned in the OP). This is fun! :D
What about one which generates a pass phrase for you like the the xkcd comic: http://xkcd.com/936/

That would probably necessitate a dictionary of words to select from. Perhaps splitting them into nouns, verbs, etc. Then generating some random sentences  :laugh: Might come up with really "strange" stuff.

Thereafter you might then use some form of mutation on those words. E.g. extract random letters from them, substituting some letters using numbers or punctuation.

lol Must have the pwgen source code.
Code - C++: [Select]
  1. /*
  2.  * pw_phonemes.c --- generate secure passwords using phoneme rules
  3.  *
  4.  * Copyright (C) 2001,2002 by Theodore Ts'o
  5.  *
  6.  * This file may be distributed under the terms of the GNU Public
  7.  * License.
  8.  */
  9. ...

But that's a good idea and sounds like fun to me! :D Damnit, now I need to see if I can scratch up some time but today looks crappy already.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Password Generator
« Reply #18 on: September 05, 2013, 12:43:26 PM »
my variant for autocad:

Code - Auto/Visual Lisp: [Select]
  1. (defun eea-pass (c n / f f1 G S)
  2.   ;;(eea-pass 8 5)
  3.   (defun f (s st c b i)
  4.     (if (and s (nth c s))
  5.       (cons (strcat "\n"
  6.                     (repeat c
  7.                       (setq s (cdr s)
  8.                             b (strcat b (chr (nth (rem (car s) i) st)))
  9.                       )
  10.                     )
  11.             )
  12.             (f s st c "" i)
  13.       )
  14.     )
  15.   )
  16.   (defun f1 (st)
  17.     (princ "\n\nThese are the very easy!")
  18.     (princ (apply (function strcat) (f s (vl-string->list (substr st 85)) c "" 10)))
  19.     (princ "\n\nThese are the easy ones!")
  20.     (princ (apply (function strcat) (f s (vl-string->list (substr st 59)) c "" 36)))
  21.     (princ "\n\nThese are the hard ones!")
  22.     (princ (apply (function strcat) (f s (vl-string->list (substr st 33)) c "" 62)))
  23.     (princ "\n\nThese are the harder ones!")
  24.     (princ (apply (function strcat) (f s (vl-string->list st) c "" 94)))
  25.   )
  26.   (princ "\nMove the cursor on the screen: \n")
  27.   (repeat (1+ (/ (* c n)3))
  28.     (while (equal (cadr (grread nil 5 1)) g))
  29.     (setq s (append s
  30.                     (mapcar (function (lambda (a) (apply (function +) (vl-string->list (rtos a 2 16)))))
  31.                             (trans (setq g (cadr (grread nil 5 1))) 0 '(-95.6564 -160.159 2327.53))
  32.                     )
  33.             )
  34.     )
  35.   )
  36.   (f1
  37.     "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
  38.   )
  39.   (princ)
  40. )

test:
Code: [Select]
Command: (eea-pass 8 5)

Move the cursor on the screen:


These are the very easy!
10639290
14518197
25729955
07319832
70999601

These are the easy ones!
f00r9wt0
5uvf2rj7
2912f3lz
onx5li7i
bezj36o5

These are the hard ones!
LW6Xf2zW
BQRL8Npd
YF7YB9H5
UJ3BhoDE
HKVp9cUB

These are the harder ones!
"Mw.VspM
1GH"yDfT
O5xO\z|v
+~t13e3_
7!LfzS+1

Command:


ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Password Generator
« Reply #19 on: September 05, 2013, 12:49:37 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun eea-pass (c n / f G S ST)
  2.   ;;(eea-pass 16 5)
  3.   (defun f (s st c b i)
  4.     (if (and s (nth c s))
  5.       (cons (strcat "\n"
  6.                     (repeat c
  7.                       (setq s (cdr s)
  8.                             b (strcat b (chr (nth (rem (car s) i) st)))
  9.                       )
  10.                     )
  11.             )
  12.             (f s st c "" i)
  13.       )
  14.     )
  15.   )
  16.   (princ "\nMove the cursor on the screen: \n")
  17.   (repeat (1+ (/ (* c n) 3))
  18.     (while (equal (cadr (grread nil 5 1)) g))
  19.     (setq s (append s
  20.                     (mapcar (function (lambda (a) (apply (function +) (vl-string->list (rtos a 2 16)))))
  21.                             (trans (setq g (cadr (grread nil 5 1))) 0 '(-95.6564 -160.159 2327.53))
  22.                     )
  23.             )
  24.     )
  25.   )
  26.   (setq st "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
  27.   (foreach a '(("\n\nThese are the very easy!" 85 10)
  28.                ("\n\nThese are the easy ones!" 59 36)
  29.                ("\n\nThese are the hard ones!" 33 62)
  30.                ("\n\nThese are the harder ones!" 1 94)
  31.               )
  32.     (princ (car a))
  33.     (princ (apply (function strcat) (f s (vl-string->list (substr st (cadr a))) c "" (caddr a))))
  34.   )
  35.   (princ)
  36. )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: (Challenge) Password Generator
« Reply #20 on: September 06, 2013, 01:49:36 PM »
I was thinking about this topic a couple of months ago, my problem was to write a encrypt and decrypt-function. The thing was I want that my collegues sent me a 4 sign PIN and when would get a activate key from me to can activae the my program.

Code: [Select]
(defun encrypt (str / p)
    (setq p (mapcar '+ (vl-string->list str) '(1 8 14 19  3 6 17 36 25 4  1  9 62)))
    (princ (strcat "\n The activate key is: " (vl-list->string p)))
    (princ)
    )

(defun decrypt (str / p)
    (setq p (vl-list->string (mapcar '- (vl-string->list str) '(1 8 14 19  3 6 17 36 25 4  1  9 62))))
    )

(defun c:GetAPassword (/ key)
    (if (and (setq password (getstring "\n Type a 4 sign PIN! "))
             (setq key (strcat password (rtos (getvar "cdate") 2 0)))
             )
        (encrypt key)
        )
    (princ)
    )

(defun c:ActivatePassWord (/ fname file)
        (if (eq (decrypt (getstring "\n Type in Activate key! "))
                (strcat (if (null password)
                            (progn
                                (princ "\n Password is expiered\n")
                                (exit)
                                )
                            password
                            )
                        (rtos (getvar "cdate") 2 0)
                 )
             )
            (progn
                (princ "\n Program is activated! ")
                (vl-registry-write "HKEY_CURRENT_USER\\Test" "" password)
               
                (setq fname (strcat "C:\\Temp\\Test\\password" ".txt")) ; here it saved your password
                (if (setq file (open fname "w"))
                    (write-line password file)
                    )
                (close file)
                )
            (princ "\n Password i wrong! ")
            )
    (setq password nil)
    (princ)
    )
       
(defun c:foo ( / fname file)
   (if (= (if (setq fname (strcat "C:\\Temp\\Test\\password" ".txt"))
              (if (not (setq file (open fname "r")))
                  (princ "\n You have no password ")
                  (read-line file)
              )
           )

          (if (not (vl-registry-read "HKEY_CURRENT_USER\\Test"))
              (princ "\n You have no PIN")
              (vl-registry-read "HKEY_CURRENT_USER\\Test")
              )
       )
       (alert " Program is starting ")
       (alert "\n No license! ")
       )
   (princ)
   )
       
   


I´m not proffs, I think your password-generator looks fine here. Are you thinking as same way when I to activate a program ?