Skip to content

Instantly share code, notes, and snippets.

@ropnop
Created July 18, 2019 02:16
Show Gist options
  • Save ropnop/c21c35e67a07da2ab50dbb8a085ccd22 to your computer and use it in GitHub Desktop.
Save ropnop/c21c35e67a07da2ab50dbb8a085ccd22 to your computer and use it in GitHub Desktop.
Docker aliases
function dockershell() {
docker run --rm -i -t --entrypoint=/bin/bash "$@"
}
function dockershellsh() {
docker run --rm -i -t --entrypoint=/bin/sh "$@"
}
function dockershellhere() {
dirname=${PWD##*/}
docker run --rm -it --entrypoint=/bin/bash -v `pwd`:/${dirname} -w /${dirname} "$@"
}
function dockershellshhere() {
docker run --rm -it --entrypoint=/bin/sh -v `pwd`:/${dirname} -w /${dirname} "$@"
}
function dockerwindowshellhere() {
dirname=${PWD##*/}
docker -c 2019-box run --rm -it -v "C:${PWD}:C:/source" -w "C:/source" "$@"
}
impacket() {
docker run --rm -it rflathers/impacket "$@"
}
smbservehere() {
local sharename
[[ -z $1 ]] && sharename="SHARE" || sharename=$1
docker run --rm -it -p 445:445 -v "${PWD}:/tmp/serve" rflathers/impacket smbserver.py -smb2support $sharename /tmp/serve
}
nginxhere() {
docker run --rm -it -p 80:80 -p 443:443 -v "${PWD}:/srv/data" rflathers/nginxserve
}
webdavhere() {
docker run --rm -it -p 80:80 -v "${PWD}:/srv/data/share" rflathers/webdav
}
metasploit() {
docker run --rm -it -v "${HOME}/.msf4:/home/msf/.msf4" metasploitframework/metasploit-framework ./msfconsole "$@"
}
metasploitports() {
docker run --rm -it -v "${HOME}/.msf4:/home/msf/.msf4" -p 8443-8500:8443-8500 metasploitframework/metasploit-framework ./msfconsole "$@"
}
msfvenomhere() {
docker run --rm -it -v "${HOME}/.msf4:/home/msf/.msf4" -v "${PWD}:/data" metasploitframework/metasploit-framework ./msfvenom "$@"
}
reqdump() {
docker run --rm -it -p 80:3000 rflathers/reqdump
}
postfiledumphere() {
docker run --rm -it -p80:3000 -v "${PWD}:/data" rflathers/postfiledump
}
@mjwhitta
Copy link

mjwhitta commented Jul 19, 2019

Just saw your post on docker aliases. Really liked it! Thought you
might appreciate this:

function msfvenom() {
    local entrydir="/usr/src/metasploit-framework"
    local image="metasploitframework/metasploit-framework:latest"
    local name="msfvenom_$(head -c 8 /dev/random | xxd -p)"

    mkdir -p "$HOME/.msf4"
    docker run -e MSF_GID=$(id -g) -e MSF_UID=$(id -u) \
        --entrypoint "$entrydir/docker/entrypoint.sh" -i \
        --name "$name" --rm -tv "$HOME/.msf4":/home/msf/.msf4 \
        -v "$(pwd)":/msf:Z -w /msf $image "$entrydir/msfvenom" "$@"
}

This allows you to get around that -o /data/... issue you mentioned.
It also might help in case of selinux shenanigans. The same can also
be used for msfconsole.

@ropnop
Copy link
Author

ropnop commented Jul 20, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment