├── LICENSE ├── README.md ├── install.sh ├── oscp-transfer.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Bit-ByteBandit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
7 | A Streamlined Solution for File Transfers During the OSCP Exam Using FTP,HTTP(PUT,GET),SMB
8 |
13 |
14 |
23 | Key Features • 24 | Requirements • 25 | Installation • 26 | Usage • 27 | Running Servers • 28 | Examples • 29 | Contributing • 30 | License 31 |
32 | 33 | 34 | ## Table of Contents 35 | 36 | - [Key Features](#key-features) 37 | - [Requirements](#requirements) 38 | - [Installation](#installation) 39 | - [Usage](#usage) 40 | - [Running Servers](#running-servers) 41 | - [Examples](#examples) 42 | - [Contributing](#contributing) 43 | - [License](#license) 44 | 45 | ## Key Features 46 | 47 | - **Multi-protocol support**: FTP, HTTP (PUT/GET), and SMB 48 | - **Easy-to-use command-line interface** 49 | - **Flexible configuration options** 50 | - **Automatic server setup** for quick file transfers 51 | - **OSCP exam-friendly**: Designed with the OSCP exam environment in mind 52 | - **Minimal dependencies**: Relies primarily on Python standard libraries 53 | 54 | ## Requirements 55 | 56 | - Python 3.6 or higher 57 | - Git (for cloning the repository) 58 | - Additional dependencies will be installed by the `install.sh` script 59 | 60 | ## Installation 61 | 62 | 1. Clone the Repository: 63 | ```bash 64 | git clone https://github.com/Bit-ByteBandit/OSCP-Transfer.git 65 | ``` 66 | 67 | 2. Navigate to the Directory: 68 | ```bash 69 | cd OSCP-Transfer 70 | ``` 71 | 72 | 3. Install Dependencies: 73 | ```bash 74 | chmod +x ./install.sh && ./install.sh 75 | ``` 76 | 77 | ## Usage 78 | 79 | The tool offers flexible transfer methods and customizable options: 80 | 81 | ``` 82 | oscp-transfer -m {METHOD} [options] 83 | ``` 84 | 85 | ### Options: 86 | 87 | - `-h, --help`: Display the help message and exit. 88 | - `-m {PUT, FTP, SMB, GET}`: Choose the transfer method. 89 | - `-l PORT`: Specify the listening port (default: 21 for FTP). 90 | - `-d DIRECTORY`: For FTP or SMB, set the working directory. 91 | - `-sh SHARE`: Name for SMB share (default: SHARE). 92 | - `-u USERNAME`: Provide the FTP or SMB username (default for FTP only: user). 93 | - `-p PASSWORD`: Provide the FTP or SMB password (default for FTP only: user). 94 | - `-smb2`: Use SMB2 protocol (for SMB transfers only). 95 | 96 | ## Running Servers 97 | 98 | Start different types of servers easily: 99 | 100 | ```bash 101 | # Start GET-HTTP Server 102 | oscp-transfer -m GET 103 | 104 | # Start SMB Server 105 | oscp-transfer -m SMB 106 | 107 | # Start FTP Server 108 | oscp-transfer -m FTP 109 | 110 | # Start PUT-HTTP Server 111 | oscp-transfer -m PUT 112 | ``` 113 | 114 | ## Examples 115 | 116 | 1. Initiate a GET server on port 80: 117 | ```bash 118 | oscp-transfer -m GET -l 80 119 | ``` 120 | 121 | 2. Initiate a PUT server on port 80: 122 | ```bash 123 | oscp-transfer -m PUT -l 80 124 | ``` 125 | 126 | 3. Use FTP with custom options: 127 | ```bash 128 | oscp-transfer -m ftp -l 21 -d /path/to/directory -u username -p password 129 | ``` 130 | 131 | 4. Use SMB with a username and a password: 132 | ```bash 133 | oscp-transfer -m smb -u foo -p foo -sh MySharefoo -smb2 134 | ``` 135 | 136 | 5. Upload a file using PUT request: 137 | ```bash 138 | curl http://[IP] -T [File] 139 | ``` 140 | 141 | ## Contributing 142 | 143 | We welcome contributions to improve the OSCP File Transfer Tool! Here's how you can contribute: 144 | 145 | 1. Fork the repository 146 | 2. Create a new branch (`git checkout -b feature/AmazingFeature`) 147 | 3. Make your changes 148 | 4. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 149 | 5. Push to the branch (`git push origin feature/AmazingFeature`) 150 | 6. Open a Pull Request 151 | 152 | Please ensure your code adheres to the project's coding standards and includes appropriate tests. 153 | 154 | ## License 155 | 156 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 157 | 158 | --- 159 | 160 |161 | Made by Bit-ByteBandit 162 |
163 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/bash 3 | echo "[+] installing requirements" 4 | pip3 install -r requirements.txt 5 | echo "[+] copy to environement /usr/bin" 6 | sudo cp oscp-transfer.py /usr/bin/oscp-transfer 7 | sudo chmod +x /usr/bin/oscp-transfer 8 | echo "[+] refresh the terminal" 9 | . ~/.bashrc 10 | . ~/.zshrc 11 | echo "[+] Done" 12 | -------------------------------------------------------------------------------- /oscp-transfer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import argparse 3 | import os 4 | import threading 5 | import http.server 6 | import psutil 7 | import socket 8 | import socketserver 9 | from pyftpdlib.authorizers import DummyAuthorizer 10 | from pyftpdlib.handlers import FTPHandler 11 | from pyftpdlib.servers import FTPServer 12 | from impacket import smbserver 13 | from impacket.ntlm import compute_lmhash, compute_nthash 14 | import sys 15 | 16 | class FileUploadHandler(http.server.BaseHTTPRequestHandler): 17 | def do_PUT(self): 18 | content_length = int(self.headers['Content-Length']) 19 | file_path = self.path[1:] 20 | with open(file_path, 'wb') as file: 21 | file.write(self.rfile.read(content_length)) 22 | self.send_response(200) 23 | self.end_headers() 24 | self.wfile.write(b'File uploaded successfully via HTTP') 25 | 26 | 27 | def interface_check(protocol,port): 28 | network_interfaces = psutil.net_if_addrs() 29 | for interface_name, interface_addresses in network_interfaces.items(): 30 | if interface_name != 'lo': 31 | for address in interface_addresses: 32 | if address.family == socket.AF_INET: 33 | print(f"{protocol} is Listening On {interface_name} {address.address} on port {port}") 34 | 35 | # http put request server to upload files from target to you 36 | def listen_put(port): 37 | try: 38 | server_address = ('', port) 39 | httpd = http.server.HTTPServer(server_address, FileUploadHandler) 40 | interface_check('HTTP PUT',port) 41 | httpd.serve_forever() 42 | except KeyboardInterrupt: 43 | print("\nStopping HTTP Server") 44 | except Exception as e: 45 | print("Exception:", e) 46 | # http get request server to download files 47 | def listen_get(port): 48 | handler = http.server.SimpleHTTPRequestHandler 49 | with socketserver.TCPServer(("0.0.0.0", port), handler) as server: 50 | interface_check('HTTP GET',port) 51 | try: 52 | server.serve_forever() 53 | 54 | except KeyboardInterrupt: 55 | print("\nServer stopped.") 56 | except Exception as e: 57 | print("Exception:", e) 58 | 59 | 60 | def listen_ftp(port, directory, username, password): 61 | try: 62 | authorizer = DummyAuthorizer() 63 | authorizer.add_user(username, password, directory, perm="elradfmw") 64 | handler = FTPHandler 65 | handler.authorizer = authorizer 66 | interface_check('FTP',port) 67 | server = FTPServer(("0.0.0.0", port), handler) 68 | server.serve_forever() 69 | except KeyboardInterrupt: 70 | print("\nKeyboard interrupt received. Stopping the SMB server.") 71 | except Exception as e: 72 | print("Exception:", e) 73 | 74 | 75 | def listen_smb(directory, port, sharename, username, password, SMB2Support): 76 | try: 77 | server = smbserver.SimpleSMBServer(listenAddress='0.0.0.0', listenPort=int(port)) 78 | server.addShare(sharename, directory, 'SMB Share') 79 | interface_check('SMB', port) 80 | server.setSMB2Support(SMB2Support) 81 | server.setSMBChallenge('') 82 | server.setLogFile('') 83 | 84 | # Calculate the LM hash and NT hash based on the provided password 85 | 86 | 87 | if username is not None: 88 | lmhash = compute_lmhash(password) 89 | nthash = compute_nthash(password) 90 | server.addCredential(username, '0',lmhash, nthash) 91 | 92 | server.start() 93 | 94 | except KeyboardInterrupt: 95 | print("\nKeyboard interrupt received. Stopping the SMB server.") 96 | except Exception as e: 97 | print("Exception:", e) 98 | 99 | 100 | def main(): 101 | parser = argparse.ArgumentParser( 102 | description='File Transfer Listener', 103 | usage='%(prog)s -m [METHOD] -l [PORT] -d [DIRECTORY] -u [USERNAME] -p [PASSWORD]', 104 | formatter_class=argparse.RawDescriptionHelpFormatter 105 | ) 106 | parser.add_argument('-m', '--method', choices=['PUT', 'put', 'ftp', 'FTP', 'SMB', 'smb', 'get', 'GET'], help='Transfer method') 107 | parser.add_argument('-l', '--port', type=int, help='Port to listen on - #FTP 21 by Default - #SMB 445 By Default') 108 | parser.add_argument('-d', '--directory', default='.', help='FTP or SMB - #specify working directory or `.` by Default - Directory for file storage') 109 | parser.add_argument('-u', '--username', help='Specifies the username, SMB OR FTP. The default FTP user is `user`.') 110 | parser.add_argument('-p', '--password', help='Specifies the password, SMB OR FTP. The default FTP pass is `user`.') 111 | parser.add_argument('-sh', '--sharename', default='share', help='SMB Share-name By #Default `share`') 112 | parser.add_argument('-smb2', '--SMB2Support', action='store_true' , help='adding SMB2Support By Default = `False`') 113 | example_text = ''' 114 | examples: 115 | %(prog)s -m GET 116 | 117 | %(prog)s -m PUT 118 | 119 | %(prog)s -m ftp 120 | 121 | %(prog)s -m smb -u oscp -p oscp -smb2 122 | 123 | ''' 124 | 125 | parser.epilog = example_text 126 | args = parser.parse_args() 127 | 128 | allowed_methods = ['SMB', 'GET', 'PUT', 'FTP'] 129 | if len(sys.argv) < 2: 130 | print("oscp-transfer -m [METHOD] -l [PORT] -d [DIRECTORY] -u [USERNAME] -p [PASSWORD]") 131 | return 132 | if args.method.upper() in allowed_methods: 133 | 134 | if args.method.upper() == 'PUT': 135 | 136 | if args.port is None: 137 | args.port = 80 138 | 139 | listen_put(args.port) 140 | 141 | elif args.method.upper() == 'FTP': 142 | 143 | if args.port is None: 144 | args.port = 21 145 | if args.username is None: 146 | args.username = 'user' 147 | if args.password is None: 148 | args.password = 'user' 149 | 150 | listen_ftp(args.port, args.directory, args.username, args.password) 151 | 152 | elif args.method.upper() == 'SMB': 153 | 154 | if args.port is None: 155 | args.port = 445 156 | 157 | # Provide username and password for authentication 158 | listen_smb(args.directory, args.port, args.sharename, args.username, args.password,args.SMB2Support) 159 | 160 | if args.method.upper() == 'GET': 161 | 162 | if args.port is None: 163 | args.port = 80 164 | 165 | listen_get(args.port) 166 | else: 167 | print('Invalid transfer method. Please choose one of the available options.') 168 | 169 | 170 | if __name__ == '__main__': 171 | main() 172 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | impacket==0.9.24 2 | psutil==5.9.5 3 | pyftpdlib==1.5.7 4 | --------------------------------------------------------------------------------