hacktricks/physical-attacks/physical-attacks.md

165 lines
8.5 KiB
Markdown
Raw Normal View History

2022-05-01 13:25:53 +00:00
# Physical Attacks
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Support HackTricks and get benefits!</strong></summary>
2022-09-09 11:28:04 +00:00
- Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- **Share your hacking tricks by submitting PRs to the** [**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
2022-04-28 16:01:33 +00:00
</details>
2022-05-01 13:25:53 +00:00
## BIOS password
2022-04-28 16:01:33 +00:00
2022-05-01 13:25:53 +00:00
### The battery
2022-05-01 13:25:53 +00:00
Most of the **motherbords** have a **battery**. If you **remove** it **30min** the settings of the BIOS will be **restarted** (password included).
2022-05-01 13:25:53 +00:00
### Jumper CMOS
Most of the **motherboards** have a **jumper** that can restart the settings. This jumper connects a central pin with another, if you **connect thoses pins the motherbord will be reseted**.
2022-05-01 13:25:53 +00:00
### Live Tools
2022-05-01 13:25:53 +00:00
If you could **run** for example a **Kali** Linux from a Live CD/USB you could use tools like _**killCmos**_ or _**CmosPWD**_ (this last one is included in Kali) you could try to **recover the password of the BIOS**.
2022-05-01 13:25:53 +00:00
### Online BIOS password recovery
2022-05-01 13:25:53 +00:00
Put the password of the BIOS **3 times wrong**, then the BIOS will **show an error messag**e and it will be blocked.\
Visit the page [https://bios-pw.org](https://bios-pw.org) and **introduce the error code** shown by the BIOS and you could be lucky and get a **valid password** (the **same search could show you different passwords and more than 1 could be valid**).
2022-05-01 13:25:53 +00:00
## UEFI
2022-05-01 13:25:53 +00:00
To check the settings of the UEFI and perform some kind of attack you should try [chipsec](https://github.com/chipsec/chipsec/blob/master/chipsec-manual.pdf).\
Using this tool you could easily disable the Secure Boot:
2022-05-01 13:25:53 +00:00
```
python chipsec_main.py -module exploits.secure.boot.pk
```
2022-05-01 13:25:53 +00:00
## RAM
2022-05-01 13:25:53 +00:00
### Cold boot
2022-05-01 13:25:53 +00:00
The **RAM memory is persistent from 1 to 2 minutes** from the time the computer is powered off. If you apply **cold** (liquid nitrogen, for example) on the memory card you can extend this time up to **10 minutes**.
2022-05-01 13:25:53 +00:00
Then, you can do a **memory dump** (using tools like dd.exe, mdd.exe, Memoryze, win32dd.exe or DumpIt) to analyze the memory.
You should **analyze** the memory **using volatility**.
2022-05-01 13:25:53 +00:00
### [INCEPTION](https://github.com/carmaa/inception)
2022-05-01 13:25:53 +00:00
Inception is a **physical memory manipulation** and hacking tool exploiting PCI-based DMA. The tool can attack over **FireWire**, **Thunderbolt**, **ExpressCard**, PC Card and any other PCI/PCIe HW interfaces.\
**Connect** your computer to the victim computer over one of those **interfaces** and **INCEPTION** will try to **patch** the **pyshical memory** to give you **access**.
**If INCEPTION succeeds, any password introduced will be vaid.**
2021-07-27 15:02:16 +00:00
**It doesn't work with Windows10.**
2022-05-01 13:25:53 +00:00
## Live CD/USB
2022-05-01 13:25:53 +00:00
### Sticky Keys and more
* **SETHC:** _sethc.exe_ is invoked when SHIFT is pressed 5 times
* **UTILMAN:** _Utilman.exe_ is invoked by pressing WINDOWS+U
* **OSK:** _osk.exe_ is invoked by pressing WINDOWS+U, then launching the on-screen keyboard
* **DISP:** _DisplaySwitch.exe_ is invoked by pressing WINDOWS+P
2022-05-01 13:25:53 +00:00
These binaries are located inside _**C:\Windows\System32**_. You can **change** any of them for a **copy** of the binary **cmd.exe** (also in the same folder) and any time that you invoke any of those binaries a command prompt as **SYSTEM** will appear.
2022-05-01 13:25:53 +00:00
### Modifying SAM
2022-05-01 13:25:53 +00:00
You can use the tool _**chntpw**_ to **modify the** _**SAM**_ **file** of a mounted Windows filesystem. Then, you could change the password of the Administrator user, for example.\
This tool is available in KALI.
2022-05-01 13:25:53 +00:00
```
chntpw -h
chntpw -l <path_to_SAM>
```
**Inside a Linux system you could modify the** _**/etc/shadow**_ **or** _**/etc/passwd**_ **file.**
2022-05-01 13:25:53 +00:00
### **Kon-Boot**
2022-05-01 13:25:53 +00:00
**Kon-Boot** is one of the best tools around which can log you into Windows without knowing the password. It works by **hooking into the system BIOS and temporarily changing the contents of the Windows kernel** while booting (new versions work also with **UEFI**). It then allows you to enter **anything as the password** during login. The next time you start the computer without Kon-Boot, the original password will be back, the temporary changes will be discarded and the system will behave as if nothing has happened.\
Read More: [https://www.raymond.cc/blog/login-to-windows-administrator-and-linux-root-account-without-knowing-or-changing-current-password/](https://www.raymond.cc/blog/login-to-windows-administrator-and-linux-root-account-without-knowing-or-changing-current-password/)
2022-05-01 13:25:53 +00:00
It is a live CD/USB that can **patch the memory** so you **won't need to know the password to login**.\
Kon-Boot also performs the **StickyKeys** trick so you could press _**Shift**_ **5 times to get an Administrator cmd**.
2022-05-01 13:25:53 +00:00
## **Running Windows**
2022-05-01 13:25:53 +00:00
### Initial shortcuts
2022-05-01 13:25:53 +00:00
### Booting shortcuts
* supr - BIOS
* f8 - Recovery mode
* _supr_ - BIOS ini
* _f8_ - Recovery mode
2022-05-01 13:25:53 +00:00
* _Shitf_ (after the windows banner) - Go to login page instead of autologon (avoid autologon)
2022-05-01 13:25:53 +00:00
### **BAD USBs**
2022-05-01 13:25:53 +00:00
#### **Rubber Ducky tutorials**
* [Tutorial 1](https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Tutorials)
* [Tutorial 2](https://blog.hartleybrody.com/rubber-ducky-guide/)
2022-05-01 13:25:53 +00:00
#### **Teensyduino**
* [Payloads and tutorials](https://github.com/Screetsec/Pateensy)
There are also tons of tutorials about **how to create your own bad USB**.
2022-05-01 13:25:53 +00:00
### Volume Shadow Copy
2022-05-01 13:25:53 +00:00
With administrators privileges and powershell you could make a copy of the SAM file.[ See this code](../windows-hardening/basic-powershell-for-pentesters/#volume-shadow-copy).
2022-05-01 13:25:53 +00:00
## Bypassing Bitlocker
2022-05-01 13:25:53 +00:00
Bitlocker uses **2 passwords**. The one used by the **user**, and the **recovery** password (48 digits).
2022-05-01 13:25:53 +00:00
If you are lucky and inside the current session of Windows exists the file _**C:\Windows\MEMORY.DMP**_ (It is a memory dump) you could try to **search inside of it the recovery password**. You can **get this file** and a **copy of the filesytem** and then use _Elcomsoft Forensic Disk Decryptor_ to get the content (this will only work if the password is inside the memory dump). You could also **force the memory dump** using _**NotMyFault**_ of _Sysinternals,_ but this will reboot the system and has to be executed as Administrator.
You could also try a **bruteforce attack** using _**Passware Kit Forensic**_.
2022-05-01 13:25:53 +00:00
### Social Engineering
Finally, you could make the user add a new recovery password making him executed as administrator:
```bash
schtasks /create /SC ONLOGON /tr "c:/windows/system32/manage-bde.exe -protectors -add c: -rp 000000-000000-000000-000000-000000-000000-000000-000000" /tn tarea /RU SYSTEM /f
```
2022-05-01 13:25:53 +00:00
This will add a new recovery key (composed of 48 zeros) in the next login.
To check the valid recovery keys you can execute:
2022-05-01 13:25:53 +00:00
```
manage-bde -protectors -get c:
```
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Support HackTricks and get benefits!</strong></summary>
2022-09-09 11:28:04 +00:00
- Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
2022-04-28 16:01:33 +00:00
2022-09-09 11:28:04 +00:00
- **Share your hacking tricks by submitting PRs to the** [**hacktricks github repo**](https://github.com/carlospolop/hacktricks)**.**
2022-04-28 16:01:33 +00:00
</details>