Skip to content

Commit

Permalink
initial push, still have a lot to do...
Browse files Browse the repository at this point in the history
  • Loading branch information
elreydetoda committed May 27, 2019
0 parents commit ebd0943
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3-stretch
LABEL author='alex(at)secureideas(dot)com'
RUN git clone https://github.com/Bashfuscator/Bashfuscator
WORKDIR /Bashfuscator
RUN python setup.py install
COPY ./docker-entrypoint.sh ./
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["--help"]
42 changes: 42 additions & 0 deletions bashfuscator_options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Bashfuscator options

**NOTE**: I created this, so I don't have to keep doing `--help` to figure out all the options. This is a static file, so this could be out of date but this was only for the initial instantiation of the Dockerfile

```
[Program Options]
-l, --list List all the availible obfuscators, compressors, and
encoders
-c COMMAND, --command COMMAND
Command to obfuscate
-f FILE, --file FILE Name of the script to obfuscate
--stdin Obfuscate stdin
-o OUTFILE, --outfile OUTFILE
File to write payload to
-q, --quiet Print only the payload
--clip Copy the payload to clipboard
--test Test the payload after running it. Not compatible with
-q
[obfuscation options]
-s {1,2,3}, --payload-size {1,2,3}
Desired size of the payload. Default: 2
-t {1,2,3}, --execution-time {1,2,3}
Desired speed of the payload. Default: 2
--layers LAYERS Number of layers of obfuscation to apply. Default is 1
when --choose-mutators is used, otherwise: 2
--include-binaries BINARIES [BINARIES ...]
Binaries you exclusively want used in the generated
payload
--exclude-binaries BINARIES [BINARIES ...]
Binaries you don't want to be used in the generated
payload
--no-file-write Don't use obfuscators that require writing to files
--write-dir WRITE_DIR
Directory to use if Mutators need to write to or
create files
Advanced Options:
--choose-mutators MUTATOR [MUTATOR ...]
Manually choose what mutators are used in what order
--choose-all MUTATOR [MUTATOR ...]
Manually choose what mutators and their stubs if
```
74 changes: 74 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set -exuo pipefail

bin_path="/usr/local/bin"

prep_next_arg(){
tmp_str=''
export tmp_str
}

append_str(){
tmp_str="${tmp_str} + ${1}"
export tmp_str

}
parse(){
# this function is to parse bashfuscation arguments, because docker
# doesn't allow quotes from being passed through unless it is env variables
# which would dissrupt the flow of this application too much instead
# of treating it like how it supposed to do and keep appending

# TODO: Implement reading from stdin
# body: Need to work on trying to check for the parser function if input
# can be read from stdin from a docker container, I am thinking yes if
# someone does `-- <(file_path)` at the end of running a container, but
# need to validate this later down the road.

parsed_string=()
tmp_str=''
oldIFS="${IFS}"
IFS=' '
for given_string in "${@}" ; do

# first argument getting passed to bashfuscator is a flag indicating what
# you want to invoke the obfuscation on (i.e. enter in a command (-c) in
# from a file (-f), list this options (-l)

case "${given_string}" in
-c)
if [[ -z "${tmp_str}" ]] ; then
parsed_string+=("${given_string}")
else
append_str "${given_string}"
fi
esac

done
IFS="${oldIFS}"
export parsed_string
}

main(){
case "$1" in
bashrc)
/usr/local/bin/register-python-argcomplete bashfuscator
;;
--help)
"${bin_path}/bashfuscator" "$@"
# printf "If you want to be able to copy this to your clipboard append the following to normal execution: "
# printf "-"
;;
bash)
"${bin_path}/bashfuscator" "$@"
;;
*)
echo "${@}"
parse "${@}"
# "${bin_path}/bashfuscator" "$@"
;;
esac
}

main "${@}"

0 comments on commit ebd0943

Please sign in to comment.