-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpoly.py
More file actions
37 lines (31 loc) · 1.21 KB
/
poly.py
File metadata and controls
37 lines (31 loc) · 1.21 KB
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
#! /usr/bin/python
# -*- coding: utf-8 -*-
import argparse
from src.php import Php
from src.asp import Asp
from src.aspx import Aspx
ap = argparse.ArgumentParser()
ap.add_argument('-c', help= 'Shell code. [ php, asp, aspx ]', required = True)
ap.add_argument('-e', help= 'Encoding method. [ b64, ord, rnd, rot ]', default = 'b64')
ap.add_argument('-p', help= 'Path to shell.', default = None)
ap.add_argument('-j', help= 'Add junk code.', action = 'store_true', default = False)
args = ap.parse_args()
shell_type = args.c.lower() if args.p is None else args.p.split('.')[-1].lower()
shell_encoding = args.e.lower()
shell_path = args.p
junk = args.j
if shell_type not in [ 'php', 'asp', 'aspx' ] :
exit("{} shells are not supported.".format(shell_type))
if shell_encoding not in [ 'b64', 'ord', 'rnd', 'rot' ] :
exit("'{}' encoding is not supported.".format(shell_encoding))
if shell_type == 'php' :
poly = Php(shell_path)
if shell_type == 'asp' :
poly = Asp(shell_path)
if shell_type == 'aspx' :
poly = Aspx(shell_path)
if poly.shell_text == None :
exit("Can't access file: {}".format(poly.shell_path))
encoded = poly.Encode(shell_encoding)
encoded_shell = poly.Create(encoded, junk)
poly.Write(encoded_shell)