Random password string

Anyone have any action script code they would be willing to share that generates a random x digits string to be used as a password? Perhaps at least 1 upper char, at least 1 lower char, at least 1 number etc?

1 Like

I personally use sites - a lot of them even have the functions to essentially execute the functions locally (it does it directly within the browser without sending it as a request to the page). Example: https://passwordsgenerator.net/. If you need it as a script to do it on the go plenty of examples to do if you google it - here is one with Powershell: https://adamtheautomator.com/random-password-generator/.

Not every endpoint (where this action runs) will have access to anything external, hence the need to do it within the action script. I guess another idea is warranted here.

https://bigfix-ideas.hcltechsw.com/ideas/BFPTCH-I-165

I’m sure there are better or more elegant ways of doing this, but based on https://bigfix.me/relevance/details/3019529, the following are some sample Client-side relevance statements that could be used in actionscript via relevance substitution.

// 2 random number characters (you can adjust the number of characters returned by adjusting the number at the end of the relevance statement - in this example **2** -1)
Q: concatenation of (characters it) of (it + 48) of (random integer of it) of (9) of integers to (2-1)
A: 17

// 5 random upper case characters (you can adjust the number of characters returned by adjusting the number at the end of the relevance statement - in this example **5** -1)
Q: concatenation of (characters it) of (it + 65) of (random integer of it) of (25) of integers to (5-1)
A: FPSZP

// 5 random lower case characters (you can adjust the number of characters returned by adjusting the number at the end of the relevance statement - in this example **5** -1)
Q: concatenation of (characters it) of (it + 97) of (random integer of it) of (25) of integers to (5-1)
A: gumsp

// combined (2 random numbers, then 5 random upper case, then 5 random lowercase, then 2 random numbers)
Q: concatenation of ((concatenation of (characters it) of (it + 48) of (random integer of it) of (9) of integers to (2-1));(concatenation of (characters it) of (it + 65) of (random integer of it) of (25) of integers to (5-1));(concatenation of (characters it) of (it + 97) of (random integer of it) of (25) of integers to (5-1));(concatenation of (characters it) of (it + 48) of (random integer of it) of (9) of integers to (2-1)))
A: 86PENJKbzvyd11

// another approach
Q: concatenation of (characters it) of (if ((it >= 58 AND it <= 64) OR (it >= 91 AND it <= 96)) then ((it + 48) of random integer of 9) else it) of (it + 48) of (random integer of it) of (74) of integers to (12-1)
A: lQkaoOD3T8LI
1 Like

Can those statements be used in action script? I was looking here https://developer.bigfix.com/action-script/reference/ and didn’t see where those are mentioned.

They can :slight_smile:

Check out https://developer.bigfix.com/action-script/guide/substitution.html

1 Like

I was working today on adding in special characters, but excluding some special characters which can cause issues like SQL injection… like ` ’ ? < > ;

I also wanted to insure that I had at least one upper, one lower, one number and one special.

Generating the 4 character classes (and the 5th class which is the combination of any of the classes)

q: (item 0 of it, item 1 of it, item 2 of it, item 3 of it, item 0 of it & item 1 of it & item 2 of it & item 3 of it) of (concatenation of characters (integers in (48,57)), concatenation of characters (integers in (65,90)), concatenation of characters (integers in (97,122)), concatenation of characters (33;35;36;38;40;41;42;43;45;47;58;61;64;91;92;93;94;95;123;125))
A: 0123456789, ABCDEFGHIJKLMNOPQRSTUVWXYZ, abcdefghijklmnopqrstuvwxyz, !#$&()*+-/:=@[\]^_{}, 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}

<<EDIT - I have an edge case - solving >>

Putting the classes together into 10 slots. This does have the weakness in a pattern of Number, Any, Upper,Lower,Any,Special. but the character positions will slide left or right in a subsequent step.

q: (item 4 of it;item 4 of it;item 0 of it;item 4 of it;item 1 of it;  item 2 of it; item 4 of it; item 3 of it; item 4 of it;item 4 of it) of (item 0 of it, item 1 of it, item 2 of it, item 3 of it, item 0 of it & item 1 of it & item 2 of it & item 3 of it) of (concatenation of characters (integers in (48,57)), concatenation of characters (integers in (65,90)), concatenation of characters (integers in (97,122)), concatenation of characters (33;35;36;38;40;41;42;43;45;47;58;61;64;91;92;93;94;95;123;125))
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}
A: 0123456789
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}
A: ABCDEFGHIJKLMNOPQRSTUVWXYZ
A: abcdefghijklmnopqrstuvwxyz
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}
A: !#$&()*+-/:=@[\]^_{}
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}
A: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$&()*+-/:=@[\]^_{}

We then choose one of each class (in order) and concatenate them into one string and trim to the first 8

q: first 8 of following text of position (random integer of 2) of concatenation of (first 1 of following text of position (random integer of (length of it - 1)) of it) of (item 4 of it;item 4 of it;item 0 of it;item 4 of it;item 1 of it;  item 2 of it; item 4 of it; item 3 of it; item 4 of it;item 4 of it) of (item 0 of it, item 1 of it, item 2 of it, item 3 of it, item 0 of it & item 1 of it & item 2 of it & item 3 of it) of (concatenation of characters (integers in (48,57)), concatenation of characters (integers in (65,90)), concatenation of characters (integers in (97,122)), concatenation of characters (33;35;36;38;40;41;42;43;45;47;58;61;64;91;92;93;94;95;123;125))
A: k5ERdc@3

If you run that one a bunch of times, you will see that pattern shifts left and right. If you wanted to change that pattern, you could shift around this portion, (item 4 of it;item 4 of it;item 0 of it;item 4 of it;item 1 of it; item 2 of it; item 4 of it; item 3 of it; item 4 of it;item 4 of it), but always leave the item 4 (any) in positions 1, 2, 9 and 10, because those are the slots that get randomly trimmed.

Then you can just stack these up several times and trim the result to your desired password length:

q: first (16) of (concatenation of (first 8 of following text of position (random integer of 2) of concatenation of (first 1 of following text of position (random integer of (length of it - 1)) of it) of (item 4 of it;item 4 of it;item 0 of it;item 4 of it;item 1 of it;  item 2 of it; item 4 of it; item 3 of it; item 4 of it;item 4 of it) of (item 0 of it, item 1 of it, item 2 of it, item 3 of it, item 0 of it & item 1 of it & item 2 of it & item 3 of it) of (concatenation of characters (integers in (48,57)), concatenation of characters (integers in (65,90)), concatenation of characters (integers in (97,122)), concatenation of characters (33;35;36;38;40;41;42;43;45;47;58;61;64;91;92;93;94;95;123;125))) of integers to 5)
A: #h44Ppx:-j2\Dd)*

Slight tweak to remove one layer of tuple and a modification on generation of the Any class.

q: first (16) of concatenation of ((first 8 of following text of position (random integer of 2) of concatenation of (first 1 of following text of position (random integer of (length of it - 1)) of it) of (item 4 of it;item 4 of it;item 0 of it;item 4 of it;item 1 of it;  item 2 of it; item 4 of it; item 3 of it; item 4 of it;item 4 of it) of  (/*numbers*/concatenation of characters (integers in (48,57)), /*UPPER*/concatenation of characters (integers in (65,90)), /*lower*/concatenation of characters (integers in (97,122)), /*special*/concatenation of  characters (33;35;36;38;40;41;42;43;45;47;58;61;64;91;92;93;94;95;123;125), /*Any*/concatenation of characters ((integers in (33,126))whose (it is not contained by set of (/*exclude from Any*/34;37;39;44;46;59;60;62;63;96;124))))) of integers to 5)
A: iF2JThM=_&8SSwi:

This variation is a lot tighter, but does not guarantee that each of the 4 classes will be present:

q: (concatenations of ((first 1 of following texts of positions (random integer of (length of it -1)) of it) of     concatenation of characters ((integers in (33,126))whose (it is not contained by set of (34;37;39;44;46;59;60;62;63;96;124)))) of integers to 15) 
A: $4fn:ThzMc{{eKXp
1 Like

Here is something I now use on some of my nightly jobs that hit upwards of a thousand clients around the same time via Server Automation, which download multiple zip files from a server, and it has almost got rid of all connection/winsock errors on clients. It’s not the prettiest :wink: , but it works great. Hopefully some of you may find it helpful. Just adding a 1-40 random interval and using that with the old ping localhost -n.

dos set /a num=%random% %40 +1 > c:\temp\random.txt
parameter “random” = "{line of file “c:\temp\random.txt”}"
dos ping 127.0.0.1 -n {parameter “random”} > c:\temp\wait.txt