Created
January 28, 2024 18:32
-
-
Save totekuh/6c26bd9774e06f855d1b0a45e73e44bd to your computer and use it in GitHub Desktop.
This Bash script quickly sets up an SMB server using Docker and Impacket, allowing users to share files on a network. It supports custom share names.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get IP addresses | |
ip_addresses=$(ip -4 addr show scope global | grep inet | awk '{print $2}' | cut -d '/' -f 1) | |
echo "The SMB server will be accessible from the following IP addresses:" | |
for ip in $ip_addresses; do | |
echo $ip | |
done | |
share_name="my-awesome-share" | |
folder="" | |
# Parse command line arguments | |
while (( "$#" )); do | |
case "$1" in | |
--share) | |
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then | |
share_name=$2 | |
shift 2 | |
else | |
echo "Error: Argument for $1 is missing" >&2 | |
exit 1 | |
fi | |
;; | |
*) | |
if [ -z "$folder" ]; then | |
folder=$1 | |
else | |
echo "Error: Multiple non-option arguments provided" | |
exit 1 | |
fi | |
shift | |
;; | |
esac | |
done | |
if [ -z "$folder" ]; then | |
echo "Usage: $0 <folder> [--share <share-name>]" | |
exit 0 | |
fi | |
echo "[*] Using the share name: $share_name" | |
docker run --rm -it -p 445:445 \ | |
-v $folder":/tmp/serve" \ | |
rflathers/impacket smbserver.py \ | |
-smb2support $share_name /tmp/serve |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment