Skip to content
/ incp Public

Insecure copy - copy files to a remote computer on a trusted network

License

Notifications You must be signed in to change notification settings

ccassise/incp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

incp

Insecure copy - copy files to a remote computer on a trusted network. Works on Windows, Linux, and macOS.

Files are transferred over a TCP connection as raw bytes. There is no encryption or compression being used. You probably want scp, rsync, Copy-Item, or maybe just piping a tar.gz through netcat.

Usage

incp -l [PORT]

Listens on the optional port for a one time transfer of files. After the files have been transferred, the server shuts down. If no port is given, it will listen on the default port of 4627.

incp SOURCE [SOURCE...] <IPv4 ADDRESS>[:PORT]:DESTINATION

Attempt to transfer the source file(s) to the destination directory or file at the given address on the given port. If no port is given, it will attempt to connect to the default port of 4627. For the most part, this should work exactly like cp except the destination includes an IPv4 address. Currently, incp is only able to transfer files and not directories.

Build

Unix

$ make

Windows

Open the Developer Powershell for Visual Studio and then change the directory to the project. incp uses the clang frontend for MSVC.

$ nmake /F Makefile-win

File Permissions

incp will attempt to copy the file permissions from the source file if its destination does not already exist. If the destination exists, then permissions will not be modified. When transferring to or from Windows, only the user's read, write, and execute permissions are transferred. Group and other permissions are cleared.

Protocol

incp-sequence

incp uses a simple protocol to exchange files. The above diagram shows a successful transfer of files between remote computers. The protocol consists of three "types." Strings, file info, and then raw data.

Strings are text that ends in a CRLF, e.g.

HELLO\r\n

File info contains three space-separated columns and ends with a CRLF. The columns are file type and file permission info, file size in bytes, and the file path. Everything after size is considered part of the path, so paths may contain spaces, e.g.

-rwxrw-rw- 1234 path/to/file\r\n

Raw data is only transferred after file info has been transferred. The raw data shall be exactly the same amount of bytes as was given in the file info size.