UJP - 技術情報1

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

pkcrackをmacOS Montereyで動作するようにビルドして使う

pkcrackをmacOS Montereyで動作するようにビルドして使う


概要

更新履歴

  • 2024/02/14 初版

目次

はじめに

 このドキュメントは暗号化ZIPファイルのパスワードクラックツール,pkcrackを使ってみる.
 pkcrackで行えるのは既知平文攻撃(Known Plaintext Attack)というもので,平文のファイルを用いてZIPファイルのパスワードを紐解くことになる.
 条件として,複数ファイルをZIPして暗号化しており,そのうちの1つのファイルは平文(暗号化されてない)ファイルを持っている必要がある.平文の ファイルとZIPファイル内で暗号化されたファイルを比較する事でパスワードを解読し,ZIPファイル全体のZIP暗号を解くために使われる.
 主にCTFの最初の一歩らしい.

インストール

HomeBrewでインストールするも失敗

  • まずはHomeBrewでパッケージを確認.

bash-5.2$ brew search pkcrack🆑
==> Formulae
pkcrack🈁              bkcrack              pdfcrack             ophcrack             ncrack               lcrack
bash-5.2$ brew info pkcrack
==> pkcrack: stable 1.2.2 (bottled)
Implementation of an algorithm for breaking the PkZip cipher
https://web.archive.org/web/20220128084028/https://www.unix-ag.uni-kl.de/~conrad/krypto/pkcrack.html
Disabled because it is not maintained upstream!
Conflicts with:
  csound (because both install `extract` binaries)
  libextractor (because both install `extract` binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/pkcrack.rb
==> Analytics
install: 0 (30 days), 0 (90 days), 25 (365 days)
install-on-request: 0 (30 days), 0 (90 days), 25 (365 days)
build-error: 0 (30 days)
bash-5.2$

  • パッケージがあったけど,install-on-requestがゼロっていうのはどうなの...
  • パッケージをインストールする.

bash-5.2$ brew install pkcrack🆑
Error: pkcrack has been disabled because it is not maintained upstream!
bash-5.2$

  • 「pkcrackはアップストリームでメンテナンスされていないため、無効化されている!」というエラーが出た.
  • つまり,pkcrackは現在はHomeBrewではインストール出来ない.

公式サイトからソースコードをダウンロードしてビルドするも失敗

  • 公式サイトからソースコードを入手してビルドしてみる.

bash-5.2$ mkdir pkcrack🆑
bash-5.2$ cd pkcrack🆑
bash-5.2$ wget https://www.unix-ag.uni-kl.de/~conrad/krypto/pkcrack/pkcrack-1.2.2.tar.gz🆑
--2024-02-13 23:10:31--  https://www.unix-ag.uni-kl.de/~conrad/krypto/pkcrack/pkcrack-1.2.2.tar.gz
www.unix-ag.uni-kl.de (www.unix-ag.uni-kl.de) をDNSに問いあわせています... 131.246.124.83
www.unix-ag.uni-kl.de (www.unix-ag.uni-kl.de)|131.246.124.83|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 174208 (170K) [application/x-gzip]
`pkcrack-1.2.2.tar.gz' に保存中

pkcrack-1.2.2.tar.gz                 100%[==========================>] 170.12K   208KB/s 時間 0.8s

2024-02-13 23:10:34 (208 KB/s) - `pkcrack-1.2.2.tar.gz' へ保存完了 [174208/174208]

bash-5.2$

  • ファイルを確認.

bash-5.2$ ls -la🆑
total 172
drwxr-xr-x  3 ujpadmin staff     96  2 13 23:12 .
drwxr-xr-x 45 ujpadmin staff   1440  2 13 23:12 ..
-rw-r--r--  1 ujpadmin staff 174208  1  7  2003 pkcrack-1.2.2.tar.gz🈁
bash-5.2$

  • ファイルを展開する.

bash-5.2$ tar xfvz pkcrack-1.2.2.tar.gz🆑
x pkcrack-1.2.2/src/crc.c
x pkcrack-1.2.2/src/crc.h
x pkcrack-1.2.2/src/debug.c
x pkcrack-1.2.2/src/debug.h
x pkcrack-1.2.2/src/exfunc.c
x pkcrack-1.2.2/src/extract.c
x pkcrack-1.2.2/src/findkey.c
x pkcrack-1.2.2/src/headers.h
x pkcrack-1.2.2/src/keystuff.c
x pkcrack-1.2.2/src/keystuff.h
x pkcrack-1.2.2/src/main.c
x pkcrack-1.2.2/src/makekey.c
x pkcrack-1.2.2/src/mktmptbl.c
x pkcrack-1.2.2/src/mktmptbl.h
x pkcrack-1.2.2/src/pkcrack.h
x pkcrack-1.2.2/src/pkctypes.h
x pkcrack-1.2.2/src/readhead.c
x pkcrack-1.2.2/src/stage1.c
x pkcrack-1.2.2/src/stage1.h
x pkcrack-1.2.2/src/stage2.c
x pkcrack-1.2.2/src/stage2.h
x pkcrack-1.2.2/src/stage3.c
x pkcrack-1.2.2/src/stage3.h
x pkcrack-1.2.2/src/writehead.c
x pkcrack-1.2.2/src/zdmain.c
x pkcrack-1.2.2/src/zipdecrypt.c
x pkcrack-1.2.2/src/Makefile
x pkcrack-1.2.2/src/Makefile.emx
x pkcrack-1.2.2/src/Makefile.wat
x pkcrack-1.2.2/doc/CHANGES
x pkcrack-1.2.2/doc/KNOWN_BUGS
x pkcrack-1.2.2/doc/LIESMICH
x pkcrack-1.2.2/doc/README
x pkcrack-1.2.2/doc/README.W32
x pkcrack-1.2.2/doc/README.html
x pkcrack-1.2.2/doc/appnote.iz.txt
x pkcrack-1.2.2/doc/pkzip.ps.gz
x pkcrack-1.2.2/test/Makefile
x pkcrack-1.2.2/test/bug.zip
x pkcrack-1.2.2/test/test.sh
bash-5.2$

  • srcディレクトリ配下に移動してmakeする.

bash-5.2$ cd pkcrack-1.2.2/src/🆑
bash-5.2$ make🆑
gcc -O6 -Wall   -c -o crc.o crc.c
warning: optimization level '-O6' is not supported; using '-O3' instead
crc.c:24:13: warning: unused variable 'RCSID' [-Wunused-variable]
static char RCSID[]="$Id: crc.c,v 1.3 1997/09/18 18:07:24 lucifer Release1_2_1 $";
            ^
2 warnings generated.
gcc -O6 -Wall   -c -o mktmptbl.o mktmptbl.c
warning: optimization level '-O6' is not supported; using '-O3' instead
mktmptbl.c:58:5: error: implicitly declaring library function 'memset' with type 'void *(void *, int, uns
igned long)' [-Werror,-Wimplicit-function-declaration]
    memset(numEntries, 0, sizeof(numEntries));
    ^
mktmptbl.c:58:5: note: include the header <string.h> or explicitly provide a declaration for 'memset'
1 warning and 1 error generated.
make: *** [mktmptbl.o] Error 1
bash-5.2$

  • 調べるとmalloc関連のincludeの互換性に問題があり,ソースコードを編集する必要がある模様.
  • いくつかソースを変更してみたが,泥沼に入りそうだったので諦めた.

Githubからソースをダウンロードしてビルドする

  • ソースコードがgithubで配布されていることを知ったので,そこから入手してビルドする.
  • githubのURLはこちら.
  • GitHub - keyunluo/pkcrack: pkcrack with modern building tools
    • https://github.com/keyunluo/pkcrack
  • インストール手順を確認すると,cmakeが必要なのでHomeBrewでインストールする.
  • パッケージの確認

$ brew info cmake🆑
Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
==> cmake: stable 3.28.3 (bottled), HEAD
Cross-platform make
https://www.cmake.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c/cmake.rb
License: BSD-3-Clause
==> Options
--HEAD
    Install HEAD version
==> Caveats
To install the CMake documentation, run:
  brew install cmake-docs
==> Analytics
install: 136,814 (30 days), 419,937 (90 days), 1,357,653 (365 days)
install-on-request: 108,618 (30 days), 330,842 (90 days), 1,064,512 (365 days)
build-error: 585 (30 days)
[MacPro2013:ujpadmin 00:31:18 ~ ]
$

  • cmakeパッケージインストール.

$ brew install cmake🆑
==> Downloading https://formulae.brew.sh/api/formula.jws.json
################################ 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
################################ 100.0%
Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.28.3
################################ 100.0%
==> Fetching cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:d3219efe5909
################################ 100.0%
==> Pouring cmake--3.28.3.monterey.bottle.tar.gz
==> Caveats
To install the CMake documentation, run:
  brew install cmake-docs

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake
==> Summary
🍺  /usr/local/Cellar/cmake/3.28.3: 3,329 files, 60.4MB
==> Running `brew cleanup cmake`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
[MacPro2013:ujpadmin 00:31:46 ~ ]
$

  • 問題なくインストール出来た模様.
  • pkcrackのパッケージをgithubからcloneする.
bash-5.2$ git clone https://github.com/keyunluo/pkcrack🆑
Cloning into 'pkcrack'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 83 (delta 0), reused 2 (delta 0), pack-reused 76
Receiving objects: 100% (83/83), 147.92 KiB | 4.11 MiB/s, done.
Resolving deltas: 100% (15/15), done.
bash-5.2$

  • インストール手順通りに作業する.

bash-5.2$ cd pkcrack🆑
bash-5.2$ mkdir pkcrack/build🆑
bash-5.2$ cd pkcrack/build/🆑

  • cmakeを実行.

bash-5.2$ cmake ..🆑
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.0s)
-- Generating done (0.1s)
-- Build files have been written to: /Users/ujpadmin/bin/pkcrack/build🈁
bash-5.2$

  • ビルドファイルが書き出され,エラーは出ずに終了した模様.
  • 作成されたファイルを確認.

bash-5.2$ ls -la🆑
total 28
drwxr-xr-x 13 ujpadmin staff   416  2 14 00:53 .
drwxr-xr-x 17 ujpadmin staff   544  2 14 00:53 ..
-rw-r--r--  1 ujpadmin staff 14159  2 14 00:53 CMakeCache.txt
drwxr-xr-x 12 ujpadmin staff   384  2 14 00:53 CMakeFiles
-rw-r--r--  1 ujpadmin staff  6827  2 14 00:53 Makefile
-rw-r--r--  1 ujpadmin staff  2067  2 14 00:53 cmake_install.cmake
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 common
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 extract
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 findkey
drwxr-xr-x  2 ujpadmin staff    64  2 14 00:53 lib
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 makekey
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 pkcrack
drwxr-xr-x  5 ujpadmin staff   160  2 14 00:53 zipdecrypt
bash-5.2$
bash-5.2

  • makeする.

bash-5.2$ make🆑
[  4%] Building C object common/CMakeFiles/common.dir/crc.c.o
[  9%] Building C object common/CMakeFiles/common.dir/debug.c.o
[ 13%] Building C object common/CMakeFiles/common.dir/exfunc.c.o
[ 18%] Building C object common/CMakeFiles/common.dir/keystuff.c.o
[ 22%] Building C object common/CMakeFiles/common.dir/mktmptbl.c.o
[ 27%] Building C object common/CMakeFiles/common.dir/readhead.c.o
[ 31%] Building C object common/CMakeFiles/common.dir/stage1.c.o
[ 36%] Building C object common/CMakeFiles/common.dir/stage2.c.o
[ 40%] Building C object common/CMakeFiles/common.dir/stage3.c.o
[ 45%] Building C object common/CMakeFiles/common.dir/writehead.c.o
/Users/ujpadmin/bin/pkcrack/common/writehead.c:64:58: warning: format specifies
type 'unsigned long' but the argument has type 'int' [-Wformat]
  fprintf( stderr, "Write unknown signature: 0x%08lx\n", sigType );
                                               ~~~~~     ^~~~~~~
                                               %08x
1 warning generated.
[ 50%] Building C object common/CMakeFiles/common.dir/zipdecrypt.c.o
/Users/ujpadmin/bin/pkcrack/common/zipdecrypt.c:245:24: warning: logical not is
only applied to the left hand side of this comparison [-Wlogical-not-parenthes
es]
                err = (!read_ddesc(infile, 0) < 0);
                       ^                      ~
/Users/ujpadmin/bin/pkcrack/common/zipdecrypt.c:245:24: note: add parentheses a
fter the '!' to evaluate the comparison first
                err = (!read_ddesc(infile, 0) < 0);
                       ^
                        (                        )
/Users/ujpadmin/bin/pkcrack/common/zipdecrypt.c:245:24: note: add parentheses a
round left hand side expression to silence this warning
                err = (!read_ddesc(infile, 0) < 0);
                       ^
                       (                     )
/Users/ujpadmin/bin/pkcrack/common/zipdecrypt.c:245:47: warning: result of comp
arison of constant 0 with boolean expression is always false [-Wtautological-c
onstant-compare]
                err = (!read_ddesc(infile, 0) < 0);
                       ~~~~~~~~~~~~~~~~~~~~~~ ^ ~
2 warnings generated.
[ 54%] Linking C static library ../lib/libcommon.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ../lib/libcommon.a(d
ebug.c.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ../lib/libcommon.a(d
ebug.c.o) has no symbols
[ 54%] Built target common
[ 59%] Building C object pkcrack/CMakeFiles/pkcrack.dir/main.c.o
/Users/ujpadmin/bin/pkcrack/pkcrack/main.c:132:1: warning: return type of 'main
' is not 'int' [-Wmain-return-type]
void main( int argc, char **argv )
^
/Users/ujpadmin/bin/pkcrack/pkcrack/main.c:132:1: note: change return type to '
int'
void main( int argc, char **argv )
^~~~
int
1 warning generated.
[ 63%] Linking C executable /Users/ujpadmin/bin/pkcrack/bin/pkcrack
[ 63%] Built target pkcrack
[ 68%] Building C object findkey/CMakeFiles/findkey.dir/findkey.c.o
/Users/ujpadmin/bin/pkcrack/findkey/findkey.c:59:1: warning: return type of 'ma
in' is not 'int' [-Wmain-return-type]
void main( int argc, char **argv )
^
/Users/ujpadmin/bin/pkcrack/findkey/findkey.c:59:1: note: change return type to
'int'
void main( int argc, char **argv )
^~~~
int
1 warning generated.
[ 72%] Linking C executable /Users/ujpadmin/bin/pkcrack/bin/findkey
[ 72%] Built target findkey
[ 77%] Building C object zipdecrypt/CMakeFiles/zipdecrypt.dir/zdmain.c.o
/Users/ujpadmin/bin/pkcrack/zipdecrypt/zdmain.c:38:1: warning: return type of '
main' is not 'int' [-Wmain-return-type]
void main( int argc, char **argv )
^
/Users/ujpadmin/bin/pkcrack/zipdecrypt/zdmain.c:38:1: note: change return type
to 'int'
void main( int argc, char **argv )
^~~~
int
1 warning generated.
[ 81%] Linking C executable /Users/ujpadmin/bin/pkcrack/bin/zipdecrypt
[ 81%] Built target zipdecrypt
[ 86%] Building C object extract/CMakeFiles/extract.dir/extract.c.o
/Users/ujpadmin/bin/pkcrack/extract/extract.c:94:1: warning: return type of 'ma
in' is not 'int' [-Wmain-return-type]
void main(int argc, char *argv[])
^
/Users/ujpadmin/bin/pkcrack/extract/extract.c:94:1: note: change return type to
'int'
void main(int argc, char *argv[])
^~~~
int
1 warning generated.
[ 90%] Linking C executable /Users/ujpadmin/bin/pkcrack/bin/extract
[ 90%] Built target extract
[ 95%] Building C object makekey/CMakeFiles/makekey.dir/makekey.c.o
/Users/ujpadmin/bin/pkcrack/makekey/makekey.c:28:1: warning: return type of 'ma
in' is not 'int' [-Wmain-return-type]
void main( int argc, char **argv )
^
/Users/ujpadmin/bin/pkcrack/makekey/makekey.c:28:1: note: change return type to
'int'
void main( int argc, char **argv )
^~~~
int
1 warning generated.
[100%] Linking C executable /Users/ujpadmin/bin/pkcrack/bin/makekey
[100%] Built target makekey
bash-5.2$

  • たくさんwarningが出ているが,mail()関数の戻り値をvoidをintに変更したというものなので,動作に問題ないのでは?と思う.

bash-5.2$ find ../.. | grep pkctypes.h
../../include/pkctypes.h
bash-5.2$

  • 作成された実行ファイルを確認.

bash-5.2$ ls -la ../bin/🆑
total 392
drwxr-xr-x 12 ujpadmin staff   384  2 14 00:54 .
drwxr-xr-x 17 ujpadmin staff   544  2 14 00:53 ..
-rwxr-xr-x  1 ujpadmin staff 50840  2 14 00:54 extract
-rw-r--r--  1 ujpadmin staff 16384  2 14 00:53 extract.exe
-rwxr-xr-x  1 ujpadmin staff 51456  2 14 00:54 findkey
-rw-r--r--  1 ujpadmin staff 13824  2 14 00:53 findkey.exe
-rwxr-xr-x  1 ujpadmin staff 50072  2 14 00:54 makekey
-rw-r--r--  1 ujpadmin staff  9216  2 14 00:53 makekey.exe
-rwxr-xr-x  1 ujpadmin staff 87120  2 14 00:54 pkcrack
-rw-r--r--  1 ujpadmin staff 32768  2 14 00:53 pkcrack.exe
-rwxr-xr-x  1 ujpadmin staff 51664  2 14 00:54 zipdecrypt
-rw-r--r--  1 ujpadmin staff 19456  2 14 00:53 zipdecrypt.exe
bash-5.2$

  • 実行プログラムは問題なく作成されている模様.

demoを使ってpkcrackを実行する

  • demo用のファイルが配置されているので,それを利用して動作確認する.
  • buildディレクトリからbinディレクトリに移動して実行プログラムを確認.

bash-5.2$ cd ../bin🆑
bash-5.2$ ls -la🆑
total 392
drwxr-xr-x 12 ujpadmin staff   384  2 14 00:54 .
drwxr-xr-x 17 ujpadmin staff   544  2 14 00:53 ..
-rwxr-xr-x  1 ujpadmin staff 50840  2 14 00:54 extract
-rw-r--r--  1 ujpadmin staff 16384  2 14 00:53 extract.exe
-rwxr-xr-x  1 ujpadmin staff 51456  2 14 00:54 findkey
-rw-r--r--  1 ujpadmin staff 13824  2 14 00:53 findkey.exe
-rwxr-xr-x  1 ujpadmin staff 50072  2 14 00:54 makekey
-rw-r--r--  1 ujpadmin staff  9216  2 14 00:53 makekey.exe
-rwxr-xr-x  1 ujpadmin staff 87120  2 14 00:54 pkcrack
-rw-r--r--  1 ujpadmin staff 32768  2 14 00:53 pkcrack.exe
-rwxr-xr-x  1 ujpadmin staff 51664  2 14 00:54 zipdecrypt
-rw-r--r--  1 ujpadmin staff 19456  2 14 00:53 zipdecrypt.exe
bash-5.2$

  • pkcrackが動作するか確認する.

bash-5.2$ ./pkcrack -v🆑
Usage: ./pkcrack -c <crypted_file> -p <plaintext_file> [other_options],
where [other_options] may be one or more of
 -o <offset>    for an offset of the plaintext into the ciphertext,
            (may be negative)
 -C <c-ZIP>    where c-ZIP is a ZIP-archive containing <crypted_file>
 -P <p-ZIP>    where p-ZIP is a ZIP-archive containing <plaintext_file>
 -d <d-file>    where d-file is the name of the decrypted archive which
        will be created by this program if the correct keys are found
        (can only be used in conjunction with the -C option)
 -i    switch off case-insensitive filename matching in ZIP-archives
 -a    abort keys searching after first success
 -n    no progress indicator
bash-5.2$

  • demoディレクトリに移動してファイルを確認.

bash-5.2$ cd ../demo🆑
bash-5.2$ ls -la🆑
total 12
drwxr-xr-x  5 ujpadmin staff  160  2 14 00:53 .
drwxr-xr-x 17 ujpadmin staff  544  2 14 00:53 ..
-rw-r--r--  1 ujpadmin staff 1221  2 14 00:53 README.txt
-rw-r--r--  1 ujpadmin staff  767  2 14 00:53 README.zip
-rw-r--r--  1 ujpadmin staff  999  2 14 00:53 demo.zip
bash-5.2$

  • demoを実行してみる.

bash-5.2$ ../bin/pkcrack  -C demo.zip -c README.txt -P README.zip -p README.txt -d cracked.zip -a🆑
Files read. Starting stage 1 on Wed Feb 14 01:21:51 2024
Generating 1st generation of possible key2_624 values...done.
Found 4194304 possible key2-values.
Now we're trying to reduce these...
Done. Left with 11054 possible Values. bestOffset is 24.
Stage 1 completed. Starting stage 2 on Wed Feb 14 01:22:05 2024
Ta-daaaaa! key0=be5382c6, key1= 750a330, key2=e7d4dbfe
Probabilistic test succeeded for 605 bytes.
Ta-daaaaa! key0=be5382c6, key1= 750a330, key2=e7d4dbfe
Probabilistic test succeeded for 605 bytes.
Stage 2 completed. Starting zipdecrypt on Wed Feb 14 01:23:37 2024
Decrypting CRACK.txt (aafa572da93cf74237fbca5d)... OK!
Decrypting README.txt (83c0bfb47b83166f9f43a365)... OK!
Finished on Wed Feb 14 01:23:37 2024
bash-5.2$

  • コマンドのパラメータは次の通り.
    • -C [暗号化されたzipファイル]
    • -c [暗号化されたzipファイルの中で平文がわかるファイル]
    • -p [平文のファイル]
    • -d [出力先(復号したzipファイルの名前)]
  • DecryptingがOKとなっているのでパスワードが解読できた模様.
  • ファイルを確認.

bash-5.2$ ls -la🆑
total 16
drwxr-xr-x  6 ujpadmin staff  192  2 14 01:23 .
drwxr-xr-x 17 ujpadmin staff  544  2 14 00:53 ..
-rw-r--r--  1 ujpadmin staff 1221  2 14 00:53 README.txt
-rw-r--r--  1 ujpadmin staff  767  2 14 00:53 README.zip
-rw-r--r--  1 ujpadmin staff  975  2 14 01:23 cracked.zip🈁
-rw-r--r--  1 ujpadmin staff  999  2 14 00:53 demo.zip
bash-5.2$

  • cracked.zipというファイルが作成されている.このファイルがdemo.zipファイルのパスワードを解除したファイル.
  • zipinfoコマンドでZIPファイルを確認.

bash-5.2$ zipinfo cracked.zip🆑
Archive:  cracked.zip
Zip file size: 975 bytes, number of entries: 2
-rw-a--     3.1 fat       48 bX defN 17-Dec-07 11:46 CRACK.txt
-rw-a--     3.1 fat     1221 bX defN 17-Dec-07 12:45 README.txt
2 files, 1269 bytes uncompressed, 659 bytes compressed:  48.1%
bash-5.2$

  • 元のフィルのdemo.zipファイルをzipinfoで確認.

bash-5.2$ zipinfo demo.zip🆑
Archive:  demo.zip
Zip file size: 999 bytes, number of entries: 2
-rw-a--     3.1 fat       48 BX defN 17-Dec-07 11:46 CRACK.txt
-rw-a--     3.1 fat     1221 BX defN 17-Dec-07 12:45 README.txt
2 files, 1269 bytes uncompressed, 659 bytes compressed:  48.1%
bash-5.2$

ZIPファイルのファイルサイズが異なるが,中にあるファイルは同じ模様.

パスワード付きZIPファイルのdemo.zipをunzipしてみる.

bash-5.2$ unzip demo.zip🆑
Archive:  demo.zip
[demo.zip] CRACK.txt password:🆑
   skipping: CRACK.txt               incorrect password
   skipping: README.txt              incorrect password
bash-5.2$

  • パスワードがわからないのでUNZIP失敗.
  • 次にパスワード解除後のcracked.zipをUNZIPする.

ash-5.2$ unzip cracked.zip🆑
Archive:  cracked.zip
  inflating: CRACK.txt
replace README.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: r🆑
new name: README.txt.1
  inflating: README.txt.1
bash-5.2$

  • 既にREADME.txtがあるのでリネームしてUNZIPする.

bash-5.2$ ls -la🆑
total 24
drwxr-xr-x  8 ujpadmin staff  256  2 14 01:27 .
drwxr-xr-x 17 ujpadmin staff  544  2 14 00:53 ..
-rw-r--r--  1 ujpadmin staff   48 12  7  2017 CRACK.txt
-rw-r--r--  1 ujpadmin staff 1221 12  7  2017 README.txt.1
-rw-r--r--  1 ujpadmin staff 1221  2 14 00:53 README.txt
-rw-r--r--  1 ujpadmin staff  767  2 14 00:53 README.zip
-rw-r--r--  1 ujpadmin staff  975  2 14 01:23 cracked.zip
-rw-r--r--  1 ujpadmin staff  999  2 14 00:53 demo.zip
bash-5.2$



bash-5.2$ cat CRACK.txt🆑
Wow, You have cracked me!
The password is crack
bash-5.2$

  • パスワードはcrackだった模様.
  • README.TXTの中身は次の通り.
Hello,
This is the Plain Text File
Used by Pkcrack

With version 1.2 pkcrack has become one of those "fire & forget" programs. If you are a hacker of the experimental kind you may want to look at the "more complete instructions" below. Otherwise, stick to the "simple instructions".
The first thing you have to know is that this program applies a known plaintext attack to an encrypted file. A known-plaintext-attack recovers a password using the encrypted file and (part of) the unencrypted file. Please note that cryptographers use the word 'plaintext' for any kind of unencrypted data - not necessarily readable ASCII text.

Before you ask why somebody may want to know the password when he already knows the plaintext think of the following situations:

Usually there's a large number of files in a ZIP-archive. Usually all these files are encrypted using the same password. So if you know one of the files, you can recover the password and decrypt the other files.
You need to know only a part of the plaintext (at least 13 bytes). Many files have commonly known headers, like DOS .EXE-files. Knowing a reasonably long header you can recover the password and decrypt the entire file.
Back to the program.

こんにちは、
これはプレーンテキストファイルです
Pkcrackで使用

バージョン1.2で、pkcrackは "fire & forget "プログラムの1つになりました。もしあなたが実験的なハッカーなら、以下の「より完全な説明」を見た方がいいかもしれません。そうでなければ、"簡単な説明 "に従ってください。
最初に知っておかなければならないのは、このプログラムは暗号化されたファイルに既知の平文攻撃を適用する ということです。既知の平文攻撃は、暗号化されたファイルと暗号化されていないファイル(の一部)を使ってパスワードを復元します。暗号技術者は、暗号化 されていないあらゆる種類のデータ(必ずしも読み取り可能なASCIIテキストではない)を「平文」という言葉で表現することに注意してください。

平文をすでに知っているのに、なぜパスワードを知りたがるのかと尋ねる前に、次のような状況を思い浮かべてほしい:

通常、ZIPアーカイブには大量のファイルがあります。通常、これらのファイルはすべて同じパスワードを使って暗号化されています。そのため、ファイルの1つを知っていれば、パスワードを回復して他のファイルを復号化することができます。
あなたは平文の一部(少なくとも13バイト)だけを知っている必要があります。多くのファイルには、DOSの.EXEファイルのように、一般的に知られているヘッダーがある。それなりに長いヘッダを知ることで、パスワードを復元し、ファイル全体を復号化することができる。
プログラムに戻る。

www.DeepL.com/Translator(無料版)で翻訳しました。


広告スペース
Google