Last active
February 12, 2024 03:02
-
-
Save odtmusisi19/178ad15b04da6d3c57616167d9cdd539 to your computer and use it in GitHub Desktop.
digunakan untuk mengubah mac address secara otomatis ketika komputer tidak terhubung ke internet, kumpulan mac addressnya di ambil dari file.txt, yang dimana ketika tidak terhubung ke internet maka mac address akan dibuah. NOTE : ini hanya digunakan untuk wifi vouceran yang bisa akses internet ketika mac tersebut sudah terdaftar di MIkrotik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sesuaikan lokasi tempat ada menyimpan file.txt yang berisi mac address. | |
$macAddressFilePath = "C:\Users\ASUS\OneDrive\Desktop\WireShark Output\MAC_Address.txt" | |
function Set-MACAddress { | |
param( | |
[string]$interfaceName, | |
[string]$macAddress | |
) | |
Write-Host "Mengubah MAC Address menjadi $macAddress" | |
Set-NetAdapterAdvancedProperty -Name $interfaceName -RegistryKeyword "NetworkAddress" -RegistryValue $macAddress | |
} | |
function Test-InternetConnection { | |
try { | |
$request = [System.Net.WebRequest]::Create("http://www.google.com") | |
$response = $request.GetResponse() | |
$response.Close() | |
return $true | |
} catch { | |
return $false | |
} | |
} | |
function Get-MACAddressesFromFile { | |
try { | |
$macAddresses = Get-Content $macAddressFilePath | |
return $macAddresses -split "`r?`n" | ForEach-Object { $_.Trim() } | |
} catch { | |
Write-Host "Gagal membaca MAC Address dari file." | |
return $null | |
} | |
} | |
# Ambil semua MAC Address dari file teks | |
$macAddresses = Get-MACAddressesFromFile | |
# Indeks untuk mengikuti MAC Address yang sedang digunakan | |
$currentMacIndex = 0 | |
while ($true) { | |
if (Test-InternetConnection) { | |
Write-Host "Terhubung ke Internet." | |
} else { | |
Write-Host "Tidak terhubung ke Internet. Mengubah MAC Address." | |
$macAddress = $macAddresses[$currentMacIndex] | |
if ($macAddress) { | |
Set-MACAddress -interfaceName "Ethernet" -macAddress $macAddress | |
$currentMacIndex = ($currentMacIndex + 1) % $macAddresses.Count | |
} else { | |
Write-Host "Gagal mengubah MAC Address karena tidak bisa membaca dari file." | |
} | |
} | |
# Menunggu 30 detik sebelum memeriksa koneksi lagi | |
Start-Sleep -Seconds 10 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Untuk menggunkan script ini anda harus menginstal Python Terlebih dahulu. | |
# Sesuaikan nama dan lokasi dari file.txt dan output.txt. | |
input_file = "file.txt" | |
output_file = "output.txt" | |
# Membaca isi file input | |
with open(input_file, "r") as f: | |
lines = f.readlines() | |
# Membuka file output untuk menulis | |
with open(output_file, "w") as f: | |
# Loop melalui setiap baris dalam file input | |
for line in lines: | |
# Mencari teks yang diapit oleh tanda kutip (" ") | |
start_quote_index = line.find('"') | |
end_quote_index = line.find('"', start_quote_index + 1) | |
if start_quote_index != -1 and end_quote_index != -1: | |
text_inside_quotes = line[start_quote_index + 1:end_quote_index] | |
# Menulis teks yang di dalam tanda kutip ke file output | |
f.write(text_inside_quotes + "\n") | |
print("Hasil telah disimpan dalam file", output_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jalankan script di atas di Powershel, gunakan perintah = > Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/odtmusisi19/178ad15b04da6d3c57616167d9cdd539/raw/55351e91e194cb0f58982e02e2883c12b92de6ac/autoChangeMacAddress.ps1'))