vanityhash.pod 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. =head1 NAME
  2. vanityhash - A hex hash fragment creation tool
  3. =head1 SYNOPSIS
  4. B<vanityhash> S<[ B<options> ]> hexfragment < inputfile
  5. B<vanityhash> B<--append> S<[ B<options> ]> hexfragment < inputfile > outputfile
  6. =head1 DESCRIPTION
  7. B<vanityhash> is a tool that can discover data to be added to the end
  8. of a file to produce a desired hex hash fragment. It searches a
  9. message space and runs a hashing algorithm against the original data
  10. plus the appended data to determine if the desired hash fragment is
  11. present. vanityhash can run multiple parallel workers to effectively
  12. make use of multiple processors/cores/threads, and supports multiple
  13. hash digest types (MD5, SHA1, SHA256, etc).
  14. vanityhash can be used to append data to files that are capable of
  15. ignoring garbage data at the end of the file (such as ISO images and
  16. some types of graphic images), in order to produce a "vanity" hash.
  17. vanityhash is fast, as it only reads the base input data once, and then
  18. reverts back to that base state over and over while it permeates the
  19. search space, rather than hashing the entire source during each
  20. permeation.
  21. vanityhash operates on the concept of a "search space". For example,
  22. given a 24-bit search space, vanityhash will run from 0x00000000 to
  23. 0x00ffffff, append the 4-byte packed version of each number to the end
  24. of the input data, calculate the resulting hash, and search the hash
  25. value for the desired hex fragment pattern. A desired hex fragment can
  26. be larger than the search space (for example, searching for "abcdef" in
  27. a 16-bit search space), but the chances of finding a match reduce
  28. drastically the larger the desired hex fragment is.
  29. In its default operation, vanityhash will search the entire specified
  30. search space and output all matching results to STDOUT, one result per
  31. line, in the form "extradata hash", where both "extradata" and "hash"
  32. are in hex form. When the B<--append> option is specified, this
  33. behavior changes. If a match is found, the original input data plus
  34. the extra data (in byte form) are outputted, and searching ends after
  35. the first successful match. If no matches are found, the original data
  36. only is outputted.
  37. =head1 OPTIONS
  38. =over
  39. =item B<-b> I<bits>, B<--bits>=I<bits>
  40. Space to be searched, in bits. Allowed values range from 1 to 64.
  41. Default is 24. Search spaces larger than the host operating system's
  42. native (i.e. 64 on a 32-bit operating system) will incur a performance
  43. penalty.
  44. =item B<-t> I<bits>, B<--bits-pack>=I<bits>
  45. By default, the size used to contain the search space is computed
  46. automatically. For example, a 24-bit search space requires a 32-bit
  47. (4-byte) pack. If you would like to use a larger pack size, this can be
  48. specified. For example, to search a 24-bit space by appending 8 bytes,
  49. use "--bits=24 --bits-pack=64". Must be 8, 16, 32, or 64, and must be
  50. equal to or larger than --bits.
  51. =item B<-p> I<position>, B<--position>=I<position>
  52. The position within the hex hash to look for the desired fragment, in
  53. hex digits. The beginning starts at 0. Default is 0. Negative numbers
  54. extend backward from the end of the hash.
  55. =item B<-y>, B<--any-position>
  56. When enabled, this option will override B<--position> and will return
  57. hashes that contain the desired fragment in any position within the
  58. hash.
  59. =item B<-n>, B<--byte-order>=I<order>
  60. Used to set the byte order (endianness) of the space being searched.
  61. Values are "native", "little" or "big". Default is "native". Use this
  62. when spreading workers over multiple machines whose architectures differ
  63. in endianness (but this incurs a performance penalty).
  64. =item B<-s> I<seconds>, B<--progress>=I<seconds>
  65. The number of seconds between printing of progress lines, default 5
  66. seconds. A decimal value may be specified. A value of 0 disabled
  67. printing progress lines.
  68. =item B<-w> I<workers>, B<--workers>=I<workers>
  69. The number of workers to be spawned. Default is the number of logical
  70. processors if this can be determined, otherwise 1. Recommended value is
  71. the number of logical processors on the running system.
  72. This option can also be used to specify a "worker space", and then
  73. specify which workers within that space to actually launch. This way
  74. the work can be split up among multiple vanityhash invocations on
  75. different systems. For example:
  76. host1$ vanityhash -w 8:1,3,5,7 < inputfile
  77. host2$ vanityhash -w 8:2,4,6,8 < inputfile
  78. This sets a worker space of 8 workers, but only launches workers 1, 3, 5
  79. and 7 on host1, and 2, 4, 6 and 8 on host2. To do this, the input data
  80. must be on all hosts, and ideally the vanityhash version should be the
  81. same as well.
  82. =item B<-d> I<digesttype>, B<--digest>=I<digesttype>
  83. The hashing digest type to use. Default is "md5". Digests available
  84. depend on the OpenSSL compiled against Python.
  85. =item B<-a>, B<--append>
  86. When enabled, the original data is outputted back to STDOUT. Then,
  87. when/if the first matching hash is found, the data fragment used to
  88. produce the matching hash is outputted to STDOUT. STDOUT can then be
  89. redirected to another file to produce the modified file.
  90. =item B<-e>, B<--append-empty>
  91. When using --append, if a match is not found, add empty (zeroed) pack
  92. bytes anyway. This way, the STDOUT data will always be the same byte
  93. length no matter if a match is found or not.
  94. =item B<-q>, B<--quiet>
  95. Normally vanityhash sends a fair amount of status information to STDERR
  96. during operation. When enabled, all non-error status information is
  97. instead suppressed.
  98. =item B<-?>, B<--help>
  99. Print a synposis and exit.
  100. =back
  101. =head1 BUGS / LIMITATIONS
  102. vanityhash should work on any POSIX operating system, and has been
  103. tested on Linux and Mac OS X. It currently does not work on Windows,
  104. due to Python multiprocessing limitations.
  105. =head1 CREDITS
  106. B<vanityhash> was written by Ryan Finnie <ryan@finnie.org>. vanityhash
  107. was inspired by Seth David Schoen's 2003 program, hash_search.