-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile_devpkginstall
120 lines (95 loc) · 3.81 KB
/
Dockerfile_devpkginstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
FROM sagemath/sagemath:latest
RUN sudo apt-get update && sudo apt-get install -y tzdata # avoid select timezone
RUN sudo apt-get update && sudo apt-get upgrade -y
RUN sudo apt-get install -y \
vim \
less \
git \
tmux \
netcat
### for building fplll, flatter
RUN sudo apt-get update \
&& sudo apt-get install -y \
cmake \
libtool \
libgmp-dev \
libmpfr-dev \
libeigen3-dev \
libblas-dev \
liblapack-dev
USER sage
RUN sage --pip install --no-cache-dir \
pwntools \
pycryptodome \
z3-solver \
tqdm
### prepare build fplll, flatter
RUN mkdir /home/sage/coppersmith
COPY --chown=sage:sage *.py /home/sage/coppersmith/
COPY --chown=sage:sage flatter /home/sage/coppersmith/flatter/
### install fplll
USER root
RUN apt-get install -y fplll-tools libfplll-dev
USER sage
### install flatter
WORKDIR /home/sage/coppersmith/flatter
RUN mkdir build
WORKDIR /home/sage/coppersmith/flatter/build
RUN cmake ..
RUN make -j4
USER root
RUN make install
WORKDIR /home/sage/coppersmith
RUN rm -rf flatter
RUN apt-get remove --purge -y cmake
RUN apt-get autoremove --purge -y
USER sage
#### other lattice library download
RUN mkdir /home/sage/collection_lattice_tools
WORKDIR /home/sage/collection_lattice_tools
ENV PYTHONPATH=/home/sage/collection_lattice_tools/:$PYTHONPATH
### defund/coppersmith
RUN git clone https://github.com/defund/coppersmith
RUN ln -s /home/sage/collection_lattice_tools/coppersmith/coppersmith.sage /home/sage/collection_lattice_tools/defund_coppersmith.sage
## load("/home/sage/collection_lattice_tools/defund_coppersmith.sage")
### josephsurin/lattice-based-cryptanalysis
RUN git clone https://github.com/josephsurin/lattice-based-cryptanalysis
RUN sed -i "s/algorithm='msolve', //g" /home/sage/collection_lattice_tools/lattice-based-cryptanalysis/lbc_toolkit/common/systems_solvers.sage
ENV PYTHONPATH=/home/sage/collection_lattice_tools/lattice-based-cryptanalysis/:$PYTHONPATH
### jvdsn/crypto-attacks
RUN git clone https://github.com/jvdsn/crypto-attacks/
RUN mv crypto-attacks crypto_attacks
ENV PYTHONPATH=/home/sage/collection_lattice_tools/crypto_attacks/:$PYTHONPATH
### rkm0959/Inequality_Solving_with_CVP
RUN git clone https://github.com/rkm0959/Inequality_Solving_with_CVP
RUN ln -s /home/sage/collection_lattice_tools/Inequality_Solving_with_CVP/solver.sage /home/sage/collection_lattice_tools/inequ_cvp_solve.sage
## load("/home/sage/collection_lattice_tools/inequ_cvp_solve.sage")
### nneonneo/pwn-stuff (including math/solvelinmod.py)
RUN git clone https://github.com/nneonneo/pwn-stuff
RUN ln -s /home/sage/collection_lattice_tools/pwn-stuff/math/solvelinmod.py /home/sage/collection_lattice_tools/solvelinmod.py
### maple3142/lll_cvp
RUN git clone https://github.com/maple3142/lll_cvp
RUN ln -s /home/sage/collection_lattice_tools/lll_cvp/lll_cvp.py /home/sage/collection_lattice_tools/lll_cvp.py
### TheBlupper/linineq
RUN git clone https://github.com/TheBlupper/linineq
RUN ln -s /home/sage/collection_lattice_tools/linineq/linineq.py /home/sage/collection_lattice_tools/linineq.py
### coppersmith package config
WORKDIR /home/sage/
ENV PYTHONPATH=/home/sage/coppersmith/:$PYTHONPATH
ENV COPPERSMITHFPLLLPATH=/usr/bin/
ENV COPPERSMITHFLATTERPATH=/usr/local/bin/
### follow cryptohack-docker (https://github.com/cryptohack/cryptohack-docker)
ENV PWNLIB_NOTERM=true
ENV BLUE='\033[0;34m'
ENV YELLOW='\033[1;33m'
ENV RED='\e[91m'
ENV NOCOLOR='\033[0m'
ENV BANNER=" \n\
${BLUE}----------------------------------${NOCOLOR} \n\
${YELLOW}CryptoHack Docker Container${NOCOLOR} \n\
\n\
${RED}After Jupyter starts, visit http://127.0.0.1:8888${NOCOLOR} \n\
${BLUE}----------------------------------${NOCOLOR} \n\
"
#CMD ["echo -e $BANNER && sage -n jupyter --NotebookApp.token='' --no-browser --ip='0.0.0.0' --port=8888"]
CMD ["/home/sage/sage/sage", "--python", "coppersmith/example.py"]