summarylogtreecommitdiffstats
path: root/install.py
blob: fa71fb9b50b743b9cb3d51e93d7a460ae5f0f95b (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3

# Whole script made in Vim :D

# Thanks to the people behind https://github.com/mozilla/libdmg-hfsplus
# for fixing the dmg binary!
# And of course, thanks to planetbeing for making xpwn!

import os
import subprocess
import shutil
import zipfile


if __name__ == '__main__':
    # Check build folder exists, so we can ensure cmake
    # is using correct OpenSSL version

    if os.path.exists('build'):
        shutil.rmtree('build')

    os.mkdir('build')
    os.chdir('build')

    # Begin building inside build folder

    path = '/usr/local/ssl'

    cmake_cmd = subprocess.run([
            'cmake',
            '-DOPENSSL_ROOT_DIR={}'.format(path),
            '-DOPENSSL_LIBRARIES={}/lib'.format(path),
            '..'
        ],
        stdout=subprocess.PIPE,
        universal_newlines=True
    )

    make_cmd = subprocess.run([
            'make',
            'libXPwn.a'
        ],
        subprocess.PIPE,
        universal_newlines=True
    )

    # Some reason I still get ld errors on linux and on windows,
    # though we can still build

    try:
        os.path.exists('common/libcommon.a')
        os.path.exists('ipsw-patch/libxpwn.a')
    except FileNotFoundError as error:
        print('Oof, got error:', error)
    else:
        print('Seems like we built just fine')
    finally:
        print('Do not worry if you see some errors here.', "")
        print('Also, do not send me logs/pictures of those errors,', "")
        print('I know about them.')

    print('Unzipping xpwn headers...')
    zip = zipfile.ZipFile('../xpwn-modified-headers.zip')
    zip.extractall("../headers")

    print('Ok, everything should be done!')