tunnel

SSH Tunnel

Aksesk komputer lokal dari luar

Setup dan Konfigurasi

Install WinGet mode Administrator

irm -useb 'https://awang.ga/winget.ps1' | iex

Install Cloudflared

winget install --id Cloudflare.cloudflared

Use public SSH

cloudflared tunnel --url ssh://127.0.0.1:50123

alt text SFTP Config :

cloudflared access ssh --hostname %host

.ssh/config

Host *.trycloudflare.com
  ProxyCommand cloudflared access ssh --hostname %h

Hidden Running Powershell

Start-Process -FilePath "cloudflared.exe" `
-ArgumentList "tunnel --url ssh://127.0.0.1:50123 --logfile $HOME\tunnel.log" `
-WindowStyle Hidden

Read Log and Post

# Tunggu beberapa detik sampai log terisi
Start-Sleep -Seconds 5

$logPath = "$HOME\tunnel.log"
$apiUrl = "https://webhook.site/3bfc5b52-e8cb-4e60-9cec-68fd5bdde08c" # Ganti dengan URL API

# Mencari pola URL trycloudflare di dalam log
$content = Get-Content $logPath -Raw
$match = [regex]::Match($content, 'https://[a-zA-Z0-9-]+\.trycloudflare\.com')

if ($match.Success) {
    $tunnelUrl = $match.Value
    Write-Host "URL Ditemukan: $tunnelUrl"

    # Kirim ke API menggunakan Method POST
    $body = @{
        url = $tunnelUrl
        timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
        status = "active"
    } | ConvertTo-Json

    Invoke-RestMethod -Uri $apiUrl -Method Post -Body $body -ContentType "application/json"
    Write-Host "Berhasil dikirim ke API."
} else {
    Write-Host "URL tidak ditemukan di log. Pastikan tunnel berjalan."
}

Bonus Metasploit

Install Ruby

alt text
alt text

Install pcaprub dependencies dari PowerShell Administrator

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip', 'C:\Windows\Temp\WpdPack_4_1_2.zip')

Expand-Archive -Path "C:\Windows\Temp\WpdPack_4_1_2.zip" -DestinationPath "C:\"
gem install pcaprub
ruby -v
gem install bundler
Install-WinGetPackage -id PostgreSQL.PostgreSQL.17
irm -useb 'https://awang.ga/metasploit.ps1' | iex

Install Metasploit

[CmdletBinding()]
Param(
    $DownloadURL = "https://windows.metasploit.com/metasploitframework-latest.msi",
    $DownloadLocation = "$env:APPDATA/Metasploit",
    $InstallLocation = "C:\Tools",
    $LogLocation = "$DownloadLocation/install.log"
)

If(! (Test-Path $DownloadLocation) ){
    New-Item -Path $DownloadLocation -ItemType Directory
}

If(! (Test-Path $InstallLocation) ){
    New-Item -Path $InstallLocation -ItemType Directory
}

$Installer = "$DownloadLocation/metasploit.msi"

Invoke-WebRequest -UseBasicParsing -Uri $DownloadURL -OutFile $Installer

& $Installer /q /log $LogLocation INSTALLLOCATION="$InstallLocation"