标题: [转载代码] [PowerShell每日技巧]创建随机密码(20131211) [打印本页]
作者: DAIC 时间: 2013-12-23 11:26 标题: [PowerShell每日技巧]创建随机密码(20131211)
Here's a chunk of code that creates random passwords of different lengths for you:- $length = 8
- $characters = [Char[]]((31..50) + (65..90) + (97..122))
- $characters = $characters -ne 'O' -ne 'o' -ne 'l' -ne '1' -ne '-'
- $password = -join ($characters | Get-Random -Count $length)
- "Your temporary $length-character-password is $password"
复制代码
The password length is set by $length. The characters used to compose the passwords are defined in $characters. By default, all ASCII codes from 31-50, 65-90, and 97-122 are used. As you can see, with the -ne operator, you can fine-tune the list and exclude characters. In our example, we exclude characters that can easily be misinterpreted.
http://powershell.com/cs/blogs/tips/archive/2013/12/11/creating-temporary-password.aspx
作者: terse 时间: 2014-1-29 17:07
也发现一个- Add-Type -AssemblyName System.Web
- [System.Web.Security.Membership]::GeneratePassword(10,2)
复制代码
作者: PowerShell 时间: 2014-4-17 22:52
it人的终极梦想是什么?
答:先进的技术,就像下述电影里演的那样。
“电脑:启动医学紧急全息投影程序!” ----------太好了!
推荐观看 星际旅行---航海家号 1-7季全集,清晰度=h.264,字幕=外挂
http://pan.baidu.com/s/1sjrVI1J
“电脑,护盾全开,导弹全轰!”
“呀被打败了,启动自毁程序,安全码是xxx”
“呀,安全码几百年没改,被人穷举出来改掉了,不灵了。。。”
观众:“靠~~~~”
身为it人,密码还总不灵,真是%#¥%#¥%……
特奉献我写的密码生成脚本:
1 密码生成位数,默认为8,容易修改
2 默认8位,大小写+数字,修改脚本第19行。
3 默认每次产生1000个密码,在d:\tools\小写加数字密码.txt 含大写密码.txt 含特殊符号密码.txt
4每生成一个字母后,都随机延时,生成的比较慢,要n个小时,但随机性可靠,开了程序,一晚上就会产生很多密码在文本中,用时随意取,并在文本中标注即可。
5 傻瓜都能懂,菜鸟都能改。
作者: PowerShell 时间: 2014-4-17 22:53
- <#
- 转帖
- 管理员不能无耻到如此程度!!!---------------人家好心好意把你网站的漏洞报给你,你却把人加入了黑名单!
- CSDN 600万 人人500万 多玩800万 等等 互联网泄密风云仍在继续!!就在刚刚 本站又获得消息 国内著名的域名注册商xinnet 新网的 管理员密码造泄漏!
- 此消息由国内著名安全漏洞网站WooYun 爆出!
- 保守估计漏洞爆出的 域名管理密码在30万以上。这个漏洞最早在2010年2月就被发现,当时就已经与新网取得联系但是石沉大海 没有任何回复,当近期再次联系时发现邮箱地址已经被对方列入黑名单!
- 长达两年时间 这个漏洞一直没有修复。完全是不把用户安全放在心上!用户安全荡然无存。
- 为此,本人特贡献,生成8位随机密码的powershell脚本!
- #>
-
-
-
- $每个密码位数 = 8
- $存盘目录 = 'd:\TOOLS\'
- $纯小写密码 = $存盘目录 + '纯小写密码.txt'
- $小写加数字密码 = $存盘目录 + '小写加数字密码.txt'
- $含大写密码 = $存盘目录 + '含大写密码.txt'
- $含特殊符号密码 = $存盘目录 + '含特殊符号密码.txt'
- $密码类型 = 3 # 4=小写+数字+特殊符号,3=大写+小写+数字,2=小写+数字
- $生成密码总个数 = 1000
-
-
- mkdir $存盘目录
- Write-Host "---每生成一个字母后,都随机延时---"
- Write-Host "---生成的比较慢,但随机性可靠---"
- $随机延时 = 50,60,70,100,200,88,95,111,120,135,146,160,170,181,189
-
- for ($l=$生成密码总个数;$l -gt 0;$l--)
- {
- [string]$结果 = "a","b","c","d","e","f","g","h","i","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z" | Get-Random
- Start-Sleep -m ($随机延时 | Get-Random)
- #某些网站有别扭的要求“密码首字符必须为字母”,所以本程序首字符,固定为小写字母,
- for ($i=1;$i -lt $每个密码位数;$i++)
- {
- $小写字母 = "a","b","c","d","e","f","g","h","i","j","k","m","n","o","p","q","r","s","t","u","v","w","x","y","z" | Get-Random
- #小写字母没有字母 l
- Start-Sleep -m ($随机延时 | Get-Random)
-
-
- $数字 = "2","3","4","5","6","7","8","9" | Get-Random
- #没有0,1
- Start-Sleep -m ($随机延时 | Get-Random)
-
- $大写字母 = "A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z" | Get-Random
- #大写字母没有字母 I,O
- Start-Sleep -m ($随机延时 | Get-Random)
-
- $特殊符号 = "~","!","@","#","$","%","^","&","*","(",")" | Get-Random
- #大写字母没有字母 I,O
- Start-Sleep -m ($随机延时 | Get-Random)
-
- switch ($密码类型)
- {
- #1 {$结果 = $结果 + $小写字母;break}
- 2 {$结果 = $结果 + ($小写字母,$数字| Get-Random) ; break}
- 3 {$结果 = $结果 + ($小写字母,$数字,$大写字母| Get-Random) ; break}
- 4 {$结果 = $结果 + ($小写字母,$数字,$特殊符号| Get-Random) ; break}
- }
-
- }
-
- #洗牌
- $结果 = $结果 | Get-Random -Count $每个密码位数
-
- if ( $结果 -match "[~!@#$%^&*()]+" )
- {
- $结果 >> $含特殊符号密码
- }
-
- if ( ($结果 -notmatch "[~!@#$%^&*()]+") -and ($结果 -cmatch "[A-Z]+") )
- {
- $结果 >> $含大写密码
- }
-
- if ( ($结果 -notmatch "[~!@#$%^&*()]+") -and ($结果 -cnotmatch "[A-Z]+") )
- {
- $结果 >> $小写加数字密码
- }
-
-
-
- Write-Host "." -NoNewline -ForegroundColor Yellow
- }
- Write-Host "`n---完成 $生成密码总个数 个密码创建---"
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |