HACKING 120% {Hacking, programmazione, computer & molto altro}

[linux/asm_x-86_64] Emulazione di 'cat'

« Older   Newer »
  Share  
vogy
view post Posted on 17/9/2014, 18:26     +1   -1




Dopo essermi fatto quella porcheria di haskell me la darete un po' di pausa, vero?
CODICE
; asmcat :: linux 'cat' asm-x_86-64 revisited
; $ nasm -f elf64 thisfile.asm
; $ ld -f elf_x86_64 thisfile.o -o filename

global _start

section .bss

  Buffer   resb 0x1000       ; 4096 byte

section .text

_start:

  push     rbp
  mov      rbp,rsp

  cmp      rsp,0x2           ; argc = 2
  jl       _exit

  mov      rax,0x2           ; open((argv[1]), 0, 0)
  mov      rdi,[rsp+0x18]
  mov      rsi,0
  mov      rdx,0
  syscall
  mov      rbx,rax           ; save fhandle

_input:

  mov      rax,0             ; read
  mov      rdi,rbx
  mov      rsi,Buffer
  mov      rdx,0x1000
  syscall

  cmp      rax,0
  jl       _exit
  jne      _output

  mov      rax, 0x3          ; close file
  mov      rdi, rbx
  syscall
  jmp      _exit

_output:

  mov      rdx, rax
  mov      rax,0x1           ; write
  mov      rdi,0x1
  mov      rsi,Buffer
  syscall
  cmp      rax, 0
  jle      _exit
  jmp      _input

_exit:

  mov rax,0x3c               ; exit
  syscall

CODICE
vogy@eve:~$ for i in `seq 10000`; do cat /etc/init.d/cups >> asmcat_test; done
vogy@eve:~$ ls -sk | grep asmcat_test
31100 asmcat_test
vogy@eve:~$ time cat asmcat_test
.....
real    0m5.444s
user    0m0.002s
sys     0m1.621s
vogy@eve:~$  time ./asmcat asmcat_test
.....
real    0m4.858s
user    0m0.007s
sys     0m1.268s

Nota importante:
il buffer di lettura è di 4Kb che supongo vada bene un po' per tutti; il valore ottimale dipende dal vostro hardware, più è alto più il programma fila via.
Le righe da sostituire sono 2:
CODICE
.....
  Buffer   resb 0x1000          ; 4096 byte
.....
  mov      rdx,0x1000
 
Top
view post Posted on 17/9/2014, 18:44     +1   -1
Avatar

Water can take unforseen forms.

Group:
Founder
Posts:
5,273
Reputation:
+1,147
Location:
Shabang

Status:


Yee! :rolleyes:
 
Web  Top
vogy
view post Posted on 18/9/2014, 00:43     +1   -1




...mi piace il look serioso del tuo nuovo avatar :o:
 
Top
view post Posted on 18/9/2014, 22:34     +1   -1
Avatar

Water can take unforseen forms.

Group:
Founder
Posts:
5,273
Reputation:
+1,147
Location:
Shabang

Status:


Un font fiqo e un cerchio; il tutto inclinato .. Non è così complesso :asd:
 
Web  Top
gianna77
view post Posted on 19/9/2014, 14:18     +1   -1




come posso ricavare cvv dai 16
 
Top
vogy
view post Posted on 20/9/2014, 18:03     +1   -1




CITAZIONE (gianna77 @ 19/9/2014, 15:18) 
come posso ricavare cvv dai 16

suppongo che la domanda sia: "Come posso ricavare il CVV di una carta di credito avendo il codice a 16 caratteri?"
...sicuramente non con un cat scritto in asm
tra l'altro sta anche attenta a cercare certe info, ci sta che ti fanno fuori il tuo
 
Top
5 replies since 17/9/2014, 18:26   145 views
  Share