{"id":1832,"date":"2015-01-24T00:30:45","date_gmt":"2015-01-23T16:30:45","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1832"},"modified":"2015-01-24T00:30:45","modified_gmt":"2015-01-23T16:30:45","slug":"%e8%af%91%e5%8f%a6%e7%b1%bb%e7%9a%84%e5%af%86%e7%a0%81%e7%a0%b4%e8%a7%a3%e9%80%9f%e6%9f%a5%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1832.html","title":{"rendered":"[\u8bd1]\u53e6\u7c7b\u7684\u5bc6\u7801\u7834\u89e3\u901f\u67e5\u8868"},"content":{"rendered":"<p><strong>\u539f\u6587\u94fe\u63a5<\/strong>\uff1a<a href=\"http:\/\/www.unix-ninja.com\/p\/A_cheat-sheet_for_password_crackers\" target=\"_blank\">unix-ninja :: A cheat-sheet for password crackers<\/a><\/p>\n<p>\u5728\u6587\u7ae0\u6b63\u6587\u5f00\u59cb\u4e4b\u524d\u5148\u8bf4\u51e0\u53e5\uff1a\u5176\u5b9e\u633a\u6fc0\u52a8\u7684\uff0c\u8fd9\u4e48\u597d\u7684\u6587\u7ae0\uff0c\u73b0\u5728\u624d\u770b\u5230\uff1b\u8001\u5916\u7684\u5206\u4eab\u610f\u8bc6\u592a\u7ed9\u529b\u4e86\uff0c\u6211\u89c9\u5f97\u5982\u679c\u662f\u56fd\u5185\u7684\u8bdd\uff0c\u8fd9\u4e48\u597d\u7684\u5185\u5bb9\u5728\u516c\u5f00\u7684\u573a\u5408\u53ef\u80fd\u5c31\u770b\u4e0d\u5230\u4e86\uff08\u81ea\u5df1\u5077\u5077\u6478\u6478\u7684\u7528\u5c31\u884c\u4e86\uff0c\u80af\u5b9a\u4e0d\u4f1a\u653e\u51fa\u6765\u7684\uff0c\u6216\u8005\u53ea\u662f\u5728\u5c0f\u8303\u56f4\u5185\u6d41\u4f20\uff09\uff0c\u50cf\u6211\u80af\u5b9a\u662f\u770b\u4e0d\u5230\u7684::&gt;_&lt;:: \u6700\u521d\u662f\u5728<a href=\"http:\/\/bobao.360.cn\/\" target=\"_blank\">360\u5b89\u5168\u64ad\u62a5<\/a>\u91cc\u9762\u770b\u5230\u7684<a href=\"http:\/\/bobao.360.cn\/learning\/detail\/167.html\" target=\"_blank\">\u6587\u7ae0<\/a>\uff0c\u4f46\u662f\u91cc\u9762\u7684\u7ffb\u8bd1\u5176\u5b9e\u633a\u4e0d\u7528\u5fc3\u7684\uff08\u4f46\u4e5f\u5f97\u611f\u8c22360\u5b89\u5168\u64ad\u62a5\uff0c\u8981\u4e0d\u7136\u73b0\u5728\/\u4e00\u6bb5\u65f6\u95f4\u5185\u6211\u8fd8\u771f\u770b\u4e0d\u5230\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5728\u6b64\u611f\u8c22\u4ed6\u4eec\u7684\u8f9b\u52e4\u6536\u96c6\uff09\uff0c\u800c\u4e14\u5bf9\u4e8e\u8fd9\u7c7b\u6587\u7ae0\u4e2d\u6700\u91cd\u8981\u7684\u793a\u4f8b\u4ee3\u7801\u7adf\u7136\u4e5f\u6ca1\u6709\u6ce8\u610f\u53ef\u80fd\u5b58\u5728\u7684\u8f6c\u4e49\u95ee\u9898\uff0c\u4ece\u800c\u5bfc\u81f4\u4e86\u4e0d\u5c11\u9519\u8bef\uff0c\u6211\u53ea\u6709\u4ece\u82f1\u6587\u539f\u6587\u4e2d\u53bb\u6bd4\u5bf9\u3001\u91cd\u65b0\u7ffb\u8bd1\uff08\u771f\u7684\u662f\u7b2c\u4e00\u6b21\u8fdb\u884c\u8fd9\u6837\u7684\u7ffb\u8bd1\uff0c\u82f1\u8bed\u4e22\u4e86\u597d\u4e45\u4e86\uff0c\u867d\u7136\u82b1\u4e86\u4e00\u5b9a\u7684\u65f6\u95f4\u8fdb\u884c\u6821\u5bf9\uff0c\u4f46\u8fd8\u662f\u5e0c\u671b\u51fa\u9519\u7684\u5730\u65b9\u4e0d\u8981\u592a\u591a\u2026\u2026\uff09\uff0c\u7136\u540e\u6839\u636e\u81ea\u5df1\u4ec5\u6709\u7684\u4e00\u4e9b\u7ecf\u9a8c\u8fdb\u884c\u4e86\u6821\u5bf9\uff0c\u80af\u5b9a\u8fd8\u6709\u4e0d\u5bf9\u7684\u5730\u65b9\uff0c\u8fd8\u671b\u591a\u591a\u7406\u89e3~~<\/p>\n<hr \/>\n<p>\u672c\u6587\u4e2d\u6211\u5c06\u5206\u4eab\u4e00\u4e9b\u6211\u5728\u5bc6\u7801\u7834\u89e3\u8fc7\u7a0b\u4e2d\u89c9\u5f97\u6709\u7528\u7684Bash\u547d\u4ee4\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u5927\u591a\u6570\u65f6\u5019\uff0c\u6211\u4eec\u901a\u8fc7\u7c7b\u4f3c\u4e8ePastebin\u8fd9\u6837\u7684\u7f51\u7ad9\u6765\u7834\u89e3hash\u3002\u8003\u8651\u5230\u624b\u5de5\u5206\u79bbhash\u662f\u4e00\u4e2a\u975e\u5e38\u8017\u65f6\u95f4\u7684\u8fc7\u7a0b\uff0c\u6240\u4ee5\u8fd9\u91cc\u6211\u4eec\u5c06\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8ba9\u6211\u4eec\u7684\u751f\u6d3b\u751f\u6d3b\u66f4\u8f7b\u677e\uff01<\/p>\n<h6>\u63d0\u53d6 MD5 \u54c8\u5e0c(egrep\u65b9\u5f0f)<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|$)' *.txt | egrep -o '[a-fA-F0-9]{32}' &gt; md5-hashes.txt<\/pre>\n<h6>\u53e6\u4e00\u79cdsed\u7684\u65b9\u5f0f<\/h6>\n<pre class=\"lang:default decode:true\"># sed -rn 's\/.*[^a-fA-F0-9]([a-fA-F0-9]{32})[^a-fA-F0-9].*\/\\1\/p' *.txt &gt; md5-hashes<\/pre>\n<p>\u8bf4\u660e\uff1a\u4e0a\u9762\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u4e8e\u63d0\u53d6\u4ee5\u5341\u516d\u8fdb\u5236\u8868\u793a\u7684SHA1\/SHA256\u548c\u5176\u5b83\u672a\u52a0\u76d0\u7684hash\u5bc6\u7801\uff0c\u4f60\u552f\u4e00\u9700\u8981\u505a\u7684\u5c31\u662f\u6839\u636e\u5177\u4f53\u7684hash\u7c7b\u578b\u4fee\u6539\u4e0a\u9762\u768432\u4e3a\u76f8\u5e94\u7684hash\u5b57\u7b26\u4e32\u957f\u5ea6\u3002<\/p>\n<h6>\u63d0\u53d6\u6709\u6548MySQL-Old\u54c8\u5e0c<\/h6>\n<pre class=\"lang:default decode:true\"># grep -e \"[0-7][0-9a-f]\\{7\\}[0-7][0-9a-f]\\{7\\}\" *.txt &gt; mysql-old-hashes.txt<\/pre>\n<h6>\u63d0\u53d6 blowfish \u54c8\u5e0c<\/h6>\n<pre class=\"lang:default decode:true\"># grep -e \"\\$2a\\\\$\\08\\\\$\\(.\\)\\{75\\}\" *.txt &gt; blowfish-hashes.txt<\/pre>\n<h6>\u63d0\u53d6 Joomla \u54c8\u5e0c<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o \"([0-9a-zA-Z]{32}):(\\w{16,32})\" *.txt &gt; joomla.txt<\/pre>\n<h6>\u63d0\u53d6 VBulletin \u54c8\u5e0c<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o \"([0-9a-zA-Z]{32}):(\\S{3,32})\" *.txt &gt; vbulletin.txt<\/pre>\n<h6>\u63d0\u53d6 phpBB3-MD5<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$H\\$\\S{31}' *.txt &gt; phpBB3-md5.txt<\/pre>\n<h6>\u63d0\u53d6 WordPress-MD5<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$P\\$\\S{31}' *.txt &gt; wordpress-md5.txt<\/pre>\n<h6>\u63d0\u53d6 Drupal 7<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$S\\$\\S{52}' *.txt &gt; drupal-7.txt<\/pre>\n<h6>\u63d0\u53d6 old Unix-md5<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$1\\$\\w{8}\\S{22}' *.txt &gt; md5-unix-old.txt<\/pre>\n<h6>\u63d0\u53d6 md5-apr1<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$apr1\\$\\w{8}\\S{22}' *.txt &gt; md5-apr1.txt<\/pre>\n<h6>\u63d0\u53d6 sha512crypt, SHA512(Unix)<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -o '\\$6\\$\\w{8}\\S{86}' *.txt &gt; sha512crypt.txt<\/pre>\n<h6>\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u63d0\u53d6 Email\u5730\u5740<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"\\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\\.[a-zA-Z0-9.-]+\\b\" *.txt &gt; e-mails.txt<\/pre>\n<h6>\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u63d0\u53d6 URL<\/h6>\n<pre class=\"lang:default decode:true\"># grep http | grep -shoP 'http.*?[\" &gt;]' *.txt &gt; http-urls.txt<\/pre>\n<h6>\u63d0\u53d6HTTPS\u3001FTP\u548c\u5176\u4ed6\u7684URL\u683c\u5f0f<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E '(((https|ftp|gopher)|mailto)[.:][^ &gt;\"\\t]*|www\\.[-a-z0-9.]+)[^ .,;\\t&gt;\"&gt;\\):]' *.txt &gt; urls.txt<\/pre>\n<p>\u6ce8\u610f:\u5982\u679cgrep\u8fd4\u56de &#8220;Binary file (standard input) matches&#8221; \u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5<\/p>\n<pre class=\"lang:default decode:true\"># tr '[\\000-\\011\\013-\\037\\177-\\377]' '.' &lt; *.log | grep -E \"Your_Regex\"\nor\n# cat -v *.log | egrep -o \"Your_Regex\"<\/pre>\n<h6>\u63d0\u53d6\u6d6e\u70b9\u6570<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$\" *.txt &gt; floats.txt<\/pre>\n<h6>\u63d0\u53d6 Visa \u4fe1\u7528\u5361\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"4[0-9]{3}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}\" *.txt &gt; visa.txt<\/pre>\n<h6>\u63d0\u53d6 MasterCard \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"5[0-9]{3}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}\" *.txt &gt; mastercard.txt<\/pre>\n<h6>\u63d0\u53d6 American Express \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"\\b3[47][0-9]{13}\\b\" *.txt &gt; american-express.txt<\/pre>\n<h6>\u63d0\u53d6 Diners Club \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"\\b3(?:0[0-5]|[68][0-9])[0-9]{11}\\b\" *.txt &gt; diners.txt<\/pre>\n<h6>\u63d0\u53d6 Discover \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"6011[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}\" *.txt &gt; discover.txt<\/pre>\n<h6>\u63d0\u53d6 JCB \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"\\b(?:2131|1800|35\\d{3})\\d{11}\\b\" *.txt &gt; jcb.txt<\/pre>\n<h6>\u63d0\u53d6 AMEX \u7684\u6570\u636e<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"3[47][0-9]{2}[ -]?[0-9]{6}[ -]?[0-9]{5}\" *.txt &gt; amex.txt<\/pre>\n<h6>\u63d0\u53d6 \u793e\u4f1a\u5b89\u5168\u53f7\u7801 (Social Security Number &#8211; SSN)<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"[0-9]{3}[ -]?[0-9]{2}[ -]?[0-9]{4}\" *.txt &gt; ssn.txt<\/pre>\n<h6>\u63d0\u53d6 Indiana\u9a7e\u7167\u53f7\u7801 (Indiana Driver License Number)<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"[0-9]{4}[ -]?[0-9]{2}[ -]?[0-9]{4}\" *.txt &gt; indiana-dln.txt<\/pre>\n<h6>\u63d0\u53d6\u7f8e\u56fd\u62a4\u7167\u5361\u53f7 (US Passport Cards)<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"C0[0-9]{7}\" *.txt &gt; us-pass-card.txt<\/pre>\n<h6>\u63d0\u53d6\u7f8e\u56fd\u62a4\u7167\u53f7\u7801 (US Passport Number)<\/h6>\n<pre class=\"lang:default decode:true\"># grep -E -o \"[23][0-9]{8}\" *.txt &gt; us-pass-num.txt<\/pre>\n<h6>\u63d0\u53d6\u7f8e\u56fd\u7684\u624b\u673a\u53f7\u7801<\/h6>\n<pre class=\"lang:default decode:true\"># grep -Po '\\d{3}[\\s\\-_]?\\d{3}[\\s\\-_]?\\d{4}' *.txt &gt; us-phones.txt<\/pre>\n<h6>\u63d0\u53d6 ISBN \u53f7\u7801<\/h6>\n<pre class=\"lang:default decode:true\"># egrep -a -o \"\\bISBN(?:-1[03])?:? (?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}$|97[89][0-9]{10}$|(?=(?:[0-9]+[- ]){4})[- 0-9]{17}$)(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]\\b\" *.txt &gt; isbn.txt<\/pre>\n<p>========<\/p>\n<h5>\u7528 sed\/awk\/grep \u5904\u7406\u7684\u4e00\u4e9b\u5c0f\u6280\u5de7<\/h5>\n<p>\u7528sed\u79fb\u9664\u7a7a\u5b57\u7b26(Remove the space character with sed)<\/p>\n<pre class=\"lang:default decode:true\"># sed -i 's\/ \/\/g' file.txt\nOR\n# egrep -v \"^[[:space:]]*$\" file.txt<\/pre>\n<h6>\u7528sed\u79fb\u9664\u6700\u540e\u7684\u7a7a\u767d\u5b57\u7b26(Remove the last space character with sed)<\/h6>\n<pre class=\"lang:default decode:true\"># sed -i s\/.$\/\/ file.txt<\/pre>\n<h6>\u6309\u5355\u8bcd\u7684\u957f\u5ea6\u6392\u5e8f<\/h6>\n<pre class=\"lang:default decode:true\"># awk '{print length, $0}' rockyou.txt | sort -n | cut -d \" \" -f2- &gt; rockyou_length-list.txt<\/pre>\n<p>\u5c06\u5927\u5c0f\u5199\u4e92\u76f8\u8f6c\u6362(Convert uppercase to lowercase and the opposite)<\/p>\n<pre class=\"lang:default decode:true\"># tr [A-Z] [a-z] &lt; file.txt &gt; lower-case.txt\n# tr [a-z] [A-Z] &lt; file.txt &gt; upper-case.txt<\/pre>\n<p>\u7528sed\u5220\u9664\u7a7a\u884c<\/p>\n<pre class=\"lang:default decode:true\"># sed -i '\/^$\/d' List.txt<\/pre>\n<p>\u7528sed\u5220\u9664\u81ea\u5b9a\u4e49\u5b57\u7b26<\/p>\n<pre class=\"lang:default decode:true\"># sed -i \"s\/'\/\/\" file.txt<\/pre>\n<p>\u7528sed\u5220\u9664\u4e00\u4e2a\u5b57\u7b26\u4e32<\/p>\n<pre class=\"lang:default decode:true\"># echo 'This is a foo test' | sed -e 's\/&lt;foo&gt;\/\/g'<\/pre>\n<p>\u7528tr\u66ff\u6362\u5b57\u7b26<\/p>\n<pre class=\"lang:default decode:true\"># tr '@' '#' &lt; emails.txt\nOR\n# sed 's\/@\/#' file.txt<\/pre>\n<p>\u7528awk\/cut\u547d\u4ee4\u6253\u5370\u6307\u5b9a\u5217(Print specific columns with awk)<\/p>\n<pre class=\"lang:default decode:true\"># awk -F \",\" '{print $3}' infile.csv &gt; outfile.csv\nor\n# cut -d \",\" -f 3 infile.csv &gt; outfile.csv<\/pre>\n<p>Note: if you want to isolate all columns after column 3 use (\u5982\u679c\u4f60\u60f3\u6392\u9664\u7b2c3\u5217\u4e4b\u540e\u7684\u5185\u5bb9\u8bf7\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4)<\/p>\n<pre class=\"lang:default decode:true\"># cut -d \",\" -f 3- infile.csv &gt; outfile.csv<\/pre>\n<h6>\u4f7f\u7528urandom\u751f\u6210\u968f\u673a\u5bc6\u7801(Generate Random Passwords with urandom)<\/h6>\n<pre class=\"lang:default decode:true\"># tr -dc 'a-zA-Z0-9._!@#$%^&amp;*()' &lt; \/dev\/urandom | fold -w 8 | head -n 500000 &gt; wordlist.txt\n# tr -dc 'a-zA-Z0-9-_!@#$%^&amp;*()_+{}|:&lt;&gt;?=' &lt; \/dev\/urandom | fold -w 12 | head -n 4\n# base64 \/dev\/urandom | tr -d '[^:alnum:]' | cut -c1-10 | head -2\n# tr -dc 'a-zA-Z0-9' &lt; \/dev\/urandom | fold -w 10 | head -n 4\n# tr -dc 'a-zA-Z0-9-_!@#$%^&amp;*()_+{}|:&lt;&gt;?=' &lt; \/dev\/urandom | fold -w 12 | head -n 4 | grep -i '[!@#$%^&amp;*()_+{}|:&lt;&gt;?=]'\n# tr -dc '[:print:]' &lt; \/dev\/urandom | fold -w 10| head -n 10\n# tr -cd '[:alnum:]' &lt; \/dev\/urandom | fold -w30 | head -n2<\/pre>\n<p>\u5220\u9664\u62ec\u53f7(Remove Parenthesis with tr)<\/p>\n<pre class=\"lang:default decode:true\"># tr -d '()' &lt; in_file &gt; out_file<\/pre>\n<h6>\u7528\u4f60\u7684\u6587\u4ef6\u540d\u751f\u6210\u5355\u8bcd\u5217\u8868(Generate wordlists from your file-names)<\/h6>\n<pre class=\"lang:default decode:true\"># ls -A | sed 's\/regexp\/&amp;\\n\/g'<\/pre>\n<p>\u5f53\u9047\u5230cat\u547d\u4ee4\u65e0\u6cd5\u5904\u7406\u7684\u5947\u7279\u5b57\u7b26\u65f6(Process text files when cat is unable to handle strange characters)<\/p>\n<pre class=\"lang:default decode:true\"># sed 's\/\\([[:alnum:]]*\\)[[:space:]]*(.)\\(\\..*\\)\/\\1\\2\/' *.txt<\/pre>\n<p>\u4f7f\u7528awk\u8fc7\u6ee4\u51fa\u6307\u5b9a\u957f\u5ea6\u7684\u5185\u5bb9(Generate length based wordlists with awk)<\/p>\n<pre class=\"lang:default decode:true\"># awk 'length == 10' file.txt &gt; 10-length.txt<\/pre>\n<p>\u5408\u5e76\u4e24\u4e2a\u4e0d\u540c\u7684txt\u6587\u4ef6<\/p>\n<pre class=\"lang:default decode:true\"># paste -d' ' file1.txt file2.txt &gt; new-file.txt<\/pre>\n<h6>\u5229\u7528parallel\u547d\u4ee4\u8fdb\u884c\u5feb\u901f\u6392\u5e8f(Faster sorting)<\/h6>\n<pre class=\"lang:default decode:true\"># export alias sort='sort --parallel=&lt;number_of_cpu_cores&gt; -S &lt;amount_of_memory&gt;G ' &amp;&amp; export LC_ALL='C' &amp;&amp; cat file.txt | sort -u &gt; new-file.txt<\/pre>\n<h6>Mac\u5230UNIX\u683c\u5f0f\u7684\u8f6c\u6362(Mac to unix)<\/h6>\n<pre class=\"lang:default decode:true\"># tr '\\015' '\\012' &lt; in_file &gt; out_file<\/pre>\n<p>Dos\u5230UNIX\u683c\u5f0f\u7684\u8f6c\u6362(Dos to Unix)<\/p>\n<pre class=\"lang:default decode:true\"># dos2unix file.txt<\/pre>\n<p>Unix\u5230Dos\u683c\u5f0f\u7684\u8f6c\u6362(Unix to Dos)<\/p>\n<pre class=\"lang:default decode:true\"># unix2dos file.txt<\/pre>\n<h6>\u5229\u7528grep\u79fb\u9664\u672c\u6587\u4ef6\u4e2d\u5df2\u5728\u5176\u4ed6\u6587\u4ef6\u4e2d\u51fa\u73b0\u7684\u5185\u5bb9(Remove from one file what is in another file)<\/h6>\n<pre class=\"lang:default decode:true\"># grep -F -v -f file1.txt -w file2.txt &gt; file3.txt<\/pre>\n<p>\u7528sed\u547d\u4ee4\u63d0\u53d6\u6307\u5b9a\u884c\u7684\u5185\u5bb9(Isolate specific line numbers with sed)<\/p>\n<pre class=\"lang:default decode:true\"># sed -n '1,100p' test.file &gt; file.out<\/pre>\n<p>\u63d0\u53d6pdf\u6587\u4ef6\u4e2d\u7684\u6587\u672c\u5185\u5bb9(Create Wordlists from PDF files)<\/p>\n<pre class=\"lang:default decode:true\"># pdftotext file.pdf file.txt<\/pre>\n<p>\u67e5\u627e\u4e00\u4e2a\u6587\u4ef6\u4e2d\u7684\u6307\u5b9a\u884c\/\u5185\u5bb9(Find the line number of a string inside a file)<\/p>\n<pre class=\"lang:default decode:true\"># awk '{ print NR, $0 }' file.txt | grep \"string-to-grep\"\nor\n# grep -n \"string-to-grep\"<\/pre>\n<p>====<br \/>\n\u66f4\u5feb\u7684\u8fc7\u6ee4\u8bf7\u53c2\u8003(Faster filtering with the silver searcher)<br \/>\n<a href=\"https:\/\/github.com\/ggreer\/the_silver_searcher\" target=\"_blank\">https:\/\/github.com\/ggreer\/the_silver_searcher<\/a><\/p>\n<p>(\u5982\u679c\u60f3\u8fdb\u884c\u66f4\u5feb\u7684\u5339\u914d\uff0c\u8bf7\u5c06\u4e0a\u9762\u547d\u4ee4\u4e2d\u7684grep\u66ff\u6362\u4e3aag\uff0c\u800c\u4fdd\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u4e0d\u53d8)For faster grepping use all the above grep regular expressions with the command ag. The following is a proof of concept of its speed:<\/p>\n<pre class=\"lang:default decode:true\"># time ack-grep -o \"\\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\\.[a-zA-Z0-9.-]+\\b\" *.txt &gt; \/dev\/null\nreal 1m2.447s\nuser 1m2.297s\nsys 0m0.645s\n\n# time egrep -o \"\\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\\.[a-zA-Z0-9.-]+\\b\" *.txt &gt; \/dev\/null\nreal 0m30.484s\nuser 0m30.292s\nsys 0m0.310s\n\n# time ag -o \"\\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\\.[a-zA-Z0-9.-]+\\b\" *.txt &gt; \/dev\/null\nreal 0m4.908s\nuser 0m4.820s\nsys 0m0.277s<\/pre>\n<p>====<\/p>\n<h6>cat\u547d\u4ee4\u7684\u6709\u6548\u4f7f\u7528(Useful Use of Cat)<\/h6>\n<p>Contrary to what many veteran unix users may believe, this happens to be one of the rare opportunities where using cat can actually make your searches faster. The SilverSearcher utility is (at the time of this writing) not quite as efficient as cat when it comes to reading from file handles. Therefore, you can pipe output from cat into ag to see nearly a 2x real time performance gain{\u8fd9\u79cd\u60c5\u51b5\u51fa\u73b0\u5728\uff1a\u4f7f\u7528cat\u547d\u4ee4\u6253\u5f00\u5927\u91cf\u6587\u4ef6\u800c\u4e0d\u662f\u81ea\u5df1\u4f7f\u7528\u6587\u4ef6\u53e5\u67c4\u4e00\u4e2a\u4e00\u4e2a\u7684\u8fdb\u884c\u8bfb\u53d6\uff0c\u4ece\u800c\u5f97\u5230\u4e86\u5f88\u5927\u7684\u6027\u80fd\u63d0\u5347}:<\/p>\n<pre class=\"lang:default decode:true\">$ time ag -o '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|\\$)' *.txt | ag -o '[a-fA-F0-9]{32}' &gt; \/dev\/null\nreal 0m10.851s\nuser 0m13.069s\nsys 0m0.092s\n\n$ time cat *.txt | ag -o '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|\\$)' | ag -o '[a-fA-F0-9]{32}' &gt; \/dev\/null\nreal 0m6.689s\nuser 0m7.881s\nsys 0m0.424s<\/pre>\n<p>&nbsp;<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.unix-ninja.com\/p\/A_cheat-sheet_for_password_crackers\" target=\"_blank\">unix-ninja :: A cheat-sheet for password crackers<\/a><\/li>\n<li><a href=\"http:\/\/bobao.360.cn\/learning\/detail\/167.html\" target=\"_blank\">BASH+\u6b63\u5219\u7834\u89e3\u5904\u7406\u4e0d\u540c\u79cd\u7c7b\u5bc6\u7801<\/a><\/li>\n<\/ul>\n<h6>\u62d3\u5c55\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"https:\/\/github.com\/ggreer\/the_silver_searcher\" target=\"_blank\">https:\/\/github.com\/ggreer\/the_silver_searcher<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/petdance\/ack2\" target=\"_blank\">https:\/\/github.com\/petdance\/ack2<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1aunix-ninja :: A cheat-sheet for password crackers  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7,12],"tags":[444,74,77,445,78],"class_list":["post-1832","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-programing","category-tools","tag-ag","tag-awk","tag-grep","tag-hash","tag-sed"],"views":9178,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1832","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=1832"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1832\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}