Privacy Shield configuration
- Clone the GitHub repository PDNS_PRIVACY using Git. You should have the following three folders:
- pdns_collector
- pdns_privacy_shield
- pdns_sensor
-
Create a virtual environment in every folder and install the packages listed in
requirements.txtWindows (PowerShell)
python -m venv .venv .\.venv\Scripts\Activate.ps1 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser pip install -r .\requirements.txtmacOS (Terminal)
python3 -m venv .venv source .venv/bin/activate pip3 install -r requirements.txtLinux (Ubuntu)
python3 -m venv .venv source .venv/bin/activate pip3 install -r requirements.txt -
Provide the appropriate argument value for each of the components
Privacy Shield
- Today's Password - Obtain the password from the Passive DNS Dashboard
- GUID - obtained from
user.db - IP address - Host's IP address
- Username - obtained from
database.pyunder pdns_privacy_shield - Password - obtained from
database.pyunder pdns_privacy_shield
*The collector runs without any argumentsSensor
- Sensor ID - Create your own ID
- Today's Password - Must match the password entered in pdns_privacy_shield
- IP address:port number - Provide the IP address and port number of the Sensor Dashboard instance.
Persistent Service Configuration
Reliable, long-running processes are essential for system stability. To achieve this, we can configure the application as a persistent service using the appropriate system service manager for each OS.
repeat the steps below forprivacyshield.pyand collector.py as well
Systemd (Linux)
- Create a new service file:
- Define how the service runs:
- Reload systemd:
- Start the service:
- Enable at boot:
- Check status:
sudo nano /etc/systemd/system/<SERVICE_NAME>.service
[Unit]
Description=PDNS Sensor
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=/opt/pdns_sensor
ExecStart=<PYTHON_PATH> https_sensor.py <SENSOR_ID> <TODAY_PASSWORD> <IP_ADDRESS:PORT>
Restart=always
RestartSec=5
User=root
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start <SERVICE_NAME>
sudo systemctl enable <SERVICE_NAME>
systemctl status <SERVICE_NAME>
launchd (macOS)
- Create a new .plist file:
- Add configuration:
- Load the service:
- Start it manually:
- Check status:
nano ~/Library/LaunchAgents/<SERVICE_NAME>.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string><SERVICE_NAME></string>
<key>WorkingDirectory</key>
<string><PATH_TO_PROJECT_DIRECTORY></string>
<key>ProgramArguments</key>
<array>
<string><PATH_TO_PYTHON></string>
<string><SCRIPT_NAME></string>
<string><SENSOR_ID></string>
<string><TODAY_PASSWORD></string>
<string><IP_ADDRESS:PORT></string>
</array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>EnvironmentVariables</key>
<dict>
<key>PYTHONUNBUFFERED</key>
<string>1</string>
</dict>
</dict>
</plist>
launchctl load ~/Library/LaunchAgents/<SERVICE_NAME>.plist
launchctl start <SERVICE_NAME>
launchctl list | grep <SERVICE_NAME>
Task Scheduler (Windows)
- Create a task.xml file:
- Add configuration:
- Register task:
- Start service:
- Check last run:
- Delete:
task.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Actions Context="Author">
<Exec>
<Command><PYTHON_PATH></Command>
<Arguments><SCRIPT_NAME> <SENSOR_ID> <TODAY_PASSWORD> <IP_ADDRESS:PORT></Arguments>
<WorkingDirectory><WORKING_DIRECTORY></WorkingDirectory>
</Exec>
</Actions>
</Task>
schtasks /Create /TN "<SERVICE_NAME>" /XML task.xml /F
schtasks /Run /TN "<SERVICE_NAME>"
schtasks /Query /TN "<SERVICE_NAME>" /V /FO LIST
schtasks /Delete /TN "<SERVICE_NAME>" /F