04. THE SAFE ANALYSIS LAB

PROTOCOL: ISOLATION & VIRTUALIZATION TECHNIQUES
STATUS: ACTIVE RESEARCH

☣️ 09. The Golden Rule: Isolation

The most common mistake beginners make in hardware security is testing "unknown" USB devices on their primary computer. This is a fatal error. A single BadUSB script can exfiltrate your Chrome passwords, install a persistent backdoor, or encrypt your files (Ransomware) in under 5 seconds. A USB Killer will physically fry your motherboard instantly.

Therefore, we must build a dedicated environment. This concept is called "Air Gapping" or "Sandboxing".

09. රන් නීතිය: හුදකලා කිරීම (Isolation)
හාඩ්වෙයාර් හැකින් ඉගෙන ගන්න අය කරන ලොකුම මෝඩකම තමයි, තමන් දන්නේ නැති USB ඩිවයිස් තමන්ගේ ප්‍රධාන කම්පියුටර් එකට (Personal PC) ගහලා බලන එක. මේක මාරාන්තික වැරැද්දක්.
BadUSB එකකට පුළුවන් තත්පර 5ක් ඇතුළත ඔයාගේ බ්‍රව්සර් එකේ සේව් කරලා තියෙන පාස්වර්ඩ් ටික උස්සන්න, නැත්නම් රැන්සම්වෙයාර් (Ransomware) එකක් දාලා ෆයිල් ඔක්කොම ලොක් කරන්න. USB Killer එකක් ගැහුවොත් මදර්බෝඩ් එක එතනම ඉවරයි.

ඒ නිසා අපි හදන්න ඕනේ "Lab Environment" එකක්. ඒ කියන්නේ අපේ වටිනා මැෂින් එකට හානියක් නොවී මේවා ටෙස්ට් කරන ක්‍රමයක්.

WARNING: NEVER PLUG A FOUND USB DRIVE INTO YOUR MAIN PC.
අවවාදයයි: අහුලාගත් පෙන් ඩ්‍රයිව් කිසිවිටෙකත් ඔබගේ ප්‍රධාන පරිගණකයට සම්බන්ධ නොකරන්න.

💻 10. Level 1 Defense: Virtual Machines (VM)

For Software-based attacks (like BadUSB/Rubber Ducky), we can use Virtual Machines. A VM is a computer inside a computer. If the virus destroys the VM, your real computer stays safe. We use tools like VMware Workstation or Oracle VirtualBox.

Crucial Step: USB Passthrough
By default, when you plug a USB, the host (Main PC) reads it first. We need to configure the VM to "grab" the USB connection before the host processes it completely. This is risky but effective for script analysis.

10. පළමු ආරක්ෂක වළල්ල: අතථ්‍ය පරිගණක (Virtual Machines)
BadUSB වගේ "සොෆ්ට්වෙයාර්" පැත්තේ ඇටෑක් වලට අපිට Virtual Machine (VM) එකක් පාවිච්චි කරන්න පුළුවන්. VM එකක් කියන්නේ අපේ කම්පියුටර් එක ඇතුළේ දුවන තවත් පොඩි කම්පියුටර් එකක්. වයිරස් එකක් ගිහින් VM එක කැඩුණත්, අපේ ඇත්ත කම්පියුටර් එකට මුකුත් වෙන්නේ නෑ. අපි මේකට VirtualBox හෝ VMware පාවිච්චි කරනවා.

වැදගත්ම දේ: USB Passthrough
සාමාන්‍යයෙන් පෙන් එකක් ගැහුවම මුලින්ම ඒක කියවන්නේ අපේ ඇත්ත මැෂින් එක (Host). ඒක භයානකයි. ඒ නිසා අපි VM එකේ සෙටින්ග්ස් හදන්න ඕනේ, පෙන් එක ගැහුව ගමන් ඒක කෙළින්ම VM එක ඇතුළට ඇදලා ගන්න විදිහට. (මේක ටිකක් අවදානම්, ඒත් ස්ක්‍රිප්ට් බලන්න හොඳ ක්‍රමයක්).

[HOST-OS] sudo dmesg | grep usb
[ 12.459] New USB Device Found: idVendor=05ac, idProduct=12a8
[HOST-OS] VBoxManage list usbhost
UUID: 3498-5588-acde-9900
VendorId: 0x05ac (Apple)
ProductId: 0x12a8 (Keyboard?)
>> ATTACHING TO VM "KALI_LINUX_LAB" <<
[WARNING] USB Handover initiated. Host will lose control of this device.

🐑 11. Level 2 Defense: The "Sacrificial Lamb"

For Hardware-based attacks (like USB Killers), a Virtual Machine is USELESS. A USB Killer will fry the physical USB port, the motherboard, and potentially the host CPU, regardless of whether you are running a VM.

The Solution: Use a "Sacrificial Lamb". This is an old, cheap laptop or a Raspberry Pi that you don't mind destroying. Never test a USB Killer on a machine you love.

11. දෙවන ආරක්ෂක වළල්ල: බිලි දෙන මැෂින් එක (The Sacrificial Lamb)
හොඳට මතක තියාගන්න: USB Killer එකකට VM හරියන්නේ නෑ!
USB Killer එකකින් එන වෝල්ට් 200ක කරන්ට් එක VM එක අස්සේ හිර වෙන්නේ නෑ. ඒක කෙළින්ම ඇවිල්ලා ඔයාගේ ඇත්ත මදර්බෝඩ් එක පුච්චලා දානවා. සොෆ්ට්වෙයාර් වලින් හාඩ්වෙයාර් කරන්ට් නවත්වන්න බෑ.

විසඳුම: පරණ, කාටවත් එපා වුණ ලැප්ටොප් එකක් හෝ Raspberry Pi එකක් පාවිච්චි කරන්න. ඒක පිච්චුණාට කමක් නැති වෙන්න ඕනේ. අපි ඒකට කියන්නේ "Sacrificial Lamb" (බිල්ලට දෙන සතා) කියලා. USB Killer ටෙස්ට් කරන්න තියෙන එකම ආරක්ෂිත ක්‍රමය මේකයි.

🛡️ 12. The USB "Condom" (Data Blocker)

If you need to charge your phone at a public station (Airport, Cafe), or plug an unknown device just for power, you need a USB Data Blocker (often jokingly called a USB Condom). This device physically disconnects the Data Pins (D+ and D-) and only allows the Power Pins (VCC and GND) to connect.

With a Data Blocker, a BadUSB cannot send keystrokes because the data bridge is broken. It turns a smart hacking tool into a dumb power brick.

12. ඩේටා බ්ලොකර් (USB Condom) - සරල ආරක්ෂාව
ඔයාට කවදාහරි එයාර්පෝට් එකේදී හෝ කැෆේ එකකදී පබ්ලික් පෝර්ට් එකකින් ෆෝන් එක චාර්ජ් කරන්න වුණාද? එහෙම නැත්නම් සැක සහිත ඩිවයිස් එකක් චාර්ජ් කරන්න විතරක් මැෂින් එකට ගහන්න ඕනද? එහෙනම් ඔයාට ඕන USB Data Blocker එකක්.

මේ පුංචි ගැජට් එකෙන් කරන්නේ USB කේබල් එකේ තියෙන ඩේටා යවන වයර් දෙක (D+ සහ D-) භෞතිකව කපලා දාන එකයි. එතකොට කරන්ට් එක විතරක් (VCC/GND) පාස් වෙනවා. BadUSB එකක් මේක හරහා ගැහුවොත්, ඒකේ තියෙන "Keyboard Script" එක මැෂින් එකට යන්න විදිහක් නෑ. ඒ නිසා 100% ක් ආරක්ෂිතයි.

[ USB DATA BLOCKER CIRCUIT DIAGRAM ] (MALE USB SIDE) (FEMALE USB SIDE) [Connects to PC] [Connects to BadUSB] PIN 1 (VCC +5V) -------------------- PIN 1 (VCC) --> [PASS] PIN 2 (DATA -) --X (CUT) X-- PIN 2 (D-) --> [BLOCKED] PIN 3 (DATA +) --X (CUT) X-- PIN 3 (D+) --> [BLOCKED] PIN 4 (GND) -------------------- PIN 4 (GND) --> [PASS] * Result: Power flows, but Scripts/Viruses cannot pass.

📡 13. Analysis Tools: Wireshark & USBPcap

Once you have a safe VM setup, how do you see what the BadUSB is doing? We use Wireshark combined with USBPcap.

USBPcap captures the raw data packets traveling through the USB cable. Wireshark visualizes them. By analyzing these packets, you can see the exact keystrokes the BadUSB is trying to type, even if you execute them inside a safe sandbox.

  • Step 1: Install Wireshark with USBPcap.
  • Step 2: Select the USB Root Hub to sniff.
  • Step 3: Plug in the device.
  • Step 4: Look for "URB_INTERRUPT" packets containing HID data.

13. ඇතුළත දකින ඇස: Wireshark සහ USBPcap
VM එකක් හදාගත්තට පස්සේ, අපි කොහොමද හරියටම බලාගන්නේ මේ BadUSB එක මොනවද කරන්න හදන්නේ කියලා? ඒකට අපි පාවිච්චි කරන්නේ Wireshark.

USB කේබල් එක අස්සෙන් යන ඩේටා පැකට් (Data Packets) අල්ලගන්න අපිට USBPcap කියන ටූල් එක ඕන වෙනවා. මේක දාලා බැලුවම, අර BadUSB එක ටයිප් කරන්න හදන හැම අකුරක්ම, හැම කමාන්ඩ් එකක්ම අපිට ස්ක්‍රීන් එකේ බලාගන්න පුළුවන්. ඒක හරියට USB එකේ "x-ray" එකක් ගත්තා වගේ.

[WIRESHARK CAPTURE START]
Source Destination Protocol Info
Host 3.15.1 USBHID GET_DESCRIPTOR Request DEVICE
3.15.1 Host USBHID GET_DESCRIPTOR Response DEVICE (Ducky)
3.15.1 Host USBHID URB_INTERRUPT in (Key: "W")
3.15.1 Host USBHID URB_INTERRUPT in (Key: "i")
3.15.1 Host USBHID URB_INTERRUPT in (Key: "n")
3.15.1 Host USBHID URB_INTERRUPT in (Key: "R")
[ANALYSIS] Payload detected: "Win+R" (Run Dialog) sequence.