Advertisement
EdmundC

terminal

Oct 6th, 2024 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data
  2.     prompt_msg db "Enter command: ", 0
  3.     ld_bash db "/ld bash", 0
  4.     ld_zsh db "/ld zsh", 0
  5.     ld_crosh db "/ld crosh", 0
  6.     ld_py db "/ld ", 0
  7.     bash_shell db "/bin/bash", 0
  8.     zsh_shell db "/bin/zsh", 0
  9.     crosh_shell db "/path/to/crosh", 0
  10.     python_cmd db "/usr/bin/python3", 0
  11.  
  12. section .bss
  13.     command resb 256
  14.     filename resb 256
  15.  
  16. section .text
  17.     global _start
  18.  
  19. _start:
  20.     ; Display prompt
  21.     mov eax, 4
  22.     mov ebx, 1
  23.     mov ecx, prompt_msg
  24.     mov edx, 13
  25.     int 0x80
  26.  
  27.     ; Read user input
  28.     mov eax, 3
  29.     mov ebx, 0
  30.     mov ecx, command
  31.     mov edx, 256
  32.     int 0x80
  33.  
  34.     ; Check if command is /ld bash
  35.     mov esi, command
  36.     mov edi, ld_bash
  37.     call check_command
  38.     jz load_bash
  39.  
  40.     ; Check if command is /ld zsh
  41.     mov esi, command
  42.     mov edi, ld_zsh
  43.     call check_command
  44.     jz load_zsh
  45.  
  46.     ; Check if command is /ld crosh
  47.     mov esi, command
  48.     mov edi, ld_crosh
  49.     call check_command
  50.     jz load_crosh
  51.  
  52.     ; Check if command starts with /ld filename.py
  53.     mov esi, command
  54.     mov edi, ld_py
  55.     call check_command
  56.     jz decompile_python
  57.  
  58.     ; Exit program if no matching command
  59.     mov eax, 1
  60.     xor ebx, ebx
  61.     int 0x80
  62.  
  63. load_bash:
  64.     ; Execute bash shell
  65.     mov eax, 11
  66.     mov ebx, bash_shell
  67.     xor ecx, ecx
  68.     xor edx, edx
  69.     int 0x80
  70.  
  71. load_zsh:
  72.     ; Execute zsh shell
  73.     mov eax, 11
  74.     mov ebx, zsh_shell
  75.     xor ecx, ecx
  76.     xor edx, edx
  77.     int 0x80
  78.  
  79. load_crosh:
  80.     ; Execute crosh shell
  81.     mov eax, 11
  82.     mov ebx, crosh_shell
  83.     xor ecx, ecx
  84.     xor edx, edx
  85.     int 0x80
  86.  
  87. decompile_python:
  88.     ; Parse filename from command
  89.     mov esi, command
  90.     add esi, 4
  91.     mov edi, filename
  92.     call copy_filename
  93.  
  94.     ; Decompile Python file (simulated)
  95.     ; Use python command to decompile or run
  96.     ; Command: python3 -m py_compile filename.py
  97.     mov eax, 11
  98.     mov ebx, python_cmd
  99.     mov ecx, filename
  100.     xor edx, edx
  101.     int 0x80
  102.  
  103. check_command:
  104.     ; Compare esi (input) with edi (expected)
  105.     mov ecx, 256  ; max length to compare
  106.     repe cmpsb
  107.     sete al
  108.     ret
  109.  
  110. copy_filename:
  111.     ; Copy filename from input to filename buffer
  112.     mov ecx, 256
  113. .copy_loop:
  114.     lodsb
  115.     stosb
  116.     loop .copy_loop
  117.     ret
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement