This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
easy_install.py
70 lines (59 loc) · 2.45 KB
/
easy_install.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
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import urllib2
import zipfile
import ida_diskio
import ida_loader
# Allow the user to override the download URL
if "URL" not in locals():
URL = "https://github.com/IDArlingTeam/IDArling/archive/master.zip"
print("[*] Installing IDArling...")
# Install into the user directory on all platforms
user_dir = ida_diskio.get_user_idadir()
plug_dir = os.path.join(user_dir, "plugins")
if not os.path.exists(plug_dir):
os.makedirs(plug_dir, 493) # 0755
print("[*] Downloading master.zip archive...")
archive_path = os.path.join(plug_dir, "master.zip")
if os.path.exists(archive_path):
os.remove(archive_path)
with open(archive_path, "wb") as f:
f.write(urllib2.urlopen(URL).read())
print("[*] Unzipping master.zip archive...")
archive_dir = os.path.join(plug_dir, "IDArling-master")
if os.path.exists(archive_dir):
shutil.rmtree(archive_dir)
with zipfile.ZipFile(archive_path, "r") as zip:
for zip_file in zip.namelist():
if zip_file.startswith(os.path.basename(archive_dir)):
zip.extract(zip_file, plug_dir)
print("[*] Moving the IDArling files...")
src_path = os.path.join(archive_dir, "idarling_plugin.py")
dst_path = os.path.join(plug_dir, os.path.basename(src_path))
if os.path.exists(dst_path):
os.remove(dst_path)
shutil.move(src_path, dst_path)
src_dir = os.path.join(archive_dir, "idarling")
dst_dir = os.path.join(plug_dir, os.path.basename(src_dir))
if os.path.exists(dst_dir):
shutil.rmtree(dst_dir)
shutil.move(src_dir, dst_dir)
print("[*] Removing master.zip archive...")
if os.path.exists(archive_path):
os.remove(archive_path)
if os.path.exists(archive_dir):
shutil.rmtree(archive_dir)
print("[*] Loading IDArling into IDA Pro...")
plugin_path = os.path.join(plug_dir, "idarling_plugin.py")
ida_loader.load_plugin(plugin_path)
print("[*] IDArling installed successfully!")