すべての組み合わせを使用して単語リストを生成する

すべての組み合わせを使用して単語リストを生成する

私はTruecryptコンテナを無差別に攻撃するために使用できる単語のリストを生成しようとしています。私はパスワードの一部が長さを増やすために他の既知のパスワードのブロックを使用していることを知っていますが、ブロックが使用された順序と一部のブロックがまったく使用されていないかどうかを忘れました。

スペースで区切られた「ブロック」の例:dog cat bird xyz cow1 lion8

私が望むのは、これらの塊のすべての可能な組み合わせを含む単語のリストを作成することです。例えば

dog
cat
dogcat
catdog
bird
dogbird
catbird
birdcat
birddog
dogcatbird
catdogbird
xyz
dogcatbirdxyz
cow1
xyzcow1dogcat
xyzcow1dogcatbird
catdogbirdxyzcow8
lion8
catdogbirdxyzcow1lion8
lion8catdogbirdxyzcow1
dogcatbirdxyzcow1lion8
cow1birddogcatxyzlion8
cow1lion8birddogcatxyz
...

これまで私はクランチというツールを使ってみました。http://www.irongeek.com/i.php?page=backtrack-r1-man-pages/crunch

しかし、問題は、既知のブロックをすべて含まない短い組み合わせの組み合わせを生成する方法のようです(たとえば、dogcat2つのブロックのみを含む)。

たぶん私よりもよく知っている人がいるかもしれませんし、crunch私が使うべき他のツールやツールの組み合わせがありますか?

ベストアンサー1

そしてPython

#! /usr/bin/env python3
import sys
from itertools import chain, permutations
# from the docs https://docs.python.org/3/library/itertools.html#itertools-recipes
# modified for permutations instead of combinations


def powerset_perm(iterable):
    s = list(iterable)
    return chain.from_iterable(permutations(s, r) for r in range(1, len(s) + 1))


for w in powerset_perm(sys.argv[1:]):
    print("".join(w))

例:

~ ./foo.py foo フー bar1™
foo
フー
bar1™
fooフー
foobar1™
フーfoo
フーbar1™
bar1™foo
bar1™フー
fooフーbar1™
foobar1™フー
フーfoobar1™
フーbar1™foo
bar1™fooフー
bar1™フーfoo

おすすめ記事