Running x86 code on ARM devices

    Table of Contents

    To run x86 code we are going to utilize qemu-user-static.

    Install necessary packages

    [email protected]:~$ sudo apt update
    [email protected]:~$
    [email protected]:~$ sudo apt install -y qemu-user-static binfmt-support
    [email protected]:~$
    [email protected]:~$ sudo dpkg --add-architecture amd64
    [email protected]:~$
    [email protected]:~$ sudo apt update
    [email protected]:~$
    [email protected]:~$ sudo apt install libc6:amd64
    [email protected]:~$
    

    Please keep in mind that more libraries may need to be installed depending on what package is being ran. In some cases these libraries will be installed automatically with the package install, however in others some research must be done to learn what is missing.

    Running x86 code

    # Before qemu-user-static install
    [email protected]:~$ sudo dpkg --add-architecture amd64
    [email protected]:~$
    [email protected]:~$ sudo apt install -y powershell
    [email protected]:~$
    [email protected]:~$ file /opt/microsoft/powershell/7/pwsh
    /opt/microsoft/powershell/7/pwsh: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9c3feab2531f770c71d023f031faf37758181701, stripped
    [email protected]:~$
    [email protected]:~$ pwsh
    zsh: exec format error: pwsh
    [email protected]:~$
    # After qemu-user-static install
    [email protected]:~$ sudo apt install -y qemu-user-static binfmt-support
    [email protected]:~$
    [email protected]:~$ pwsh
    PowerShell 7.1.3
    Copyright (c) Microsoft Corporation.
    
    https://aka.ms/powershell
    Type 'help' to get help.
    
    
    ┌──(kali㉿kali)-[/home/kali]
    └─PS>
    

    If there is a downloaded binary that is x86 that is not automatically being ran under qemu-user-static, you can invoke it with the following command:

    [email protected]:~$ qemu-x86_x64-static my_x86_code
    [email protected]:~$
    

    Updated on: 2023-Feb-04
    Author: gamb1t