9 ms·
Show HN: Transfer files to mobile device by scanning a QR code from the terminal
- daw___ 9y agoFrom the README: This program binds a web server to the address of your wifi network interface on a random port, and sets a default handler for it. The default handler serves the content and quits the program when the transfer is complete. The program prints a QR code that encodes the text: http://{address}:{port} http://{address}:{port} Most QR apps can detect URLs in decoded text and act accordingly (i.e.: open the URL with the default browser), so when QR the code is scanned the content starts being downloaded by the mobile browser.
- koolba 9y agoWhy not add a random suffix? http://{address}:{port}/{32-bytes http://{address}:{port}/{32-bytes from /dev/urandom as hex} If the URL isn't being manually entered (I mean that's the whole point of the QR code right?) then adding some random unguessable text would solve the problem of something else on your network connecting to that port. It doesn't solve the problem entirely as it's still possible to MITM the HTTP connection but it's a tad more difficult.
- daw___ 9y agoThanks, very good point. Initially I thought that shorter the better for URL, but since it doesn't have to be entered then it makes sense to make it a bit longer to be unguessable (and for sake of completeness, the port is randomly decided at each run).
- Zenbit_UX 9y agoI'd actually rather not have this addition. Despite your marketing this as a desktop > mobile transfer right now there's no reason your app can't be used for desktop > desktop sharing unless you add that random string. I can see myself using this to move files quickly between a desktop and a laptop or vice versa by ignoring the QR code and just putting in the port. Alternatively you could try the gfycat method by appending a few adjectives and a noun to create a readable but nonsensical phrase: https://gfycat.com/enlightenedpositiveasianporcupine https://gfycat.com/enlightenedpositiveasianporcupine But IMHO If security on your own network is so intense that a random app opening temporarily on a random local port is a security concern then this app isn't for you.
- koolba 9y agoThat’s what netcat is for! Host A: $ nc -l 12345 < data.txt Host B: $ nc host-a-or-its-ip 12345 > data.txt
- Zenbit_UX 9y agoSure that's useful, thanks. Although his app handles both use cases (desktops & phones).
- jakobegger 9y agonc is probably already installed on your desktop, though
- arantius 9y agohttp://www.home.unix-ag.org/simon/woof.html http://www.home.unix-ag.org/simon/woof.html
- jermaustin1 9y agoOr to be less dependent on a specific OS, use a hash of the file's name/path/content?
- woodrowbarlow 9y agooh, this is clever! i was worried that it would upload my file to a cloud service, or that i would need to install a custom app on my phone.
- daw___ 9y agoThanks! That's the fastest thing I could came up with to solve the problem of moving a tiny little piece of data between my computer and my smartphone without installing apps or physically connecting the device and using `adb`!
- ktpsns 9y agoAn innovative idea, I like it and could think of using it. Actually it would be more helpful if there was a way to transfer multiple files in a reasonable manner. While the server implementation would be trivial, the mass downloading client on the mobile phone is obviously the tricky part. Effective file managament on the mobile phone is even bad on Android, in my experience.
- daw___ 9y agoThanks for your feedback. > transfer multiple files in a reasonable manner you mean, for example, choosing the destination directory and things like that?
- ktpsns 9y agoWell, transfering multiple files most likely means to zip/tarball them together at the server side. But unpacking an archive after downloading it on a mobile OS needs a number of clicks (and an unpacking app), which is cumbersome. In the end, it is probably about a client endpoint for your tool.
- thrownaway954 9y agoawesome project
- daw___ 9y ago:-) thanks
- kureikain 9y agoThis is amazing. Always looking for something like this. The old way I used to do is to run a HTTP server with an upload form in the mobile phone. But this requires an app on phone to run that server. The idea of QR code is amazing. I'll put this to my news letter next week. Look out for it
- daw___ 9y agoThanks! I use this "disposable" web server approach a lot actually, usually by running `python -m http.server` from the directory that contains the file I want to transfer, and then `wget`'ing the file from another terminal, or opening it as a stream in VLC if the file is a media.
- laurent123456 9y agoThat's pretty cool. I wonder if it could be adapted to use something like Nextcloud to avoid the requirement of being on the same wifi. The workflow would be something like: Upload to Nextcloud (it would need to ask username/password) => Get Nextcloud URL (eg via WebDAV) => Create QR code.
- paulgb 9y agoNice! (Shameless plug follows) I use a similar technique in the notify-run Python package for setting up push notifications to an Android device from Python: https://github.com/paulgb/notify.run/blob/master/py_client/README.rst https://github.com/paulgb/notify.run/blob/master/py_client/R...
- f2n 9y agoHoly shit that's amazing. I've been wanting this service for a while, so badly that I've actually been building something similar for the last few weeks. I'll probably continue, since mine is slightly different in a couple of ways and its an interesting learning experience, but glad this is becoming more of a thing.
- daw___ 9y agoWow, that's interesting! Starred.
- yoz-y 9y agoLooks useful and fun, however it does not seem to work correctly with ipv6 on mac? I obtain: 2018/03/22 18:46:55 listen tcp: address fe80::XX:XXXX:XXX:XXXX:57532: too many colons in address
- daw___ 9y agoOh, thanks for reporting, I didn't test it with IPv6s yet; will file an issue.
- throw501 9y agoworkaround if you don't need IP6: System Preferences > Network > [click your ethernet or wifi adapter on left, unlock padlock if needed] > Click Advanced on right > Click TCP/IP tab > NONE, or Configure IPv6: Link-local only
- tmuir 9y agowhat exactly am I giving up, by doing this?
- voxadam 9y agoIPv6
- yoz-y 9y agoI actually already have this setting enabled. But it will still give you an ipv6 address and even though I do have a local ipv4 address on this interface, the application will pick up the ipv6. The problem seems to come from the fact that the port is just appended to the address, but with an ipv6 you have to surround it with brackets [1::c0de:f0r::f00d]:1337
- dyarosla 9y agoLooks like a cool project! Only quickly glanced at the code but couldn’t find it: where does this transfer files to on an iOS device? Does it even work with iOS?
- daw___ 9y agoHi, thanks! Yes, it works on iOS, it works on every device that has a QR reader and a regular internet browser. The workflow is easy: 1. the tool spawns a disposable web server 2. the tool prints a QR code that encodes an URL that points to the server 3. the device scans the QR, the scanned text is the URL 4. the tool turns off the disposable server as soon as the transfer is complete
- ReverseCold 9y agoJudging from the gif it just makes a webserver and makes a QR code pointing to that url. That should work on any platform.
- vk2 9y agoExcellent idea, agreed. iOS doesn't have built-in QR reader. So good QR app just should open recognized URL, and then suggest application which will be used to open the file. Could anyone recommend such app? Tried "Scan" (iOS app), doesn't work for me: has problems recognizing qr code (probably because of my terminal fonts/background) and doesn't suggest app to open file even if QR code is recognized.
- daw___ 9y agoHi, I'm hearing of issues about QR codes unable to be scanned; can you please try scanning the code that I posted in this comment and tell me if it works? : https://github.com/claudiodangelis/qr-filetransfer/issues/6#issuecomment-375439155 https://github.com/claudiodangelis/qr-filetransfer/issues/6#... I'm trying to collect as much info as possible to identify the cause. Thanks!
- virusduck 9y agoIt does, actually! If you have the camera app open and have a qr code in view, the link comes up as a banner which you can tap.
- daw___ 9y agoDemo (GIF): https://twitter.com/daw985/status/976881805864337409 https://twitter.com/daw985/status/976881805864337409
- throw501 9y agonice, thanks. would be nice if it could allow pipes. example to send the clipboard: $ pbpaste | qr-filetransfer 2018/03/22 15:06:48 At least one argument is required
- daw___ 9y agoThat's an interesting point. Maybe the tool could create a temporary file with the data piped to it. But for now I think you should stick with: pbpaste > /tmp/clipboard.txt && qr-filetransfer /tmp/clipboard.txt Thanks for the idea, I'm tracking it in github.
- throw501 9y agohmm. i'd rather not. generally don't want the clipboard going to disk. thanks though.
- daw___ 9y agoReasonable
- JetSpiegel 9y agoPipe to /dev/shm/filename
- dmitrygr 9y agowhy not pbpaste | qr-filetransfer /dev/stdin
- jakobegger 9y agoOr even just qr-filetransfer <(pbpaste)
- daw___ 9y agoThis is not going to work unfortunately, the program expects the arguments to be paths.
- ryanmarsh 9y agoI’ve experimented with this for a while. My clients often have very locked down windows laptops but they oddly allow hand typed powershell scripts to run. If you “play” a series of qr codes with checksums and record them from a phone and process the video on the phone you can exfil data without tripping any IDS. Opening a port often requires privileges or can at least trip an IDS. Silly really.
- tmuir 9y agowouldn't there be some sort of log that the http server utilized the network in some capacity? I have to assume its still opening TCP connections, and using all of the traditional layers below that, all of whose activities are possible to capture.
- ryanmarsh 9y agoNo http server. Modulate the data to an analog set of pictures (actually text based QR codes) then demodulate the pictures from video. No network needed.
- tmuir 9y agoI see, so the relatively low bandwidth of a static QR code is mitigated by a high frame rate. What your saying is that these machines don't log at the operating system level, in the fashion of a tracelog, but count on bad actors to use COTS implementations of those system level calls, and log the high level events? Its a good thing that there isn't much overlap between people who understand penetration strategies and people who can write their own software.
- XorNot 9y agoThis is what I was hoping but not expecting to see here really.
- jonplackett 9y agoReally smart. Was also worried it would be tranfered via some random web server but it’s a really elegant solution. Well done!
- daw___ 9y agoThanks!
- kamil9 9y agodid something similar with features like upload,view files before download and file creation time (shameless plug :P ) https://github.com/kamilkabir9/LDrop https://github.com/kamilkabir9/LDrop
- daw___ 9y agoWhoa!
- fiatjaf 9y agoDoesn't work here. As soon as I scan the QR code with my phone, I'm prompted by the barcode-scanner app to open the URL (192.168.15.whatever) on the browser, but at the time this happens qr-filetransfer is already closed and not listening anymore, it has closed immediately when the QR code was read. How does it happen I cannot know.
- fiatjaf 9y agoHad tried it 3 times, with 3 failures. Tried once again after posting this comment and it worked. Who knows where the software goes.
- daw___ 9y agoOh, sorry to hear! I have no idea at the moment, do you mind opening an issue on Github? I can take care of opening an issue myself tomorrow if you can't. https://github.com/claudiodangelis/qr-filetransfer/issues https://github.com/claudiodangelis/qr-filetransfer/issues Thanks!
- andmarios 9y agoHere is a small issue: https://github.com/claudiodangelis/qr-filetransfer/blob/master/main.go#L65 https://github.com/claudiodangelis/qr-filetransfer/blob/mast... I don't know if it is the barcode scanner app (I use the one from zxing, a very popular choice), or the Android implementation (LG, Android 7), but here is a description of what happens: As soon as I scan the barcode, it is copied to the clipboard. Then something goes to check if the URL is working (the barcode app? android clipboard? not sure). Since you exit after the first request, my browser never gets the chance to download the file. If I remove the os.Exit(), I get it working (and then terminate qr-filetransfer via ctrl+c). Anyhow, very nice work. Kudos!
- daw___ 9y agoHi, this has been already reported, many thanks for the headsup. The reason of that os.Exit(0) is to let the user not to care about quitting the tool after the transfer has been completed. There might be pending pull requests that fix this problem, I'm going to review later today. Users response to this tool is really overwhelming, lots of interesting ideas and solutions have been already provided in the last 24 hours!
- eudoxus 9y agoHow is this not called qrcp? :/
- spieglt 9y agoGreat project! I'm working on one that's somewhat related, it's basically cross-platform AirDrop (though only for laptops). Seems like mine could really benefit from a method of getting files to phones like this, and yours could benefit from not needing a wireless network like Flying Carpet. http://github.com/spieglt/flyingcarpet http://github.com/spieglt/flyingcarpet
- daw___ 9y agoOh, that looks interesting and definitely related! Starred, will have a look soon.
- kodejuice 9y agoVery similar to the way Expo works
- kodejuice 9y agoVery similar to the eay Expo works