Windows 许可证密钥的所有排列

我需要为我的笔记本电脑申请 Windows 8升级,为此我需要在笔记本电脑底部的 Windows 7许可证密钥。

因为微软用他们无限的智慧决定创建一个逐渐消失的许可标签,而我无法清楚地读取我的许可密钥,这意味着我无法使用自动化程序为我的笔记本电脑注册 Windows 升级服务。

通过将笔记本电脑与光线成一个角度,我已经能够验证大部分代码,但有几个字母是模棱两可的(再次感谢微软在你的标签中使用容易误读的字符)。

我有以下(模糊)许可证密钥,

MPP6R-09RXG-2H[8B]MT-[B8]K[HN]M9-V[6G]C8R

其中方括号中的字符是模糊的,所以它是 8或者 BB或者 8H或者 N6或者 G

做16个组合。

使用 itertools 生成这个许可密钥的可能排列是否合适,还是有更好的方法?

多亏了贡献者,我才拿到了正确的钥匙。检查密钥是否有效的一种非常方便的方法是使用 Windows7产品密钥检查器

5439 次浏览

http://www.magicaljellybean.com/keyfinder/

The Magical Jelly Bean Keyfinder is a freeware utility that retrieves your Product Key (cd key) used to install windows from your registry. It also has a community-updated configuration file that retrieves product keys for many other applications.

Just run it on the install you want the key for.

from itertools import product
for perm in product('8B', 'B8', 'HN', '6G'):
print 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % perm

Disclaimer: Yes, I know that this is not Python code. It just popped into my mind and I simply had to write it down.

The simplest way is the use of shell expansion:

$ echo MPP6R-09RXG-2H{8,B}MT-{B,8}K{H,N}M9-V{6,G}C8R
MPP6R-09RXG-2H8MT-BKHM9-V6C8R
MPP6R-09RXG-2H8MT-BKHM9-VGC8R
MPP6R-09RXG-2H8MT-BKNM9-V6C8R
MPP6R-09RXG-2H8MT-BKNM9-VGC8R
MPP6R-09RXG-2H8MT-8KHM9-V6C8R
MPP6R-09RXG-2H8MT-8KHM9-VGC8R
MPP6R-09RXG-2H8MT-8KNM9-V6C8R
MPP6R-09RXG-2H8MT-8KNM9-VGC8R
MPP6R-09RXG-2HBMT-BKHM9-V6C8R
MPP6R-09RXG-2HBMT-BKHM9-VGC8R
MPP6R-09RXG-2HBMT-BKNM9-V6C8R
MPP6R-09RXG-2HBMT-BKNM9-VGC8R
MPP6R-09RXG-2HBMT-8KHM9-V6C8R
MPP6R-09RXG-2HBMT-8KHM9-VGC8R
MPP6R-09RXG-2HBMT-8KNM9-V6C8R
MPP6R-09RXG-2HBMT-8KNM9-VGC8R

How about using itertools and functools at the same time?

>>> from operator import mod
>>> from functools import partial
>>> from itertools import product
>>> map(partial(mod, 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R'), product('8B', 'B8', 'HN', '6G'))
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKHM9-VGC8R', 'MPP6R-09RXG-2H8MT-BKNM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKNM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KHM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KHM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KNM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KNM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKHM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKHM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKNM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKNM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KHM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KHM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KNM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']

Another way to generate the combinations

>>> ['MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % (a, b, c, d)
...  for a in '8B' for b in 'B8' for c in 'HN' for d in '6G']
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R',
'MPP6R-09RXG-2H8MT-BKHM9-VGC8R',
'MPP6R-09RXG-2H8MT-BKNM9-V6C8R',
'MPP6R-09RXG-2H8MT-BKNM9-VGC8R',
'MPP6R-09RXG-2H8MT-8KHM9-V6C8R',
'MPP6R-09RXG-2H8MT-8KHM9-VGC8R',
'MPP6R-09RXG-2H8MT-8KNM9-V6C8R',
'MPP6R-09RXG-2H8MT-8KNM9-VGC8R',
'MPP6R-09RXG-2HBMT-BKHM9-V6C8R',
'MPP6R-09RXG-2HBMT-BKHM9-VGC8R',
'MPP6R-09RXG-2HBMT-BKNM9-V6C8R',
'MPP6R-09RXG-2HBMT-BKNM9-VGC8R',
'MPP6R-09RXG-2HBMT-8KHM9-V6C8R',
'MPP6R-09RXG-2HBMT-8KHM9-VGC8R',
'MPP6R-09RXG-2HBMT-8KNM9-V6C8R',
'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']
>>>