nihil7771

pass cracking cheat sheet :)

Jun 16th, 2019
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.45 KB | None | 0 0
  1. Extract MD5 hashes:
  2.     egrep -oE '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|$)' *.txt | egrep -o '[a-fA-F0-9]{32}' > md5-hashes.txt
  3.  
  4.     An alternative could be with sed
  5.         sed -rn 's/.*[^a-fA-F0-9]([a-fA-F0-9]{32})[^a-fA-F0-9].*/\1/p' *.txt > md5-hashes
  6.  
  7.     Note: The above regexes can be used for SHA1, SHA256 and other unsalted hashes represented in hex. The only thing you have to do is change the '{32}' to the corresponding length for your desired hash-type.
  8.  
  9. Extract valid MySQL-Old hashes
  10. # grep -e "[0-7][0-9a-f]\{7\}[0-7][0-9a-f]\{7\}" *.txt > mysql-old-hashes.txt
  11.  
  12. Extract blowfish hashes
  13. # grep -e "\$2a\\$\08\\$\(.\)\{75\}" *.txt > blowfish-hashes.txt
  14.  
  15. Extract Joomla hashes
  16. # egrep -o "([0-9a-zA-Z]{32}):(\w{16,32})" *.txt > joomla.txt
  17.  
  18. Extract VBulletin hashes
  19. # egrep -o "([0-9a-zA-Z]{32}):(\S{3,32})" *.txt > vbulletin.txt
  20.  
  21. Extraxt phpBB3-MD5
  22. # egrep -o '\$H\$\S{31}' *.txt > phpBB3-md5.txt
  23.  
  24. Extract Wordpress-MD5
  25. # egrep -o '\$P\$\S{31}' *.txt > wordpress-md5.txt
  26.  
  27. Extract Drupal 7
  28. # egrep -o '\$S\$\S{52}' *.txt > drupal-7.txt
  29.  
  30. Extract old Unix-md5
  31. # egrep -o '\$1\$\w{8}\S{22}' *.txt > md5-unix-old.txt
  32.  
  33. Extract md5-apr1
  34. # egrep -o '\$apr1\$\w{8}\S{22}' *.txt > md5-apr1.txt
  35.  
  36. Extract sha512crypt, SHA512(Unix)
  37. # egrep -o '\$6\$\w{8}\S{86}' *.txt > sha512crypt.txt
  38.  
  39. Extract e-mails from text files
  40. # grep -E -o "\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\.[a-zA-Z0-9.-]+\b" *.txt > e-mails.txt
  41.  
  42. Extract HTTP URLs from text files
  43. # grep http | grep -shoP 'http.*?[" >]' *.txt > http-urls.txt
  44.  
  45.     For extracting HTTPS, FTP and other URL format use
  46.     # grep -E '(((https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' *.txt > urls.txt
  47.    
  48.     Note: if grep returns "Binary file (standard input) matches" use the following approaches
  49.         # tr '[\000-\011\013-\037\177-\377]' '.' < *.log | grep -E "Your_Regex"
  50.     OR
  51.         # cat -v *.log | egrep -o "Your_Regex"
  52.  
  53. Extract Floating point numbers
  54. # grep -E -o "^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$" *.txt > floats.txt
  55.  
  56. Extract credit card data:
  57.  
  58.     Visa
  59.     # grep -E -o "4[0-9]{3}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}" *.txt > visa.txt
  60.    
  61.     MasterCard
  62.     # grep -E -o "5[0-9]{3}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}" *.txt > mastercard.txt
  63.  
  64.     American Express
  65.     # grep -E -o "\b3[47][0-9]{13}\b" *.txt > american-express.txt
  66.  
  67.     Diners Club
  68.     # grep -E -o "\b3(?:0[0-5]|[68][0-9])[0-9]{11}\b" *.txt > diners.txt
  69.  
  70.     Discover
  71.     # grep -E -o "6011[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}" *.txt > discover.txt
  72.  
  73.     JCB
  74.     # grep -E -o "\b(?:2131|1800|35\d{3})\d{11}\b" *.txt > jcb.txt
  75.  
  76.     AMEX
  77.     # grep -E -o "3[47][0-9]{2}[ -]?[0-9]{6}[ -]?[0-9]{5}" *.txt > amex.txt
  78.  
  79. Extract Social Security Number (SSN)
  80. # grep -E -o "[0-9]{3}[ -]?[0-9]{2}[ -]?[0-9]{4}" *.txt > ssn.txt
  81.  
  82. Extract Indiana Driver License Number
  83. # grep -E -o "[0-9]{4}[ -]?[0-9]{2}[ -]?[0-9]{4}" *.txt > indiana-dln.txt
  84.  
  85. Extract US Passport Cards
  86. # grep -E -o "C0[0-9]{7}" *.txt > us-pass-card.txt
  87.  
  88. Extract US Passport Number
  89. # grep -E -o "[23][0-9]{8}" *.txt > us-pass-num.txt
  90.  
  91. Extract US Phone Numberss
  92. # grep -Po '\d{3}[\s\-_]?\d{3}[\s\-_]?\d{4}' *.txt > us-phones.txt
  93.  
  94. Extract ISBN Numbers
  95. # 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 > isbn.txt
  96.  
  97. WordList Manipulation
  98.    
  99.     Remove the space character with sed
  100.     # sed -i 's/ //g' file.txt
  101.     OR
  102.     # egrep -v "^[[:space:]]*$" file.txt
  103.  
  104.     Remove the last space character with sed
  105.     # sed -i s/.$// file.txt
  106.  
  107.     Sorting Wordlists by Length
  108.     # awk '{print length, $0}' rockyou.txt | sort -n | cut -d " " -f2- > rockyou_length-list.txt
  109.  
  110.     Convert uppercase to lowercase and the opposite
  111.     # tr [A-Z] [a-z] < file.txt > lower-case.txt
  112.     # tr [a-z] [A-Z] < file.txt > upper-case.txt
  113.     Remove blank lines with sed
  114.     # sed -i '/^$/d' List.txt
  115.  
  116.     Remove defined character with sed
  117.     # sed -i "s/'//" file.txt
  118.  
  119.     Delete a string with sed
  120.     # echo 'This is a foo test' | sed -e 's/\<foo\>//g'
  121.  
  122.     Replace characters with tr
  123.     # tr '@' '#' < emails.txt
  124.     OR
  125.     # sed 's/@/#' file.txt
  126.  
  127.     Print specific columns with awk
  128.     # awk -F "," '{print $3}' infile.csv > outfile.csv
  129.     OR
  130.     # cut -d "," -f 3 infile.csv > outfile.csv
  131.  
  132.     Note: if you want to isolate all columns after column 3 use
  133.     # cut -d "," -f 3- infile.csv > outfile.csv
  134.  
  135.     Generate Random Passwords with urandom
  136.     # tr -dc 'a-zA-Z0-9._!@#$%^&*()' < /dev/urandom | fold -w 8 | head -n 500000 > wordlist.txt
  137.     # tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' < /dev/urandom | fold -w 12 | head -n 4
  138.     # base64 /dev/urandom | tr -d '[^:alnum:]' | cut -c1-10 | head -2
  139.     # tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 4
  140.     # tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' < /dev/urandom | fold -w 12 | head -n 4 | grep -i '[!@#$%^&*()_+{}|:<>?=]'
  141.     # tr -dc '[:print:]' < /dev/urandom | fold -w 10| head -n 10
  142.     # tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n2
  143.     Remove Parenthesis with tr
  144.     # tr -d '()' < in_file > out_file
  145.  
  146.     Generate wordlists from your file-names
  147.     # ls -A | sed 's/regexp/&\n/g'
  148.  
  149.     Process text files when cat is unable to handle strange characters
  150.     # sed 's/\([[:alnum:]]*\)[[:space:]]*(.)\(\..*\)/\1\2/' *.txt
  151.  
  152.     Generate length based wordlists with awk
  153.     # awk 'length == 10' file.txt > 10-length.txt
  154.  
  155.     Merge two different txt files
  156.     # paste -d' ' file1.txt file2.txt > new-file.txt
  157.  
  158.     Faster sorting
  159.     # export alias sort='sort --parallel=<number_of_cpu_cores> -S <amount_of_memory>G ' && export LC_ALL='C' && cat file.txt | sort -u > new-file.txt
  160.  
  161.     Mac to unix
  162.     # tr '\015' '\012' < in_file > out_file
  163.  
  164.     Dos to Unix
  165.     # dos2unix file.txt
  166.  
  167.     Unix to Dos
  168.     # unix2dos file.txt
  169.  
  170.     Remove from one file what is in another file
  171.     # grep -F -v -f file1.txt -w file2.txt > file3.txt
  172.  
  173.     Isolate specific line numbers with sed
  174.     # sed -n '1,100p' test.file > file.out
  175.  
  176.     Create Wordlists from PDF files
  177.     # pdftotext file.pdf file.txt
  178.  
  179.     Find the line number of a string inside a file
  180.     # awk '{ print NR, $0 }' file.txt | grep "string-to-grep"
  181.  
  182.    
  183. Faster filtering with the silver searcher
  184.     https://github.com/ggreer/the_silver_searcher
  185.  
  186.     For faster searching, use all the above grep regular expressions with the command ag. The following is a proof of concept of its speed:
  187.  
  188.     # time ack-grep -o "\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\.[a-zA-Z0-9.-]+\b" *.txt > /dev/null
  189.     real    1m2.447s
  190.     user    1m2.297s
  191.     sys 0m0.645s
  192.  
  193.     # time egrep -o "\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\.[a-zA-Z0-9.-]+\b" *.txt > /dev/null
  194.     real    0m30.484s
  195.     user    0m30.292s
  196.     sys 0m0.310s
  197.  
  198.     # time ag -o "\b[a-zA-Z0-9.#?$*_-]+@[a-zA-Z0-9.#?$*_-]+\.[a-zA-Z0-9.-]+\b" *.txt > /dev/null
  199.     real    0m4.908s
  200.     user    0m4.820s
  201.     sys 0m0.277s
  202.  
  203.  
  204. Useful Use of Cat
  205.  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.
  206.  The SilverSearcher utility is (at the time of this writing) not quite as efficient as cat when it comes to reading from file handles.
  207.  Therefore, you can pipe output from cat into ag to see nearly a 2x real time performance gain:
  208.  
  209. $ time ag -o '(^|[^a-fA-F0-9])[a-fA-F0-9]{32}([^a-fA-F0-9]|\$)' *.txt | ag -o '[a-fA-F0-9]{32}' > /dev/null
  210.  
  211. real    0m10.851s
  212. user    0m13.069s
  213. sys 0m0.092s
  214.  
  215. $ 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}' > /dev/null
  216.  
  217. real    0m6.689s
  218. user    0m7.881s
  219. sys 0m0.424s
Add Comment
Please, Sign In to add comment