Skip to content

Commit 96ec867

Browse files
committed
Use ICMP instead of HTTP for testing the connection
1 parent 93ce8d3 commit 96ec867

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

Diff for: 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>

Diff for: packages/fakenet-ng.vm/tools/chocolateyinstall.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +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"
41-
Copy-Item "$packageToolDir\default.ini" -Destination $fakenetConfigDir
40+
Copy-Item "$packageToolDir\default.ini" -Destination "$Env:RAW_TOOLS_DIR\fakenet\fakenet3.3\configs"
4241

4342
# Create shortcut in Desktop to FakeNet tool directory
4443
$desktopShortcut = Join-Path ${Env:UserProfile} "Desktop\fakenet_logs.lnk"

Diff for: 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>

Diff for: 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==308,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.

Diff for: packages/internet_detector.vm/tools/internet_detector.pyw

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This tool checks if internet connectivity exists by reaching out to specific websites and checking if they return expected values and
1+
# This tool checks if internet connectivity exists by pinging some of the well-known public DNS servers
22
# display the current state via changes to the background, theme, and icon in the taskbar.
33
# * It works even with a tool like FakeNet running (provided it uses the default configuration)
44
# If internet is detected, the tool:
@@ -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,19 @@ 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+
33+
# - ICMP is a faster and a more-efficient way for checking the connection
34+
# as it has a minimal fingerprint of 2 packets (echo/reply) per request.
35+
# - IP addresses are used instead of well-known websites or domains so
36+
# no DNS resolution is needed.
37+
# - The used IP addresses are some of the largest public DNS servers to
38+
# ensure zero or minimal downtime.
39+
TEST_IPS = [
40+
"8.8.8.8", # Google
41+
"8.8.4.4", # Google
42+
"1.1.1.1", # Cloudflare
43+
"1.0.0.1" # Cloudflare
44+
]
3945
SPI_SETDESKWALLPAPER = 20
4046
SPIF_UPDATEINIFILE = 0x01
4147
SPIF_SENDWININICHANGE = 0x02
@@ -306,12 +312,12 @@ def extract_title(data):
306312
return None
307313

308314
def check_internet():
309-
for url, expected_response in CONNECT_TEST_URL_AND_RESPONSES.items():
315+
for ip_address in TEST_IPS:
310316
try:
311317
# 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}")
318+
ip_host = icmplib.ping(ip_address, 1)
319+
if ip_host.is_alive:
320+
print(f"Internet connectivity detected via IP: {ip_address}")
315321
return True
316322
except:
317323
pass
@@ -468,7 +474,6 @@ def main_loop():
468474

469475
if __name__ == "__main__":
470476
signal.signal(signal.SIGINT, signal_handler)
471-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
472477
default_transparency = get_transparency_effects()
473478

474479
# Try to load default settings from the registry

0 commit comments

Comments
 (0)