Kali信息收集
信息收集包括的内容:
域名信息、IP段、开放的端口、网站架构、文件目录结构、软件版本、WAD、旁站、C段……
1 域名
1.1 whois
└─$ whois --help
Usage: whois [OPTION]... OBJECT...
-h HOST, --host HOST connect to server HOST
-p PORT, --port PORT connect to PORT
-I 查询whois网站并参考其推荐
-H 隐藏法律免责声明
--verbose 打印操作该命令的执行过程
--no-recursion 禁用从注册表到注册表服务器的递归
--help 显示命令帮助后退出
--version 打印版本信息后退出
这些标志是由 whois.ripe.net 和 RIPE-like 服务器支持的:
-l 寻找有更少具体匹配的一个级别
-L 寻找所有更少具体匹配的级别
-m 寻找有更加具体匹配的一个级别
-M 寻找有更加具体的匹配的所有级别
-c 寻找包含 mnt-irt 属性的最小匹配
-x 精确匹配
-b return brief IP address ranges with abuse contact
(返回简短的IP地址范围与滥用联系)
-B 关闭对象过滤(显示 email 地址)
-G 关闭相关联对象的分组
-d 返回 DNS 反解授权对象
-i ATTR[,ATTR]... 对特定的属性( ATTR )进行逆向查询
-T TYPE[,TYPE]... 只寻找 TYPE 的对象
-K 只返回主键
-r 关闭联系信息的递归查询
-R 强制显示域对象的本地副本,即使它包含引用
-a 一并搜索所有的数据库镜像
-s SOURCE[,SOURCE]... 从 SOURCE 中搜索数据库镜像
-g SOURCE:FIRST-LAST 从串行的 FIRST 到 LAST 的 SOURCE 中查找更新
-t TYPE 请求 TYPE 对象的模板
-v TYPE 请求 TYPE 对象的详细模板
-q [version|sources|types] 询问制定服务器信息
但是whois
支持有限:
The Registry database contains ONLY .COM, .NET, .EDU domains and Registrars.
#注册表数据库只包含.com,.net,.edu域和注册表。
1.2 Maltego
Maltego可以通过域名注册、搜索引擎、社交网络、电子邮件等各种渠道搜集信息。
kali-linux-2022.1开始不再默认安装Maltego,需要安装只需在命令行输入
maltego
根据提示操作即可。
1.2.1 启动Maltego
-
启动Maltego很简单,从Kali工具里的信息收集分类就可以找到。第一次启动时需要选择版本,这里选择
Maltego CE(Free)
版。 -
登录需要注册,由于网络限制可能有时看不到注册窗口。
-
接下来选择
Privacy Mode
(隐私模式),共有两种模式可选:Normal
和Stealth
,默认为前者。
1.2.2 创建项目(Maltego中称为graph)
-
创建一个空项目:
-
Maltego的工作界面
1.2.3 简单测试
测试域名
testfire.net
,这是一个专门用来测试的域名。注意是域名而不是子域名!!!
-
添加节点
新建Graph后,在左侧的
Entity Palette
列表中找到Infarastructure
分类的Domain
选项,并将其拖曳到右侧的空白区域中,即可添加一个节点。 -
修改对象
空白区将看到一个域对象,双击并修改为
testfire.net
,即设置好了根节点。所有的测试都将围绕该根节点进行。 -
选择查询方式
选择上一步设置好了的根节点后,单击左侧区域的
Run View
选项卡,在Machines
菜单中罗列了集中比较经典的信息收集方式,最常用的是Footprint
系列,其中后面的数字越大,查询的深度越大。 -
单击选项右侧的▶按钮,即可开始搜集信息,结果如下
可以右击各个节点,尝试以下不同的操作。
1.3 sn0int
sn0int的功能:
1.通过证书透明日志(Certificate Transparency)和被动DNS技术来获取子域名
2.使用asn和geoip来获取IP地址
3.使用pgp密钥服务器和whois获取电子邮件信息
4.搜索为滚登录
5.在互联网上查找某人的个人资料
6.使用例如被动arp之类的扫描技术来枚举本地网络的设备
7.搜集有关电话号码的信息
8.利用Shodan实现安全检测绕过
9.从instagram配置文件中获取信息
1.3.1 安装
apt install debian-keyring
#执行以下三条命令,从密钥服务器下载密钥到可信任的密钥列表
gpg -a --export --keyring /usr/share/keyrings/debian-maintainers.gpg git@rxv.cc | apt-key add -
apt-key adv --keyserver keyserver.ubuntu.com --refresh-keys git@rxv.cc
echo deb http://apt.vulns.sexy stable main > /etc/apt/sources.list.d/apt-vulns-sexy.list
#更新源
apt update
#安装
apt install sn0int
启动sn0int
sn0int
安装模块
pkg quickstart
安装完成后显示有61个模块
1.3.2 sn0int命令
USAGE:
sn0int [OPTIONS] [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-w, --workspace <workspace> Select a different workspace instead of the default [env: SN0INT_WORKSPACE=]
SUBCOMMANDS:
activity Query logged activity
add Insert into the database
cal Calendar
completions Generate shell completions
delete Delete from the database
export Export a workspace for external processing
fsck Verify blob storage for corrupt and dangling blobs
help Prints this message or the help of the given subcommand(s)
install Install a module from the registry
login Login to the registry for publishing
new Create a new module
noscope Exclude entities from scope
notify Notify
paths Show paths of various file system locations
pkg The sn0int package manager
publish Publish a script to the registry
repl Run a lua repl
run Run a module directly
sandbox For internal use
scope Include entities in the scope
search Search in the registry
select Select from the database
stats Show statistics about your current workspace
workspace Manage workspaces
1.3.3 应用示例
这是一个示例的 流程
-
添加工作区
sn0int可同时执行多个任务,每个任务在各自的工作区完成。
#启动sn0int sn0int #添加工作区 workspace 自定义的工作区名(英文)
-
添加实体(一个域名变量)
add domain
注意是域名而不是子域名!!!
-
使用证书透明日志模块
use ctlogs run
可能扫出一些子域名。
-
扫描域名对应的DNS记录
use dns-resolve run
可以解析的会显示:resolvable=>true
-
检查可解析的子域名上是否存在web页面
use url-scan #列举子域名 target #列举可以解析的子域名 target where resolvable run
-
删除实体
noscope domains where value=xxx.com
恢复实体
scope domains where true
2 IP
2.1 ping
Packet Internet Groper因特网包探索器
Usage
ping [options] <destination>
Options:
<destination> 域名或IP地址
-a use audible ping
-A use adaptive ping
-B sticky source address
-c <count> 收到count次答复后停止 设置其为4就和Windows一样了
-D 打印时间戳
-d use SO_DEBUG socket option
-f flood ping
-h print help and exit
-I <interface> either interface name or address
-i <interval> seconds between sending each packet
-L 禁止组播报文环回
-l <preload> send <preload> number of packages while waiting replies
-m <mark> tag the packets going out
-M <pmtud opt> define mtu discovery, can be one of <do|dont|want>
-n no dns name resolution
-O report outstanding replies
-p <pattern> contents of padding byte
-q quiet output
-Q <tclass> use quality of service <tclass> bits
-s <size> use <size> as number of data bytes to be sent
-S <size> use <size> as SO_SNDBUF socket option value
-t <ttl> define time to live
-U print user-to-user latency
-v verbose output
-V print version and exit
-w <deadline> reply wait <deadline> in seconds
-W <timeout> time to wait for response
IPv4 options:
-4 use IPv4
-b allow pinging broadcast
-R record route
-T <timestamp> define timestamp, can be one of <tsonly|tsandaddr|tsprespec>
IPv6 options:
-6 use IPv6
-F <flowlabel> define flow label, default is random
-N <nodeinfo opt> use icmp6 node info query, try <help> as argument
2.2 nslookup
#查域名解析
nsllokup -type="NS" xxx.com
#查邮件解析
nslookup -type="MX" xxx.com
2.3 IP归属
3 端口
3.1 相关命令
#查看本机端口信息
netstat -an|grep 端口号
#远程机器端口
telnet IP port
wget IP port #会自动下载该IP端口下的文件,如果该端口提供了相关服务的话
nc -vz IP port
3.2 常见网络端口及服务
3.2.1 文件共享
端口号 | 服务 | 利用方向 |
---|---|---|
21/22/69 | FTP/SFTP文件传输协议 | 允许匿名上传、下载、嗅探和爆破 |
2049 | NFS服务(Network File System) | 配置不当 |
139 | Samba服务 | 爆破、未授权访问、远程代码和执行 |
389 | LDAP目录访问协议 | 注入、允许匿名访问、弱口令 |
3.2.2 远程连接
端口号 | 服务 | 利用方向 |
---|---|---|
22 | SSH远程连接 | 爆破、SSH隧道及内网代理转发、文件传输 |
23 | Telnet远程连接 | 爆破、嗅探、弱口令 |
3389 | RDP远程桌面 | Shift后门(Windows2003以下)、爆破 |
5900 | VNC | 弱口令爆破 |
5632 | PcAnywhere远程控制 | 抓密码、代码执行 |
3.2.3 web应用
端口号 | 服务 | 利用方向 |
---|---|---|
80/443/8080 | —— | web攻击、爆破、对应服务器版本漏洞 |
7001/7002 | Weblogic控制台 | Java反序列化、弱口令 |
8080/8089 | Jboss/resin/jetty/Jenkins | 反序列化、控制台弱口令 |
9090 | Websphere控制台 | Java反序列化、弱口令 |
4848 | Glassfish控制台 | 弱口令 |
1352 | Lotus domino邮件服务 | 弱口令、信息收集、爆破 |
10000 | Webmin-web控制面板 | 弱口令 |
3.2.4 数据库
端口号 | 服务 | 利用方向 |
---|---|---|
3306 | MySQL | 注入、提权、爆破 |
1433 | MSSSQL | 注入、提权、SA弱口令 |
1521 | Oracle | TNS爆破、注入、反弹shell |
5432 | PostgreSQL | 爆破、注入、弱口令 |
27017/27018 | MongoDB | 爆破、未授权访问 |
6379 | Redis | 未授权访问、弱口令 |
5000 | Sysbase/DB2 | 爆破、注入 |
3.2.5 网络常见协议
端口号 | 服务 | 利用方向 |
---|---|---|
53 | DNS域名系统 | 允许区域传送、DNS劫持、缓存投毒、欺骗 |
67/68 | DHCP服务 | 劫持、欺骗 |
161 | SNMP协议 | 爆破、搜集目标内网信息 |
3.2.6 特殊服务
端口号 | 服务 | 利用方向 |
---|---|---|
2181 | Zookeeper服务 | 未授权访问 |
8069 | Zabbix服务 | 远程执行、SQL注入 |
9200/9300 | Elasticsearch服务 | 远程执行 |
11211 | Memcached服务 | 未授权访问 |
512/513/514 | Linux Rexec服务 | 爆破、rlogin登录 |
873 | Rsync服务 | 匿名访问、文件上传 |
3690 | SVN服务 | SVN泄露、未授权访问 |
50000 | SAP Management Console | 远程执行 |
4 Nmap
官方文档:操作介绍
nmap [Scan Type(s)] [Options] {target specification}
4.1 目标类型
主机名、IP地址、网络等。
#1.扫描文件中的目标
-iL 文件名
#2.从给出的多个目标中随机挑选
-iR 多个目标
#3.设置黑名单
--exclude host1,host2...
#4.把指定文件中的目标设为黑名单
--excludefile 文件名
4.2 主机发现,如何扫描主机
-sL: List Scan - simply list targets to scan
-sn: Ping Scan - disable port scan
-Pn: Treat all hosts as online -- skip host discovery
-PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]: IP Protocol Ping
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>: Specify custom DNS servers
--system-dns: Use OS's DNS resolver
--traceroute: Trace hop path to each host跟踪每个主机的跳转路径
4.3 扫描技术
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
4.4 端口规则和扫描顺序
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
--exclude-ports <port ranges>: Exclude the specified ports from scanning
-F: Fast mode - Scan fewer ports than the default scan
-r: Scan ports consecutively - don't randomize
--top-ports <number>: Scan <number> most common ports
--port-ratio <ratio>: Scan ports more common than <ratio>
4.5 服务/版本识别
-sV: Probe open ports to determine service/version info
--version-intensity <level>: Set from 0 (light) to 9 (try all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity (for debugging)
4.6 使用LUA脚本扫描
-sC: equivalent to --script=default
--script=<Lua scripts>: <Lua scripts> is a comma separated list of directories,
script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
--script-args-file=filename: provide NSE script args in a file
--script-trace: Show all data sent and received
--script-updatedb: Update the script database.
--script-help=<Lua scripts>: Show help about scripts.
<Lua scripts> is a comma-separated list of script-files or script-categories.
--script=auth 绕过鉴权
--script=brute 暴破
--script=vuln 扫描漏洞
4.7 操作系统识别
-O: Enable OS detection
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
4.8 时间和性能设置
-T<0-5>: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
--max-retries <tries>: Caps number of port scan probe retransmissions.
--host-timeout <time>: Give up on target after this long
--scan-delay/--max-scan-delay <time>: Adjust delay between probes
--min-rate <number>: Send packets no slower than <number> per second
--max-rate <number>: Send packets no faster than <number> per second
4.9 防火墙绕过和伪装
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys 用诱饵掩盖扫描
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
--data <hex string>: Append a custom payload to sent packets
--data-string <string>: Append a custom ASCII string to sent packets
--data-length <num>: Append random data to sent packets
--ip-options <options>: Send packets with specified ip options
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
--badsum: Send packets with a bogus TCP/UDP/SCTP checksum 假IP校验
4.10 输出到文件
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
--reason: Display the reason a port is in a particular state
--open: Only show open (or possibly open) ports
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--noninteractive: Disable runtime interactions via keyboard
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--webxml: Reference stylesheet from Nmap.Org for more portable XML
--no-stylesheet: Prevent associating of XSL stylesheet w/XML output
4.11 其他
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
--unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
5 Zenmap
Zenmap是Nmap Security Scanner的官方图形用户界面(GUI)。
这里坑比较多,坑比较多,坑比较多……
确实比较多……
5.1 下载Zenmap
首先Kali2022.1
默认不安装Zenmap
了,似乎从2020版本开始就不默认安装了。使用apt install
也没用,所以想使用就必须到官网下载安装。
下载地址:Nmap官网
不用理会官方给出的安装命令,因为根本无效……
需要使用alien fakeroot
将其转换为deb
格式再进行安装。
apt-get install alien fakeroot
fakeroot alien zenmap-7.92-1.noarch.rpm
5.2 安装环境/依赖
-
首先更新源和程序
apt-get update apt-get upgrade
-
下载环境/依赖
wget http://security.ubuntu.com/ubuntu/pool/universe/p/pycairo/python-cairo_1.16.2-2ubuntu2_amd64.deb
wget http://azure.archive.ubuntu.com/ubuntu/pool/universe/p/pygobject-2/python-gobject-2_2.28.6-14ubuntu1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/p/pygtk/python-gtk2_2.24.0-5.1ubuntu2_amd64.deb
要按照顺序依次安装
-
安装依赖
python-cairo_1.16.2-2ubuntu2_amd64.deb
dpkg -i python-cairo_1.16.2-2ubuntu2_amd64.deb #这步应该不会报错
-
安装依赖
python-gobject-2_2.28.6-14ubuntu1_amd64.deb
dpkg -i python-gobject-2_2.28.6-14ubuntu1_amd64.deb #这步应该会报错,提示缺少libffi7
libffi7
下载地址:https://debian.pkgs.org/11/debian-main-amd64/libffi7_3.3-6_amd64.deb.htmlwget https://debian.pkgs.org/11/debian-main-amd64/libffi7_3.3-6_amd64.deb.html dpkg -i libffi7_3.3-6_amd64.deb
这时再执行命令安装
python-gobject-2_2.28.6-14ubuntu1_amd64.deb
即可顺利完成。 -
安装
python-gtk2_2.24.0-5.1ubuntu2_amd64.deb
dpkg -i python-gtk2_2.24.0-5.1ubuntu2_amd64.deb #会报错
首先,安装
libgdk-pixbuf2.0-0
,又报错:那么按照提示执行命令后,再次安装,完成了。
接下来切换
python
默认版本:update-alternatives --install /usr/bin/python python /usr/bin/python2 100 update-alternatives --install /usr/bin/python python /usr/bin/python3 150 #150的优先级高于100
切换时执行如下命令:
update-alternatives --config python #按照提示输入对应编号即可
再次执行安装命令:
dpkg -i python-gtk2_2.24.0-5.1ubuntu2_amd64.deb
依然报错了😡
5.3 不管了,安装Zenmap试试!
dpkg -i zenmap_7.92-2_all.deb
居然没有报错,顺利完成了……
其实不安装依赖也能完成Zenmap的安装,只是最后打不开而已🙄我是绝对不会告诉你我踩了多少坑的
本着最后一次尝试的态度,我执行了如下命令:
zenmap
发现居然运行成功了!!!经测试能用。
**写在后面:**其实是python缺少了gdk库,使用pip等方式安装好即可。这里不再演示了。
6 其他
6.1 CMS指纹识别
6.1.1 whatweb
Kali的命令行中执行如下语句:
whatweb -v 域名/IP
cmseek
#如果未安装可以根据提示进行安装
6.1.2 浏览器插件
-
Wappalyzer
https://www.wappalyzer.com
-
whatruns
https://www.whatruns.com
6.1.3 在线扫描
-
TideFinger
finger.tidesec.com
6.2 WAF
6.2.1 常见的WAF厂商
- 各种云
- 安全狗、宝塔、360、知道创宇、长亭、安恒
6.2.2 Kali工具
wafw00f IP
nmap IP --script=http-waf-detect.nse
sqlmap -u "xxx.com?id=1" --identify-waf
6.3 目录扫描
-
dirb