diff --git a/Makefile b/Makefile index 8709264..3edec04 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ CC = gcc FLAGS = -m32 -nostdlib -nostdinc -static -Wall -O2 -clean: +clean: hash @echo $(step_count) ${CC} ${FLAGS} main.c -o 0.out -remove: clean +remove: + echo "#define output" > hash.txt rm *.out + +hash: + ./jasmin.sh diff --git a/build_hash.j b/build_hash.j new file mode 100644 index 0000000..912b1d2 --- /dev/null +++ b/build_hash.j @@ -0,0 +1,19 @@ +.class public HelloWorld +.super java/lang/Object + +.method public static main([Ljava/lang/String;)V + .limit stack 5 + .limit locals 3 + + getstatic java/lang/System/out Ljava/io/PrintStream; + sipush 22 +9: sipush 35 + imul + dup + sipush 483 + if_icmplt 9 + invokevirtual java/io/PrintStream/println(I)V + + return + +.end method diff --git a/jasmin.sh b/jasmin.sh new file mode 100755 index 0000000..df37079 --- /dev/null +++ b/jasmin.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +wget https://downloads.sourceforge.net/project/jasmin/jasmin/jasmin-2.4/jasmin-2.4.zip +unzip jasmin-2.4.zip + +java -jar ./jasmin-2.4/jasmin.jar build_hash.j + +if [[ $? == 0 ]]; then + OUTPUT=$(java HelloWorld) + echo "#define HASH $OUTPUT" > hash.txt + rm jasmin-2.4.zip + rm -rf jasmin-2.4 + rm HelloWorld.class + exit 0 +else: + echo Hash not found + rm jasmin-2.4.zip + rm -rf jasmin-2.4 + rm HelloWorld.class + exit 1 +fi + diff --git a/main.c b/main.c index 1df0f30..420eef3 100644 --- a/main.c +++ b/main.c @@ -3,6 +3,8 @@ #define touches asm #define yoursyscall volatile +#include "hash.txt" + //TODO make this safe int size_of(void * in) { @@ -19,6 +21,9 @@ int owo() { char tmp1[] = "Hello world\n"; int temp1; +#ifdef output + public class BuildExecutor { +#endif touches yoursyscall ("int $0x80": "=a" (temp1): "a" (4), "b" (1), "c" (tmp1), "d" (size_of(tmp1))