> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/connect-to-machines/32-or-64-bit.md).

# 32- or 64-bit?

Before starting to look at this, its important to be clear about what you mean by "64 bit".\
You can have a 64 bit CPU, a 64 bit Operating System and a 64 bit process running.

Here are the possible combinations:

|                    | CPU Hardware | Operating System | Process  |
| ------------------ | ------------ | ---------------- | -------- |
| 32-bit hardware    | 32           | 32               | 32       |
| 32-bit OS          | **64**       | 32               | 32       |
| 32-bit application | **64**       | **64**           | 32 (WOW) |
| Full 64-bit        | **64**       | **64**           | **64**   |

## Checking the Application

### Checking on Windows

#### Checking in PowerShell

This check will output `True` on a "match" and nothing otherwise

```powershell
PS C:\> [Environment]::is64bitprocess
True
PS C:\> [Environment]::is32bitprocess
PS C:\>
```

## Checking the OS

### Checking on Linux

#### Checking with uname

This check will output `x86_54` in 64-bit and `i686` if 32-bit

```bash
┌──(kali㉿kali)-[~]
└─$ uname -m                              
x86_64
```

### Checking on Windows

#### Checking in cmd.exe

This check will output `AMD64` if 64-bit

```batch
C:\>echo %PROCESSOR_ARCHITECTURE%
AMD64
```

#### Checking in PowerShell

This check will output `True` on a "match" and nothing otherwise

```powershell
PS C:\> [Environment]::Is64BitOperatingSystem
True
PS C:\> [Environment]::Is32BitOperatingSystem
PS C:\>
```

#### Checking with wmic

This check will output `64-bit` or `32-bit`

```batch
PS C:\> wmic.exe os get osarchitecture
OSArchitecture
64-bit
```

## Checking the Hardware/CPU

### Checking on Linux

#### Checking with lshw

You may need to install this package with `sudo apt install lshw`.

```bash
┌──(kali㉿kali)-[~]
└─$ sudo lshw -class cpu
  *-cpu:0                   
       description: CPU
       product: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
       vendor: Intel Corp.
       physical id: 1
       bus info: cpu@0
       version: 6.60.3
       slot: CPU #000
       size: 3600MHz
       capacity: 4230MHz
       width: 64 bits
<---snip--->
```

## Resources

How-to: Detecting 64 bit vs 32 bit - SS64.com: <https://ss64.com/nt/syntax-64bit.html>
