{"id":415,"date":"2014-07-05T06:29:34","date_gmt":"2014-07-05T06:29:34","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=415"},"modified":"2017-09-11T19:47:27","modified_gmt":"2017-09-11T11:47:27","slug":"%e5%ad%97%e5%85%b8%e7%94%9f%e6%88%90%e5%b7%a5%e5%85%b7bak","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/415.html","title":{"rendered":"\u5b57\u5178\u751f\u6210\u5de5\u5177[bak]"},"content":{"rendered":"<h5>\u7528shell\u5199\u7684\u5b57\u5178\u751f\u6210\u5de5\u5177<\/h5>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash\r\n#by leo108\r\n#\u4f7f\u7528\u65b9\u5f0f\uff1a.\/genpwd.sh \u5bc6\u7801\u7c7b\u578b \u5bc6\u7801\u957f\u5ea6 \u751f\u6210\u6587\u4ef6\r\n#\u5bc6\u7801\u7c7b\u578b\u5982\u679c\u662f1\uff0c\u5219\u662f\u6570\u5b57+\u5b57\u6bcd\uff0c\u5982\u679c\u662f\u5176\u4ed6\u5219\u662f\u6570\u5b57\r\n#\u4f8b\u5982\uff1a.\/genpwd.sh 1 4 pwd.txt\uff0c\u751f\u6210\u957f\u5ea6\u4e3a4\u7684\u6570\u5b57+\u5b57\u6bcd\u5bc6\u7801\r\ntype=$1\r\nlength=$2\r\noutput=$3\r\nif [ $type -eq \"1\" ]; then\r\n\tg_Dict=( 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z )\r\nelse\r\n\tg_Dict=( 0 1 2 3 4 5 6 7 8 9 )\r\nfi\r\ncount=0\r\ntotal=1\r\nif [ -e tmp.txt ]; then\r\n\trm tmp.txt\r\nfi\r\nfor ((i=0;i&lt;$length;i++));\r\ndo\r\n\tlet \"total*=${#g_Dict[@]}\"\r\ndone\r\necho \"Total:\"$total\r\ndeclare -a Dict\r\ndeclare -a Array\r\nbStop=1\r\nfor ((i=0;i&lt;$length;i++));\r\ndo\r\n\tArray[$i]=0\r\ndone\r\nwhile [ $bStop != 0 ]; do\r\n\tfor ((i=0;i&lt;$length;i++));\r\n\tdo\r\n\t\tDict[$i]=${g_Dict[${Array[$i]}]}\r\n\tdone\r\n\techo ${Dict[@]} &gt;&gt; tmp.txt\r\n\tlet \"count+=1\"\r\n\tlet \"tmp=count%10000\"\r\n\tif [ $tmp -eq 0 ]; then\r\n\t\techo $count\" Generated\"\r\n\tfi\r\n\tfor ((j=$length-1;j&gt;=0;j--));\r\n\tdo\r\n\t\tlet \"Array[$j]+=1\"\r\n\t\tif [ ${#g_Dict[@]} -ne ${Array[$j]} ]; then\r\n\t\t\tbreak\r\n\t\telse\r\n\t\t\tArray[$j]=0\r\n\t\t\tif [ $j -eq 0 ]; then\r\n\t\t\t\tbStop=0\r\n\t\t\tfi\r\n\t\tfi\r\n\tdone\r\ndone\r\nsed -r 's\/ +\/\/g' tmp.txt &gt;&gt; $output\r\necho \"Finish\"\r\nrm tmp.txt<\/pre>\n<p><span style=\"color: #ff0000;\"><strong>\u53c2\u8003\u6765\u6e90<\/strong><\/span>\uff1a<a href=\"http:\/\/www.freebuf.com\/tools\/4086.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.freebuf.com\/tools\/4086.html<\/a><\/p>\n<p># .\/genpwd.sh 1 4 pwd.txt<br \/>\nTotal:1679616<br \/>\n10000 Generated<br \/>\n20000 Generated<br \/>\n\u2026\u2026<\/p>\n<p><span style=\"color: #ff0000;\">\u603b\u89c9\u5f97\u6548\u7387\u8fd8\u662f\u592a\u4f4e\u4e86\u3002\u3002\u3002<\/span>{\u8fd9\u65f6\u5c31\u5e94\u8be5\u662f\u591a\u7ebf\u7a0b\u53d1\u6325\u5a01\u529b\u7684\u5730\u65b9\u4e86\uff01}<\/p>\n<hr \/>\n<p>\u4e0b\u9762\u8fd9\u6bb5shell\u4ee3\u7801\u662f\u4e4b\u524d\u53d1\u73b0\u7684\uff0c\u4eca\u5929\u78b0\u5230\u4e0a\u9762\u8fd9\u4e2a(\u56e0\u4e3a\u89c9\u5f97\u4e0a\u9762\u8fd9\u4e2a\u6548\u7387\u4f4e\u800c\u4e14\u81ea\u5b9a\u4e49\u6027\u4e0d\u591f\u5f3a)\u6240\u4ee5\u7a81\u7136\u60f3\u8d77\u6765\u4e86\uff0c\u7528Everything\u641c\u7d22\u51fa\u6765\uff0c\u7136\u540e\u6267\u884c\u770b\u4e86\u4e0b\u6548\u679c\uff0c\u89c9\u5f97\u8fd8\u4e0d\u9519\uff0c\u5c31\u5148\u8bb0\u4e0b\u6765\u4e86\uff0c\u653e\u5728\u4e0b\u9762\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash\r\n## Koen Noens, December 2007\r\n## word generator : random 'words'\r\n## with given length, or range\r\n## with choice of wharacters to be used\r\n\r\nchars0=\"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\r\nchars1=\"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\"\r\nchars2=\"0 1 2 3 4 5 6 7 8 9\"\r\nchars3=\"&amp; | \u00e9 @ \u20ac \" # ' ( \u00a7 ^ \u00e8 ! \u00e7 { \u00e0 } ) - _ \u00b0 ^ \" $ [ ] % \u00f9 \u00a3 \u00b5 = + ~ : \/ ; . , ? \"\r\n\r\nfunction increment { #recursive or iterative ???\r\n\tINPUT=$1\r\n\t[[ ${#INPUT} -ge $minlen ]]  &amp;&amp; echo $1\r\n\tif [[ ${#INPUT} -lt $maxlen ]]; then\r\n\t\tfor c in $chars; do\r\n\t\t\tincrement $1$c\r\n\t\tdone\r\n\tfi\r\n}\r\n\r\nfunction showUsage {\r\n\techo \"$0 MAXLEN [MINLEN] [a [A [n [p]]]]\"\r\n\techo\r\n\techo \" MAXLEN integer Maximum lenght, or specific lengt if MINLEN is omitted\"\r\n\techo \" MINLEN integer Minimum lenght, equals MAXLEN if omitted\"\r\n\techo \"\"\r\n\techo \" characters:\"\r\n\techo \" a lower case  a-z\"\r\n\techo \" A Uppercase  A-Z\"\r\n\techo \" n numeric  0-9\"\r\n\techo \" p punctuation . ?\"\r\n}\r\n\r\n## argument handler\r\n[[ \"$1\" = \"\" ]] &amp;&amp; showUsage &amp;&amp; exit\r\nmaxlen=$1\r\n[[ $2 -eq 0 ]] &amp;&amp; minlen=$maxlen || minlen=$2\r\n\r\nfor arg in \"$@\"; do  # \"$@\" ???\r\n\tcase $arg in\r\n\t\ta) chars=\"$chars $chars0\" ;;\r\n\t\tA) chars=\"$chars $chars1\" ;;\r\n\t\tn) chars=\"$chars $chars2\" ;;\r\n\t\tp) chars=\"$chars $chars3\" ;;\r\n\tesac;\r\ndone\r\n\r\n#fallback\r\n[[ \"$chars\" = \"\" ]] &amp;&amp; chars=\"$chars0\" # Default is $chars0\r\n\r\n## kickof\r\nfor i in $chars; do  # call the function defined before\r\n\tincrement $i\r\ndone<\/pre>\n<p><span style=\"color: #ff0000;\"><strong>\u6765\u6e90<\/strong><\/span>\uff1a<a href=\"http:\/\/users.telenet.be\/mydotcom\/program\/shell\/generatewords.txt\" target=\"_blank\" rel=\"noopener\">http:\/\/users.telenet.be\/mydotcom\/program\/shell\/generatewords.txt<\/a><br \/>\n\u6ce8\uff1a\u5728\u8be5\u7f51\u7ad9\u4e0b\u8fd8\u6709\u4e0d\u5c11\u522b\u7684\u5f88\u597d\u7684shell\u811a\u672c\u3002<\/p>\n<h6>\u4f7f\u7528\u793a\u4f8b\uff08\u4fdd\u5b58\u4e3agenerator.sh\uff0c\u6dfb\u52a0\u53ef\u6267\u884c\u6743\u9650\uff09\uff1a<\/h6>\n<p>$ .\/generator.sh 4 4 a #\u751f\u62104\u4f4d\u5f62\u5982\uff1aaaaa-zzzz\u7684\u5b57\u7b26\u7ec4\u5408<br \/>\n$ .\/generator.sh 4 4 A #\u751f\u62104\u4f4d\u5f62\u5982\uff1aAAAA-ZZZZ\u7684\u5b57\u7b26\u7ec4\u5408<br \/>\n$ .\/generator.sh 4 4 n #\u751f\u62104\u4f4d\u5f62\u5982\uff1a0000-1111\u7684\u6570\u5b57\u7ec4\u5408<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528shell\u5199\u7684\u5b57\u5178\u751f\u6210\u5de5\u5177 #!\/bin\/bash #by leo108 #\u4f7f\u7528\u65b9\u5f0f\uff1a.\/genpwd.sh [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7,25,12],"tags":[199,65],"class_list":["post-415","post","type-post","status-publish","format-standard","hentry","category-linux","category-programing","category-security","category-tools","tag-password","tag-shell"],"views":2207,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=415"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/415\/revisions"}],"predecessor-version":[{"id":3606,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/415\/revisions\/3606"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}