Be myself :: shared object executable

달력

32024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

shared object executable

Exploit 2015. 6. 27. 00:26

http://stackoverflow.com/questions/1449987/building-a-so-that-is-also-an-executable


/* pie.c */
#include <stdio.h>
int foo()
{
  printf("in %s %s:%d\n", __func__, __FILE__, __LINE__);
  return 42; 
}
int main() 
{ 
  printf("in %s %s:%d\n", __func__, __FILE__, __LINE__);
  return foo(); 
}


/* main.c */
#include <stdio.h>

extern int foo(void);
int main() 
{ 
  printf("in %s %s:%d\n", __func__, __FILE__, __LINE__);
  return foo(); 
}


$ gcc -fPIC -pie -o pie.so pie.c -Wl,-E
$ gcc main.c ./pie.so


$ ./pie.so
in main pie.c:9
in foo pie.c:4
$ ./a.out
in main main.c:6
in foo pie.c:4
$

use pie option

'Exploit' 카테고리의 다른 글

elf의 보호기법 파악  (0) 2014.10.09
메타스플로잇을 이용한 쉘코드 작성  (0) 2014.10.03
스택 보호기법  (2) 2014.09.22
Double free exploit  (0) 2014.09.17
RTL을 이용한 쉘코드 작성  (3) 2014.08.02
Posted by flack3r
|