Compilation statique !
This commit is contained in:
parent
6d87ea0b61
commit
62678bdd67
20
Dockerfile
20
Dockerfile
|
@ -8,16 +8,15 @@ RUN echo "http://alpine.42.fr/v3.13/main" > /etc/apk/repositories
|
||||||
RUN echo "http://alpine.42.fr/v3.13/community" >> /etc/apk/repositories
|
RUN echo "http://alpine.42.fr/v3.13/community" >> /etc/apk/repositories
|
||||||
RUN apk --no-cache update
|
RUN apk --no-cache update
|
||||||
RUN apk --no-cache upgrade
|
RUN apk --no-cache upgrade
|
||||||
RUN apk --no-cache add bash util-linux coreutils curl make cmake gcc g++ libstdc++ libgcc zlib-dev \
|
RUN apk --no-cache add bash util-linux coreutils curl make cmake gcc g++ libstdc++ libgcc \
|
||||||
git sed tar wget gzip indent binutils hexdump dos2unix xxd autoconf automake autoconf-archive\
|
git sed tar wget gzip indent binutils autoconf automake autoconf-archive\
|
||||||
libtool linux-headers ncurses-dev
|
libtool linux-headers ncurses-dev python3-dev
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
RUN wget https://github.com/unicorn-engine/unicorn/archive/${UNICORN_VER}.tar.gz && tar -xzf ${UNICORN_VER}.tar.gz
|
RUN wget https://github.com/unicorn-engine/unicorn/archive/${UNICORN_VER}.tar.gz && tar -xzf ${UNICORN_VER}.tar.gz
|
||||||
WORKDIR /usr/src/unicorn-${UNICORN_VER}
|
WORKDIR /usr/src/unicorn-${UNICORN_VER}
|
||||||
RUN UNICORN_ARCHS="x86" ./make.sh && UNICORN_ARCHS="x86" ./make.sh install
|
RUN UNICORN_ARCHS="x86" ./make.sh && UNICORN_ARCHS="x86" ./make.sh install
|
||||||
|
|
||||||
RUN apk --no-cache add python3-dev
|
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
RUN wget https://github.com/keystone-engine/keystone/archive/${KEYSTONE_VER}.tar.gz && tar -xzf ${KEYSTONE_VER}.tar.gz
|
RUN wget https://github.com/keystone-engine/keystone/archive/${KEYSTONE_VER}.tar.gz && tar -xzf ${KEYSTONE_VER}.tar.gz
|
||||||
RUN ls
|
RUN ls
|
||||||
|
@ -27,6 +26,8 @@ WORKDIR /usr/src/keystone-${KEYSTONE_VER}/build
|
||||||
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="X86" -G "Unix Makefiles" ..
|
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="X86" -G "Unix Makefiles" ..
|
||||||
RUN make -j8
|
RUN make -j8
|
||||||
RUN make install
|
RUN make install
|
||||||
|
RUN MAKE_INSTALL_PREFIX=/usr CMAKE_BUILD_TYPE=Release BUILD_SHARED_LIBS=ON LLVM_TARGETS_TO_BUILD="X86" ../make-lib.sh
|
||||||
|
RUN cp /usr/src/keystone-0.9.2/build/llvm/lib64/libkeystone.a /usr/lib64/
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
RUN wget https://github.com/aquynh/capstone/archive/${CAPSTONE_VER}.tar.gz && tar -xzf ${CAPSTONE_VER}.tar.gz
|
RUN wget https://github.com/aquynh/capstone/archive/${CAPSTONE_VER}.tar.gz && tar -xzf ${CAPSTONE_VER}.tar.gz
|
||||||
|
@ -40,12 +41,17 @@ RUN mkdir build
|
||||||
WORKDIR /usr/src/struct_mapping/build
|
WORKDIR /usr/src/struct_mapping/build
|
||||||
RUN cmake .. && cmake --build . && cmake --install .
|
RUN cmake .. && cmake --build . && cmake --install .
|
||||||
|
|
||||||
WORKDIR /usr/src/
|
WORKDIR /usr/src
|
||||||
RUN git clone https://github.com/dahut87/finalcut.git
|
RUN git clone https://github.com/dahut87/finalcut.git
|
||||||
WORKDIR /usr/src/finalcut
|
WORKDIR /usr/src/finalcut
|
||||||
RUN autoreconf --install --force && ./configure --prefix=/usr && make && make install
|
RUN autoreconf --install --force && ./configure --prefix=/usr && make && make install
|
||||||
|
|
||||||
RUN apk --no-cache add zlib-dev
|
WORKDIR /usr/src
|
||||||
|
RUN git clone https://github.com/madler/zlib.git
|
||||||
|
WORKDIR /usr/src/zlib
|
||||||
|
RUN ./configure && make && make install prefix=/usr/
|
||||||
|
|
||||||
|
RUN apk --no-cache add ncurses-static
|
||||||
|
|
||||||
RUN adduser -D -H -u 502 utilisateur
|
RUN adduser -D -H -u 502 utilisateur
|
||||||
RUN adduser -D -H -u 1000 utilisateurs
|
RUN adduser -D -H -u 1000 utilisateurs
|
||||||
|
|
35
Makefile
35
Makefile
|
@ -1,10 +1,10 @@
|
||||||
CC=g++ -O2
|
CC=g++ -O2 -static
|
||||||
LFLAGS=-lfinal -lkeystone -lstdc++ -lm -lcapstone -lunicorn -lz
|
LFLAGS=-lfinal -lkeystone -lstdc++ -lm -lcapstone -lunicorn -lz -lncursesw
|
||||||
OPTIONS=-std=c++17
|
OPTIONS=-std=c++17
|
||||||
DOCKER=docker run --name maker --rm -v $$(pwd):/data maker
|
DOCKER=docker run --name maker --rm -v $$(pwd):/data maker
|
||||||
START=./start.sh
|
START=./start.sh
|
||||||
|
|
||||||
all: dockerfile files copy run
|
all: dockerfile files run
|
||||||
|
|
||||||
clean: dockerclean
|
clean: dockerclean
|
||||||
|
|
||||||
|
@ -37,32 +37,3 @@ stop:
|
||||||
delete:
|
delete:
|
||||||
rm -rf ./ia86
|
rm -rf ./ia86
|
||||||
|
|
||||||
copy: libcapstone.so.4 libunicorn.so.1 libfinal.so.0.7.2 libkeystone.so.0 libc.musl-x86_64.so.1 libstdc++.so.6.0.28 libz.so.1.2.11 libgcc_s.so.1
|
|
||||||
|
|
||||||
libcapstone.so.4:
|
|
||||||
${DOCKER} cp /usr/lib/libcapstone.so.4 /data/libcapstone.so.4
|
|
||||||
|
|
||||||
libunicorn.so.1:
|
|
||||||
${DOCKER} cp /usr/lib/libunicorn.so.1 /data/libunicorn.so.1
|
|
||||||
|
|
||||||
libfinal.so.0.7.2:
|
|
||||||
${DOCKER} cp /usr/lib/libfinal.so.0.7.2 /data/libfinal.so.0.7.2
|
|
||||||
ln -s ./libfinal.so.0.7.2 ./libfinal.so.0
|
|
||||||
|
|
||||||
libkeystone.so.0:
|
|
||||||
${DOCKER} cp /usr/lib64/libkeystone.so.0 /data/libkeystone.so.0
|
|
||||||
|
|
||||||
libc.musl-x86_64.so.1:
|
|
||||||
${DOCKER} cp /lib/libc.musl-x86_64.so.1 /data/libc.musl-x86_64.so.1
|
|
||||||
|
|
||||||
libz.so.1.2.11:
|
|
||||||
${DOCKER} cp /lib/libz.so.1.2.11 /data/libz.so.1.2.11
|
|
||||||
ln -s ./libz.so.1.2.11 ./libz.so.1
|
|
||||||
|
|
||||||
libstdc++.so.6.0.28:
|
|
||||||
${DOCKER} cp /usr/lib/libstdc++.so.6.0.28 /data/libstdc++.so.6.0.28
|
|
||||||
ln -s ./libstdc++.so.6.0.28 ./libstdc++.so.6
|
|
||||||
|
|
||||||
libgcc_s.so.1:
|
|
||||||
${DOCKER} cp /usr/lib/libgcc_s.so.1 /data/libgcc_s.so.1
|
|
||||||
|
|
||||||
|
|
118
ia86.cpp
118
ia86.cpp
|
@ -405,17 +405,19 @@ std::vector<Code> Assembler::MultiAssemble(std::string source,uint32_t address)
|
||||||
std::vector<Code> mcode;
|
std::vector<Code> mcode;
|
||||||
std::istringstream stream(source);
|
std::istringstream stream(source);
|
||||||
std::string line;
|
std::string line;
|
||||||
std::regex regex("^ *.org 0x([0-F]+)$");
|
std::regex regex_org("^ *.org 0x([0-F]+)$");
|
||||||
|
std::regex regex_name("^ *.title ([a-zA-Z0-9_]+)$");
|
||||||
Code *code=new Code;
|
Code *code=new Code;
|
||||||
bool begin=true;
|
bool begin=true;
|
||||||
int org=address;
|
int org=address;
|
||||||
|
std::string name="/";
|
||||||
code->address=org;
|
code->address=org;
|
||||||
while (std::getline(stream, line))
|
while (std::getline(stream, line))
|
||||||
{
|
{
|
||||||
if (line.find(".org") != std::string::npos)
|
if (line.find(".org") != std::string::npos)
|
||||||
{
|
{
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
if(std::regex_search(line, match, regex))
|
if(std::regex_search(line, match, regex_org))
|
||||||
{
|
{
|
||||||
org=std::stoul(match.str(1), nullptr, 16);
|
org=std::stoul(match.str(1), nullptr, 16);
|
||||||
}
|
}
|
||||||
|
@ -424,6 +426,16 @@ std::vector<Code> Assembler::MultiAssemble(std::string source,uint32_t address)
|
||||||
mcode.push_back(*code);
|
mcode.push_back(*code);
|
||||||
code=new Code;
|
code=new Code;
|
||||||
code->address=org;
|
code->address=org;
|
||||||
|
code->name=name;
|
||||||
|
name="/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (line.find(".title") != std::string::npos)
|
||||||
|
{
|
||||||
|
std::smatch match;
|
||||||
|
if(std::regex_search(line, match, regex_name))
|
||||||
|
{
|
||||||
|
name=match.str(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -734,6 +746,30 @@ std::string VMEngine::getRam(int segment, int address,int lines, int linesize)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::array<std::string, 7>> VMEngine::getCode()
|
||||||
|
{
|
||||||
|
int line=0;
|
||||||
|
std::vector<std::array<std::string, 7>> result;
|
||||||
|
for(Code code: mcode)
|
||||||
|
{
|
||||||
|
std::string *linestr = new std::string(to_string(line++));
|
||||||
|
std::string *name = new std::string(code.name);
|
||||||
|
std::string *address = new std::string(intToHexString(code.address,8));
|
||||||
|
std::string *size = new std::string(to_string(code.size));
|
||||||
|
std::string *srcsize = new std::string(to_string(code.src.size()));
|
||||||
|
std::string *assembled = new std::string;
|
||||||
|
if (code.assembled)
|
||||||
|
*assembled="X";
|
||||||
|
std::string *loaded = new std::string;
|
||||||
|
if (code.loaded)
|
||||||
|
*loaded="X";
|
||||||
|
std::array<std::string, 7> *array = new std::array<std::string, 7>{*linestr,*name,*address,*size,*srcsize,*assembled,*loaded};
|
||||||
|
result.push_back(*array);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::array<std::string, 4>> VMEngine::getInstr(int segment, int address,int size)
|
std::vector<std::array<std::string, 4>> VMEngine::getInstr(int segment, int address,int size)
|
||||||
{
|
{
|
||||||
uint32_t realaddress=segment*16+address;
|
uint32_t realaddress=segment*16+address;
|
||||||
|
@ -1593,21 +1629,41 @@ void Menu::showInstr()
|
||||||
{
|
{
|
||||||
if (vm.isInitialized())
|
if (vm.isInitialized())
|
||||||
{
|
{
|
||||||
debug.set(vm.getInstr(vm.getCS(),vm.getEIP(),debug.getHeight()-3));
|
try
|
||||||
debug.setmark(vm.getLine());
|
{
|
||||||
debug.setmultimark(vm.getBreapoints());
|
debug.set(vm.getInstr(vm.getCS(),vm.getEIP(),debug.getHeight()-3));
|
||||||
if (Ds_000.isChecked())
|
debug.setmark(vm.getLine());
|
||||||
mem.set(vm.getRam(vm.getDS(), 0x000000000, mem.getHeight(),mem.getWidth()));
|
debug.setmultimark(vm.getBreapoints());
|
||||||
else if (Ds_esi.isChecked())
|
regs.set(vm.getRegs());
|
||||||
mem.set(vm.getRam(vm.getDS(), vm.getESI(), mem.getHeight(),mem.getWidth()));
|
flags.set(vm.getFlags());
|
||||||
else if (Es_edi.isChecked())
|
stack.set(vm.getStack());
|
||||||
mem.set(vm.getRam(vm.getES(), vm.getEDI(), mem.getHeight(),mem.getWidth()));
|
if (Ds_000.isChecked())
|
||||||
else if (Cs_eip.isChecked())
|
mem.set(vm.getRam(vm.getDS(), 0x000000000, mem.getHeight(),mem.getWidth()));
|
||||||
mem.set(vm.getRam(vm.getCS(), vm.getEIP(), mem.getHeight(),mem.getWidth()));
|
else if (Ds_esi.isChecked())
|
||||||
else if (Ss_esp.isChecked())
|
mem.set(vm.getRam(vm.getDS(), vm.getESI(), mem.getHeight(),mem.getWidth()));
|
||||||
mem.set(vm.getRam(vm.getSS(), vm.getESP(), mem.getHeight(),mem.getWidth()));
|
else if (Es_edi.isChecked())
|
||||||
else if (Ss_FFF.isChecked())
|
mem.set(vm.getRam(vm.getES(), vm.getEDI(), mem.getHeight(),mem.getWidth()));
|
||||||
mem.set(vm.getRam(vm.getSS(), 0x0000FF20, mem.getHeight(),mem.getWidth()));
|
else if (Cs_eip.isChecked())
|
||||||
|
mem.set(vm.getRam(vm.getCS(), vm.getEIP(), mem.getHeight(),mem.getWidth()));
|
||||||
|
else if (Ss_esp.isChecked())
|
||||||
|
mem.set(vm.getRam(vm.getSS(), vm.getESP(), mem.getHeight(),mem.getWidth()));
|
||||||
|
else if (Ss_FFF.isChecked())
|
||||||
|
mem.set(vm.getRam(vm.getSS(), 0x0000FF20, mem.getHeight(),mem.getWidth()));
|
||||||
|
}
|
||||||
|
catch(exception const& e)
|
||||||
|
{
|
||||||
|
tolog(e.what());
|
||||||
|
vm.Halt();
|
||||||
|
vm.Unconfigure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regs.set("En attente d'initialisation...");
|
||||||
|
flags.set("Attente...");
|
||||||
|
stack.set("Attente...");
|
||||||
|
mem.set("En attente d'initialisation...");
|
||||||
|
screen.set("En attente d'initialisation...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(exception const& e)
|
catch(exception const& e)
|
||||||
|
@ -1619,29 +1675,6 @@ void Menu::showInstr()
|
||||||
|
|
||||||
void Menu::refresh()
|
void Menu::refresh()
|
||||||
{
|
{
|
||||||
if (!vm.isInitialized())
|
|
||||||
{
|
|
||||||
regs.set("En attente d'initialisation...");
|
|
||||||
flags.set("Attente...");
|
|
||||||
stack.set("Attente...");
|
|
||||||
mem.set("En attente d'initialisation...");
|
|
||||||
screen.set("En attente d'initialisation...");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
regs.set(vm.getRegs());
|
|
||||||
flags.set(vm.getFlags());
|
|
||||||
stack.set(vm.getStack());
|
|
||||||
}
|
|
||||||
catch(exception const& e)
|
|
||||||
{
|
|
||||||
tolog(e.what());
|
|
||||||
vm.Halt();
|
|
||||||
vm.Unconfigure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!vm.isExecuted())
|
if (!vm.isExecuted())
|
||||||
{
|
{
|
||||||
finalcut::FApplication::setDarkTheme();
|
finalcut::FApplication::setDarkTheme();
|
||||||
|
@ -1650,10 +1683,9 @@ void Menu::refresh()
|
||||||
{
|
{
|
||||||
finalcut::FApplication::setDefaultTheme();
|
finalcut::FApplication::setDefaultTheme();
|
||||||
}
|
}
|
||||||
auto root_widget = getRootWidget();
|
/*auto root_widget = getRootWidget();
|
||||||
root_widget->resetColors();
|
root_widget->resetColors();
|
||||||
root_widget->redraw();
|
root_widget->redraw();*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::exec()
|
void Menu::exec()
|
||||||
|
|
2
ia86.h
2
ia86.h
|
@ -132,6 +132,7 @@ struct Code
|
||||||
{
|
{
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
std::string name;
|
||||||
uint8_t *content;
|
uint8_t *content;
|
||||||
bool assembled;
|
bool assembled;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
@ -314,6 +315,7 @@ class VMEngine
|
||||||
std::string getRegs();
|
std::string getRegs();
|
||||||
std::string getStack();
|
std::string getStack();
|
||||||
std::vector<std::array<std::string, 4>> getInstr(int segment, int address,int size);
|
std::vector<std::array<std::string, 4>> getInstr(int segment, int address,int size);
|
||||||
|
std::vector<std::array<std::string, 7>> getCode();
|
||||||
void SetMem(Code *code);
|
void SetMem(Code *code);
|
||||||
void SetRegs(State *init);
|
void SetRegs(State *init);
|
||||||
std::string getRam(int segment, int address,int lines, int linesize);
|
std::string getRam(int segment, int address,int lines, int linesize);
|
||||||
|
|
17
start
17
start
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
X=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)
|
|
||||||
Y=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2)
|
|
||||||
if [ ${X} -ge 1920 ]; then
|
|
||||||
SIZE=11
|
|
||||||
elif [ ${X} -ge 1680 ]; then
|
|
||||||
SIZE=10
|
|
||||||
elif [ ${X} -ge 1440 ]; then
|
|
||||||
SIZE=9
|
|
||||||
elif [ ${X} -ge 1368 ]; then
|
|
||||||
SIZE=8
|
|
||||||
elif [ ${X} -ge 1280 ]; then
|
|
||||||
SIZE=7
|
|
||||||
else
|
|
||||||
SIZE=6
|
|
||||||
fi
|
|
||||||
xterm -fullscreen -fa monaco -fs ${SIZE} -bg black -fg green -e bash -c "docker run -it -e COLUMNS=213 -e LINES=58 --name maker --rm -v $(pwd):/data maker ./ia86"
|
|
Loading…
Reference in New Issue