本指南的目标非常简单——教导任何对网络安全感兴趣的人,无论其知识水平如何,如何充分利用 Netlas.io。
本指南的目标是帮助任何对网络安全感兴趣的人,无论其知识水平如何,都能充分利用 Netlas 搜索工具。这是一篇长文。我们收集了尽可能多的简单用例,并演示了如何实现自动化。
⭐️ 给我们一个 Star 以表达感谢
👁️ 订阅以获取更新
Netlas 是一个搜索引擎,用于查找和分析互联网上所有 IP 地址和域名的信息。Netlas 具备一些攻击面管理功能,但本指南主要侧重于 Netlas 搜索工具及其在自动化中的使用方法。
Netlas 包含多种搜索工具:
我们将主要使用响应搜索(互联网扫描结果),但所有工具的工作方式相同。如果您了解如何使用响应搜索工具,就能应对其他任何工具。
在深入技术细节之前,我们先通过几个简单的示例看看 Netlas.io 是如何工作的。

打开 Netlas.io IP/域名信息 并输入域名或 IP。将显示以下信息:

如果您需要查找中文或其他国际化域名,请先将它们转换为 Punycode。例如:``` domain:*.xn--fiqs8s
你可以借助专门的在线工具来完成。例如 - [Charset.org](https://www.charset.org/punycode)
### 查找标题中包含特定单词的网站

打开 [Netlas.io 响应搜索](https://app.netlas.io/responses/) 并输入:```
http.title:g*thub
这将查找所有HTTP标题包含以"g"开头并以"thub"结尾的单词的服务器的结果。阅读下方关于使用星号的更多信息。
现在我们来了解更多关于 Netlas.io 中搜索查询的工作方式。
Netlas.io 基于 Elasticsearch,一个免费且开源的分布式RESTful搜索引擎。Netlas.io 中的搜索方法与其他基于Elasticsearch的数据库非常相似。

响应、DNS、IP和证书搜索允许你在搜索查询中使用过滤器(字段)。例如:``` http.body:netlas
[Try in Netlas](https://app.netlas.io/responses/?q=http.body%3Anetlas&page=1&indices=)
您可以使用此查询来查找在其 <body> HTML 标签中包含单词 "netlas" 的页面。
每种搜索类型的可用过滤器列表显示在页面右侧。

过滤器允许您根据许多不同参数搜索服务器。例如:
* `domain`
* `ip`
* `protocol`
* `certificate`
* `cve`
* `geolocation`(`city`、`continent`、`country`)
以及许多其他参数。
### 逻辑运算符
您可以在单个查询中使用多个过滤器,并使用逻辑运算符 `AND`、`OR`、`NOT` 组合它们。例如:```
http.title:netlas NOT port:443
如果你想在查询中组合多个条件,请使用括号:``` http.title:(netlas OR shodan) NOT port:443
[在Netlas中尝试](https://nt.ls/OrFOY)
### 范围
如果你使用数字值作为字段的值,你可以将其指定为一个从...到...的值(值范围的极限):```
ip:[173.194.222.0 TO 173.194.222.255]
或者仅标记值的上限或下限:``` host:"1.1.1.1" port:<=1000
[在 Netlas 中尝试](https://app.netlas.io/responses/?q=host%3A%221.1.1.1%22%20port%3A%3C%3D1000&page=1&indices=)
### 通配符
如果你不知道查询中某个字符的确切描述(例如,你不知道域名的确切区域或名称的拼写),你可以用一个星号替换它:```
domain:google.*
您也可以使用问号:``` domain:google.?
[Try in Netlas](https://app.netlas.io/responses/?q=domain%3Agoogle.%3F&page=1&indices=)
`*` - 多个符号,`?` - 单个符号。
你也可以在过滤器中使用星号。例如:```
\*.banner:database
该查询在所有横幅类型上同时进行搜索,并替代了多个过滤器:amqp.banner:、ftp.banner:、dns.banner:、telnet.banner:等。

如果你需要按字段的近似值进行搜索,而不是精确值(例如,页面标题包含所有与Joseph发音相近的名称),只需在查询中添加~:```
http.title:Joseph~
[在Netlas中尝试](https://app.netlas.io/responses/?q=http.title%3AJoseph~&page=1&indices=)
### 正则表达式
正则表达式是一个字符序列,允许你在源文档中搜索、检索和替换匹配特定模式的文本片段。例如:
* 任何电子邮件地址: ```text
([a-zA-Z0–9+._-]+@[a-zA-Z0–9._-]+\.[a-zA-Z0–9_-]+)
关于使用正则表达式的更多信息,请参见 Netlas Cookbook(您正在阅读的内容)中的示例以及以下链接:
正则表达式如何在 OSINT 中发挥作用。理论和一些使用 Google 表格的实践

您可以将结果(全部或选定字段)保存为 JSON 和 CSV 格式,以便按您喜欢的格式查看,或使用不同工具自动分析。

您可以根据不同的字段值对结果进行分组,以加快搜索速度。例如,按域名或地理位置分组。

您可以自由分享搜索结果的链接(无需注册即可打开,除非用户已超过 50 次免费请求的限制)。

另外请注意,您在个人资料页面上可以查看所有已执行的查询(链接位于右上角)。
Netlas.io 最重要的功能是帮助人们更快、更高效地开展网络安全研究。该服务提供 API(应用程序编程接口),允许您自动执行各种请求。
既可以将其实现为简单的几行 Python 或 Bash 脚本,也可以实现为复杂的多功能应用程序。
您可以在 Netlas Cookbook(您正在阅读的内容)或官方文档中阅读更多关于使用 Netlas API 的信息:
这是开始使用 API 的第一步。您甚至不需要付费订阅(每天免费提供 50 次请求)。只需前往个人资料页面。

您无需编写脚本或创建应用程序即可开始使用 Netlas API。只需使用您喜欢的 API 客户端进行测试即可。请参阅此处的说明。

与其他 API 类似,Netlas API 响应由标头和 JSON(JavaScript 对象表示法)格式的响应体组成。JSON 文件以键值格式包含数据,并可使用几乎任何编程语言进行分析。
如果您使用 Swagger,可以复制或下载响应体,并在任何文本编辑器或 JSON 分析器中查看。

一个在编写使用 Netlas API 的代码时会有用的小技巧。为了更快地理解 JSON 文件的结构并找到获取特定值的路径,请使用以下专用工具:
自动向 Netlas API 发送请求的最简单方法是使用专门设计的 Python 库(包)。
让我们通过一个简单的例子来看看它是如何工作的。Netlas Cookbook 中的所有代码示例都位于 scripts 文件夹中。您可以克隆此仓库并在您的设备上运行它们:```shell git clone https://github.com/netlas-io/netlas-cookbook
如果你之前从未运行过 Python 脚本,也不知道如何运行,可以先在 Gitpod 中打开 Netlas CookBook 仓库。Gitpod 是一个基于 Ubuntu(Linux 发行版)的云开发环境。只需在浏览器中打开此链接(使用你的 Github 账号登录):
[Run Netlas Cookbook in Gitpod](https://gitpod.io#https://github.com/netlas-io/netlas-cookbook)

使用 pip(Python 的包安装器)安装 Netlas Python 库。在命令行中输入:```shell
pip install netlas
检查安装。在命令行中输入:```shell netlas --help
运行 netlas_python_example.py:```shell
python3 scripts/netlas_python_example.py
当然,你也可以直接复制代码并保存到文件中。这是第一个示例的代码:```python import netlas
apikey = "YOUR API KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
port:7001netlas_query = netlas_connection.query(query="port:7001")
for response in netlas_query['items']: print(f"{response['data']['ip']}:{response['data']['port']}{response['data']['path']} [{response['data']['protocol']}]")
### 获取有用数据的响应键示例
上面提到,为了找到 API 响应的 JSON 补丁以获取所需数据,你可以使用特殊的在线应用程序(JSON 评估器)。为了让你的工作更轻松,下面列出了一些最常用的 Python 库响应键示例。```python
# Main domain/ip info
response['data']['uri']
response['data']['ip']
response['data']['http']['title']
response['data']['http']['meta']
response['data']['http']['body']
# Geo info
response['data']['geo']['continent']
response['data']['geo']['country']
response['data']['geo']['city']
response['data']['geo']['location']['lat']
response['data']['geo']['location']['long']
# Whois geo info
response['data']['whois']['net']['country']
response['data']['whois']['net']['address']
response['data']['whois']['net']['city']
response['data']['whois']['net']['contacts']['emails']
response['data']['whois']['net']['contacts']['phones']
# Http status and favicon ico info
response['data']['port']
response['data']['http']['status_code']
response['data']['http']['status_line']
response['data']['http']['favicon']['image']
response['data']['http']['favicon']['path']
# Basic CVE info
response['data']['cve'][0]['name']
response['data']['cve'][0]['description']
response['data']['cve'][0]['base_score']
response['data']['cve'][0]['has_exploit']
response['data']['cve'][0]['exploit_links']

在使用 Netlas Python 库时,正确指定要检索的数据类型非常重要。默认情况下,返回的是 response 类型,许多 Netlas CookBook 示例都使用它。
但对于某些任务,例如获取域名的 whoois 信息或在子网中搜索域名,您需要使用不同的数据类型。例如:```python netlas_query = netlas_connection.query(query='a:"163.114.132.0/24"',datatype="domain")
如果您认为某些查询没有返回应得的结果——只需尝试更改 **datatype** 参数的值。这很可能会有所帮助。
可用数据类型:
- **datatype="response"** 对应于可在 [Netlas 响应搜索](https://app.netlas.io/responses/) 中获得的结果。
- **datatype="domain"** 对应于可在 [Netlas DNS 搜索](https://app.netlas.io/domains/) 中获得的结果。
- **datatype="domain-whois"** 对应于可在 [Netlas 域名 Whois 搜索](https://app.netlas.io/whois_domains/) 中获得的结果。
- **datatype="ip-whois"** 对应于可在 [Netlas IP Whois 搜索](https://app.netlas.io/whois_ip/) 中获得的结果。
- **datatype="cert"** 对应于可在 [Netlas 证书搜索](https://app.netlas.io/certs/) 中获得的结果。
### Netlas CLI 工具

您也可以直接从命令行使用 Netlas Python 库。例如:```bash
netlas search "http.title:johnsmith" -f json >results.json
这个简单命令会搜索所有在Header中包含单词johnsmith的服务器,以JSON格式返回结果,并将结果存储在resutls.json文件中。
Netlas API的所有其他功能都可以用同样的方式使用。你可以从帮助信息(-h命令)和Netlas Cookbook(你现在正在阅读的内容)中的示例了解更多信息。``` Usage: netlas [OPTIONS] COMMAND [ARGS]...
Options: -h, --help Show this message and exit.
Commands: count Calculate count of query results. download Download data. host Host (ip or domain) information. indices Get available data indices. profile Get user profile data. savekey Save API key to the local system. search (query) Search query. stat Get statistics for query.
在运行不同的Netlas CLI工具命令之前,将API密钥保存在设置中:```bash
netlas savekey YOUR_API_KEY
We also have a Github repository with a couple of examples of automating various tasks using bash script and Netlas CLI tools:
Netlas API 有许多方法,但最常用的方法是 search 和 download。它们非常相似,但仍然存在一些差异。
search 方法一次加载一页结果(20 项),最多允许加载 200 页(20*200=4000 项)。download 方法下载所有结果(但执行需要更多资源)。
还有一个 host 方法,它仅返回关于特定域或IP的最基本信息(与其他方法一样,不需要指定数据类型):```bash netlas host "51.159.153.170"
### 额外的请求参数
Netlas API 允许您通过额外参数灵活调整请求返回的数据。例如:
* indices - 对应于特定索引日期的 ID。要查找特定日期的 ID,请打开 app.netlas.io,点击搜索查询输入栏右侧的日历,选择您感兴趣的日期,并观察浏览器地址栏 URL 中 indices 参数的变化。
* start - 结果页码(默认为 0)
* fields - 要包含在结果中的字段名称(默认为所有字段)。这对于加速和优化大量请求的代码非常有用。
### 使用 Python 发起请求(不使用 Netlas Python 库)
有些情况下,您可能发现使用 Netlas Python 库不如使用许多开发者熟悉的标准 Python 请求包方便:
在命令行中输入:```bash
python scripts/python_example.py
python_example.py 的源代码:```python import requests
response = requests.get("https://app.netlas.io/api/domains/?q=ivanov.com&source_type=include&start=0&fields=*",{'X-API-Key': 'YOUR API KEY'})
print(response.json())
但是,Netlas Python Library 仍然是更优选择,因为它专为处理查询过程中的各种问题(错误、长时间等待等)而设计。
### 其他编程语言的示例
虽然我们推荐使用 Python Library 来自动化 Netlas 搜索,但值得注意的是,Netlas API 可以集成到大多数使用各种技术栈的应用程序中。关键是要能够进行 **REST 请求** 并 **解析 JSON** 数据。
以下是一些不同流行编程语言的示例。
#### NodeJS <!-- omit in toc -->

在命令行中输入:```bash
node scripts/node_example.js
如果你没有使用 Gitpod,你应该在你的设备上安装 NodeJS。
nodejs_example.js 的源代码:```javascript fetch('https://app.netlas.io/api/domains/?q=ivanov.com&source_type=include&start=0&fields=*', { headers: { "X-API-Key": "YOUR_API_KEY", }, }) .then((response) => response.text()) .then((body) => { var jsonArray = JSON.parse(body); console.log(jsonArray['items'][0]); });
#### Ruby <!-- omit in toc -->

在命令行中输入:```bash
ruby scripts/ruby_example.rb
如果你没有使用 Gitpod,你应在设备上安装 Ruby。
ruby_example.rb 的源代码:```ruby require 'net/http' require 'uri' require 'json'
uri = URI("https://app.netlas.io/api/domains/?q=ivanov.com&source_type=include&start=0&fields=*") req = Net::HTTP::Get.new(uri) req['X-API-Key'] = "YOUR_API_KEY"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
jsonArray = JSON.parse(res.body)
puts jsonArray['items'][0]['data']['domain']
#### Bash <!-- omit in toc -->

在命令行中输入:```bash
bash scripts/bash_example.sh
bash_example.sh 的源代码:```
curl -X 'GET'
'https://app.netlas.io/api/domains/?q=ivanov.com&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[0].data.last_updated
### JQ 工具
注意,在上面的示例中,使用了 JQ 工具从 JSON 数据中提取字段。
它有时被称作“像 sed 处理 JSON 数据一样”。对于处理任何 JSON 数据来说,它是一个非常方便的工具。以下是一些语法示例。
打印 JSON 数组的第一项:```
.items[0]
打印 JSON 数组的所有项:``` .items[]
输出 JSON 数组中第一个项目的所有 'data' 子项:```
.['items'][0]['data'][]
打印 JSON 数组中每个项目的所有子子项目:``` .items[].data.technical[]
您可以在JQ这里阅读更多信息(我建议特别关注数据筛选部分):[JQ实用工具文档](https://jqlang.github.io/jq/)
### 用于编写代码的AI工具

如果您在定制Netlas Cookbook示例时遇到任何问题,我们建议您向AI工具寻求帮助,以改进和编写代码。例如:
[ChatGPT](https://chatgpt.com)
[Code Llama](https://huggingface.co/spaces/codellama/codellama-playground)
[You.com](https://you.com/)
在使用此类服务时,您只需用文字描述您希望通过代码解决的任务。
### 代码检查工具

当您根据自己的需求重新改写Netlas Cookbook示例时,可能会发现代码因某些错误而无法运行。专门的在线工具可以帮助您发现并修复这些错误:
[ExtendsClass Python Tester](https://extendsclass.com/python-tester.html)
[Snyk](https://snyk.io/code-checker/python/)
如果您不想将代码复制到第三方服务,也可以使用Pylint(静态代码分析器)在您自己的设备上检查代码错误:
[Pylint Python包](https://pypi.org/project/pylint/)
## 使用Netlas.io进行OSINT(开源情报)

Netlas.io可以帮助您收集某个域名或公司的数据,以及在互联网上查找某个人的提及信息(或任何人的提及)。
它还可以用于查找旧版本的网页(类似于Wayback Machine)。
### 在WHOIS联系人中搜索人员的昵称或电子邮件
大多数情况下,WHOIS数据仅包含注册域名的公司的联系信息。但有时也可能包含感兴趣人员的个人联系方式。以下查询可以帮助您找到它们。
*此方法可能需要付费订阅。* [查看价格](https://netlas.io/pricing/)
**搜索查询示例**
```
whois.related_nets.contacts.emails:sweetwater
API请求示例
Netlas CLI工具:```bash netlas search "whois.related_nets.contacts.emails:sweetwater*" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=whois.related_nets.contacts.emails%3Asweetwater*&fields=' \
-H 'accept: application/json' \
-H 'X-API-Key: aqkd8L4MR93Tkcaz2UXDXrRleV8Vlvbv' | jq .items[].data.uri
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/osint/whois_email_search.py
脚本/osint/whois_email_search.py的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `whois.related_nets.contacts.emails:sweetwater`
netlas_query = netlas_connection.query(query="whois.related_nets.contacts.emails:sweetwater*")
# iterate over data and print: URL, Country, Related nets data
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['geo']['country'])
print (response['data']['whois']['related_nets'])
Netlas 允许您在标题和网页的 HTML 代码中搜索特定单词的提及。您可以通过精确匹配、近似匹配(请参阅模糊查询部分)进行搜索,并将不确定的字符替换为星号。
搜索查询示例
```
http.title:sweetwater OR http.body:sweetwater
[在Netlas中尝试](https://app.netlas.io/responses/?q=http.title%3Asweetwater%20OR%20http.body%3Asweetwater&page=1&indices=)
**API请求示例**
Netlas CLI Tools:```bash
netlas search "http.title:sweetwater OR http.body:sweetwater" -f json
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=whois.related_nets.contacts.emails%3Asweetwater*&fields='
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/osint/title_body_search.py
scripts/osint/title_body_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.title:sweetwater OR http.body:sweetwaternetlas_query = netlas_connection.query(query="http.title:sweetwater OR http.body:sweetwater*")
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['uri']) print (response['data']['http']['title'])
### 在公司网站的子域名上搜索“Juicy Info Files”

多年来,Metagoofil 一直是 OSINT 从业者中流行的工具。它通过 Google 搜索公司网站上的文档文件(pdf, xlsx, docx 等)并分析其元数据。
而未被 Google 索引的内容,可以使用 Netlas 找到,然后下载到本地,再通过 [MetaDetective](https://github.com/franckferman/MetaDetective) 工具进行分析。```
uri:*lidl.* AND http.body:pdf
你可以将 uri: 过滤器替换为 domain: 和 host:(我建议在使用这三种过滤器时始终比较结果)。
你也可以根据你要查找的内容,搜索各种文件扩展名。例如:``` http.body:xls http.body:xlsx http.body:doc http.body:docx http.body:ppt http.body:pptx http.body:mdb http.body:csv http.body:sql http.body:sqlite
**API 请求示例**
Netlas CLI Tools:```bash
netlas search "uri:*lidl.* AND http.body:pdf"
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=uri%3A*lidl.*%20AND%20http.body%3Apdf&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.domain
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/osint/juicyinfo_search.py
脚本源码 scripts/osint/juicyinfo_search.py:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
uri:*lidl.* AND http.body:pdfnetlas_query = netlas_connection.query(query='uri:lidl. AND http.body:pdf')
for response in netlas_query['items']: print (response['data']['uri']) print (response['data']['http']['body'])
In order to automate links to PDF documents from the web page body you can use the Python [Re](https://docs.python.org/3/library/re.html) package.
### Phone Number Mentions Search
As with nicknames and emails, you can also look for mentions of a phone number in the code of web pages or WHOIS contact information.
We single out this task as a separate example, because searching for a phone number is complicated by the fact that it can be written in different formats.
**Search query example**
```
http.body:1?234?567?89?99 OR http.body:12345678999 OR http.body:1234?5678?999
在发出请求时,您应考虑所用国家接受的电话号码记录格式,该国家拥有您感兴趣的号码。
API请求示例
Netlas CLI Tools:```bash netlas search "http.body:1?234?567?89?99 OR http.body:12345678999 OR http.body:1234?5678?999" -f json
别忘了,你不仅可以在页面正文中搜索电话号码,还可以在 WHOIS 联系信息中进行搜索。这可以通过使用过滤器 **whois.related_nets.contacts.phones:** 来实现。
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=http.body%3A1%3F234%3F567%3F89%3F99%20OR%20http.body%3A12345678999%20OR%20http.body%3A1234%3F5678%3F999&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' jq .items[].data.uri
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/osint/phonenumber_search.py
scripts/osint/phonenumber_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.body:1?234?567?89?99 OR http.body:12345678999 OR http.body:1234?5678?999`
netlas_query = netlas_connection.query(query="http.body:1?234?567?89?99 OR http.body:12345678999 OR http.body:1234?5678?999")
# iterate over data and print: ip, url
for response in netlas_query['items']:
print (response['data']['ip'])
print (response['data']['uri'])
假设你是一名音乐人,想要找到所有发布了你曲子的网站。可以通过搜索提及你名字且包含指向.mp3文件链接的页面来实现。
搜索查询示例
```
(http.title:alla OR http.body:alla) AND http.body:*.mp3
[Try in Netlas](https://nt.ls/HEhJj)
**API请求示例**
Netlas CLI工具:```bash
netlas search "(http.title:alla OR http.body:alla) AND http.body:*.mp3" -f json
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=(http.title%3Aalla%20OR%20http.body%3Aalla)%20AND%20http.body%3A*.mp3&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.http.title
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/osint/file_mentions_search.py
scripts/osint/file_mentions_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
(http.title:alla OR http.body:alla) AND http.body:*.mp3netlas_query = netlas_connection.query(query="(http.title:alla OR http.body:alla) AND http.body:*.mp3")
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['uri']) print (response['data']['http']['title'])
### 域名WHOIS信息收集
WHOIS是一个全球性的公共数据库,存储着世界上所有已注册域名的信息。
**搜索查询示例**

使用 [WHOIS域名搜索](https://app.netlas.io/whois_domains/)```
github.com
API 请求示例
Netlas CLI Tools:```bash netlas host github.com -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/whois_domains/?q=github.com&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.technical.street
代码示例(Netlas Python库)

在命令行中运行:```bash python scripts/osint/whois_search.py
scripts/osint/whois_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from whois for google.com domain
netlas_query = netlas_connection.query(query="google.com",datatype="whois-domain")
# iterate over data and print: owner name
for response in netlas_query['items']:
print (response['data']['technical']['name'])
<address>标签位于网页的<head>标签内,可能包含物理地址。使用此标签进行搜索,您可以找到与特定街道关联的网站,有时甚至能找到特定建筑物。
搜索查询示例
```
http.contacts.address:kirby
[在 Netlas 中尝试](https://app.netlas.io/responses/?q=http.contacts.address%3Akirby&page=1&indices=)
您也可以使用 http.contacts.email: 用于电子邮件搜索。
**API 请求示例**
Netlas CLI Tools:```bash
netlas search "http.contacts.address:kirby" -f json
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=http.contacts.address%3Akirby&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.http.contacts
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/osint/contacts_search.py
scripts/osint/contacts_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.contacts.address:kirbynetlas_query = netlas_connection.query(query="http.contacts.address:kirby")
for response in netlas_query['items']: print (response['data']['uri']) print (response['data']['http']['contacts'])
### 在 Meta 标签中搜索作者姓名
`<meta>` 标签位于网页的 `<head>` 标签内,包含最重要的关键词、描述、各类服务信息以及作者姓名。
通过 meta 标签(http.meta)搜索昵称和姓名,比搜索整个 HTML 代码(http.body)能更快找到与特定个人相关的网站。
**搜索示例**
```
http.meta:nazar
API请求示例
Netlas CLI工具:```bash netlas search "http.meta:nazar" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=http.meta%3Anazar&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.http.meta
代码示例(Netlas Python库)

在命令行中运行:```bash python scripts/osint/author_meta_search.py
scripts/osint/author_meta_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.meta:nazar`
netlas_query = netlas_connection.query(query="http.meta:nazar")
# iterate over data and print: ip, url
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['http']['title'])
print (response['data']['http']['meta'])
除了作者姓名外,meta标签可以包含多种信息:编码、语言、搜索引擎机器人索引页面的权限、社交网络链接卡片文本、OpenGraph元数据等等。以下是一些可能包含调查有用信息的meta标签示例:
<meta name="description"> - 网页内容描述。<meta name="keywords"> - 描述网页内容的关键词。<meta name="generator"> - 用于生成页面内容的工具名称(有助于搜索CMS和托管平台)。<meta name="copyright"> - 网页内容版权所有者(个人或公司)的名称。查找个人或公司信息的另一个重要步骤是搜索其出现在FTP服务器横幅文本中的情况。找到的服务器的IP地址有可能是查找与目标个人或公司相关的其他站点的关键。如果运气极好,还可能在那里的文件(如果FTP服务器是开放的)中找到有趣的内容。
搜索查询示例
```
ftp.banner:"Collado"
如果需要通过其他参数(如城市或IP地址范围)搜索FTP服务器,请使用 `prot7:ftp` 过滤器。
[在 Netlas 中尝试](https://app.netlas.io/responses/?q=ftp.banner%3A%22Collado%22%20&page=1&indices=)
**API 请求示例**
Netlas CLI 工具:```bash
netlas search 'ftp.banner:"Collado"' -f json
注意,当查询中使用双引号时,查询本身应写在单引号内。
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=ftp.banner%3A%22Collado%22&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/osint/ftp_banner_search.py
scripts/osint/ftp_banner_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
ftp.banner:"Collado"netlas_query = netlas_connection.query(query='ftp.banner:"Collado"')
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['uri']) print (response['data']['ftp']['banner'])
### 搜索SSL证书中的联系人信息

SSL 证书是一种数字证书,用于验证网站身份并允许使用加密连接。它可能包含所有者的信息:联系人姓名、组织名称、国家,有时甚至包括地址和邮政编码。你可以使用以下过滤器(以及许多其他过滤器)来搜索这些信息:
- `certificate.issuer.email_address`
- `certificate.issuer.given_name`
- `certificate.issuer.organization`
- `certificate.issuer.postal_code`
- `certificate.issuer.street_address`
- `certificate.issuer.surname`
让我们尝试找到证书中街道地址包含特定单词的 IP 地址:```
certificate.issuer.street_address:*mcgill*
API 请求示例
Netlas CLI Tools:```bash netlas search "certificate.issuer.street_address:mcgill" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=certificate.issuer.street_address%3A*mcgill*&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' jq .items[].data.uri
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/osint/certificates_search.py
scripts/osint/certificates_search.py的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `certificate.issuer.street_address:*mcgill*`
netlas_query = netlas_connection.query(query="certificate.issuer.street_address:*mcgill*")
print (type(netlas_query))
# iterate over data and print: ip, url, cetificate issuer
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['certificate']['issuer'])
Archive.org 一直被 OSINT 专家用来搜索网站和社交媒体资料页面的旧版本,以查找现已删除的联系信息和其他信息。
但不幸的是,archive.org 并未保存所有网站的副本,而且保存的频率也不高(有些网站每年只保存几次甚至更少)。
但 Netlas 也从 2021 年开始保存网站的旧版本!
以下过滤器最常用于搜索网站:``` http.title:"github.com"
domain:github.com
host:github.com

如果您点击搜索查询输入框右侧最外侧的图标,将会看到选择扫描日期的菜单。您可以使用它来过滤特定日期保存的站点HTML代码。

要查看站点的外观,请将"body"字段(响应选项卡)的内容复制到任何文本编辑器中,并从HTML代码中删除\t\r\n字符。

之后,将代码复制到在线HTML预览工具中,例如 [Code beautify](https://codebeautify.org/htmlviewer)。或者直接将文件保存为HTML格式,然后在浏览器中打开。
### 9种搜索相关网站的方法

在收集个人或公司的信息时,找到尽可能多的可能与它们相关的网站非常重要。使用Netlas至少有5种方法可以做到这一点。
1. 各种服务的ID(分析、广告系统、与社交网络和发布系统集成的应用程序)。它们的重叠可能表明涉及同一个人或团队。几个例子:
Google Analytics:```
http.tracker.google_analytics:"G-X82FSVSMTV"
谷歌标签管理器:``` http.tracker.google_analytics:"GTM-N6462KFQ"
AddThis:```
http.body:"AT-ra-500bcd681b192302"
Facebook Pixel:``` http.tracker.facebook_pixel:317853189093681
Yandex Metrika```
http.tracker.yandex_metrica:89723437
亚马逊发布者服务:``` http.body:APS-XXXX
是的,这些信息都可以在某些网站的代码中找到。
以及大量其他标识符,这些标识符通常出现在 HTML 代码的顶部(但有时也散布在整个代码中)。
[在 Netlas 中尝试](https://nt.ls/BCrw9)
2. 联盟计划的 ID(也可使用 http.body 进行搜索)。你可以在个人发布到其他网站或社交网络中的联盟链接里找到它们。这些通常表现为以下 URL 参数(及类似形式):```
aff_fcid=
user_id=
partner_id=
ref_id=
```
"GitHub, Inc."
[在 Netlas 中尝试](https://app.netlas.io/whois_domains/?q=%22GitHub%2C%20Inc.%22&page=1&indices=)
4. 在 DNS Netlas 搜索中按邮件服务器搜索
```
mx:*.parklogic.com
```
ns:ns?.parklogic.com
[在 Netlas 中尝试](https://app.netlas.io/domains/?q=mx%3A*.parklogic.com&page=1&indices=)
6. 文件(主要是用户标志和头像)提及搜索 [->](https://github.com/netlas-io/netlas-cookbook#search-file-mentions-looking-for-content-that-may-be-infringing-on-copyrights)
7. 子域名搜索 [->](https://github.com/netlas-io/netlas-cookbook#search-subdomains)
8. Whois 联系人搜索(在 Netlas 响应中搜索) [->](https://github.com/netlas-io/netlas-cookbook#search-persons-nickname-or-email-in-whois-contacts)
9. Favicon 搜索 [->](https://github.com/netlas-io/netlas-cookbook#favicon-search)
## 爬取(从网页正文中提取数据)
Netlas API 是收集联系人和其他网站数据的优秀工具。首先,它允许您快速完成。其次,它不需要使用代理。第三,它允许您从当前不可用的网站收集数据。
然而,它也有一些缺点:Netlas 只扫描网站的主页,一些稀有网站由于保护措施没有被包含在它的数据库中。但它仍然非常有用。
有三种主要的爬取方法:从 HTML 标签和 CSS 选择器中收集信息、使用正则表达式提取数据以及 AI 爬取。让我们仔细看看前两种。
### Beatifulsoup 包
[Beatifulsoup](https://pypi.org/project/beautifulsoup4/) 是世界上最流行的 Python 包之一,用于解析 HTML 代码和 XML 文件。让我们尝试使用它来提取页面标题(从 \<h1> 标签,而不是 \<title> 标签)。
首先,安装包:```bash
pip install beautifulsoup4
并运行 scripts/osint/scraping_beatifulsoup.py:```bash python scripts/osint/scraping_beatifulsoup.py

脚本 scripts/osint/scraping_beatifulsoup.py 的源代码:```python
import netlas
from bs4 import BeautifulSoup
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.body:shop`
netlas_query = netlas_connection.query(query="http.body:shop")
# iterate over data and print: URL, h1 tags from body
for response in netlas_query['items']:
print (response['data']['uri'])
soup = BeautifulSoup(response['data']['http']['body'], "html.parser")
try:
print(soup.find("h1").get_text())
except Exception:
print("no h1 tags")
pass
你可以以类似的方式从网页的其他元素中提取数据:``` soup.find("h3").get_text() soup.find("id='loginform'").get_text() soup.find("class='forms'").get_text() soup.find("href='https://example.com'").get_text()
If you want to find all elements of a certain type use the find_all() method.
### Re 包
[Re](https://docs.python.org/3/library/re.html) 是一个预安装的 Python 包,用于使用正则表达式搜索和检索数据。它对于从网页中提取联系信息以及许多其他任务非常有用。让我们看一个它如何工作的例子。
运行 scripts/osint/scraping_re.py:```bash
python scripts/osint/scraping_re.py

scripts/osint/scraping_re.py 的源代码:```python import netlas import re
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.body:shopnetlas_query = netlas_connection.query(query="http.body:shop")
for response in netlas_query['items']: print (response['data']['uri']) emails = re.findall("[a-zA-Z0-9-.]+@[a-zA-Z0-9-.]+", response['data']['http']['body']) try: print(emails) except Exception: print("no emails") pass
同样地,你可以提取链接、电话号码、加密货币钱包地址等。现成模式可以在正则表达式库中找到:
[Regex Lib](https://regexlib.com/)
[UI Bakery Regex Library](https://uibakery.io/regex-library)
[Regex 101](https://regex101.com/)
### 其他用于抓取的 Python 包
Beautiful Soup 和 Re 包只是使用 Python 从网页抓取数据的众多工具之一。以下是更多此类包的示例:
* [Scrapy](https://pypi.org/project/Scrapy/):它主要是一个爬虫(通过链接遍历网站页面的工具),除此之外,它还具有强大的从网页提取数据的能力。
* [Selenium](https://pypi.org/project/selenium/):一个用于自动化浏览器体验的工具。允许你从 JavaScript 生成的内容中提取数据。
* [Lxml](https://pypi.org/project/lxml/):用于抓取和验证 XML 文件的工具。
* [PDFtoText](https://pypi.org/project/pdftotext/) - 用于从 PDF 文件中提取文本内容的工具。
* [pyChatGPT](https://pypi.org/project/pyChatGPT/) - 非官方的与 CHATGP 交互的包(不需要 OpenAI API 密钥),允许使用 AI 分析文本信息。
## 使用 Netlas.io 进行加密货币调查
Netlas 为专门研究加密货币犯罪的研究人员提供了绝佳的机会。首先,它可以用来搜索钱包地址和交易编号的引用。其次,它可以用来搜索存在漏洞的矿场、节点以及其他与加密基础设施相关的服务器。
### 搜索矿场

Antminer 矿场由 Bitmain 于 2013 年首次发布,是世界上最受欢迎的矿机型号系列之一。你可以通过 www_authenticate 标头中是否存在 "antMiner" 字样来找到它们。```
http.headers.www_authenticate:antMiner
您还可以搜索其他类型的矿场。例如:``` http.headers.www_authenticate:XMR-Stak-Miner
尝试组合不同的过滤条件,以及词语“矿工/挖矿”和加密货币名称。
**API请求示例**
Netlas CLI 工具:```bash
netlas search "http.headers.www_authenticate:antMiner"
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=http.headers.www_authenticate%3AantMiner&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.uri
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/crypto/mining_farms_search.py
scripts/crypto/mining_farms_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.headers.www_authenticate:antMinernetlas_query = netlas_connection.query(query='http.headers.www_authenticate:antMiner')
for response in netlas_query['items']: print (response['data']['uri']) print (response['data']['http']['headers'])
### 搜索被加密挖矿软件感染的网站

Coinhive,一个允许网站(大多数是被黑客入侵的)利用访问者的计算机来挖掘加密货币的服务,于2019年关闭。但尽管如此,指向它的链接仍然嵌入在世界各地的许多网站中。让我们尝试找到它们:```
http.body:coinhive.min.js domain:*
请注意,我们使用 domain:* 过滤器专门查找站点,而非所有设备。
同样地,你可以搜索感染了其他加密货币挖矿程序(以及其他在用户端执行的恶意代码)的站点。
API 请求示例
Netlas CLI 工具:```bash netlas search "http.body:coinhive.min.js domain:*"
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=http.body%3Acoinhive.min.js%20domain%3A*&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.uri
代码示例 (Netlas Python 库)

在命令行中运行:```bash python scripts/crypto/search_sites_injected_with_miners.py
源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.body:coinhive.min.js domain:*`
netlas_query = netlas_connection.query(query='http.body:coinhive.min.js domain:*')
# iterate over data and print: uri
for response in netlas_query['items']:
print (response['data']['uri'])

比特币节点使用端口8333进行TCP连接。因此,使用"port:"搜索过滤器可以轻松找到它们。``` port:8333 cve:*
注意我们使用 "cve:*" 过滤器来查找存在漏洞的服务器。
**API请求示例**
Netlas CLI工具:```bash
netlas search "port:8333 cve:*"
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=port%3A8333%20cve%3A*&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.uri
**代码示例 (Netlas Python 库)**

在命令行中运行:```bash
python scripts/crypto/search_bitcoin_nodes.py
scripts/crypto/search_bitcoin_nodes.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
port:8333 cve:*netlas_query = netlas_connection.query(query='port:8333 cve:*')
for response in netlas_query['items']: print (response['data']['uri']) print (response['data']['cve'][0]['name']) print (response['data']['cve'][0]['description'])
## 使用 Neltas 进行渗透测试
Netlas.io 允许您搜索具有多种不同类型漏洞的网站。这可以通过漏洞编号(CVE-...)、服务器上安装的软件名称、页面标题中的特定词语以及其他参数来完成。
您可以在这些网站上跟踪最新发布的 CVE(通用漏洞与暴露):
* [CVE Details](https://www.cvedetails.com/)
* [VulDB](https://vuldb.com/)
* [OpenCVE](https://www.opencve.io/)
我们还会定期在我们的 [Twitter](https://twitter.com/Netlas_io)、[Telegram](https://t.me/netlas) 和 [Discord](https://nt.ls/discord) 动态,以及 [Netlas Dorks](https://github.com/netlas-io/netlas-dorks) Github 仓库中发布用于搜索易受攻击设备和软件的最相关查询。
在本节中,我们将简要介绍搜索存在漏洞的网站和服务器的通用原则。
### 子域名搜索
通过在搜索查询中使用星号,您可以找到不同级别的所有子域名(其名称以特定顶级域名(.com)或二级域名(google.com)结尾的子域名)。
**搜索查询示例**
```
domain:*.github.com OR host:*.github.com
API请求示例
Netlas CLI工具:```bash netlas search "domain:.github.com OR host:.github.com" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=domain%3A*.github.com%20OR%20host%3A*.github.com&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
代码示例 (Netlas Python Library)

在命令行中运行:```bash python scripts/pentest/subdomain_search.py
scripts/pentest/subdomain_search.py的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `domain:*.github.com OR host:*.github.com`
netlas_query = netlas_connection.query(query="domain:*.github.com OR host:*.github.com")
# iterate over data and print: ip, url
for response in netlas_query['items']:
print (response['data']['ip'])
print (response['data']['uri'])
搜索查询示例
```
cve.name:CVE-2022-22965
[尝试使用Netlas](https://app.netlas.io/responses/?q=cve.name%3ACVE-2022-22965&page=1&indices=)
**API请求示例**
Netlas CLI工具:```bash
netlas search "cve.name:CVE-2022-22965" -f json
CVE-2022-22965 - 在JDK 9+上运行的Spring MVC或Spring WebFlux应用程序可能通过数据绑定存在远程代码执行(RCE)漏洞。详情
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=http.body%3A1%3F234%3F567%3F89%3F99%20OR%20http.body%3A12345678999%20OR%20http.body%3A1234%3F5678%3F999&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' jq .items[].data.uri
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/pentest/cve_search.py
脚本/pentest/cve_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
cve.name:CVE-2022-22965netlas_query = netlas_connection.query(query="cve.name:CVE-2022-22965")
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['uri'])
### 搜索描述中包含特定词语的漏洞站点
如果你不需要调查特定类型的漏洞服务器,而只是想查看某个特定组(如 Oracle WebLogic Server 或 WordPress 站点)中的易受攻击服务器,你可以使用关键词和 cve.description: 过滤器进行搜索。
要过滤出已发布漏洞利用的站点,请使用 cve.has_exploit:true。
**搜索查询示例**
```
cve.description:weblogic AND cve.has_exploit:true
API 请求示例
Netlas CLI 工具:```bash netlas search "cve.description:weblogic AND cve.has_exploit:true" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=cve.description%3Aweblogic%20AND%20cve.has_exploit%3Atrue&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY | jq .items[].data.uri
代码示例(Netlas Python库)

在命令行中运行:```bash python scripts/pentest/cve_description_search.py
scripts/pentest/cve_description_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `cve.description:weblogic AND cve.has_exploit:true`
netlas_query = netlas_connection.query(query="cve.description:weblogic AND cve.has_exploit:true")
# iterate over data and print: url, first CVE name first CVE description
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['cve'][0]['name'])
print (response['data']['cve'][0]['description'])
此方法允许您查找特定公司制造的设备。
搜索查询示例
```
http.headers.server:"yawcam"
搜索YawCam网络摄像头。
[在Netlas中尝试](https://app.netlas.io/responses/?q=http.headers.server%3A%22yawcam%22&page=1&indices=)
**API请求示例**
Netlas CLI工具:```bash
netlas search 'http.headers.server:"yawcam"' -f json
请注意,当查询中使用双引号时,查询本身写在单引号内。
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=http.headers.server%3A%22yawcam%22&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
**代码示例(Netlas Python库)**

在命令行中运行:```bash
python scripts/pentest/server_name_search.py
scripts/pentest/server_name_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.headers.server:"yawcam"netlas_query = netlas_connection.query(query='http.headers.server:"yawcam"')
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['http']['headers']['server'])
#### 默认登录名和密码 <!-- omit in toc -->
通过服务器头中的软件名称搜索的一个实际应用是搜索特定供应商的设备。这在搜索存在特定漏洞的设备以及使用默认登录名和密码的设备时可能是必要的。

不同设备型号的标准登录名和密码可以在专门的列表中找到。例如:
* [热门路由器型号的默认路由器登录密码(2023年列表)](https://www.softwaretestinghelp.com/default-router-username-and-password-list/)
* [安防摄像头的默认用户名 – 密码 – IP地址](https://www.a1securitycameras.com/blog/default-username-passwords-ip-addresses-for-surveillance-cameras/)
* [几乎所有IP摄像头的默认密码](https://www.hackers-arise.com/post/the-default-passwords-of-nearly-every-ip-camera)
* [Datarecovery的默认密码列表](https://datarecovery.com/rd/default-passwords/)
请记住,使用默认登录名和密码登录他人系统违反道德规范,并且可能在您所在的国家是非法的。
### 通过Favicon哈希搜索易受攻击的服务器
一种查找暴露于特定漏洞的Web服务器的方法是根据特定Web服务器软件的favicon图标进行搜索。
**搜索查询示例**
```
http.favicon.hash_sha256:ebaaed8ab7c21856f888117edaf342f6bc10335106ed907f95787b69878d9d9e
此查询搜索SecurePoint favicon(CVE-2023-22620)。
API请求示例
Netlas CLI 工具:```bash netlas search "http.favicon.hash_sha256:ebaaed8ab7c21856f888117edaf342f6bc10335106ed907f95787b69878d9d9e" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=http.favicon.hash_sha256%3Aebaaed8ab7c21856f888117edaf342f6bc10335106ed907f95787b69878d9d9e&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/pentest/favicon_hash_search.py
`scripts/pentest/favicon_hash_search.py` 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.favicon.hash_sha256:ebaaed8ab7c21856f888117edaf342f6bc10335106ed907f95787b69878d9d9e`
netlas_query = netlas_connection.query(query="http.favicon.hash_sha256:ebaaed8ab7c21856f888117edaf342f6bc10335106ed907f95787b69878d9d9e")
# iterate over data and print: IP,URL,web page title
for response in netlas_query['items']:
print (response['data']['ip'])
print (response['data']['uri'])
print (response['data']['http']['title'])
为简化跨运行不同软件的服务器搜索,Netlas 会自动为搜索结果添加特定标签。
标签示例:
您可以使用 tag.name: 过滤器按标签搜索。也可以使用 tag.category: 过滤器按标签类别搜索。所有可用标签及类别的列表会在您点击 Netlas 首页搜索查询输入框右侧的图标时显示。
注意:并非所有定价方案都支持使用标签。
搜索查询示例
```
tag.name:"adobe_coldfusion"
此查询搜索 Adobe ColdFusion (CVE-2023-26359)。
[在 Netlas 中尝试](https://app.netlas.io/responses/?q=tag.name%3A%22adobe_coldfusion%22&page=1&indices=)
**API 请求示例**
Netlas CLI Tools:```bash
netlas search 'tag.name:"adobe_coldfusion"' -f json
请注意,当查询中使用双引号时,查询本身写在单引号内。 Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=tag.name%3A%22adobe_coldfusion%22&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' | jq .items[].data.uri
**代码示例(Netlas Python库)**

在命令行中运行:```bash
python scripts/pentest/search_tag_name.py
scripts/pentest/search_tag_name.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
tag.name:"adobe_coldfusion"netlas_query = netlas_connection.query(query='tag.name:"adobe_coldfusion"')
for response in netlas_query['items']: print (response['data']['ip']) print (response['data']['uri'])
### 搜索您附近(或任何其他位置)的易受攻击服务器和设备

您想知道自己周围有多少易受攻击的站点和设备吗?只需搜索特定地理位置中所有填充了CVE字段的IP地址即可。```
geo.city:London AND cve:*
您还可以使用其他地理位置筛选器。
geo.continentgeo.countrygeo.locationAPI 请求示例
Netlas CLI 工具:``` geo.city:London AND cve:*
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=geo.city%3ALondon%20AND%20cve%3A*&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.domain
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/pentest/cve_location_search.py
scripts/pentest/cve_location_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `geo.city:London AND cve:*`
netlas_query = netlas_connection.query(query='geo.city:London AND cve:*')
# iterate over data and print: uri, cve name, location
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['cve'][0]['name'])
print (response['data']['geo']['city'])

许多网站和服务器拥有登录和密码网页,可用这些页面来获取对网站或服务器的完全控制权限(通过使用默认密码、暴力破解或漏洞利用)。
你可以使用uri:或/和http.title过滤器来找到它们:```
uri:login.php
uri:login.aspx
uri:user http.title:login
uri:admin http.title:login
http.title:admin http.title:panel
组合方式如此之多。要仅查找易受攻击服务器的面板,请使用过滤器 `cve:*`。
另外,别忘了您还可以通过标签按已安装软件过滤服务器。例如:```
tag.1c_bitrix:*
tag.Cisco:
tag.amazon_s3:*
tag.drupal:*
tag.wordpress:*

让我们尝试搜索易受攻击的 phpMyAdmin 管理面板(用于管理 MySQL 数据库的最流行软件之一):``` http.title:phpMyAdmin cve:*
以下是一些其他流行的数据库管理工具的示例:
[Adminer](https://www.adminer.org/):```
http.title:adminer http.title:login cve:*
PostgreSQL``` http.title:(phpPgAdmin OR pgadmin) cve:*
你也可以使用标签或特殊过滤器来搜索安装了不同数据库软件的服务器:```
tag.adminer:*
tag.phpMyAdmin:*
tag.elastic:*
mongodb:*
mssql:*
mysql:*
django:*
以这种方式找到的服务器,搜索其管理员面板可能不是最简单的事情,因为站点管理员经常将标准链接更改为更安全的链接。

SQL注入是一种漏洞类型,允许通过操纵URL参数来执行数据库查询(这可能是由于配置错误和代码质量差导致的)。
查找可能易受SQL注入攻击的页面的最古老技术之一是使用Google Dorks搜索那些启用了MySQL查询错误消息显示的页面。
在Netlas中也可以进行类似的搜索:``` http.body:mysql_fetch_array http.body:warning
[Try in Netlas](https://app.netlas.io/responses/?q=http.body%3Amysql_fetch_array%20http.body%3Awarning&page=1&indices=)
其他几个示例:```
http.body:mysql_num_rows http.body:warning
http.body:mysql_connect http.body:denied
http.body:mysql_query http.body:warning
http.body:pg_connect http.body:fatal
API 请求示例
Netlas CLI Tools:```bash netlas search "http.body:mysql_fetch_array http.body:warning" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=http.body%3Amysql_fetch_array%20http.body%3Awarning&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' jq .items[].data.uri
代码示例(Netlas Python库)

在命令行中运行:```bash python scripts/pentest/sql_injection_search.py
scripts/pentest/sql_injection_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# search in Netlas "http.body:mysql_fetch_array http.body:warning"
netlas_query = netlas_connection.query(query="http.body:mysql_fetch_array http.body:warning")
# iterate over data and print: uri, web page body
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['http']['body'])
您还可以使用以下过滤器搜索易受攻击的 MySQL 服务器:
mysql.error_codemysql.error_idmysql.error_messageNetlas 不仅搜索网站和服务器,还搜索所有连接到互联网的设备:智能家居电器、监控摄像头、打印机、路由器、交通信号灯、医疗设备等。
主要有四种方法可以找到这些设备。

最简单的方法就是在响应的 HTTP 标题中直接搜索供应商名称或设备类型。
尝试搜索 Jeedom 智能家居设备:``` http.title:Jeedom
[尝试在 Netlas 中打开](https://app.netlas.io/responses/?q=http.title%3AJeedom&page=1&indices=)
或者 Avigilon 网络摄像头:```
http.title:"Avigilon"
这种方法有两个缺点。首先,会出现大量不相关的结果(仅仅是标题中包含相关词汇的网站)。但使用引号和像 port: 这类附加搜索过滤器时,结果会少一些。
其次,许多物联网设备的 http 标题中没有任何可用于识别它们的信息。因此,其他搜索过滤器也可能很有用。

同样,你可以尝试在 http 响应的正文中搜索关键词。为了至少过滤掉一些常见网站,请使用 NOT domain:* 过滤器。让我们尝试搜索 Reolink 摄像头:```
http.body:(clip-status) NOT domain:*
The example isn't quite right, so these cameras can be found using tags (more on that below).
### 按端口 号搜索

不同的 IoT 设备使用不同的端口进行通信。通过开放的端口号,你可以假设该 IP 地址属于某种类型的设备(**通常这种假设是正确的,但可能存在不准确和巧合的情况**)。
尝试搜索网络电台(端口 8000):```
port:8000 http.title:radio
或者所有开放了7547端口(用于通过CWMP远程管理路由器)的设备:``` port:7547
[在 Netlas 中尝试](https://app.netlas.io/responses/?q=port%3A7547&page=1&indices=)
### 按横幅搜索

让我们查找使用 Telnet 协议的路由器(你也可以使用 port:23 进行过滤):```
telnet.banner:router
在 Netlas 中尝试 或搜索所有协议的横幅:``` *.banner:router
[在Netlas中尝试](https://app.netlas.io/responses/?q=%5C*.banner%3Arouter&page=1&indices=)
### 通过图标搜索

查找安装了特定软件的设备最简单的方法之一是通过图标搜索。让我们尝试找出不同思科产品被使用的位置:```
http.favicon.hash_sha256:62a8461e328d5bace3780ff738d0b58f6502592c04afa564e0a8a792583a7bfb
在 Netlas 中通过 favicon 进行搜索主要有三种方式:

有时,http 标题中没有标识设备的明确信息,但可能存在于其他标头中。例如,在 http.server.header 中:``` http.headers.server:"i-Catcher Console"
[在Netlas中尝试](https://app.netlas.io/responses/?q=http.headers.server%3A%22i-Catcher%20Console%22&page=1&indices=)
Netlas支持搜索数十种头部类型。尝试不同的变体。
### 按Cookie搜索

搜索Eco JS Parking lots:```
http.headers.set_cookie:(regist_carNo=)

此方法可能需要付费订阅。 查看定价
您也可以尝试按标签(类别)搜索设备。``` tag.category:"IoT" tag.category:"Web cameras"
[在 Netlas 中试用](https://app.netlas.io/responses/?q=tag.category%3A%22Web%20cameras%22&page=1&indices=)
请记住,标签是自动分配的,一些合适的设备可能未被包含在相应的类别中。
### 附加搜索过滤器
它可以搜索位于特定地理位置的物联网设备:
- `geo.city`
- `geo.country`
- `geo.continent`
按 IP 地址范围筛选设备:```
ip:[162.245.241.131 TO 162.245.241.133]
或者具有"新鲜"漏洞的设备:``` cve.name:2023
更多用于搜索物联网设备的查询示例,请参见:
[Netlas Dorks](https://github.com/netlas-io/netlas-dorks)
## 使用 Netlas.io 进行暗网研究
Netlas 的主要优势之一是,你可以用它搜索那些没有被 Google 收录的内容。这可以被通俗地称为深网(DeepWeb)。例如,FTP 服务器或 Telnet 服务器:```
ftp.banner:*
telnet.banner:*
但遗憾的是,Netlas不索引暗网(.onion, .i2p等),因为它只扫描全球IP地址。但它仍然可以用于探索替代网络基础设施,并找到指向.onion站点的链接。
Tor 出口节点是网络流量离开 Tor 网络并转发到目的地的点。活动 Tor 出口节点的最新 IP 地址列表始终可在 TorProject 网站上获取:
让我们看看如何使用 Netlas 一次性收集所有活动 Tor 出口节点的信息。这个示例对于所有需要收集域名或 IP 地址列表信息的其他任务都很有用。
运行 scripts/darknet/tor_nodes.py:```bash python scripts/darknet/tor_nodes.py

scripts/darknet/tor_nodes.py的源代码:```python
import netlas
import urllib
import time
apikey = 'YOUR_API_KEY'
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# read file with Tor Exit Nodes IPs line by line
response = urllib.request.urlopen('https://check.torproject.org/torbulkexitlist?ip=1.1.1.1')
ip_lines = response.readlines()
# save each line to ip variable
for ip in ip_lines:
# wait one second
time.sleep(1)
# conver byte string to text
ip=ip.decode("utf-8")
# retrieve data from responses by query `ip: + tor exit node ip`
netlas_query = netlas_connection.query(query="ip:"+ip)
# iterate over data and print: ip, geo data, banner text
for response in netlas_query['items']:
print(response['data']['ip'])
print(response['data']['geo'])
print(response['data']['ntp']['banner'])
pass
pass
使用 time 包和 sleep 方法只适用于简单示例。最佳解决方案是使用 rate limit 包。
如上所述,Netlas 仅扫描全球域名,因此无法搜索 .onion 域名。但您可以在网页文本中搜索对 .onion 域名的引用。以下是一个简单的 Python 脚本(使用正则表达式)示例来实现这一点:
运行 scripts/darknet/onion_links.py:```bash python scripts/darknet/onion_links.py

脚本 `scripts/darknet/onion_links.py` 的源代码:```python
import netlas
import re
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.body:*.onion AND forum`
netlas_query = netlas_connection.query(query="http.body:(*.onion AND forum)")
# iterate over data and print: URL, .onion link from body
for response in netlas_query['items']:
print(response['data']['uri'])
onion_links = re.findall("[a-z-1-9]*\.onion", response['data']['http']['body'])
try:
print(onion_links)
except:
print("no onion links")
pass
你可以用同样的方式收集其他网络(如I2P)的链接:``` http.body:*.i2p
## 文件、备份和日志目录搜索

由于配置错误(有时是故意为之),有大量的网站和服务器会开放其文件目录。以下是一些可以帮助您找到它们的查询示例。
搜索任意文件目录:```
http.title:Index http.title:of
搜索包含日志文件的目录:``` http.title:Index http.title:of http.body:logs
搜索包含数据库转储的目录:```
http.title:Index http.title:of http.body:sql
搜索包含存档备份的目录:``` http.title:Index http.title:of http.body:backup?zip
搜索包含SSH访问信息的目录:```
http.title:Index http.title:of http.body:("ssh_config" OR "ssh_known_hosts" OR "authorized_keys" OR "id_rsa" OR "id_dsa")
搜索包含其他授权信息的文件的目录:``` http.title:Index http.title:of http.body:("pass" OR "logins" OR "config" OR "password")
搜索用户下载文件所在的目录:```
http.title:index http.title:of http.body:downloads
搜索包含Docker配置文件的目录:``` http.title:index http.title:of http.body:docker-compose
你可以想象出成百上千个这样的请求。尝试使用不同的文件名和扩展名。
## 使用 Netlas.io 进行数字取证和事件响应
这部分很难与 Netlas 用于开源情报(OSINT)的部分分开,因为其中列出的查询也对从事数字取证的人员有用。
在本节中,我们将介绍一些更"技术性"的查询,这些查询可以帮助收集网络技术基础设施的信息或调查网络钓鱼攻击等。
### SMTP 服务器信息收集
SMTP(简单邮件传输协议)是一种通信协议,用于发送和接收电子邮件。在大多数电子邮件客户端中,查看邮件时可以使用"显示原始内容"功能,该功能允许您查看发送该邮件的 SMTP 服务器地址。
Netlas 允许您获取有关 SMTP 服务器以及任何其他 IP 或域的信息,还可以搜索 SMTP 横幅的文本,从而找到与特定域、公司或托管提供商相关的服务器。
**搜索查询示例**
```
smtp.banner:fornex.cloud
Netlas CLI 工具:```bash netlas search "smtp.banner:fornex.cloud" -f json
Curl:```bash
curl -X 'GET' \
'https://app.netlas.io/api/responses/?q=smtp.banner%3Afornex.cloud&source_type=include&start=0&fields=*' \
-H 'accept: application/json' \
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.smtp.banner
代码示例(Netlas Python 库)

在命令行中运行:```bash python scripts/dfir/smtp_banner_search.py
脚本 scripts/dfir/smtp_banner_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `smtp.banner:fornex.cloud`
netlas_query = netlas_connection.query(query="smtp.banner:fornex.cloud")
# iterate over data and print: SMTP banner, URL, ISP
for response in netlas_query['items']:
print (response['data']['smtp']['banner'])
print (response['data']['uri'])
print (response['data']['isp'])
诈骗者常用的一种手段是使用拼写与知名公司域名极为相似的域名。
您可以使用 Netlas 和模糊搜索来查找某家公司的此类域名。

打开 Whois 域名搜索,输入公司域名 + 。例如:```
domain:facebook.com
[Try in Netlas](https://app.netlas.io/whois_domains/?q=domain%3Afacebook.com~&page=1&indices=)

之后单击左侧图标,选择导出文件类型、文件名以及要保存到文件的字段。点击“下载”并等待片刻。

例如,您可以选择CSV文件格式以及域名、过期日期、状态字段。这样的表格可以方便地在Excel、Numbers或Google Docs中查看。
### Favicon 搜索

搜索 favicon.ico 主要有三种用途。
首先,它允许您查找可能相关的站点和子域名。尝试查找与 Lidl 商店关联的 IP:```
http.favicon.perceptual_hash:003c7e72207e3c00
此外,它还可用于寻找那些模仿热门社交网络、在线商店等设计的钓鱼网站。
其次,它是针对各种物联网设备的搜索。尝试查找 HP 产品:``` http.favicon.perceptual_hash:0c5ec8c181f37e2c
[Try in Netlas](https://app.netlas.io/responses/?q=http.favicon.perceptual_hash%3A0c5ec8c181f37e2c&page=1&indices=)
第三,它会搜索运行特定软件的服务器。尝试寻找运行PhpMyAdmin的服务器:```
http.favicon.perceptual_hash:00084e5e5fffff8d
在 Netlas 中,有三种主要方式可以通过 favicon 哈希进行搜索:
您还可以使用以下筛选器按 favicon 搜索:
http.favicon.last_modifiedhttp.favicon.last_updatedhttp.favicon.urihttp.favicon.path
Netlas 域名搜索可以获取与特定 IP 地址或地址范围关联的完整域名列表。例如:``` a:"163.114.132.0/24"
[在 Netlas 中尝试](https://app.netlas.io/domains/?q=a%3A%22163.114.132.0%2F24%22&page=1&indices=)
API 请求示例
Netlas CLI 工具:```bash
netlas search -d domain a:\"163.114.132.0/24\"
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/domains/?q=a%3A%22163.114.132.0%2F24%22&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: 'YOUR_API_KEY' | jq .items[].data.domain
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/dfir/subnet_search.py
scripts/dfir/subnet_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
a:"163.114.132.0/24"netlas_query = netlas_connection.query(query='a:"163.114.132.0/24"',datatype="domain")
for response in netlas_query['items']: print (response['data']['domain'])
### 搜索带有恶意软件的服务器

Netlas 让您能够查找安装了各种恶意软件的服务器。您可以通过 http.title 或 http.body 中的特定词汇、favicon 哈希、ssl 及其他参数来发现它们。
以下是一个示例查询,用于查找安装了 GoFish(开源钓鱼框架)的服务器:```
http.title:Gophish http.title:Login
请注意,这里使用了重复相同运算符(而不是在两个单词之间使用星号)的技巧。有时这有助于你获得更多搜索结果。
以下是一些类似请求的更多示例:``` http.title:CALDERA http.title:login http.title:Deimos http.title:C2
**API请求示例**
Netlas CLI工具:```bash
netlas search "http.title:Gophish http.title:Login" -f json
Curl:```bash
curl -X 'GET'
'https://app.netlas.io/api/responses/?q=http.title%3AGophish%20http.title%3ALogin&source_type=include&start=0&fields=*'
-H 'accept: application/json'
-H 'X-API-Key: YOUR_API_KEY' jq .items[].data.uri
**代码示例(Netlas Python 库)**

在命令行中运行:```bash
python scripts/dfif/malware_search.py
scripts/dfir/malware_search.py 的源代码:```python import netlas
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
netlas_query = netlas_connection.query(query="http.title:Gophish http.title:Login")
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['http']['title'])
print (response['data']['geo']['country'])
## 搜索技术与代码示例

Netlas 与传统搜索引擎不同,它允许您搜索整个 HTML 代码,而不是页面文本。这使您能够找到使用特定 JavaScript 库的站点。这有助于您找到适合您任务的代码示例,从而节省时间。
例如,寻找使用过时的老旧图形库的站点:```
http.body:kinetic.js
您还可以了解不同CSS框架在特定主题网站上的使用方式,并借鉴优秀的设计思路:``` http.body:bootstrap.css http.title:travel
您还可以通过使用标签来筛选使用特定框架和技术的网站:```
tag.bootstrap:*
tag.angularjs:*
tag.wordpress:*
tag.nextjs:*
Netlas 与其他许多搜索引擎一样,可以无需特定目的使用,借助它探索互联网中未被探索的角落,希望能找到一些有趣的东西。
以下是一些搜索查询示例,它们将帮助你找到谷歌找不到的内容。
通过 Telnet 服务器横幅文本搜索(是的,它们依然活跃!):``` telnet.banner:library

按FTP服务器横幅文本搜索:```
ftp.banner:*library*
搜索书籍和文档的链接:``` http.body:rowlingpdf
搜索音乐和视频的链接:```
http.body:*cats*mp4
搜索种子文件的链接:``` http.body:catsmp4
请记住,Netlas 不会以任何方式审查其数据库中存储的内容。如果您发现任何非法或不道德的内容,应向域名信息中列出的托管提供商投诉。
## 常见问题
### 错误 429 - 请求过于频繁

如果您的应用程序包含对 Netlas API 的多次请求,可能会遇到此错误:```json
{'detail': 'Request was throttled. Expected available in 1 second.'}
解决此问题的一种方法是使用特殊的Python库来配置查询执行的时间限制,例如Limiter Package。
以下是在代码中使用它的示例(每分钟不超过60个请求的限制)。首先,安装包:``` pip install ratelimit
然后运行 rate_limit.py:```bash
python scripts/common_problems/rate_limit.py
exploits/exploits: 包含所有用于渗透测试框架的公共漏洞利用程序payload/payload: 各种用于利用场景的 Shellcode 和 Payload一系列用于执行自动化任务和验证手动检查的不同工具。
tools/:
@limits(calls=1, period=1) def netlas_query(): apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `cve.description:weblogic AND cve.has_exploit:true`
netlas_query = netlas_connection.query(query="cve.description:weblogic AND cve.has_exploit:true")
# iterate over data and print: url, first CVE name first CVE description
for response in netlas_query['items']:
print (response['data']['uri'])
print (response['data']['cve'][0]['name'])
print (response['data']['cve'][0]['description'])
netlas_query()
其他流行的编程语言也有类似的包,因为在使用大多数API时,超出请求限制是一个非常常见的问题。
如果您确实需要每秒进行超过一次查询,可以联系[销售团队](https://netlas.io/sales/)。
### KeyError

另一个常见问题是某些服务器的响应中缺少特定键。例如,['data']['http']['title'] 经常缺失。
如果键缺失,脚本会停止执行。标准的错误处理有助于避免这种情况。例如:```python
try:
print (response['data']['http']['title'])
except:
print ("no title")
使用 Netlas Python 或 Netlas API 与仅仅在 Netlas.io 网页版中输入查询相比,主要优势在于您可以节省大量输入通用查询的时间。例如,您可以使用非常简单的 Python 代码快速收集一长串域名的信息。
在命令行中运行:```bash python scripts/common_problems/domain_list_search.py
domain_list_search.py 的源代码:```python
import netlas
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# read file domains.txt line by line
with open("scripts/common_problems/domains.txt") as f:
# save each line to domain variable
for domain in f:
# retrieve data from responses by query `domain:domainname`
netlas_query = netlas_connection.query(
query=f"domain:{domain}", datatype="domain-whois"
)
# iterate over data and print: ip, isp
for response in netlas_query['items']:
print (response['data']['ip'])
print (response['data']['isp'])
类似地,您可以处理证书、IP地址、电子邮件等任意列表。
关于从URL加载的列表中搜索IP地址的示例,请参阅Tor出口节点搜索。

默认情况下,Netlas Python库返回字典类型的数据(与JSON非常相似)。如果您想将数据导出到MS Excel或Google Sheets,一种简单的方法是将其保存为CSV格式。
以下示例使用了CSV包。运行csv_export.py:```bash python scripts/common_problems/csv_export.py
由于没有提供需要翻译的实际内容,我无法生成译文。请提供具体的Markdown文本块。```python
import netlas
import csv
apikey = "YOUR_API_KEY"
# create new connection to Netlas
netlas_connection = netlas.Netlas(api_key=apikey)
# retrieve data from responses by query `http.meta:nazar`
netlas_query = netlas_connection.query(query="http.meta:nazar")
with open('netlas_results.csv', 'w') as csv_file:
# Create CSV writer object
writer = csv.writer(csv_file, delimiter =';')
# Create a list with data headers:
header = ['IP', 'URL', 'Title']
# Write headers to CSV file
writer.writerow(header)
# iterate over data and print: ip and url to CSV file
for response in netlas_query['items']:
# Create a list with one line of data:
data = [response['data']['ip'], response['data']['uri']]
# Write line to file
writer.writerow(data)
pass
您可以在 Excel 或任何文本编辑器中打开 netlas_results.csv。
使用 Python,您可以基于 Netlas 的数据生成多种文档,插入图像、数据可视化并自定义布局。以下是一些有用的包示例。
XLSXWriter - 生成 Microsoft Excel 文件。
PyPDF - 生成 PDF 文件。
PythonPPTX - 生成 Microsoft PowerPoint 演示文稿。
PythonDOCX - 生成 Microsoft Word 文件。

如上所述,Netlas 不会以原始编码存储非拉丁域名,而是将其编码为 Punycode。这是出于技术原因的必要操作,但对人类感知来说完全不便利。
但这个问题只需几行 Python 代码即可轻松解决。
安装 IDNA Python 包:```bash pip install idna
并在命令行中运行 punycode.py:```bash
python scripts/common_problems/punycode.py
请提供需要翻译的 Markdown 内容。```python import netlas import idna
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
domain:*.中国 OR host:*.中国 netlas_query = netlas_connection.query(query="domain:.xn--fiqs8s OR host:.xn--fiqs8s")
for response in netlas_query['items']: print (response['data']['ip']) decoded_domain = idna.decode(str(response['data']['domain'][0])) print (decoded_domain)
### What to Do If Search Queries Don't Return Results?
Sometimes you may encounter a situation where no or very few results are found on query, although you are sure there should be many more. In this case we recommend you to experiment and try to change the queries a bit.
1. Try adding two asterisks to your keyword. For example, domain:*github.com* returns 1,592,846 results. domain:githib.com - only 7911 results.
2. Try using different search filters to achieve the same goal. For example, compare results for uri:*github.com*, host:*github.com* and domain:*github.com*.
3. Do not use spaces in keywords. If you need to find the phrase "Hello world" in http.body, use the following query: ```
http.body:hello http.body:world
或 ``` http.body:(hello AND world)
4. 尽可能细化你的搜索过滤器。例如,查询 cve:*2023* 不会返回结果。但查询 cve.name:*2023* 会返回超过2800万条结果。
5. 在使用网页应用时尝试不同的选项卡,或者在使用API时尝试不同的数据类型。例如,在搜索域名时,有时候主机(Host)或域名Whois(而非响应)效果更好。
### 从HTTP响应体中移除HTML标签

键 ['data']['http']['body'] 默认返回网页的完整正文文本,包括所有HTML标签。这种格式不太容易阅读。但你可以使用Python包 [Html2text](https://pypi.org/project/html2text/) 轻松移除它们。
在命令行中运行:```bash
python scripts/common_problems/htmltotext.py
htmltotext.py 的源代码:```python import netlas import html2text
apikey = "YOUR_API_KEY"
netlas_connection = netlas.Netlas(api_key=apikey)
http.body:*phpMyAdmin*netlas_query = netlas_connection.query(query="http.body:phpMyAdmin")
for response in netlas_query['items']: print (response['data']['ip']) print (html2text.html2text(str(response['data']['http']['body'])))
## 攻击面管理
Netlas 平台包含用于攻击面管理的工具,但本指南不涉及此主题。如果你对一般的攻击面管理以及具体使用 Netlas 感兴趣,建议从以下文章开始阅读:
- [攻击面发现完整指南](https://netlas.io/blog/attack_surface_discovery_guide/)。
- [最佳攻击面可视化工具](https://netlas.io/blog/best_attack_surface_visualization_tools/)。
## 处理超大规模数据

如果你面临一个真正的大挑战。例如,你需要收集数十万个域名的数据,那么从时间和财务成本角度来看,更合理的解决方案可能是购买数据集(csv/json)并在自己的服务器上处理。
在 [Netlas 数据存储](https://app.netlas.io/datastore/) 中,你可以找到:
* 已知域名数据集(超过20亿条)
* 正向 DNS 数据集(超过20亿条)
* 已知 PTR 记录(超过10亿条) - 免费
* 前1,000,000个最常见子域名
等等。
## 致谢
非常感谢 [@cyb_detective](https://twitter.com/cyb_detective) 的帮助 (https://cybdetective.com)