(args)
| 188 | return '/syscalls' not in template_src |
| 189 | |
| 190 | def 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: |
nothing calls this directly
no test coverage detected