-
Notifications
You must be signed in to change notification settings - Fork 13
/
PySploit.py
executable file
·108 lines (105 loc) · 4.65 KB
/
PySploit.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from core.interpreter import interpreter
from core.banner import Banner
from sys import argv
from utilities.color import *
from utilities.files import *
from argparse import ArgumentParser, SUPPRESS
from subprocess import check_call, CalledProcessError, call
import os
import shutil
sample = """from core.module_obtainer import obtainer
info = {
'author' :'Creator name',
'date' :'Create date',
'rank' :'Rank of the module',
'path' :'Module create path',
'category' :'Main category of the module',
'license' :'Module license',
'description' :'Module description',
'references' :['References for further reading']
}
options = {
'options_name' :['require', 'description','value']
}
required = {
'start_required' :'False/True', # using default starter
'check_required' :'False/True' # module support on not support check option
}
def exploit(): # main exploit function
pass # stuff to do
def check(): # check function if the module require it
pass # stuff to do"""
def install():
try:
os.mkdir('/etc/pysploit-framework')
os.mkdir('/etc/pysploit-framework/docs')
except FileExistsError:
print(red('\n[!]') + green(" /etc/pysploit-framework") + " folder is exist, try --unistall command before reinstall\n")
exit()
except PermissionError:
print(red("\n[!]") + green(" You") + " should run command as root\n")
exit()
try:
copy(['PySploit.py','core/','files','modules/','samples/','utilities/'], '/etc/pysploit-framework')
copy(['README.md','LICENSE','pysploit'],'/etc/pysploit-framework/docs')
except FileExistsError:
print(red("\n[!]") + green(' Check') + " if all tool files exist and try again\n")
exit()
except PermissionError:
print(red("\n[!]") + green(" You") + " should run command as root\n")
exit()
try:
file = open('/bin/pysploit','w')
file.write('cd /etc/pysploit-framework &> /dev/null')
file.write('\npython3 PySploit.py $1 $2 $3 $4')
call('chmod 777 /bin/pysploit', shell=True)
except PermissionError:
print(red("\n[!]") + green(" You") + " should run command as root\n")
exit()
else:
print(blue('\n[CO]') + green(" Tool") + ' installed successfully type pysploit to run it\n')
def uninstall():
try:
rm('/etc/pysploit-framework/')
rm('/bin/pysploit')
except PermissionError:
print(red("\n[!]") + green(" You") + " should run command as root\n")
exit()
except FileNotFoundError:
print(red('\n[!]') + green(" Tool") + " does not installed on your device\n")
exit()
else:
print(blue('\n[CO]') + green(" Tool") + ' uninstalled successfully\n')
def main():
parser = ArgumentParser(prog='PySploit',usage='python3 PySploit.py [options]', add_help=False)
help_arguments = parser.add_argument_group('help arguments')
help_arguments.add_argument('-v', '--version', action='version', version="version 1.2")
help_arguments.add_argument('-h', '--help', action='help', default=SUPPRESS, help='show this help message and exit.')
optional_arguments = parser.add_argument_group('optional arguments')
optional_arguments.add_argument('-c', '--create', dest='filename', required=False, help='create module sample')
optional_arguments.add_argument('-u', '--upgrade', required=False, action='store_true', help='create module sample')
optional_arguments.add_argument('-m', '--manual', required=False, action='store_true', help='show tool man page')
optional_arguments.add_argument('-i', '--install', required=False, action='store_true', help='install tool on your computer')
optional_arguments.add_argument('-un', '--uninstall', required=False, action='store_true', help='uninstall tool from your computer')
args = parser.parse_args()
if len(argv) > 1:
if args.filename is not None:
filename = open(args.filename, 'w')
filename.write(sample)
elif args.upgrade == True:
interpreter().check_upgrade()
elif args.manual == True:
try:
check_call('man /etc/pysploit-framework/docs/pysploit',shell=True)
except CalledProcessError:
print(red('\n[!]') + green(' Tool') + " manual is not installed yet\n")
elif args.install == True:
install()
elif args.uninstall == True:
uninstall()
else:
Banner()
while True:
interpreter().start_interpreter()
if __name__ == '__main__':
main()