Skip to content

Commit

Permalink
Updated TOR module
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpan Sarkar committed Dec 7, 2023
1 parent c9b2180 commit 1290a80
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions Library/TORAnonymizer.ps1
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
function TORAnonymizer ($command){

#Read MAAD-AF local config for TOR module
$maad_config = Get-Content $global:maad_config_path | ConvertFrom-Json
$tor_root_directory = $maad_config.tor_config.tor_root_directory
$tor_host = $maad_config.tor_config.tor_host
$tor_port = $maad_config.tor_config.tor_port

if ($command -eq "start") {
$global:tor_proxy = $false

$inititate_anonymity = Read-Host -Prompt "`nWould you like to keep your traffic anonymous? (Yes/No)"
$global:tor_proxy = $false
mitre_details("TORAnonymizer")

Write-Host "[i] Selecting (Yes) will attempt to connect to the TOR network" -ForegroundColor Cyan

if ($inititate_anonymity -notin "No","no","N","n") {
Write-Host "`n#####################Important Information#####################" -ForegroundColor Gray
Write-Host "To offer anonymity the tool will attempt to route your traffic through TOR nodes." -ForegroundColor Gray
Write-Host "Selecting (Yes) will attempt to hide the source of your traffic by executing TOR and configuring your device to use a proxy(tool can do this automatically)." -ForegroundColor Gray
Write-Host "Enabling TOR may result in overall slower network traffic simply due to the nature of it." -ForegroundColor Gray
Write-Host "Selecting (No) will not make any changes to your host or network and MAAD-AF will continue as usual." -ForegroundColor Gray
Write-Host "Enabling TOR module requires TOR executable installed on your host, if not already installed." -ForegroundColor Gray
Write-Host "If you do not have the TOR executable installed on your host please select (No) now to skip using TOR." -ForegroundColor Gray
Write-Host "###############################################################" -ForegroundColor Gray
$inititate_anonymity = Read-Host -Prompt "`nWould you like to continue and establish anonymity? (Yes/No)"
}

$inititate_anonymity = Read-Host -Prompt "`n[?] Confirm to connect to TOR network and establish anonymity? (Yes/No)"
Write-Host ""

if ($inititate_anonymity -notin "No","no","N","n"){
mitre_details("TORAnonymizer")

#Check from local config file if TOR config has been updated by user
if ($tor_root_directory -eq "C:\Users\username\sub_folder\Tor Browser"){
Write-Host "TOR executable not found on the host!!!" -ForegroundColor Red
Write-Host "`n[Tip]`n1. Check that TOR is installed on your host. Checkout: https://www.torproject.org/`n2. Update the TOR direcotry path in MAAD_Config.ps1" -ForegroundColor Gray
Write-Host "`nMAAD-AF will now continue without TOR" -ForegroundColor Gray
if (-Not (Test-Path -Path $tor_root_directory)){
Write-Host "[x] TOR executable not found" -ForegroundColor Red
Write-Host "[i] Check if TOR is installed on your host" -ForegroundColor Cyan
Write-Host "[i] Checkout: https://www.torproject.org/" -ForegroundColor Cyan
Write-Host "[i] Update the TOR direcotry path in: $global:maad_config_path" -ForegroundColor Cyan
Write-Host ""
Pause
return
}

Write-Host "Initiating TOR..." -ForegroundColor Gray
invoke-expression 'cmd /c start powershell -NoExit -Command {. .\Library\TORAnonymizer.ps1;TORProxy}'
Write-Warning "TOR server is initiated in a separate window. Please do not close the window if you want TOR to be running!!!"
Write-Host "Connecting to TOR nodes..." -ForegroundColor Gray
Write-Host "[*] Initiating TOR" -ForegroundColor Gray
invoke-expression 'cmd /c start powershell -NoExit -Command {. .\Library\TORAnonymizer.ps1; TORProxy}'
Write-Host "[*] TOR proxy initialized in new PS window" -ForegroundColor Gray
Start-Sleep -Seconds 3

Write-Host "`nConfiguring Proxy on host to route traffic through TOR..." -ForegroundColor Gray
Write-Host "[*] Configuring host proxy to route traffic through TOR" -ForegroundColor Gray
try {
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value "http://127.0.0.1:9150" -ErrorAction Stop
Write-Host "Modified keys to add TOR proxy" -ForegroundColor Gray
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value "$($tor_host):$($tor_port)" -ErrorAction Stop
Write-Host "[*] Host keys modified to add TOR proxy" -ForegroundColor Gray
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -Value 1 -ErrorAction Stop
Write-Host "Modified keys to enable TOR proxy" -ForegroundColor Gray
Write-Host "[*] Host keys modified to enable TOR proxy" -ForegroundColor Gray
$global:tor_proxy = $true

Write-Host "`n[+] Routing traffic through TOR`n" -ForegroundColor Yellow
Write-MAADLog "START" "TOR started"
}
catch {
Write-Host "[Error] Failed to setup proxy for TOR" -ForegroundColor Red
Write-Host "`n[x] Failed to configure host proxy for TOR" -ForegroundColor Red
break
}
}

Write-Host "`nRouting traffic through TOR nodes..." -ForegroundColor Gray
Write-Host "[TOR Active] Going Dark - You are now anonymous" -ForegroundColor Yellow
Write-MAADLog "START" "TOR started"
Write-Host ""
Pause
}
}

Expand All @@ -62,6 +62,7 @@ function TORAnonymizer ($command){
}
function TORProxy {
#Load local proxy configuration from maad_config
$global:maad_config_path = ".\Local\MAAD_AF_Global_Config.json"
$maad_config = Get-Content $global:maad_config_path | ConvertFrom-Json

$control_port = $maad_config.tor_config.control_port
Expand All @@ -70,15 +71,17 @@ function TORProxy {
$tor_port = $maad_config.tor_config.tor_port

#set parameters for tor executable
$tor_exe = "tor_root_directory\Browser\TorBrowser\Tor\tor.exe"
$tor_exe = "$tor_root_directory\Browser\TorBrowser\Tor\tor.exe"
$torrc_defaults = "$tor_root_directory\Browser\TorBrowser\Data\Tor\torrc-defaults"
$torrc = "$tor_root_directory\Browser\TorBrowser\Data\Tor\torrc"
$tor_data = "$tor_root_directory\Browser\TorBrowser\Data\Tor"
$geo_IP_file = "$tor_root_directory\Browser\TorBrowser\Data\Tor\geoip"
$geo_IPv6_file = "$tor_root_directory\Browser\TorBrowser\Data\Tor\geoip6"

#Run TOR proxy
Write-Host "`nRunning TOR..." -ForegroundColor Gray
Write-Host "`nHit 'Ctrl+C' to stop Tor!" -ForegroundColor Gray
Write-Host "`n[*] TOR started" -ForegroundColor Gray
Write-Host "`n[i] Do not close the window if you want TOR running" -ForegroundColor Cyan
Write-Host "`n[i] Continue using MAAD-AF in the primary terminal" -ForegroundColor Cyan
Write-Host "`n[i] Press 'Ctrl+C' to stop TOR" -ForegroundColor Cyan
& "$tor_exe" --defaults-torrc $torrc_defaults -f $torrc DataDirectory $tor_data GeoIPFile $geo_IP_file GeoIPv6File $geo_IPv6_file +__ControlPort $control_port +__HTTPTunnelPort "${tor_host}:$tor_port IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth" __OwningControllerProcess $PID | more
}

0 comments on commit 1290a80

Please sign in to comment.