diff --git a/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/bogosort.c b/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/bogosort.c index 8cd52ce0..93b44476 100644 --- a/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/bogosort.c +++ b/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/bogosort.c @@ -39,9 +39,9 @@ int main(void) if (is_sorted(numbers, 6)) /* TODO use goto instead of break */ - break; + goto end; } - + end: for (i = 0; i < 6; i++) printf("%d ", numbers[i]); printf("\n"); diff --git a/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/rez1 b/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/rez1 new file mode 100755 index 00000000..140fdc4b Binary files /dev/null and b/laborator/content/toolchain-decompilare/2-warm-up-gotos/a-bogosort/rez1 differ diff --git a/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments new file mode 100755 index 00000000..bfe8aab1 Binary files /dev/null and b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments differ diff --git a/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments.c b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments.c index 85abdb2b..d9c90ab3 100644 --- a/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments.c +++ b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/ignore_the_comments.c @@ -38,11 +38,11 @@ int main(void) float x = 42; /* drunk, fix later */ + begin: while (ago < 0x2a) { - printf("http://stackoverflow.com/questions/184618/what-is-the-best - -comment-in-source-code-you-have-ever-encountered\n"); + printf("http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered\n"); ago++; - continue; /* TODO: use goto for Pete's sake! */ + goto begin; /* TODO: use goto for Pete's sake! */ printf("Fast inverse square root: %f\n", Q_rsqrt(x)); /* i'm sorry */ } diff --git a/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/rez1 b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/rez1 new file mode 100755 index 00000000..f1744a71 Binary files /dev/null and b/laborator/content/toolchain-decompilare/2-warm-up-gotos/b-ignore_the_comments/rez1 differ diff --git a/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/rez b/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/rez new file mode 100755 index 00000000..9935f66a Binary files /dev/null and b/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/rez differ diff --git a/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/vector_max.c b/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/vector_max.c index 3d28d646..ce70e82c 100644 --- a/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/vector_max.c +++ b/laborator/content/toolchain-decompilare/3-goto-algs/a-vector_max/vector_max.c @@ -11,7 +11,16 @@ int main(void) /* TODO: Implement finding the maximum value in the vector */ max = v[0]; i = 1; + loop: + if (i >= 7) + goto end; + if (v[i] > max) + max = v[i]; + i++; + goto loop; + end: + printf("%d\n", max); (void) i; (void) max; } diff --git a/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/binary_search.c b/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/binary_search.c index eb817220..c3d1ed39 100644 --- a/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/binary_search.c +++ b/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/binary_search.c @@ -1,16 +1,37 @@ -// SPDX-License-Identifier: BSD-3-Clause - #include -int main(void) -{ - int v[] = {1, 2, 15, 51, 53, 66, 202, 7000}; - int dest = v[2]; /* 15 */ - int start = 0; - int end = sizeof(v) / sizeof(int) - 1; +int main(void) { + int v[] = {1, 2, 15, 51, 53, 66, 202, 7000}; + int dest = v[2]; /* 15 */ + int start = 0; + int end = sizeof(v) / sizeof(int) - 1; + int found = 0; + int mid; + +binary_search: + if (start > end) + goto not_found; + mid = (start + end) / 2; + if (v[mid] == dest) { + found = 1; + goto found; + } else if (v[mid] < dest) { + start = mid + 1; + goto binary_search; + } else { + end = mid - 1; + goto binary_search; + } + +not_found: + printf("not found.\n"); + goto end_prog; - /* TODO: Implement binary search */ - (void) dest; - (void) start; - (void) end; +found: + printf("index %d.\n", mid); + goto end_prog; + +end_prog: + return 0; } + diff --git a/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/rez b/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/rez new file mode 100755 index 00000000..3a780693 Binary files /dev/null and b/laborator/content/toolchain-decompilare/3-goto-algs/b-binary_search/rez differ diff --git a/laborator/content/toolchain-decompilare/4-tutorial-ghidra/crackme b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/crackme old mode 100644 new mode 100755 index 202bfc81..8d25771e Binary files a/laborator/content/toolchain-decompilare/4-tutorial-ghidra/crackme and b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/crackme differ diff --git a/laborator/content/toolchain-decompilare/4-tutorial-ghidra/readme.txt b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/readme.txt new file mode 100644 index 00000000..b7d91d00 --- /dev/null +++ b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/readme.txt @@ -0,0 +1 @@ +./crackme AAAEAAAA diff --git a/laborator/content/toolchain-decompilare/4-tutorial-ghidra/run b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/run new file mode 100755 index 00000000..db861ee3 Binary files /dev/null and b/laborator/content/toolchain-decompilare/4-tutorial-ghidra/run differ