libc database. local에서 사용해보자.

2023. 1. 7. 22:39·Tips & theory
728x90
반응형

서론

사실 매번 

libc-database

 

libc-database

 

libc.rip

에서 검색해서 사용했는데, local에서 사용할 수 있는 방법이 있다.

 

예전부터 알고 있었는데 사실 그냥 귀찮아서 자세히 찾아보지 않았었고,

그닥 필요 없을거라 생각해서 안썼는데,

CTF를 뛰다 ld 파일을 구하기가 힘들어서 사용하게 되었다.

 

설치

github를 통해 다운로드 가능하다.

GitHub - niklasb/libc-database: Build a database of libc offsets to simplify exploitation

 

GitHub - niklasb/libc-database: Build a database of libc offsets to simplify exploitation

Build a database of libc offsets to simplify exploitation - GitHub - niklasb/libc-database: Build a database of libc offsets to simplify exploitation

github.com

 

또는 아래 명령어로 다운로드 하면 된다.

$ git clone https://github.com/niklasb/libc-database

 

설치 후 다운로드된 폴더에 들어가서

$ ./get ubuntu

와 같이 원하는 os에 따라 libc를 다운로드 해줘야한다.

지원되는 os는 아래와 같고

Please specify libc categories to download:
        * ubuntu
        * debian
        * rpm
        * centos
        * arch                                                  
        * alpine
        * kali
        * parrotsec
        * launchpad

all 또는 원하는 부분만 다운로드 가능하다.

$ ./get ubuntu rpm arch
$ ./get all

 

만일 ./get 을 하였는데, 뭔가 다운로드 되지 않는다면(다운로드 하는데 한참 걸림.)

requirement를 충족시키지 못했기 때문이다.

os에 따라 아래 프로그램들이 설치되어있는지 확인해서 누락되었다면 추가로 설치해주자

### General

To run these scripts, you will need following command on your PATH:

* readelf
* objdump
* strings
* perl
* find
* grep
* md5sum
* sha1sum
* sha256sum
* file


### Debian-based (Ubuntu, Debian, Kali Linux, ParrotSec)

* mktemp
* perl
* wget
* ar
* tar
* grep
* zstd


### RPM-based (category 'rpm')

* mktemp
* perl
* wget
* rpm2cpio
* cpio
* grep


### CentOS-based

In addition to the RPM-Based requirements, you will need:

* wget
* gzip
* grep


### Pacman-based

* mktemp
* perl
* grep
* sed
* cat
* wget
* zstd
* xz-utils
* tar


### APK Based

* mktemp
* perl
* wget
* tar
* gzip
* grep


### Launchpad-based

In addition to the Debian-based requirements, you will need:

* jq


### Install everything

To install everything on Debian 10, run these commands:

```sh
apt-get update
apt-get install -y \
  binutils file \
  wget \
  rpm2cpio cpio \
  zstd jq
```

 

사용법

./get 명령어를 통해 libc를 다운로드 받았다면 아래와 같이 사용 가능하다.

 

custom libc 추가하기

$ ./add /usr/lib/libc-2.21.so

 

libc 찾기

$ ./find printf 260 puts f30
    archive-glibc (libc6_2.19-10ubuntu2_i386)
$ ./find __libc_start_main_ret a83
    ubuntu-trusty-i386-libc6 (libc6_2.19-0ubuntu6.6_i386)
    archive-eglibc (libc6_2.19-0ubuntu6_i386)
    ubuntu-utopic-i386-libc6 (libc6_2.19-10ubuntu2.3_i386)
    archive-glibc (libc6_2.19-10ubuntu2_i386)
    archive-glibc (libc6_2.19-15ubuntu2_i386)

 

libc로부터 주요 offset 가져오기

$ ./dump libc6_2.19-0ubuntu6.6_i386
    offset___libc_start_main_ret = 0x19a83
    offset_system = 0x00040190
    offset_dup2 = 0x000db590
    offset_recv = 0x000ed2d0
    offset_str_bin_sh = 0x160a24

 

hash로 libc 찾기

$ ./identify bid=ebeabf5f7039f53748e996fc976b4da2d486a626
    libc6_2.17-93ubuntu4_i386
$ ./identify md5=af7c40da33c685d67cdb166bd6ab7ac0
    libc6_2.17-93ubuntu4_i386
$ ./identify sha1=9054f5cb7969056b6816b1e2572f2506370940c4
    libc6_2.17-93ubuntu4_i386
$ ./identify sha256=8dc102c06c50512d1e5142ce93a6faf4ec8b6f5d9e33d2e1b45311aef683d9b2
    libc6_2.17-93ubuntu4_i386

 

libc & ld download

사실 이게 필요했다 ㅋ

    $ ./download libc6_2.23-0ubuntu10_amd64
    Getting libc6_2.23-0ubuntu10_amd64
        -> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb
        -> Downloading package
        -> Extracting package
        -> Package saved to libs/libc6_2.23-0ubuntu10_amd64
    $ ls libs/libc6_2.23-0ubuntu10_amd64
    ld-2.23.so ... libc.so.6 ... libpthread.so.0 ...

 

728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

'Tips & theory' 카테고리의 다른 글

Diffie–Hellman key exchange 이론 및 중간자 공격  (2) 2023.01.30
command injection  (2) 2023.01.25
dreamhack 문제 upload + git 기본 사용법  (0) 2022.12.21
C random 함수를 python에서 실행하기.  (0) 2022.12.09
for "민규"  (0) 2022.11.27
'Tips & theory' 카테고리의 다른 글
  • Diffie–Hellman key exchange 이론 및 중간자 공격
  • command injection
  • dreamhack 문제 upload + git 기본 사용법
  • C random 함수를 python에서 실행하기.
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (493)
      • To do list (6)
        • Doing (0)
        • Complete (6)
      • Diary (35)
      • Tips & theory (77)
      • Kernel Exploit (22)
      • Wargame (313)
        • pwn.college (34)
        • Dreamhack (148)
        • pwnable.kr (15)
        • Lord of Sqlinjection (3)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (40)
        • Solved (38)
        • Unsolved (2)
      • Script (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

    • PWN wargame 모음 (및 느낀점)
    • 비공개 글들에 대해.
    • 뭐라도 하나 얻어가시길...
  • 인기 글

  • 태그

    x86
    dreamhack
    la ctf
    heap
    root
    docker
    pwnable.kr
    Buffer Overflow
    Format String Bug
    phoenix
    vtable
    FSB
    32bit
    tcache
    pwntools
    CANARY
    BOF
    libc
    ROOT ME
    hackerschool
    RTL
    Me
    rop
    64bit
    exploit education
    cryptohack
    _IO_FILE
    root-me
    x64
    lob
  • 최근 댓글

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
libc database. local에서 사용해보자.
상단으로

티스토리툴바