Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Made a quick filesharing bash script inspired by another Show HN post
2 points by sanroot99 on Oct 6, 2022 | hide | past | favorite | 2 comments
I got inspiration from this post https://news.ycombinator.com/item?id=33094627

Here is the script

#!/bin/bash qrcode() {

  qrcode-terminal "http://"$(ip addr show wlp3s0 |grep -Eo $ipregex |head -n1 )":9000/"
  cd ~/.webshare && python3 -m http.server 9000 
} share()

{ if [[ "$1" = "f" ]] then echo "success $1"

  [[ ! -d ~/.webshare   ]] && mkdir -p ~/.webshare 
  #cp  -r --reflink "$2" ~/.webshare/ 
  path="$(realpath "$2")"
  ln -s "$path" "/home/sanbotbtrfs/.webshare/"
  qrcode
elif [[ "$1" = "s" ]] then path="$( find "$2" |fzf )" path="$(realpath "$path")" ln -s "$path" "/home/sanbotbtrfs/.webshare/" qrcode else error fi }

cleanup() { echo 'cleanup operation ' rm -vrf ~/.webshare/* } error() { echo 'usage share [s/f] <filename/dir> ; s is for fuzzy search and f is regular '

} trap cleanup 1 2 3 6 14 15 ; [[ $# -eq 2 ]] && share "$1" "$2" || error



python3 -m http.server 9000 does all the heavy lifting.

What is interesting is the qrcode-terminal. Never seen that before but makes me wonder. In terms of data exfiltration, you could absolutely store data inside a qrcode.

Looked it up, qrcodes can store about 4000 characters. I guess in situations where node is available it could be useful


Yeh true , it's just a hacky makeshift solution




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: