⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x86.s

📁 UNIX、linux密码的破密程序源代码实现
💻 S
📖 第 1 页 / 共 2 页
字号:
/* * This file is part of John the Ripper password cracker, * Copyright (c) 1996-2003 by Solar Designer *//* * x86 assembly routines. */#include "arch.h"#ifdef UNDERSCORES#define DES_IV				_DES_IV#define DES_count			_DES_count#define DES_KS_current			_DES_KS_current#define DES_KS_copy			_DES_KS_copy#define DES_KS_table			_DES_KS_table#define DES_SPE_L			_DES_SPE_L#define DES_SPE_H			_DES_SPE_H#define DES_SPE_F			_DES_SPE_F#define DES_std_crypt			_DES_std_crypt#define DES_xor_key1			_DES_xor_key1#define DES_xor_key2			_DES_xor_key2#define MD5_body			_MD5_body#define BF_body				_BF_body#define BF_current			_BF_current#define CPU_detect			_CPU_detect#endif/* * Some broken systems don't offer section alignments larger than 4 bytes, * while for the MMX code we need at least an 8 byte alignment. ALIGN_FIX * is here to work around this issue when we happen to get bad addresses. */#ifndef ALIGN_FIX#ifdef ALIGN_LOG#define DO_ALIGN(log)			.align (log)#elif defined(DUMBAS)#define DO_ALIGN(log)			.align 1 << log#else#define DO_ALIGN(log)			.align (1 << (log))#endif#else#ifdef ALIGN_LOG#define DO_ALIGN(log)			.align (log); .space 4#else#define DO_ALIGN(log)			.align (1 << (log)); .space 4#endif#endif/* * DES stuff. * * Included are versions for: * 1. MMX (Pentium MMX and newer Intel x86 CPUs, some clones); * 2. Intel Pentium without MMX; * 3. The rest (good for Pentium Pro, 486, clones). * * MMX has to be enabled at compile time (via DES_X2 in arch.h), while #2 * or #3 is chosen based on CPUID info at runtime. * * Note: MMX code for the bitslice DES implementation is in x86-mmx.S, so * you probably want to look in there instead. */.text#if DES_X2/* * DES MMX routines. */#define R				%mm0#define L				%mm1#define tmp1				%mm2#define tmp2				%mm3#define K1				%mm4#define K2				%mm5#define K3				%mm6#define K4				%mm7#define DES_copy(ofs1, ofs2) \	movq ofs1(%edx),%mm0; \	movq ofs2(%edx),%mm1; \	movq %mm0,DES_KS_copy+ofs1; \	movq %mm1,DES_KS_copy+ofs2#define DES_2_ROUNDS_START(K) \	pxor R,tmp1; \	movd tmp1,%eax; \	movb %al,%bl; \	movb %ah,%dl; \	shrl $16,%eax; \	psrlq $32,tmp1; \	pxor DES_SPE_F(%ebx,%ebx),L; \	pxor DES_SPE_F+0x200(%edx,%edx),L; \	movb %al,%bl; \	movb %ah,%dl; \	movd tmp1,%eax; \	pxor DES_SPE_F+0x400(%ebx,%ebx),L; \	pxor DES_SPE_F+0x600(%edx,%edx),L; \	movb %al,%bl; \	movb %ah,%dl; \	shrl $16,%eax; \	pxor DES_SPE_F+0x800(%ebx,%ebx),L; \	pxor DES_SPE_F+0xA00(%edx,%edx),L; \	movb %al,%bl; \	movb %ah,%dl; \	movq K,tmp1; \	pxor DES_SPE_F+0xC00(%ebx,%ebx),L; \	pxor DES_SPE_F+0xE00(%edx,%edx),L; \	pxor L,tmp1; \	movd tmp1,%eax; \	movb %al,%bl; \	movb %ah,%dl; \	shrl $16,%eax; \	psrlq $32,tmp1; \	pxor DES_SPE_F(%ebx,%ebx),R; \	pxor DES_SPE_F+0x200(%edx,%edx),R; \	movb %al,%bl; \	movb %ah,%dl; \	movd tmp1,%eax; \	pxor DES_SPE_F+0x400(%ebx,%ebx),R; \	pxor DES_SPE_F+0x600(%edx,%edx),R; \	movb %al,%bl; \	movb %ah,%dl; \	shrl $16,%eax; \	pxor DES_SPE_F+0x800(%ebx,%ebx),R; \	pxor DES_SPE_F+0xA00(%edx,%edx),R; \	movb %al,%bl; \	movb %ah,%dl#define DES_2_ROUNDS(K1, K2) \	DES_2_ROUNDS_START(K1); \	movq K2,tmp1; \	pxor DES_SPE_F+0xC00(%ebx,%ebx),R; \	pxor DES_SPE_F+0xE00(%edx,%edx),RDO_ALIGN(12).globl DES_std_cryptDES_std_crypt:	movl 4(%esp),%edx	pushl %ebx	movl DES_count,%ecx	xorl %ebx,%ebx	movq (%edx),K1	movq 32(%edx),K2	movq K1,tmp1	movq 8(%edx),K3	movq 16(%edx),K4	DES_copy(24, 40)	DES_copy(48, 56)	DES_copy(64, 96)	DES_copy(72, 80)	DES_copy(88, 104)	DES_copy(112, 120)	movq DES_IV,R	xorl %edx,%edx	movq DES_IV+8,LDES_loop:	DES_2_ROUNDS(K3, K4)	DES_2_ROUNDS(DES_KS_copy+24, K2)	DES_2_ROUNDS(DES_KS_copy+40, DES_KS_copy+48)	DES_2_ROUNDS(DES_KS_copy+56, DES_KS_copy+64)	DES_2_ROUNDS(DES_KS_copy+72, DES_KS_copy+80)	DES_2_ROUNDS(DES_KS_copy+88, DES_KS_copy+96)	DES_2_ROUNDS(DES_KS_copy+104, DES_KS_copy+112)	DES_2_ROUNDS_START(DES_KS_copy+120)	movq K1,tmp1	pxor DES_SPE_F+0xC00(%ebx,%ebx),R	movq L,tmp2	pxor DES_SPE_F+0xE00(%edx,%edx),R	decl %ecx	movq R,L	movq tmp2,R	jnz DES_loop	movl 12(%esp),%edx	popl %ebx	movq R,(%edx)	movq L,8(%edx)#ifdef EMMS	emms#endif	ret#define DES_xor1(ofs1, ofs2) \	movq DES_KS_current+ofs1,%mm0; \	movq DES_KS_current+ofs2,%mm1; \	pxor ofs1(%edx),%mm0; \	pxor ofs2(%edx),%mm1; \	movq %mm0,DES_KS_current+ofs1; \	movq %mm1,DES_KS_current+ofs2DO_ALIGN(4).globl DES_xor_key1DES_xor_key1:	movl 4(%esp),%edx	DES_xor1(0, 32)	DES_xor1(8, 16)	DES_xor1(24, 40)	DES_xor1(48, 56)	DES_xor1(64, 96)	DES_xor1(72, 80)	DES_xor1(88, 104)	DES_xor1(112, 120)#ifdef EMMS	emms#endif	ret#define DES_xor2(ofs1, ofs2) \	movq DES_KS_current+ofs1,%mm0; \	movq DES_KS_current+ofs2,%mm1; \	pxor ofs1(%edx),%mm0; \	pxor ofs2(%edx),%mm1; \	pxor ofs1(%ecx),%mm0; \	pxor ofs2(%ecx),%mm1; \	movq %mm0,DES_KS_current+ofs1; \	movq %mm1,DES_KS_current+ofs2DO_ALIGN(4).globl DES_xor_key2DES_xor_key2:	movl 4(%esp),%edx	movl 8(%esp),%ecx	DES_xor2(0, 32)	DES_xor2(8, 16)	DES_xor2(24, 40)	DES_xor2(48, 56)	DES_xor2(64, 96)	DES_xor2(72, 80)	DES_xor2(88, 104)	DES_xor2(112, 120)#ifdef EMMS	emms#endif	ret#else/* * DES non-MMX routines. */#define Rl				%ecx#define Rh				%ebp#define Ll				%esi#define Lh				%edi#define DES_copy(ofs) \	movl ofs(%edx),%esi; \	movl ofs+4(%edx),%edi; \	movl %esi,DES_KS_copy+ofs; \	movl %edi,DES_KS_copy+ofs+4#define DES_CRYPT_START \	movl 4(%esp),%edx; \	pushl %ebp; \	pushl %esi; \	pushl %edi; \	pushl %ebx; \	movl (%edx),%eax; \	movl 4(%edx),%edi; \	movl %eax,DES_KS_copy; \	movl %edi,DES_KS_copy+4; \	DES_copy(32); \	DES_copy(8); \	DES_copy(16); \	DES_copy(24); \	DES_copy(40); \	DES_copy(48); \	DES_copy(56); \	DES_copy(64); \	DES_copy(96); \	DES_copy(72); \	DES_copy(80); \	DES_copy(88); \	DES_copy(104); \	DES_copy(112); \	DES_copy(120); \	movl DES_IV,Rl; \	movl DES_IV+4,Rh; \	movl DES_IV+8,Ll; \	movl DES_IV+12,Lh; \	movl DES_count,%edx; \	xorl %ebx,%ebx; \	movl %edx,DES_count_tmp; \	xorl %edx,%edx#define DES_CRYPT_END \	movl 24(%esp),%edx; \	popl %ebx; \	movl Rl,(%edx); \	movl Rh,4(%edx); \	movl Ll,8(%edx); \	movl Lh,12(%edx); \	popl %edi; \	popl %esi; \	popl %ebp; \	ret/* * Intel Pentium optimized version, extra operations are used to avoid * imperfect pairing. */#define DES_2_ROUNDS_START_P5(K) \	xorl Rl,%eax; \	movb %al,%bl; \	movb %ah,%dl; \	movl Rl,DES_SavedL; \	shrl $16,%eax; \	movl DES_SPE_L(%ebx),Rl; \	xorl Rl,Ll; \	movl DES_SPE_H(%ebx),Rl; \	xorl Rl,Lh; \	movl DES_SPE_L+0x100(%edx),Rl; \	xorl Rl,Ll; \	movl DES_SPE_H+0x100(%edx),Rl; \	movb %al,%bl; \	xorl Rl,Lh; \	movb %ah,%dl; \	movl K+4,%eax; \	movl DES_SPE_L+0x200(%ebx),Rl; \	xorl Rh,%eax; \	xorl Rl,Ll; \	movl DES_SPE_H+0x200(%ebx),Rl; \	xorl Rl,Lh; \	movl DES_SPE_L+0x300(%edx),Rl; \	xorl Rl,Ll; \	movb %al,%bl; \	movl DES_SPE_H+0x300(%edx),Rl; \	movb %ah,%dl; \	shrl $16,%eax; \	xorl Rl,Lh; \	movl DES_SPE_L+0x400(%ebx),Rl; \	xorl Rl,Ll; \	movl DES_SPE_H+0x400(%ebx),Rl; \	xorl Rl,Lh; \	movl DES_SPE_L+0x500(%edx),Rl; \	xorl Rl,Ll; \	movb %al,%bl; \	movl DES_SPE_H+0x500(%edx),Rl; \	movb %ah,%dl; \	xorl Rl,Lh; \	movl DES_SPE_L+0x600(%ebx),Rl; \	xorl Rl,Ll; \	movl DES_SPE_H+0x600(%ebx),Rl; \	xorl Rl,Lh; \	movl DES_SPE_L+0x700(%edx),Rl; \	xorl Rl,Ll; \	movl K+8,%eax; \	movl DES_SPE_H+0x700(%edx),Rl; \	xorl Ll,%eax; \	xorl Rl,Lh; \	movb %al,%bl; \	movl DES_SavedL,Rl; \	movb %ah,%dl; \	movl Ll,DES_SavedL; \	shrl $16,%eax; \	movl DES_SPE_L(%ebx),Ll; \	xorl Ll,Rl; \	movl DES_SPE_H(%ebx),Ll; \	xorl Ll,Rh; \	movl DES_SPE_L+0x100(%edx),Ll; \	xorl Ll,Rl; \	movl DES_SPE_H+0x100(%edx),Ll; \	movb %al,%bl; \	xorl Ll,Rh; \	movb %ah,%dl; \	movl K+12,%eax; \	movl DES_SPE_L+0x200(%ebx),Ll; \	xorl Lh,%eax; \	xorl Ll,Rl; \	movl DES_SPE_H+0x200(%ebx),Ll; \	xorl Ll,Rh; \	movl DES_SPE_L+0x300(%edx),Ll; \	xorl Ll,Rl; \	movb %al,%bl; \	movl DES_SPE_H+0x300(%edx),Ll; \	movb %ah,%dl; \	shrl $16,%eax; \	xorl Ll,Rh; \	movl DES_SPE_L+0x400(%ebx),Ll; \	xorl Ll,Rl; \	movl DES_SPE_H+0x400(%ebx),Ll; \	xorl Ll,Rh; \	movl DES_SPE_L+0x500(%edx),Ll; \	xorl Ll,Rl; \	movb %al,%bl; \	movl DES_SPE_H+0x500(%edx),Ll; \	movb %ah,%dl; \	xorl Ll,Rh; \	movl DES_SPE_L+0x600(%ebx),Ll; \	xorl Ll,Rl; \	movl DES_SPE_H+0x600(%ebx),Ll; \	xorl Ll,Rh; \	movl DES_SPE_L+0x700(%edx),Ll#define DES_2_ROUNDS_P5(K) \	DES_2_ROUNDS_START_P5(K); \	xorl Ll,Rl; \	movl DES_SPE_H+0x700(%edx),Ll; \	xorl Ll,Rh; \	movl K+16,%eax; \	movl DES_SavedL,LlDO_ALIGN(12)DES_std_crypt_P5:	DES_CRYPT_STARTDES_loop_P5:	DES_2_ROUNDS_P5(DES_KS_copy)	DES_2_ROUNDS_P5(DES_KS_copy+16)	DES_2_ROUNDS_P5(DES_KS_copy+32)	DES_2_ROUNDS_P5(DES_KS_copy+48)	DES_2_ROUNDS_P5(DES_KS_copy+64)	DES_2_ROUNDS_P5(DES_KS_copy+80)	DES_2_ROUNDS_P5(DES_KS_copy+96)	DES_2_ROUNDS_START_P5(DES_KS_copy+112)	xorl Rl,Ll	movl DES_SPE_H+0x700(%edx),%eax	xorl Rh,%eax	movl Lh,Rh	movl %eax,Lh	movl DES_count_tmp,%eax	movl DES_SavedL,Rl	decl %eax	movl %eax,DES_count_tmp	movl DES_KS_copy,%eax	jnz DES_loop_P5	DES_CRYPT_END/* * Generic x86 version. */#define DES_2_ROUNDS_START_ANY(K) \	xorl Rl,%eax; \	movb %al,%bl; \	movb %ah,%dl; \	shrl $16,%eax; \	xorl DES_SPE_L(%ebx),Ll; \	xorl DES_SPE_H(%ebx),Lh; \	movb %al,%bl; \	xorl DES_SPE_L+0x100(%edx),Ll; \	xorl DES_SPE_H+0x100(%edx),Lh; \	movb %ah,%dl; \	movl K+4,%eax; \	xorl DES_SPE_L+0x200(%ebx),Ll; \	xorl Rh,%eax; \	xorl DES_SPE_H+0x200(%ebx),Lh; \	movb %al,%bl; \	xorl DES_SPE_L+0x300(%edx),Ll; \	xorl DES_SPE_H+0x300(%edx),Lh; \	movb %ah,%dl; \	xorl DES_SPE_L+0x400(%ebx),Ll; \	shrl $16,%eax; \	xorl DES_SPE_H+0x400(%ebx),Lh; \	movb %al,%bl; \	xorl DES_SPE_L+0x500(%edx),Ll; \	xorl DES_SPE_H+0x500(%edx),Lh; \	movb %ah,%dl; \	xorl DES_SPE_L+0x600(%ebx),Ll; \	xorl DES_SPE_H+0x600(%ebx),Lh; \	xorl DES_SPE_L+0x700(%edx),Ll; \	movl K+8,%eax; \	xorl Ll,%eax; \	movb %al,%bl; \	xorl DES_SPE_H+0x700(%edx),Lh; \	movb %ah,%dl; \	shrl $16,%eax; \	xorl DES_SPE_L(%ebx),Rl; \	xorl DES_SPE_H(%ebx),Rh; \	movb %al,%bl; \	xorl DES_SPE_L+0x100(%edx),Rl; \	xorl DES_SPE_H+0x100(%edx),Rh; \	movb %ah,%dl; \	movl K+12,%eax; \	xorl DES_SPE_L+0x200(%ebx),Rl; \	xorl Lh,%eax; \	xorl DES_SPE_H+0x200(%ebx),Rh; \	movb %al,%bl; \	xorl DES_SPE_L+0x300(%edx),Rl; \	xorl DES_SPE_H+0x300(%edx),Rh; \	movb %ah,%dl; \	shrl $16,%eax; \	xorl DES_SPE_L+0x400(%ebx),Rl; \	xorl DES_SPE_H+0x400(%ebx),Rh; \	movb %al,%bl; \	xorl DES_SPE_L+0x500(%edx),Rl; \	xorl DES_SPE_H+0x500(%edx),Rh; \	movb %ah,%dl#define DES_2_ROUNDS_ANY(K) \	DES_2_ROUNDS_START_ANY(K); \	xorl DES_SPE_L+0x600(%ebx),Rl; \	xorl DES_SPE_H+0x600(%ebx),Rh; \	movl K+16,%eax; \	xorl DES_SPE_L+0x700(%edx),Rl; \	xorl DES_SPE_H+0x700(%edx),RhDO_ALIGN(12)DES_std_crypt_generic:	DES_CRYPT_STARTDES_loop_generic:	DES_2_ROUNDS_ANY(DES_KS_copy)	DES_2_ROUNDS_ANY(DES_KS_copy+16)	DES_2_ROUNDS_ANY(DES_KS_copy+32)	DES_2_ROUNDS_ANY(DES_KS_copy+48)	DES_2_ROUNDS_ANY(DES_KS_copy+64)	DES_2_ROUNDS_ANY(DES_KS_copy+80)	DES_2_ROUNDS_ANY(DES_KS_copy+96)	DES_2_ROUNDS_START_ANY(DES_KS_copy+112)	movl Ll,%eax	xorl DES_SPE_L+0x600(%ebx),Rl	xorl DES_SPE_H+0x600(%ebx),Rh	movl DES_SPE_L+0x700(%edx),Ll	xorl Rl,Ll	movl %eax,Rl	movl Lh,%eax	movl DES_SPE_H+0x700(%edx),Lh	xorl Rh,Lh	decl DES_count_tmp	movl %eax,Rh	movl DES_KS_copy,%eax	jnz DES_loop_generic	DES_CRYPT_END#define DES_xor1(ofs) \	movl DES_KS_current+ofs,%esi; \	movl DES_KS_current+ofs+4,%edi; \	movl ofs(%edx),%eax; \	movl ofs+4(%edx),%ecx; \	xorl %esi,%eax; \	xorl %edi,%ecx; \	movl %eax,DES_KS_current+ofs; \	movl %ecx,DES_KS_current+ofs+4DO_ALIGN(4).globl DES_xor_key1DES_xor_key1:	movl 4(%esp),%edx	pushl %esi	pushl %edi	DES_xor1(0)	DES_xor1(32)	DES_xor1(8)	DES_xor1(16)	DES_xor1(24)	DES_xor1(40)	DES_xor1(48)	DES_xor1(56)	DES_xor1(64)	DES_xor1(96)	DES_xor1(72)	DES_xor1(80)	DES_xor1(88)	DES_xor1(104)	DES_xor1(112)	DES_xor1(120)	popl %edi	popl %esi	ret#define DES_xor2(ofs) \	movl ofs(%edx),%eax; \	movl ofs+4(%edx),%ecx; \	movl ofs(%ebx),%esi; \	movl ofs+4(%ebx),%edi; \	xorl %esi,%eax; \	xorl %edi,%ecx; \	movl DES_KS_current+ofs,%esi; \	movl DES_KS_current+ofs+4,%edi; \	xorl %esi,%eax; \	xorl %edi,%ecx; \	movl %eax,DES_KS_current+ofs; \	movl %ecx,DES_KS_current+ofs+4DO_ALIGN(4).globl DES_xor_key2DES_xor_key2:	pushl %ebx	movl 8(%esp),%edx	movl 12(%esp),%ebx	pushl %esi	pushl %edi	DES_xor2(0)	DES_xor2(32)	DES_xor2(8)	DES_xor2(16)	DES_xor2(24)	DES_xor2(40)	DES_xor2(48)	DES_xor2(56)	DES_xor2(64)	DES_xor2(96)	DES_xor2(72)	DES_xor2(80)	DES_xor2(88)	DES_xor2(104)	DES_xor2(112)	DES_xor2(120)	popl %edi	popl %esi	popl %ebx	ret#endif.data/* * Weird alignments to make sure KS address's bits 5-11 never match current * instruction pointer's bits 5-11. */#ifdef DUMBASDO_ALIGN(12).zero 0x1000 - 32 - 128#elif defined(__DJGPP__).textDO_ALIGN(12).space (0x1000 - 32 - 128 - 0xE0)#elseDO_ALIGN(12).space (0x1000 - 32 - 128)#endif#if !DES_X2/* * The function pointer, set by CPU_detect(). */.globl DES_std_cryptDES_std_crypt:.long DES_std_crypt_genericDES_SavedL:.long 0#endif/* * These are in .data, not .bss, to get them in a cache line that has to be * already loaded at DES_std_crypt() startup. */.globl DES_IVDES_IV:#ifdef DUMBAS.zero 16#else.space 16#endif.globl DES_countDES_count:.long 0DES_count_tmp:.long 0DO_ALIGN(5).globl DES_KS_copyDES_KS_copy:#ifdef DUMBAS.zero 128#else.space 128#endif#ifdef __DJGPP__.space 32#endif#ifndef BSD.bss#endif#if DES_X2.globl DES_SPE_F

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -