Skip to content

Commit cb0eefc

Browse files
committed
Use a list of DNS hosts instead of URLs for testing the connection
1 parent 93ce8d3 commit cb0eefc

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

packages/fakenet-ng.vm/fakenet-ng.vm.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>fakenet-ng.vm</id>
5-
<version>3.3.0.20250117</version>
5+
<version>3.3.0.20250128</version>
66
<description>FakeNet-NG is a dynamic network analysis tool.</description>
77
<authors>Mandiant</authors>
88
<dependencies>

packages/fakenet-ng.vm/tools/chocolateyinstall.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ try {
3737

3838
# Replace `default.ini` with our modified one that includes change for 'internet_detector'.
3939
# IMPORTANT: Keep our modified `default.ini` in-sync on updates to package.
40-
$fakenetConfigDir = Get-ChildItem "C:\Tools\fakenet\*\configs"
40+
$fakenetConfigDir = @(Get-ChildItem "C:\Tools\fakenet\*\configs")[0]
4141
Copy-Item "$packageToolDir\default.ini" -Destination $fakenetConfigDir
4242

4343
# Create shortcut in Desktop to FakeNet tool directory

packages/internet_detector.vm/internet_detector.vm.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
33
<metadata>
44
<id>internet_detector.vm</id>
5-
<version>1.0.0.20241217</version>
5+
<version>1.0.0.20250128</version>
66
<authors>Elliot Chernofsky and Ana Martinez Gomez</authors>
77
<description>Tool that changes the background and a taskbar icon if it detects internet connectivity</description>
88
<dependencies>

packages/internet_detector.vm/tools/chocolateyinstall.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ New-Item -Path $toolDir -ItemType Directory -Force -ea 0
1111
VM-Assert-Path $toolDir
1212

1313
# Install pyinstaller 6.11.1 (needed to build the Python executable with a version capable of executing in admin cmd) and tool dependencies ('pywin32')
14-
$dependencies = "pyinstaller==6.11.1,pywin32"
14+
$dependencies = "pyinstaller==6.11.1,pywin32==306,icmplib==3.0.4"
1515
VM-Pip-Install $dependencies
1616

1717
# This wrapper is needed because PyInstaller emits an error when running as admin and this mitigates the issue.

packages/internet_detector.vm/tools/internet_detector.pyw

+11-13
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import winerror
2020
import winreg
2121

2222
import threading
23-
import requests
24-
import urllib3
23+
import icmplib
2524
import signal
2625
import ctypes
2726
import time
@@ -30,12 +29,12 @@ import re
3029

3130
# Define constants
3231
CHECK_INTERVAL = 2 # Seconds
33-
CONNECT_TEST_URL_AND_RESPONSES = {
34-
"https://www.msftconnecttest.com/connecttest.txt": "Microsoft Connect Test", # HTTPS Test #1
35-
"http://www.google.com": "Google", # HTTP Test
36-
"https://www.wikipedia.com": "Wikipedia", # HTTPS Test #2
37-
"https://www.youtube.com": "YouTube", # HTTPS Test #3
38-
}
32+
TEST_IPS = [
33+
"8.8.8.8", # Google
34+
"8.8.4.4", # Google
35+
"1.1.1.1", # Cloudflare
36+
"1.0.0.1" # Cloudflare
37+
]
3938
SPI_SETDESKWALLPAPER = 20
4039
SPIF_UPDATEINIFILE = 0x01
4140
SPIF_SENDWININICHANGE = 0x02
@@ -306,12 +305,12 @@ def extract_title(data):
306305
return None
307306

308307
def check_internet():
309-
for url, expected_response in CONNECT_TEST_URL_AND_RESPONSES.items():
308+
for ip_address in TEST_IPS:
310309
try:
311310
# Perform internet connectivity tests
312-
response = requests.get(url, timeout=5, verify=False)
313-
if expected_response in (extract_title(response.text) or response.text):
314-
print(f"Internet connectivity detected via URL: {url}")
311+
ip_host = icmplib.ping(ip_address, count=1, timeout=CHECK_INTERVAL)
312+
if ip_host.is_alive:
313+
print(f"Internet connectivity detected via IP: {ip_address}")
315314
return True
316315
except:
317316
pass
@@ -468,7 +467,6 @@ def main_loop():
468467

469468
if __name__ == "__main__":
470469
signal.signal(signal.SIGINT, signal_handler)
471-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
472470
default_transparency = get_transparency_effects()
473471

474472
# Try to load default settings from the registry

0 commit comments

Comments
 (0)