Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3108202

Browse files
committed
update zipfake.rb
1 parent ca9d7e8 commit 3108202

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

misc/compress/zipfake.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(filename, block_size = 10485760)
1111
@path = filename
1212
@bsize = block_size
1313
@size = File.size(filename)
14-
@mark = "\x50\x4B\x01\x02"
14+
@mark = "PK\x01\x02"
1515
end
1616

1717
def lock
@@ -27,6 +27,15 @@ def lock
2727
def unlock
2828
lock_seq = []
2929
set_encrypt_bytes(lock_seq)
30+
31+
# "PK\x03\x04\x14\x03\x00\x00\b\x00" 第7位的全局加密解锁
32+
if File.binread(@path, 7).match? /PK\x03\x04..\x01/
33+
open(@path, 'rb+') do |fio|
34+
fio.seek(6)
35+
fio.putc("\x00")
36+
end
37+
puts "recover zip magic head encryption bit"
38+
end
3039
end
3140

3241
private

0 commit comments

Comments
 (0)