Skip to content

Commit

Permalink
Add internet detector utility
Browse files Browse the repository at this point in the history
Co-authored-by: Ana Martinez Gomez <[email protected]>
  • Loading branch information
emtuls and Ana06 committed Aug 30, 2024
1 parent 5efa360 commit 43cd48d
Show file tree
Hide file tree
Showing 8 changed files with 838 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/internet_detector.vm/internet_detector.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>internet_detector.vm</id>
<version>1.0.0</version>
<authors>Elliot Chernofsky and Ana Martinez Gomez</authors>
<description>Tool that changes the background and a taskbar icon if it detects internet connectivity</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240821" />
<dependency id="libraries.python3.vm" version="0.0.0.20240726" />
<dependency id="fakenet-ng.vm" version="3.2.0.20240425" />
</dependencies>
</metadata>
</package>
42 changes: 42 additions & 0 deletions packages/internet_detector.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'internet_detector'
$category = 'Utilities'
$packageToolDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

# Install dependency for windows api
VM-Pip-Install "pywin32"
# Install dependency for creating python executable
VM-Pip-Install "pyinstaller"

pyinstaller --onefile -w --distpath $packageToolDir internet_detector.pyw

# Create tool directory
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName
New-Item -Path $toolDir -ItemType Directory -Force -ea 0
VM-Assert-Path $toolDir

# Copy executable to %RAW_TOOLS_DIR%
$executablePath = Join-Path $packageToolDir "dist\$toolName.exe"
Copy-Item $executablePath $toolDir
$rawToolPath = Join-Path $toolDir "$toolName.exe"

# Move images to %VM_COMMON_DIR% directory
$imagesPath = Join-Path $packageToolDir "Images"
Copy-Item "$imagesPath\*" ${Env:VM_COMMON_DIR} -Force

VM-Install-Shortcut $toolName $category $rawToolPath

# TODO - Uncomment when FakeNet BlackList for DNS is fixed. https://github.com/mandiant/flare-fakenet-ng/issues/190
# # Create scheduled task for tool to run every 2 minutes.
# $action = New-ScheduledTaskAction -Execute $rawToolPath
# $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 2)
# Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'Internet Detector' -Force

# Copy updated `default.ini` with tool added to ProcessBlackList to FakeNet Config Directory
$fakenetConfigDir = Join-Path ${Env:UserProfile} "Desktop\fakenet_logs.lnk"
if (Test-Path $fakenetConfigDir) { # Check if the shortcut exists
$targetPath = (New-Object -ComObject WScript.Shell).CreateShortcut($fakenetConfigDir).TargetPath
Copy-Item "$packageToolDir\default.ini" -Destination $targetPath
}
8 changes: 8 additions & 0 deletions packages/internet_detector.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'internet_detector'
$category = 'Utilities'

VM-Uninstall $toolName $category
Unregister-ScheduledTask -TaskName 'Internet Detector' -Confirm:$false
Loading

0 comments on commit 43cd48d

Please sign in to comment.