Skip to content

Commit d84a5a2

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

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
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-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 "C:\Tools\fakenet\fakenet3.3\configs"
4241

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

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==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.

packages/internet_detector.vm/tools/internet_detector.pyw

+13-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,14 @@ 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+
# Testing the internet connection by pinging some of
33+
# the largest public DNS servers (minimal downtime)
34+
TEST_IPS = [
35+
"8.8.8.8", # Google
36+
"8.8.4.4", # Google
37+
"1.1.1.1", # Cloudflare
38+
"1.0.0.1" # Cloudflare
39+
]
3940
SPI_SETDESKWALLPAPER = 20
4041
SPIF_UPDATEINIFILE = 0x01
4142
SPIF_SENDWININICHANGE = 0x02
@@ -306,12 +307,12 @@ def extract_title(data):
306307
return None
307308

308309
def check_internet():
309-
for url, expected_response in CONNECT_TEST_URL_AND_RESPONSES.items():
310+
for ip_address in TEST_IPS:
310311
try:
311312
# 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}")
313+
ip_host = icmplib.ping(ip_address, count=1, timeout=CHECK_INTERVAL)
314+
if ip_host.is_alive:
315+
print(f"Internet connectivity detected via IP: {ip_address}")
315316
return True
316317
except:
317318
pass
@@ -468,7 +469,6 @@ def main_loop():
468469

469470
if __name__ == "__main__":
470471
signal.signal(signal.SIGINT, signal_handler)
471-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
472472
default_transparency = get_transparency_effects()
473473

474474
# Try to load default settings from the registry

scripts/utils/update_package.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def get_latest_version(org, project, version):
3939
latest_version = response.json()["tag_name"]
4040
# version excludes `v` from the capturing group in the regex in update_github_url therefore latest_version_match mustn't include `v` if the version starts with `v`. Otherwise the github URL would replace the version without the `v` with the github version tag with the `v` which will result in the wrong URL such as: https://github.com/jstrosch/sclauncher/releases/download/vv0.0.6/sclauncher.exe
4141
if latest_version.startswith('v'):
42-
return latest_version[1:]
42+
return latest_version[1:]
4343
else:
44-
return latest_version
44+
return latest_version
4545

4646

4747
# Get url response's content hash (SHA256)

0 commit comments

Comments
 (0)