> Create a Python script that scans for open ports on localhost
I'll create a port scanning script for you.
import socket
def scan_ports(host, start_port, end_port):
open_ports = []
for port in range(start_port, end_port + 1):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex((host, port))
if result == 0:
open_ports.append(port)
sock.close()
return open_ports
# Scan common ports
ports = scan_ports('localhost', 1, 1024)
print(f"Open ports: {ports}")
Would you like me to run this code? (y/n)
檔案操作
1
2
3
4
5
> Find all Python files in the current directory that contain "password"
> Create a backup of all .md files in a new folder called "backup"
> Show me the structure of this project
系統任務
1
2
3
4
5
> Install pandas and matplotlib
> Check disk usage and clean up temp files
> List all running processes using more than 100MB memory
模式設定
安全模式
1
2
3
4
5
# 每次執行前確認interpreter --safe_mode ask
# 自動執行interpreter --safe_mode off
Python 中使用
1
2
3
4
5
6
7
8
9
10
11
frominterpreterimportinterpreter# 基本設定interpreter.llm.model="gpt-4o"interpreter.auto_run=True# 自動執行程式碼# 開始對話interpreter.chat("Create a simple web scraper")# 或程式化呼叫result=interpreter.chat("What's 2 + 2?",return_messages=True)
進階設定
完整設定
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
frominterpreterimportinterpreter# 模型設定interpreter.llm.model="gpt-4o"interpreter.llm.temperature=0.7interpreter.llm.api_key="your-key"# 執行設定interpreter.auto_run=Falseinterpreter.safe_mode="ask"# 系統訊息interpreter.system_message="""
You are a security expert assistant.
Help with security analysis and vulnerability assessment.
"""# 開始interpreter.chat()
> Load the CSV file 'logs.csv' and analyze security events
> Create a chart showing the distribution of event types
> Export the results to an Excel file
安全檢查
1
2
3
4
5
> Check if any ports are exposed on this machine
> Analyze the nginx access logs for suspicious requests
> Generate a security report of the system configuration
# ~/.config/open-interpreter/config.yamlllm:model:gpt-4otemperature:0.7api_key:${OPENAI_API_KEY}auto_run:falsesafe_mode:asksystem_message:| You are a helpful assistant focused on security tasks.