forked from abhi-r3v0/Adhrit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.py
executable file
·92 lines (76 loc) · 3.59 KB
/
installer.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# !/usr/bin/env python3
import os
import subprocess
import configparser
from sys import platform
class DepInstaller:
def __init__(self):
self.apt_tools = ['python-pip', 'python3-setuptools', 'python3-pip', 'android-tools-adb', 'lib32ncurses5', 'lib32z1', 'toilet']
self.pip_tools = ['PrettyTable', 'requests', 'progressbar2', 'colorama', 'urllib3', 'Jinja2']
self.uninstalled = []
def ins(self):
confparser = configparser.ConfigParser()
confparser.read('config')
if platform == "linux" or platform == "linux2":
# linux
print("\n[+] Installing necessary tools on Linux\n")
for i in self.apt_tools:
try:
subprocess.check_output(['sudo', 'apt-get', '-f', 'install', i], stderr=subprocess.PIPE)
print("\t[+] Installed " + i)
except subprocess.CalledProcessError:
print("\t\t[!] Error installing " + i + ". Please install manually: 'sudo apt-get -f install " + i + "'")
self.uninstalled.append(i)
pass
for j in self.pip_tools:
try:
subprocess.check_output(['sudo', 'pip3', 'install', j], stderr=subprocess.PIPE)
print("\t[+] Installed " + j)
except subprocess.CalledProcessError:
print("\t\t[!] Error installing " + j + ". Please install manually: 'sudo pip3 install " + j + "'")
self.uninstalled.append(j)
pass
if len(self.uninstalled) > 0:
print("\n[-] " + str(len(self.uninstalled)) + " not installed.")
else:
confparser.set('config-data', 'dependencies_status', 'complete')
with open('config', 'w') as updatedconf:
confparser.write(updatedconf)
print("\n[+] Installation of requirements complete. Check with 'python3 adhrit.py -h'")
elif platform == "darwin":
print("\n[+] Installing necessary tools on MAC")
try:
os.system('brew install toilet')
print("\n[+] Installation of dependencies complete")
except OSError:
print("\n[!] Error installing dependency")
print("\n[+] Installing ARM dependencies")
try:
os.system('brew tap osx-cross/arm')
os.system('brew install arm-gcc-bin')
os.system('brew install binutils')
os.system('brew install ncurses')
print("\n[+] Installation of ARM tools complete")
except OSError:
print("\n[!] Error installing ARM dependencies")
print("\n[+] Installing Android debug tools ")
try:
os.system('brew cask install android-platform-tools')
print("\n[+] Installation of Android tools complete")
except OSError:
print("\n[!] Error installing Android tools")
try:
for j in self.pip_tools:
subprocess.check_output(['sudo', 'pip3', 'install', j], stderr=subprocess.PIPE)
print("\t[+] Installed " + j)
except subprocess.CalledProcessError as ose:
print(ose)
print("\n[!] Error installing dependencies")
elif platform == "win32":
# TO-DO Windows
print("\n[+] Installing necessary tools on Windows")
def main():
dep = DepInstaller()
dep.ins()
if __name__ == '__main__':
main()