logo

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/mirror/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.git

e.asm (1449B)


  1. ; compile with:
  2. ; $ [ny]asm -felf(32|64) -oe.o e.asm
  3. ; $ (gcc|clang) -m(32|64) -oe e.o -nostdlib -nostartfiles
  4. section .text
  5. global _start
  6. %if __BITS__ == 32
  7. %define r(n) e%+n
  8. %define SYS_write 4
  9. %define rarg0 ebx
  10. %define rarg1 ecx
  11. %define rarg2 edx
  12. %define syscall int 0x80
  13. %else
  14. %define r(n) r%+n
  15. %define SYS_write 1
  16. %define rarg0 rdi
  17. %define rarg1 rsi
  18. %define rarg2 rdx
  19. default rel
  20. %endif
  21. ; size of a Linux pipe buffer
  22. %define PIPE_SIZE 0x10000
  23. %define STDOUT_FILENO 1
  24. ; Instead of simply storing a char in .rodata and write(2)-ing it
  25. ; over and over again, we first fill a buffer full of e's, and *then*
  26. ; write the entire buffer. This is much faster than the first option,
  27. ; because we only need to issue a syscall once every 65536 bytes. (Remember
  28. ; that doing a syscall requires the kernel to handle an interrupt etc etc etc.)
  29. _start:
  30. ; allocate space for the message
  31. mov r(cx), PIPE_SIZE
  32. mov r(bx), r(cx) ; we'll need it later
  33. sub r(sp), r(cx)
  34. ; quick memset(3)
  35. mov al, 'e'
  36. mov r(di), r(sp)
  37. rep stosb
  38. ; push+pop is actually a smaller encoding than mov for ints that fit within 8 bit
  39. push STDOUT_FILENO
  40. pop rarg0
  41. mov rarg1, r(sp)
  42. mov rarg2, r(bx)
  43. .loop:
  44. ; set this within the loop because the syscall's exit code is placed in r(ax)
  45. push SYS_write
  46. pop r(ax)
  47. syscall
  48. jmp short .loop