Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by ���ܵ�Сʨ
Sat, 18 Apr 1998 00:00
ZIP������ⷨ
Author: ���ܵ�Сʨ
Date: Sat, 18 Apr 1998 00:00
Date: Sat, 18 Apr 1998 00:00
138 lines
8525 bytes
8525 bytes
ZIP�ļ��������ʽ
���ļ�ͷ��Ϣ+�ļ�ѹ�����
����Ŀ¼+����Ŀ¼��¼�����
1.���ļ�ͷ��Ϣ:
�ֽ��� ����
4 ���ļ�ͷ��Ϣ��־(0x04034b50)
2 ��ѹ������汾
2 ͨ�ñ��ر�־λ(�ñ���0λ=����;�ñ���1λ=ʹ��ѹ
����ʽ6,��ʹ��8k�仯Ŀ¼,����ʹ��4k�仯Ŀ¼;�ñ���2λ=ʹ��ѹ
����ʽ6,��ʹ��3��ShannonFano���Ա仯Ŀ¼�������,����ʹ��2��
ShannonFano���Ա仯Ŀ¼�������,�������λδ��)
2 ѹ����ʽ(0=��ѹ��,1=��С,2=��ѹ������1��С,3=��
ѹ������2��С,4=��ѹ������3��С,5=��ѹ������4��С,6=��չ)
2 �ļ������ʱ��
2 ����������
4 32λУ����
4 ѹ���ļ���С
4 δѹ���ļ���С
2 ���
2 ��չ�γ�
? ���(������)
? ��չ��(������)
2.����Ŀ¼�ṹ
�ļ�ͷ��Ϣ...����Ŀ¼��¼�����
�ļ�ͷ:
�ֽ��� ����
4 �����ļ�ͷ��Ϣ��־(0x02014b50)
2 �������ϵͳ(��λ�ֽڱ�ʾ�������ϵͳ,��λ��
�ڱ�ʾZIPѹ������汾��,��ֵ����10��ʾ���汾��,��ֵģ10��ʾ
�ΰ汾�š�0=MS-DOS,OS/2 FAT�ļ�ϵͳ,1=Ami ga,2=VMS,3=Unix��
����,4=VM/CMS,5=AtariST,6=OS/2 HPFS,7=Macintosh,8=Z-System,9
=C P/M,10-255�)
2 ��ѹ������汾
2 ͨ�ñ��ر�־
2 ѹ����ʽ
2 �ļ������ʱ��(�ñ���MS-DOSʱ���� �ڸ�ʽ
����)
2 ����������
4 32λУ����(ʹ��David Schwaderer��CRC-32�㷨��
��)
4 ѹ���ļ���С
4 δѹ���ļ���С
2 ���
2 ��չ�γ�
2 �ļ�ע�ͳ�(�ֱ�Ϊ�ļ���,��չ��,ע�� ��,С��
64K)
2 ������ʼ��(���ļ��ڴ����е���ʼ��)
2 �ڲ��ļ�����(���λ����1,��ʾΪASC�ı�,����Ϊ
���������,����λδ��)
4 �ⲿ�ļ�����(�������������ϵͳ)
4 ���ļ�ͷ���λ��
? ���(������)
? ��չ��(������,����δ����չ,�Ͱ汾Ϊ0��)
? �ļ�ע��(������)
3.����Ŀ¼��¼�����
�ֽ��� ����
4 ����Ŀ¼��ǽ����(0x06054b50)
2 ���̺�(���а�������Ŀ¼�����¼)
2 ��������Ŀ¼��ʼ��
2 ��������Ŀ¼�������
2 ����Ŀ¼�������(ZIP�ļ��е��ļ�����)
2 �������Ŀ¼��С
4 ������ʼ���̺ŵ�����Ŀ¼��ʼƫ��
2 ZIP�ļ�ע�ͳ���
? ZIP�ļ�ע��(������)
���ܷ���
PKZIP��ʹ�õļ��ܷ�����Roger Schlafly�ṩ��ZIP�ļ��ڽ�ѹ
��ǰ�����Ƚ��ܡ�ÿ�������ļ�����һ��12�ֽڵļ����ļ�ͷ��չ��
Ϣ,�洢����������ʼλ��,����ǰ������һ����ʼֵ,Ȼ�����3
2λ����Կ���ܡ���Կ��ʹ�����ṩ�Ŀ����ʼ����12���ֽڼ���֮
��,��PKZIP��α��������,���PKZIP��ʹ��CRC-32�㷨����Կ
���и��¡�
����ʵʩ��Ϊ��:
1.�ÿ�������32λ��Կ��ʼ����
K(0)=305419896,K(1)=591751049,K(2)=878082192
ѭ�� for i=0 to length(password)-1
���ø�����Կ���� update_keys(password(i))
����ѭ��(ѭ������ȴ�)
���и�����Կ����Ϊ:
update_keys(char):
Key(0)=crc32(key(0),char)
Key(1)=Key(1)+(Key(0)& 000000ffH)
Key(1)=Key(1)*134775813+1
Key(2)=crc32(Key(2),Key(1)����24)
end update_keys
CRC32������,��һ��4�ֽڵ�CRCֵ��һ���ַ�,����һ����CRC
-32�㷨���µ�CRC������Ϊ:
crc32(c,b)=crc32tab[(c^b)&0xff]^(c>>8),crc32tab[256]��ֵ
Ϊ�̶���256��4�ֽ���
2.��ȡ������12�ֽڵļ���ͷ,�ٴζ���Կ���г�ʼ����
��12���ֽڵļ���ͷ���뻺����buffer(0)��buffer(11),ѭ��fo
r i=0 to 11
C=buffer(i)^decrypt_byte()
update_keys(C)
buffer(i)=C
����ѭ��(ѭ��12��)
���е�decrypt_byte()����Ϊ:
unsigned char decrypt_byte()
local unsigned short temp
temp=Key(2)|2
decrypt_byte=((temp*(temp^1))>>8)&0xff
end decrypt_byte
�ò������,�����������Ķ����ֽ�buffer(10)��buffer(11)
����Ϊ�����ļ�У����Ķ������λ(��������˳����)����ZIP��
���ļ����н�ѹ��ǰ,PKUNZIP�����ʹ�����ṩ�Ŀ������������
����д���,�õ��Ľ����У����Ķ�����λ�ֽڽ��бȽ�,ֻ�е���
������ȷ�Ŀ���ʱ,���һ��,���ܽ��к���Ľ�ѹ�����,����,PKZI
P���������Ϣ,�����Զ�����
3.��ȡѹ������������Լ�����Կ������м��ܡ�
ѹ���������������̼���:
ѭ�� ֱ�����������
C=�������һ���ֽ�
temp=C^decrypt_byte()
update_keys(temp)
���temp
����ѭ��
�������ȡ����
ͨ�����������ֵ�����,����֪��:��Ϊ���ܹ���в����㷨����
Կ���ϸ���,��ֱ��ʵʩ���ܵ�����(����),����ֻ��ֱ�ӹ�����
��,���������İ취,��У�������жϿ������ȷ��������
,����������,����,һ��ʹ���˴�СдӢ����ĸ(a-z,A-Z),����(0 -9
),�ͱ����(@#$%^&*()_+-[]{},��\"/?:;`')�������ĸ�Ŀ���,��
����Ϊ88��5��Ļ(Լ53��)�������ֻʹ����Сд��ĸ,���������Ϊ
һǧ��Ρ�����,��ȡZIP�Ŀ���,������ֻ�в��ֵijɹ��ʡ�ֻ����
Ϊ������ʹ�ÿ���ʱ����©��(��̿���,ֻ��Сд��ĸ,ֻ������,��
�����������),��ʹ��ȡZIP�������һ���ijɹ��ʡ�
--
[m[1;37m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn][m
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads