1.Crunch移植到windows平台:

1.1.cygwin64下编译Crunch会遇到如下错误:

$ make
Building binary...
/usr/bin/gcc  -pthread -Wall -pedantic -std=c99  undefined crunch.c -lm  -o crunch
gcc: 错误:undefined:No such file or directory
make: *** [Makefile:75:crunch] 错误 1

定位到Makefile文件75行:

crunch: crunch.c@echo "Building binary..."$(CC) $(CPPFLAGS) $(CFLAGS_STD) $(CFLAGS) $(LFS) $? $(LIBFLAGS) $(LDFLAGS) -o $@@echo ""

makefile在执行$(LFS)命令时出错,原因是cygwin64中POSIX_V6_ILP32_OFFBIG_CFLAGS(用于支持读写操作4G大文件----不要惊讶字典文件超过4G是常态)的值未定义:

$ getconf POSIX_V6_ILP32_OFFBIG_CFLAGS
undefined

题外话,getconf用于获得系统变量值,如判断系统是32bit还是64bit,可以通过下列命令得到:

$ getconf -a|grep LONG_BIT
LONG_BIT                            64
#getconf -a获得全部系统配置值

解决这个问题只需在Makefile中把LFS置空即可:

...
LFS     = $(shell getconf POSIX_V6_ILP32_OFFBIG_CFLAGS)
LFS=
ifeq ($(UNAME_LOOKUP),Darwin)
...

1.2.安装crunch时报错:

$ make install
Creating directories...
sudo /usr/bin/install -d -g root -o root \/usr/bin \/usr/share/man/man1 \/usr/share/crunch \/usr/share/doc/crunch
make:sudo:命令未找到
make: *** [Makefile:87:install] 错误 127$ make install
Creating directories...
/usr/bin/install -d -g root -o root \/usr/bin \/usr/share/man/man1 \/usr/share/crunch \/usr/share/doc/crunch
/usr/bin/install: 无效的组"root"
make: *** [Makefile:87:install] 错误 1

第一个错误是cygwin64中不支持sudo命令,第二个错误是cygwin64中没有root组。分别修改Makefile以下内容即可:

#INSTALL     = sudo $(shell which install)
INSTALL     = $(shell which install)
ifeq ($(UNAME_LOOKUP),Darwin)
...
else
...#INSTALL_OPTIONS = -g root -o root
endif

1.3.安装后将cygwin64的/usr/bin绝对路径加到Windows环境变量PATH中:

之后就可以在命令行中使用crunch了。

2.Crunch使用 (满满的坑):

crunch的核心是-t 控制输出的格式以及输出的顺序,它根据前面字符集(man crunch输出的"charset string")来生成字典:

crunch <min-len> <max-len> [<charset string>] [options]charset stringYou  may specify character sets for crunch to use on the commandline or if you leave it blank crunch will use the default  char‐acter sets.  The order MUST BE lower case characters, upper casecharacters, numbers, and then symbols.  If you don't follow thisorder  you  will not get the results you want.  You MUST specifyeither values for the character type or a plus sign.

上面的输出包含4部分信息:

2.1.参数"charset string"用于指定字符集,-t 依次读取后面的输出控制符, 当遇到@,%^时,会从前面字符集中取出字符生成字典。

如,指定小写字符集为abc,当-t 遇到@都只会从abc这3个字母中取值:

pi@raspberrypi:~ $ crunch 5 5 abc -t @-@-@
#第一个位置上的@从abc中取值 第三个位置上的@从abc中取值 第五个位置上的@仍从abc中取值
Crunch will now generate the following number of lines: 27
a-a-a
a-a-b
a-a-c
a-b-a
a-b-b
a-b-c
a-c-a
a-c-b
a-c-c
b-a-a
b-a-b
b-a-c
b-b-a
...

又如,指定大写字符集为XY,当-t 遇到,都只会从XY这2个字母中取值:

pi@raspberrypi:~ $ crunch 5 5 + XY -t -,-,- |more
#第二个位置上的,从XY中取值 第四个位置上的,从XY中取值
Crunch will now generate the following number of lines: 4
-X-X-
-X-Y-
-Y-X-
-Y-Y-

又如,同时制定小写大写字符集ab CD, 当-t 遇到@只会从ab这2个字母中取值,遇到,时从CD这2个字母中取值。这个例子同时说明字典输出字符的顺序仅由-t来控制,和前面的字符集出现的顺序无关:

pi@raspberrypi:~ $ crunch 7 7 ab CD -t ,-,-@-@
#大写-大写-小写-小写
Crunch will now generate the following number of lines: 16
C-C-a-a
C-C-a-b
C-C-b-a
C-C-b-b
C-D-a-a
C-D-a-b
C-D-b-a
C-D-b-b
D-C-a-a
D-C-a-b
D-C-b-a

2.2.指定字符集时必须注意顺序:必须以先小写 再大写 第三数字 最后符号的顺序指定字符集,否则得不到预期效果!(影响-t 的输出)

2.2.1.比如,可以以ab CD 12的形式指定字符集

pi@raspberrypi:~ $ crunch 9 9 ab CD 12 -t @-%-,-@-,
#正确的字符集顺序
#本意为小写-数字-大写-小写-大写
Crunch will now generate the following number of lines: 32
a-1-C-a-C
a-1-C-a-D
a-1-C-b-C
a-1-C-b-D
a-1-D-a-C
a-1-D-a-D
a-1-D-b-C
a-1-D-b-D
a-2-C-a-C
a-2-C-a-D
a-2-C-b-C
a-2-C-b-D
a-2-D-a-C

其他错误的字符集顺序:

2.2.2.当字符集顺序为先数字 后小写 最后大写,-t后面的内容不变时:

pi@raspberrypi:~ $ crunch 9 9 12 ab CD -t @-%-,-@-,
Crunch will now generate the following number of lines: 32
1-C-a-1-a
1-C-a-1-b
1-C-a-2-a
1-C-a-2-b
1-C-b-1-a
1-C-b-1-b
1-C-b-2-a
1-C-b-2-b
1-D-a-1-a
1-D-a-1-b
1-D-a-2-a
1-D-a-2-b

2.2.3.当字符集顺序为先大写 后数字 最后小写,-t后面的内容不变时:

pi@raspberrypi:~ $ crunch 9 9 CD 12 ab -t @-%-,-@-,
Crunch will now generate the following number of lines: 32
C-a-1-C-1
C-a-1-C-2
C-a-1-D-1
C-a-1-D-2
C-a-2-C-1
C-a-2-C-2
C-a-2-D-1
C-a-2-D-2
C-b-1-C-1

2.3.字符集中加号(+)的作用:

2.2.节中提到了字符集的顺序不能打乱。假设,我只想设置大写字母的字符集,其他保持默认,可以猜测到,下面的方式必然会引起错误:

pi@raspberrypi:~ $ crunch 3 3 ABC -t @,@
#-t的本意是小写大写小写,结果如下:
Crunch will now generate the following number of lines: 234
AAA
AAB
AAC
ABA
ABB
ABC
ACA
ACB
...

错误的原因是字符集必须以小写开头!为了规避这种错误,crunch提出了+号解决这个问题。先来看一个有趣的字符集:

pi@raspberrypi:~ $ crunch 3 3 + + +  -t @,% |more
#example 1:
Crunch will now generate the following number of lines: 6760
aA0
aA1
aA2
aA3
aA4pi@raspberrypi:~ $ crunch 3 3 -t @,% |more
#example 2:
Crunch will now generate the following number of lines: 6760
aA0
aA1
aA2
aA3
aA4

上面example1和example2的输出一致。

Example1暗示,字符集中+ + +的形式如同全体小写 全体大写 全体数字的形式,第一个+代表全体小写字母,第二个+代表全体大写字母 第三+代表全体数字。crunch用+号代表字符集中的占位符,也就是说字符集一共有4个位置:1号位,2号位,3号位,4号位以此是小写字母,大写字母,数字,符号。如果对各个位置没有特殊的要求,直接用4个+号代替(中间用空格分隔) 形如 + + + +。只要字符集不违反先小写 再大写 第三数字 最后符号的顺序,+号可以省略,如:

#ab和ab + + +等效
pi@raspberrypi:~ $ crunch 3 3 ab + + -t @,%
Crunch will now generate the following number of lines: 520
aA0
aA1
aA2
aA3
aA4
pi@raspberrypi:~ $ crunch 3 3 ab  -t @,%
Crunch will now generate the following number of lines: 520
aA0
aA1
aA2
aA3
aA4#ab CD和ab CD + +等效
pi@raspberrypi:~ $ crunch 3 3 ab CD  -t @,% |more
Crunch will now generate the following number of lines: 40
aC0
aC1
aC2
aC3
aC4
pi@raspberrypi:~ $ crunch 3 3 ab CD +  -t @,% |more
Crunch will now generate the following number of lines: 40
aC0
aC1
aC2
aC3
aC4

但是,如果对某一号位的字符有特殊需求,则不能省略其前面所有号位,且用+代替,否则会引起错误。如,我对大写有要求,小写没有要求,则(二号位前面的)一号位必须有+号,二号位根据实际要求填写:

pi@raspberrypi:~ $ crunch 4 4 + XYZ + -t ,,%@
#以大写大写数字小写的顺序输出
Crunch will now generate the following number of lines: 2340
XX0a
XX0b
XX0c
XX0d
XX0e#或者
pi@raspberrypi:~ $ crunch 4 4 + XYZ  -t ,,%Q
Crunch will now generate the following number of lines: 2340
XX0a
XX0b
XX0c
XX0d
XX0e

如,我对数字有要求,大小写没有要求,则(三号位前面的)一号位二号必须有+号,三号位根据实际要求填写:

pi@raspberrypi:~ $ crunch 4 4 + + 123 -t ,,%@|more
#仍以大写大写数字小写的顺序输出
Crunch will now generate the following number of lines: 52728
AA1a
AA1b
AA1c
AA1d
AA1e

又如,我对小写和数字有要求,大写没有要求,则(三号位前面的)二号必须有+号,一号和三号位根据实际要求填写:

pi@raspberrypi:~ $ crunch 4 4 abc + 123 -t ,,%@|more
#仍以大写大写数字小写的顺序输出
Crunch will now generate the following number of lines: 6084
AA1a
AA1b
AA1c
AA2a
AA2b
AA2c
AA3a

2.4.社会工程学:

字典中往往含有生日项,手机号项,qq号项等组合,crunch -p对这些通过社工获得的项进行数学全排列。-p也能对多个字符项进行全排列,各项之间用空格分隔:

如,我用生日:1980.01.01   手机号:188xxxxxxxx  qq:35yyyyyyy 生成字典:

pi@raspberrypi:~ $ crunch 1 1 -p 1980.01.01 188xxxxxxxx 35yyyyyyy
Crunch will now generate the following number of lines: 6
188xxxxxxxx1980.01.0135yyyyyyy
188xxxxxxxx35yyyyyyy1980.01.01
1980.01.01188xxxxxxxx35yyyyyyy
1980.01.0135yyyyyyy188xxxxxxxx
35yyyyyyy188xxxxxxxx1980.01.01
35yyyyyyy1980.01.01188xxxxxxxx

如,我用字符a,b,c 作为字典:

pi@raspberrypi:~ $ crunch 1 1 -p a b c
Crunch will now generate the following number of lines: 6
abc
acb
bac
bca
cab
cba

-p和-t还能结合,在指定位置上输出项:

pi@raspberrypi:~ $ crunch 5 5  m -t e@e@e -p 1980.01.01 188xxxxxxxx 35yyyyyyy
Crunch will now generate the following number of lines: 6
188xxxxxxxxm1980.01.01m35yyyyyyy
188xxxxxxxxm35yyyyyyym1980.01.01
1980.01.01m188xxxxxxxxm35yyyyyyy
1980.01.01m35yyyyyyym188xxxxxxxx
35yyyyyyym188xxxxxxxxm1980.01.01
35yyyyyyym1980.01.01m188xxxxxxxxpi@raspberrypi:~ $ crunch 4 4  m -t e@e@e -p 1980.01.01 188xxxxxxxx 35yyyyyyy
The maximum and minimum length should be the same size as the pattern you specified.
min = 4  max = 4  strlen(e@e@e)=5

根据前面的输出可知,crunch把-p中以空格分隔的项当做一个字符分别插入 -t中非@,%^部分。要求-p中的项多余-t中的项,否则会段错误:

pi@raspberrypi:~ $ crunch 4 4  m -t eeee -p a b c d e
#像是A45=5*4*3*2: -p中的项代表总数m -t中的非@,^%部分代表从总数m中选取n项做排列
Crunch will now generate the following number of lines: 120
abcd
abce
abdc
abde
abec
abed
acbd
acbe
acdb

在参考网页2中,作者提到:"还有个问题,能够实现我-t 参数 使用两个% 但是两个%参数我要不同的值?"

-p和-t的组合能解决他的一部分难题:

pi@raspberrypi:~ $ crunch 2 2 + + 123 -t e% -p 4
Crunch will now generate the following number of lines: 3
41
42
43pi@raspberrypi:~ $ crunch 2 2 + + 123 -t e% -p 4 5
Crunch will now generate the following number of lines: 6
41
42
43
51
52
53pi@raspberrypi:~ $ crunch 2 2 + + 123 -t e% -p 4 5 6
Crunch will now generate the following number of lines: 18
41
42
43
41
42
43
51
52
53
51
52
53
61

参考:

1.Linux下的字典生成工具Crunch,创造自己的专属字典

2.Crunch工具的注意点以及与Cupp Cewl的对比

字典生成器crunch问题汇总(移植到Windows/字符集)相关推荐

  1. Crunchx--基于文法的字典生成器

    Crunchx--基于文法的字典生成器 写在前面的话 第一次在CSDN上写博客,N年后夜深人静的某个地点,夏末,微凉,终于可以静下心来写下拙文. 背景 很长一段时间,对wifi破解尤为感兴趣,很长时间 ...

  2. ffmpeg-0.6.3 移植到 windows 开源代码

    ffmpeg-0.6.3开源编码解码库,从linux下移植到windows vs2005,全部开源. 需要 Intel C++ Compile 和 开源的SDL库支持,由于 Intel C++ Com ...

  3. ffmpeg-0.8 开源编码解码库从linux下移植到windows vs2005

    最新 ffmpeg-0.8 开源编码解码库,从linux下移植到windows vs2005,全部开源. 需要 Intel C++ Compile 和 开源的SDL库支持,由于 Intel C++ C ...

  4. Python3之字典生成器结合lambda实现按key/value排序

    Python3之字典生成器结合lambda实现按key/value排序 1.先介绍不常见的字典按value排序: dict1 = {"g": 2, "f": 1 ...

  5. linux网络通信移植,基于socket API的C/S通信:将Qt程序从Linux移植到windows

    Qt是一个跨平台的GUI开发语言,它是对C++在图形设计方面上的一种扩充.Qt本身包含一系列用来设计图形界面的类,并且对C++原有的类都进行了再次封装.如果你的程序采用Qt的类库,那么源程序在不同平台 ...

  6. RethinkDB已经将其数据库移植到Windows

    RethinkDB已经推出了其数据库的Windows版本.该版本耗时一年开发,可以运行在64位Windows操作系统上,目前尚处于Beta测试阶段. \\ 考虑到此次移植所付出的巨大的时间成本,我们采 ...

  7. tar在linux编译为exe,将Linux代码移植到Windows的简单方法 1

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 一.前言 Linux拥有丰富各种源代码资源,但是大部分代码在Windows平台情况是无法正常编译的.Windows平台根本无法直接利用这些源代码资源.如果 ...

  8. 将Linux代码移植到Windows的简单方法

    将Linux代码移植到Windows的简单方法 一.前言 Linux拥有丰富各种源代码资源,但是大部分代码在Windows平台情况是无法正常编译的.Windows平台根本无法直接利用这些源代码资源.如 ...

  9. ffmpeg-0.6.3开源编码解码库,从linux下移植到windows vs2005,全部开源。

    ffmpeg-0.6.3开源编码解码库,从linux下移植到windows vs2005,全部开源. 需要 Intel C++ Compile 和 开源的SDL库支持,由于 Intel C++ Com ...

最新文章

  1. 【Spring】spring基于纯注解的声明式事务控制
  2. [How TO]-堡垒机快捷登陆SSH服务器-expect自动输密码
  3. 记录爬取信用中国,里面的行政许可内容,行政处罚,守信激励的内容,并以excel形式显示
  4. inotify监听文件夹的变动
  5. 08.28 JavaScript 边界 选择修饰符 模式单元 修饰符 正则的使用
  6. 7.Springcloud的Ribbon的自定义算法实现
  7. 如何恢复手机通讯录号码呢?该怎么恢复呢
  8. 微信公众号web端关闭本页面
  9. ant部署web工程模板
  10. LINUX命令之stat及显示的三个时间戳
  11. STL笔记 ( 迭代器 )
  12. 【光学】干涉衍射仿真含Matlab源码
  13. 黄金分割点公式java_java如何实现黄金分割数 java实现黄金分割数代码
  14. 打造您的赚钱机器2.0视频-精华笔记-独家分享
  15. idea中启动项目 就报异常
  16. 修改IAR for msp430工程名方法
  17. matlab 黄金分析,matlab黄金分割法求解
  18. 使用Telerik的登陆模板实现DoubanFm的登陆(WP7)
  19. Win7用户文件夹转移
  20. java——html

热门文章

  1. 计算机网络中的IP到底是什么?
  2. 【Linux】Linux的共享内存
  3. 杰理之统一音量控制【篇】
  4. 系统怎么设计usb启动_在启动中启动设计系统
  5. ipv6默认网关怎么打开。有偿。
  6. 安徽审计职业学院计算机成绩,历年安徽审计职业学院计算机软件工程专业毕业论文选题.doc...
  7. Kite的学习历程之SpringCloud之Rest微服务构建之微服务提供者支付Moudle
  8. ​40岁男子将妻子送出火场再去救18岁儿子时父子俩遇难
  9. API 接口认证与传输数据加密
  10. 酒店管理与计算机未来的结合,智慧酒店:未来酒店发展新方向