
10分钟打造属于你的AI侦查工具——深度探索DeepSeek-R1与Ollama完美结合!
- Rifx.Online
- Programming , Technology , Data Science
- 12 Feb, 2025
大家好!在这篇博客中,我将帮助您利用DeepSeek-R1模型提升生产力,并指导您在系统上进行设置。对于不同的操作系统,有多种安装方法,您可以在博客中进行探索。然而,我不会将其与ChatGPT或OpenAI进行比较,因为这是一个有争议的话题,并超出了本文的范围。
什么是 DeepSeek?
DeepSeek 人工智能有限公司是一家专注于推进 AGI(人工通用智能) 的中国人工智能公司。他们开发了像 DeepSeek-R1(机器人技术)和 DeepSeek-V2(一种成本效益高的 LLM)这样的模型。
DeepSeek-R1 Github 仓库:
主要特点包括:
- 自动化:脚本化重复任务。
- 数据洞察:使用 AI 驱动的工具分析数据集。
- 自定义工作流程:为您的需求构建量身定制的解决方案。
- 协作:与团队共享洞察和工作流程。
在您的系统上安装 DeepSeek
前提条件
- 操作系统:兼容 Windows、macOS 和 Linux。
- Python:确保安装 Python 3.7+(CLI/Python 集成所需)。
- 硬件:8GB+ RAM 和 20GB+ 存储以获得最佳性能。 (我们不安装更高版本的模型,如果您想要更高版本的模型,则需要 400GB 磁盘空间和大量 CPU)
Deepseek R1模型的安装步骤:
方法 1 安装 Ollama:
2. 安装下载的 Ollama 最新版本
3. 通过打开命令提示符并输入以下内容来验证 Ollama 是否已安装在您的系统上:
Ollama
方法 2 安装模块
- 在 Ollama.com 的搜索框中搜索 deepseek-r1。
2. 点击 deepseek-r1 选项,您将被重定向到 Ollama deepseek-r1 模型页面。
3. 您可以从多个模型中进行选择,但在这篇博客中,我选择了 1.5B 参数和 1.1GB 大小 的 small 模型。
4. 从右侧复制 Ollama 命令。
5. 在执行命令之前,将 Run 修改为 Pull,因为我不想立即下载并运行它。
ollama pull deepseek-r1:1.5b
6. 使用以下命令检查您系统上安装的模型列表。
ollama list
7. 使用以下命令测试下载的模型。
ollama run deepseek-r1:1.5b
方法 3 为该模型设置 Python 搜索环境
1. 前往 C:\ 驱动器并通过在命令提示符中运行以下命令创建一个 DeepSeek-R1 文件夹:
cd\
mkdir DeepSeek-R1
cd DeepSeek-R1
注意:此文件夹将用于为 DeepSeek-R1 模型设置 Python 环境。
2. 使用以下命令验证您的系统上是否安装了 Python:
python -- version
或者
py --version
如果未安装 Python,请从 官方 Python 网站 或 Microsoft Store 下载并安装最新版本。
3. 创建一个 Python 虚拟环境运行以下命令以创建虚拟环境:
py -m venv env1
4. 激活虚拟环境使用以下命令激活虚拟环境:
env1\Scripts\activate.bat
5. 安装 Ollama 库在虚拟环境中使用以下命令安装 Ollama 库:
pip install ollama
6. 要打开 VS Code,请运行以下命令:
code .
7. 创建一个 Python 文件- 在 VS Code 中创建一个名为 test.py 的新文件- 将其保存在 DeepSeek-R1 文件夹中。
8. 编写 Python 代码- 打开 test.py 并编写您的 Python 脚本。以下是一个针对网络侦察的 Python 脚本,使用 Deepseek-R1 模型进行网络安全:
import ollama
import requests
import socket
from urllib.parse import urlparse
import concurrent.futures
TARGET_DOMAIN = "example.com" # Replace with your target domain
COMMON_SUBDOMAINS = [
'www', 'mail', 'admin', 'dev', 'test', 'staging', 'api',
'secure', 'portal', 'webmail', 'blog', 'ftp', 'vpn', 'mx'
]
def save_report(content: str):
"""Save results to a timestamped file"""
filename = f"{TARGET_DOMAIN.replace('.', '_')}-recon.txt"
with open(filename, 'w') as f:
f.write(f"Subdomain Recon Report for {TARGET_DOMAIN}\n")
f.write(f"Generated at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
f.write("="*50 + "\n")
f.write(content)
return filename
def analyze_with_deepseek(report: str) -> str:
"""Analyze subdomain findings with Deepseek-R1"""
prompt = f"""Act as a cybersecurity expert. Analyze these subdomain reconnaissance findings:
{report}
List potential security risks with:
- Vulnerability Type
- Severity (Critical/High/Medium/Low)
- Explanation
- Remediation Steps
Format as markdown table."""
try:
response = ollama.generate(
model="deepseek-r1",
prompt=prompt,
options={'temperature': 0.2, 'num_ctx': 4096}
)
return response['response']
except Exception as e:
return f"Analysis failed: {str(e)}"
def check_subdomain(subdomain: str) -> dict:
"""Check subdomain existence and HTTP details"""
full_domain = f"{subdomain}.{TARGET_DOMAIN}"
result = {'subdomain': full_domain, 'exists': False}
try:
# DNS Resolution
socket.gethostbyname(full_domain)
result['exists'] = True
# HTTP Check
try:
response = requests.get(
f"http://{full_domain}",
timeout=5,
allow_redirects=False
)
result.update({
'status': response.status_code,
'headers': dict(response.headers),
'server': response.headers.get('Server', 'Unknown')
})
except requests.exceptions.SSLError:
# Try HTTPS
response = requests.get(
f"https://{full_domain}",
timeout=5,
verify=True
)
result.update({
'status': response.status_code,
'headers': dict(response.headers),
'server': response.headers.get('Server', 'Unknown'),
'https': True
})
except (socket.gaierror, requests.RequestException):
pass
return result
def main():
print(f"[*] Starting subdomain scan for {TARGET_DOMAIN}")
# Multithreaded subdomain checking
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
futures = {executor.submit(check_subdomain, sub): sub for sub in COMMON_SUBDOMAINS}
results = []
for future in concurrent.futures.as_completed(futures):
result = future.result()
if result['exists']:
results.append(result)
# Generate report
report_header = f"Found {len(results)} active subdomains:\n\n"
report_body = "\n".join([
f"Subdomain: {res['subdomain']}\n"
f"Status: {res.get('status', 'N/A')}\n"
f"Server: {res.get('server', 'Unknown')}\n"
f"HTTPS: {res.get('https', False)}\n"
f"Headers: {res.get('headers', {})}\n{'-'*40}"
for res in results
])
full_report = report_header + report_body
print("\n[*] Requesting AI analysis...")
analysis = analyze_with_deepseek(full_report)
# Combine findings and analysis
final_output = f"{full_report}\n\n{'='*50}\nAI ANALYSIS:\n{analysis}"
# Save to file
filename = save_report(final_output)
print(f"\n[+] Report saved to: {filename}")
if __name__ == "__main__":
main()
- 编辑后保存文件。
9. 选择 Python 解释器- 按 Ctrl + Shift + P,搜索 “Python: Select Interpreter”,并选择来自您虚拟环境 (env1) 的解释器。
10. 只需单击 VS Code 右上角的运行按钮以执行脚本。运行后,我在运行时遇到了 Import request error
要解决此问题,请使用以下命令:
.\env1\Scripts\activate
pip install requests ollama beautifulsoup4
再次运行脚本。如果您遇到任何问题,请随时在下面评论 — 我会尽快帮助您!
以下是显示目标侦察输出文件内容的命令:
Get-Content .\example_com-recon.txt
示例:
Get-Content .\evil_com-recon.txt
开始使用 DeepSeek
1. 自动化重复任务
使用 DeepSeek 的脚本引擎来自动化文件管理或电子邮件分类等任务。
示例:自动化数据备份
from deepseek import Automator
automator = Automator()
automator.schedule_task(
task_type="backup",
source_dir="/home/user/documents",
target_dir="/cloud/backup",
interval="daily"
)
2. 数据分析与可视化
利用 DeepSeek 与 pandas 和 Matplotlib 的集成快速获取洞察。
示例:销售报告生成
import deepseek.analytics as ds
data = ds.load_csv("sales_data.csv")
summary = ds.analyze(data, report_type="summary")
ds.visualize(summary, chart_type="bar", output_file="sales_report.png")
3. 构建自定义工作流程
结合 DeepSeek 模块创建端到端解决方案。
客户反馈分析的示例工作流程
- 从电子邮件/社交媒体抓取反馈。
- 使用 DeepSeek 的 NLP 工具进行情感分析。
- 生成报告并通过 Slack 提醒您的团队。
使用 DeepSeek 提高生产力
1. 与现有工具集成
- 将 DeepSeek 连接到 Slack、Microsoft Teams 或 Zapier 以获取通知。
- 与 Google Sheets 或 Notion 同步以实现实时数据更新。
2. 安排任务
使用 DeepSeek 的调度程序或系统工具,如 cron(Linux)或 任务调度程序(Windows),在非高峰时段运行任务。
3. 监控性能
通过 DeepSeek 的仪表板跟踪任务执行和资源使用:
deepseek monitor --dashboard
4. 高效协作
- 使用 DeepSeek 的导出功能与团队共享工作流程:
deepseek workflow export --name "customer_analysis" --format json
- 使用版本控制(Git)来管理工作流程的更改。
高级技巧
- 训练自定义模型:在您的数据集上微调 DeepSeek 的 AI,以执行特定任务。
- API:使用其 REST API 将 DeepSeek 集成到 Web 应用程序中。
- 安全性:使用 DeepSeek 内置的
secure_mode
加密敏感数据:
automator.enable_secure_mode(encryption_key="your_private_key")
DeepSeek 是一个多功能工具,可以无缝适应您的工作流程,无论您是在自动化重复任务还是提取数据驱动的洞察。通过遵循本指南,您已经迈出了提升生产力的第一步。可以从小处着手——自动化一个任务——随着您的成长逐渐探索更多用例。
我很高兴通过这个博客提供有用的见解和知识。如果您觉得有帮助,请点赞、在下方评论,并分享您对 DeepSeek 的看法。
祝您编码愉快,别忘了关注以获取更多内容!