forked from pullp/pwn_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplie_glibcs.py
35 lines (28 loc) · 1.11 KB
/
complie_glibcs.py
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
32
33
34
35
#! /usr/bin/python
import os
import shutil
global GLIBCS_PATH
GLIBCS_PATH = "/var/glibcs"
def compile(version):
"""
download glibcs from http://ftp.gnu.org/gnu/libc/ or https://mirrors.tuna.tsinghua.edu.cn/gnu/glibc/
recommended path is /var/glibs/ remember to chmod -R
"""
global GLIBCS_PATH
os.chdir(GLIBCS_PATH)
os.system("tar zxvf ./glibc-%s.tar.gz"%(version))
os.mkdir("glibc-%s_build"%(version))
os.mkdir("glibc-%s_out"%(version))
os.chdir("glibc-%s_build"%(version))
os.system("../glibc-%s/configure '--prefix=%s/glibc-%s_out'"%(version, GLIBCS_PATH, version))
os.system("make && make install")
os.chdir("../glibc-%s_out/lib"%(version))
shutil.copy("./libc-%s.so"%(version), "../ld_and_libcs_x64/libc_%s.so"%(version))
shutil.copy("./elf/ld-%s.so"%(version), "../ld_and_libcs_x64/ld_%s.so"%(version))
if __name__ == "__main__":
compile("2.27")
compile("2.29")
# CC="gcc -m32" CXX="g++ -m32" \
# CFLAGS="-g -g3 -ggdb -gdwarf-4 -Og -Wno-error" \
# CXXFLAGS="-g -g3 -ggdb -gdwarf-4 -Og" \
# ../configure --prefix=/var/glibcs/glibc-2.23_out --host=i686-linux-gnu