home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / hack / progsy / hasla / johnr15 / DOC / EXAMPLES < prev    next >
Encoding:
Text File  |  1998-05-15  |  11.6 KB  |  329 lines

  1.  
  2.  John the Ripper's Usage Examples
  3. ==================================
  4.  
  5. These examples are to give you some tips on what John's features can be
  6. used for. Some of them may not be obvious, I'm sorry if others are, but
  7. anyway, I just got tired of answering questions.
  8.  
  9.  Command Line
  10. --------------
  11.  
  12. 1. First, you need to get a copy of your password file. If you got shadow
  13. passwords, then (as root):
  14.  
  15.     unshadow /etc/passwd /etc/shadow > passwd.1
  16.  
  17. or similar should do (replace the filenames as needed, and make sure that
  18. your combined password file isn't readable by others). Otherwise, just:
  19.  
  20.     cp /etc/passwd passwd.1
  21.  
  22. 2. Assume you just got a password file, 'passwd.1', and want to crack it.
  23. It is wise to start with the "single crack" mode:
  24.  
  25.     john -single passwd.1
  26.  
  27. or, since options can be abbreviated (however, I'll be using full names
  28. for most options in these examples):
  29.  
  30.     john -si passwd.1
  31.  
  32. If you have more files to crack, better to load them at the same time:
  33.  
  34.     john -single passwd.1 passwd.2
  35.  
  36. or even:
  37.  
  38.     john -single passwd.*
  39.  
  40. 3. Now, you got some passwords cracked, they are saved in ~/john.pot. You
  41. want to retrieve them:
  42.  
  43.     john -show passwd.1
  44.  
  45. If the account list gets large and doesn't fit on the screen, you can, of
  46. course, use output redirection. (There's intentionally no example here, a
  47. few people have asked for one, but they shouldn't be using John anyway.)
  48.  
  49. Now, you may notice that many accounts have a disabled shell, you can make
  50. John ignore these (assume that shell is called '/etc/expired'):
  51.  
  52.     john -show -shells:-/etc/expired passwd.1
  53.  
  54. or, shorter, but will also match '/any/path/expired':
  55.  
  56.     john -show -shells:-expired passwd.1
  57.  
  58. or, if you also want to ignore some other shell, say '/etc/newuser':
  59.  
  60.     john -show -shells:-expired,newuser passwd.1
  61.  
  62. (Note: the above syntax has changed since version 1.4 so that it's more
  63. logical and shorter to type.)
  64.  
  65. To check if any root (uid 0) accounts got cracked:
  66.  
  67.     john -show -users:0 passwd.1
  68.  
  69. or, to check for cracked root (uid 0) accounts in all the files:
  70.  
  71.     john -show -users:0 passwd.*
  72.  
  73. To display the root (login 'root') account only:
  74.  
  75.     john -show -users:root passwd.1
  76.  
  77. And finally, to check for privileged groups:
  78.  
  79.     john -show -groups:0,1 passwd.1
  80.  
  81. 4. To catch more complicated (but still weak) passwords, you can use more
  82. powerful cracking modes. First, try a wordlist:
  83.  
  84.     john -w:words.lst passwd.1
  85.  
  86. or, with rules enabled (slower, but more powerful; this is what you should
  87. use if you're trying to locate almost all the weak passwords):
  88.  
  89.     john -w:words.lst -rules passwd.1
  90.  
  91. This is going to take some time, so you will probably want to continue
  92. cracking in the background. You can simply disconnect, or close your
  93. xterm: John will ignore the SIGHUP and continue running. Alternatively,
  94. you might prefer to start it like this, and then logout:
  95.  
  96.     nice -n 20 john -w:words.lst -rules passwd.1 &
  97.  
  98. To only crack accounts with a good shell (in general, the shell, user and
  99. group filters described above work for all the cracking modes also):
  100.  
  101.     john -w:words.lst -rules -shells:sh,csh,tcsh,bash passwd.1
  102.  
  103. Like with all the other cracking modes, faster to crack all the files you
  104. need cracked simultaneously:
  105.  
  106.     john -w:words.lst -rules passwd.*
  107.  
  108. You can crack some passwords only. This will try cracking all root (uid 0)
  109. accounts in all the password files:
  110.  
  111.     john -w:words.lst -rules -users:0 passwd.*
  112.  
  113. Alternatively, you may wish not to waste the time cracking your very own
  114. passwords, if you're sure they're uncrackable:
  115.  
  116.     john -w:words.lst -rules -users:-root,solar passwd.*
  117.  
  118. Sometimes it is useful to split your password files into two parts which
  119. you crack separately, like:
  120.  
  121.     john -w:words.lst -rules -salts:2 passwd.*
  122.     john -w:words.lst -rules -salts:-2 passwd.*
  123.  
  124. This will make John try salts with two or more passwords faster, and then
  125. try the rest. Total cracking time will be about the same, but you will get
  126. some passwords cracked earlier, and may not need the rest. Also, you might
  127. want to try all the accounts with a small wordlist, and only those that
  128. you can try faster (with '-salts:2') with a larger one. Often it is better
  129. to use a larger value than 2 for '-salts' (sometimes even as high as 1000
  130. will do, indicating a problem with your password changing program though),
  131. adjust it for your particular case.
  132.  
  133. Note that the default wordlist rules include ':' (which means "try words
  134. as they are in the list") as the first line. If you already ran through a
  135. wordlist without using rules, and then decided to try the same wordlist
  136. with rules also, you'd better comment this line out.
  137.  
  138. 5. The most powerful cracking mode in John is called "incremental" (not a
  139. proper name, but kept for historical reasons). You can simply run:
  140.  
  141.     john -i passwd.1
  142.  
  143. This will use the default incremental mode parameters, which are defined
  144. in ~/john.ini's [Incremental:All] section. In the configuration file
  145. supplied with John these parameters are to use the full 95 character set,
  146. and to try all possible password lengths, from 0 to 8. (By zero password
  147. length I mean a hashed empty string, this sometimes happens.) Don't expect
  148. this to terminate in a reasonable time (unless all the passwords were weak
  149. and got cracked), read doc/MODES for an explanation.
  150.  
  151. In some cases it is faster to use some other pre-defined incremental mode
  152. parameters and only crack simpler passwords, from a limited charset. The
  153. following command will try 26 different characters only, passwords from
  154. 'a' to 'zzzzzzzz':
  155.  
  156.     john -i:alpha passwd.1
  157.  
  158. Again, you can crack root accounts only and use some other John's features
  159. with the incremental mode. This command will try cracking all root (uid 0)
  160. accounts in all the password files, and only those of them that produce
  161. matching salts, so you get at least twice the performance -- if you have a
  162. lot of password files (like 100+ of them, named '*.pwd'), otherwise there
  163. will probably be no roots with matching salts:
  164.  
  165.     john -i -users:0 -salts:2 *.pwd
  166.  
  167. 6. If you got a password file and already have a lot of passwords cracked
  168. or sniffed, and the passwords are unusual, then you might want to generate
  169. a new charset file, based on characters from that password file only:
  170.  
  171.     john -makechars:custom.chr passwd.1
  172.  
  173. Then use that new file for the incremental mode.
  174.  
  175. If you got many password files from your country, your university, etc,
  176. it might be useful to use all of them for the charset file that you then
  177. use to crack more passwords in these files, or some other files from the
  178. same place:
  179.  
  180.     john -makechars:custom.chr passwd.1 passwd.2
  181.     [ Add your custom incremental mode to ~/john.ini now. See below. ]
  182.     john -i:custom passwd.3
  183.  
  184. You can use some pre-defined or custom word filters when generating the
  185. charset file, to make it only try some simpler words:
  186.  
  187.     john -makechars:my_alpha.chr -external:filter_alpha passwd.1
  188.  
  189. If your ~/john.pot file got large enough (or if you don't have any charset
  190. files at all), you might want to use it for new main charset files:
  191.  
  192.     john -makechars:all.chr
  193.     john -makechars:alpha.chr -external:filter_alpha
  194.     john -makechars:digits.chr -external:filter_digits
  195.  
  196. In the example above, John will overwrite the charset files with new ones
  197. that are based on your entire ~/john.pot (John uses the entire file if you
  198. don't specify any password files). Note that the word filters used here
  199. are pre-defined in ~/john.ini supplied with John, for your convenience.
  200.  
  201. 7. Finally, you might want to mail all the users who got weak passwords,
  202. to tell them to change the passwords. It's not always a good idea though
  203. (unfortunately, lots of people seem to ignore such mail, it can be used
  204. as a hint for crackers, etc), but anyway, I'll assume you know what you're
  205. doing. Edit the 'mailer' script supplied with John: the message it sends,
  206. and possibly the mail command (especially if the password file is from a
  207. different box than you got John running on). Then run:
  208.  
  209.     mailer passwd.1
  210.  
  211.  Configuration File
  212. --------------------
  213.  
  214. 1. Assume you notice that in some password file a lot of users have their
  215. passwords set to login names with '?!' appended. Then you just make a new
  216. "single crack" mode rule (see doc/RULES for information on the syntax),
  217. and place it somewhere near the beginning:
  218.  
  219.     [List.Rules:Single]
  220.     $?$!
  221.  
  222. Hint: if you want to temporarily comment out all the default rules, you
  223. can simply rename the section to something John doesn't use, and define
  224. a new one with the section's old name, but be sure to leave the 'list.'
  225. part of the name, so that you don't get a parse error.
  226.  
  227. All the same applies to the wordlist rules also.
  228.  
  229. 2. If you generate a custom charset file (described above) you will also
  230. need to define a ~/john.ini section with the incremental mode parameters.
  231. In the simplest case it will be like this (where 'Custom' can be replaced
  232. with any name you like):
  233.  
  234.     [Incremental:Custom]
  235.     File = custom.chr
  236.  
  237. This will make John use characters that were in passwords used to generate
  238. the charset file only. To make John try some more characters, add:
  239.  
  240.     Extra = !@#$%
  241.  
  242. These extra characters will then be added, but still considered the least
  243. probable. If you want to make sure that, with your extra characters, John
  244. will try all the 95 characters, you can add:
  245.  
  246.     CharCount = 95
  247.  
  248. This will make John print a warning if it only has less than 95 characters
  249. in its charset.
  250.  
  251. You can also use CharCount to limit the number of different characters
  252. that John tries, even if the charset file has more:
  253.  
  254.     CharCount = 25
  255.  
  256. If you didn't use any filters when generating the charset file, setting
  257. CharCount that low will most likely disable some rare characters, and make
  258. John try complicated long passwords earlier. However, the default length
  259. switching is usually smart enough so that you shouldn't need such a trick.
  260.  
  261. To make John try passwords of some lengths only, use the following lines:
  262.  
  263.     MinLen = 6
  264.     MaxLen = 8
  265.  
  266. Setting 'MinLen' high, as in the example above, is reasonable if shorter
  267. passwords weren't allowed to set on the machine you got the password file
  268. from (however, note that root can usually set any password for any user).
  269.  
  270. On the contrary, you might want to set 'MaxLen' low if you think there's
  271. a lot of short passwords.
  272.  
  273. 3. Another example: a lot of users at some site suffix their passwords
  274. with a '1'. You can code an external word filter:
  275.  
  276.     [List.External:Filter1]
  277.     void filter()
  278.     {
  279.         int i;
  280.  
  281.         i = 0;
  282.         while (word[i] && word[i] >= 'a' && word[i] <= 'z') i++;
  283.         if (word[i] != '1' || word[i + 1]) word = 0;
  284.     }
  285.  
  286. This filter will only leave words with some alphabetical characters and
  287. '1' at the end. You can now use it with some other cracking modes, but
  288. this will most likely be slow, since most words will get filtered out. It
  289. is better to use it for generating the charsets, and use them instead (if
  290. you have enough passwords cracked that will pass the filter).
  291.  
  292. If you can't use the frequency tables for some reason, you can do the same
  293. by coding a totally new external mode:
  294.  
  295.     [List.External:Suffix1]
  296.     int length, current[9];
  297.  
  298.     void init()
  299.     {
  300.         int i;
  301.  
  302.         current[length = 6] = 0; current[i = length - 1] = '1';
  303.         while (i--) current[i] = 'a';
  304.     }
  305.  
  306.     void generate()
  307.     {
  308.         int i;
  309.  
  310.         i = length + 1;
  311.         while (i--) word[i] = current[i];
  312.  
  313.         i = length - 2;
  314.         while (++current[i] > 'z')
  315.         if (i) current[i--] = 'a'; else current = -1;
  316.     }
  317.  
  318.     void restore()
  319.     {
  320.         int i;
  321.  
  322.         i = length + 1;
  323.         while (i--) current[i] = word[i];
  324.     }
  325.  
  326. See doc/EXTERNAL for information on the language used. You can also have
  327. a look at the default ~/john.ini for an example of a useful external mode,
  328. with a lot of comments.
  329.