{"id":4743,"date":"2023-02-25T17:13:00","date_gmt":"2023-02-25T23:13:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4743"},"modified":"2023-02-25T13:52:03","modified_gmt":"2023-02-25T19:52:03","slug":"send-receive-a-file-with-netcat","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/send-receive-a-file-with-netcat\/","title":{"rendered":"Send\/Receive a File with Netcat"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">For clarity of instructions, we will use the following terminology.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Server = Remote system, typically like a web server<br>Client = Local system, the computer\/vm you are using<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download file from Server<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command on the server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat file.txt | nc -l -p 1234<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Client<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now on the client we can download the file with the following.  Change the IP to the Server IP address<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nc 192.168.1.20 1234 > file.txt<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Upload from Client to Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If we want to reverse this, aka. send a file from the client to the server, we can do the following<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This will write the file to file.txt<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nc -l -p1234 -q 1 > file.txt &lt; \/dev\/null<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Client<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Send file.txt to 192.168.1.20.  Change the file and IP address as needed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat file.txt | nc 192.168.1.20 1234<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/superuser.com\/questions\/98089\/sending-file-via-netcat\">https:\/\/superuser.com\/questions\/98089\/sending-file-via-netcat<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For clarity of instructions, we will use the following terminology. Server = Remote system, typically like a web serverClient = Local system, the computer\/vm you are using Download file from Server Server Run the following command on the server. cat &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/send-receive-a-file-with-netcat\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420],"tags":[1077,421,705,701,1407],"class_list":["post-4743","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-file","tag-hacking","tag-nc","tag-netcat","tag-send-receive"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4743"}],"version-history":[{"count":1,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4743\/revisions"}],"predecessor-version":[{"id":4850,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4743\/revisions\/4850"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}