MCPcopy
hub / github.com/Gallopsled/pwntools / main

Function main

pwnlib/commandline/shellcraft.py:190–384  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

188 return '/syscalls' not in template_src
189
190def main(args):
191 delim = '+'
192 if args.delim:
193 delim = args.delim.strip()
194
195 shellcodes = []
196 if args.shellcode:
197 current = []
198 for s in args.shellcode:
199 if s.strip() == delim:
200 shellcodes.append(current)
201 current = []
202 else:
203 current.append(s)
204 if len(current) > 0:
205 shellcodes.append(current)
206
207 if args.list:
208 templates = shellcraft.templates
209
210 if args.shellcode:
211 template_array = []
212 for s in shellcodes:
213 template_array.extend(list(filter(lambda a: s[0] in a, templates)))
214 templates = template_array
215 elif not args.syscalls:
216 templates = list(filter(is_not_a_syscall_template, templates))
217
218 print('\n'.join(templates))
219 exit()
220
221 if not args.shellcode:
222 common.parser.print_usage()
223 exit()
224
225 try:
226 funcs = get_template(shellcodes)
227 except AttributeError:
228 log.error("Unknown shellcraft template %r. Use --list to see available shellcodes." % args.shellcode)
229
230 if args.show:
231 for (name, func, _args) in funcs:
232 # remove doctests
233 doc = []
234 in_doctest = False
235 block_indent = None
236 caption = None
237 lines = func.__doc__.splitlines()
238 i = 0
239 if len(funcs) > 1:
240 print('%s:' % name)
241 while i < len(lines):
242 line = lines[i]
243 if line.lstrip().startswith('>>>'):
244 # this line starts a doctest
245 in_doctest = True
246 block_indent = None
247 if caption:

Callers

nothing calls this directly

Calls 15

PwntoolsLexerClass · 0.90
get_templateFunction · 0.85
funcFunction · 0.85
cppFunction · 0.85
make_elf_from_assemblyFunction · 0.85
asmFunction · 0.85
encodeFunction · 0.85
make_elfFunction · 0.85
run_shellcodeFunction · 0.85
_stringFunction · 0.85
hexiiFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected