-
Notifications
You must be signed in to change notification settings - Fork 0
/
mantool
executable file
·216 lines (201 loc) · 7.28 KB
/
mantool
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env python
import os
import sys
import argparse
import re
print('''\033[1;32m _____ _
_ __ ___ __ _ _ __/__ \___ ___ | |
| '_ ` _ \ / _` | '_ \ / /\/ _ \ / _ \| |
| | | | | | (_| | | | / / | (_) | (_) | |
|_| |_| |_|\__,_|_| |_\/ \___/ \___/|_|\033[1;31mv1.0\033[0m
\033[1;36mmade by Pushpam kumar\033[0m \033[1;41m@00pushpam\033[0m
''')
class Tool(object):
def __init__(self,toolname,toolpath,options):
self.toolname=toolname
self.toolpath=toolpath
self.options=options
try:
with open('/root/.setting.txt','a') as sett_file:
sett_file.write('\nTool: '+toolname+' \n\tpath: '+toolname+'.'+toolpath+'\n\tcommand: '+toolname+'.'+options)
except IOError:
print('\033[1;31m[-] IOError: Did you delete /root/.setting.txt file?\033[0m')
def check(toollist,target):
try:
with open('/root/.setting.txt','r') as searchfile:
for tool in toollist:
for line in searchfile.readlines():
toolname = re.search(tool, line)
if toolname:
tool=toolname.group()
searchfile.seek(0)
break
for line in searchfile.readlines():
if tool:
toolpath=re.search('path: '+str(tool), line, re.M|re.I)
if toolpath:
pathline=line
searchfile.seek(0)
break
for line in searchfile.readlines():
if tool:
toolcommand=re.search('command: '+str(tool), line, re.M|re.I)
if toolcommand:
commandline=line
searchfile.seek(0)
break
if toolname and toolcommand and toolpath:
tool=toolname.group()
path=toolpath.group()
command=toolcommand.group()
path=re.sub('\n|'+path+'.','',pathline).lstrip()
commandline=commandline.replace('target',target)
command=re.sub('\n|'+command+'.','',commandline).lstrip()
execute(path,command,tool)
except IOError:
print('\033[1;31m[-] IOError: while searching for tool in /root/.setting.txt file\033[0m')
def execute(pathname,command,tname):
if pathname is not 'None' and command is not 'None':
print('\n\t\t\t\t'+'\033[1;31m'+str(tname).upper()+'\033[0m'+'\n')
try:
os.system('cd '+pathname+' && '+command)
except:
print('\033[1;31m[-] Please check your toolpath and command in /root/.setting.txt file\033[0m')
else:
print('\033[1;31m[-] Not able to run'+tname+'\033[0m')
print('\033[1;31m[-] please check pathname and command in /root/.setting.txt file\033[0m')
def delete(deltoollist):
try:
x=len(deltoollist)
for deltool in deltoollist:
with open('/root/.setting.txt','r') as file:
with open('new.txt','wb') as new:
for line in file.readlines():
deletetool=re.search(deltool, line)
if not deletetool:
new.write(line)
os.remove('/root/.setting.txt')
os.rename('new.txt','/root/.setting.txt')
print('\033[1;31m[-] Deleted\033[0m')
except IOError:
print('\033[1;31m[-] IOError: while deleting tool '+deltool+'\033[0m')
def edit(edittoollist):
try:
with open('/root/.setting.txt','r') as searchfile:
for tool in edittoollist:
toolname=False
for line in searchfile.readlines():
toolname = re.search(tool, line)
if toolname:
tool=toolname.group()
searchfile.seek(0)
break
for line in searchfile.readlines():
if tool:
toolpath=re.search('path: '+str(tool), line, re.M|re.I)
if toolpath:
pathline=line
toolpath=toolpath.group()
toolpath=re.sub('\n|'+toolpath+'.','',pathline).lstrip()
searchfile.seek(0)
break
for line in searchfile.readlines():
if tool:
toolcommand=re.search('command: '+str(tool), line, re.M|re.I)
if toolcommand:
commandline=line
toolcommand=toolcommand.group()
toolcommand=re.sub('\n|'+toolcommand+'.','',commandline).lstrip()
searchfile.seek(0)
break
if toolname:
too=[]
too.append(tool)
char=raw_input('\033[1;33m[?] What you want to edit Path or command or both p/c/b\033[0m: ')
if char == 'p' or char == 'P':
print('\033[1;31m[-]'+toolpath.strip()+'\033[0m')
newp=raw_input('\033[1;36m[+] Enter new path\033[0m: ')
delete(too)
Tool(tool,str(newp),toolcommand)
print('\033[1;32m[+] Updated \033[0m')
elif char == 'c' or char == 'C':
print('\033[1;31m[-]'+toolcommand.strip()+'\033[0m')
newc=raw_input('\033[1;36m[+] Enter new command\033[0m: ')
delete(too)
Tool(tool,toolpath,str(newc))
print('\033[1;32m[+] Updated \033[0m')
elif char == 'b' or char == 'B':
print('\033[1;31m[-]'+toolpath.strip()+'\033[0m')
newp=raw_input('\033[1;36m[+] Enter new path\033[0m: ')
print('\033[1;31m[-]'+toolcommand.strip()+'\033[0m')
newc=raw_input('\033[1;36m[+] Enter new command\033[0m: ')
delete(too)
Tool(tool,str(newp),str(newc))
print('\033[1;32m[+] Updated \033[0m')
else:
print('\033[1;31m[?] Enter any one p/c/b')
else:
print('\033[1;31m[-] Tool name not found\033[0m')
except IOError:
print('\033[1;31m[-] IOError: while editing for tool in /root/.setting.txt file\033[0m')
def add(num):
for i in range(0,num):
toolname=raw_input('\033[1;36m[+] Enter Tool Name of '+str(i+1)+' Tool\033[0m: ')
toolpath=raw_input('\033[1;36m[+] Enter Tool path\033[0m: ')
toolcommand=raw_input('\033[1;36m[+] How you want to execute\033[0m: ')
Tool(toolname,toolpath,toolcommand)
print('\033[1;32m[+] Added\033[0m')
def listt():
try:
with open('/root/.setting.txt','r') as searchfile:
for line in searchfile.readlines():
toolname=re.search('Tool: ', line, re.M|re.I)
if toolname:
tool=toolname.group()
tool=re.sub('Tool: ','',line).strip()
print('\033[1;36m'+str(tool)+'\033[0m')
except IOError:
print('\033[1;31m[-] IOError: while listing\033[0m')
if __name__ == "__main__":
parse=argparse.ArgumentParser()
parse.add_argument('-a','--add',type=int,help='Add new Tool(eg. mantool -a Toolname)')
parse.add_argument('-t','--target',help='your target website')
parse.add_argument('-r','--run',nargs='*',type=str,help='Type the name of tools you want to run')
parse.add_argument('-d','--delete',nargs='*',type=str,help='Delete your saved tool')
parse.add_argument('-e','--edit',nargs='*',type=str,help='Edit your saved tool')
parse.add_argument('--list', action='store_true',help='List of added tools')
#parse.add_argument('-i','--inputfile',type=str,help='input file')
#parse.add_argument('-o','--outputfile',type=str,help='output file')
args=parse.parse_args()
if args.add and (args.target or args.run):
print('\033[1;31m[-] Either Run Tools or Add Tools\033[0m')
elif args.add:
add(args.add)
elif args.target and args.run:
if args.run[0] is 'e' and len(args.run)==1:
try:
toollist=[]
with open('/root/.setting.txt','r') as searchfile:
for line in searchfile.readlines():
tool=re.search('Tool: ', line, re.M|re.I)
if tool:
tool=re.sub('\n|Tool: ','',line)
toollist.append(tool.strip())
except:
print('\033[1;36m[-] \'check in elif args.target and args.run:\' loop\033[0m')
y=[str(item) for item in toollist]
check(y,args.target)
else:
y=[str(item) for item in args.run]
check(y,args.target)
elif args.delete:
y=[str(item) for item in args.delete]
delete(y)
elif args.edit:
y=[str(item) for item in args.edit]
edit(y)
elif args.list:
listt()
else:
parse.print_help()
sys.exit(0)