Rust Vs C
Reverse Engineering
What is C
- General-purpose procedural programming language.
- Designed in 1972 by Dennis Ritchie
- Designed to construct utilities running on Linux.
- "You control everything, including memory safety"
What is Rust
- Multi-paradigm programming language designed for productivity and performance.
- Syntactically similar to C++
- Can guarantee memory safety through the borrow checker.
- No garbage collection
- Reference counting is optional
Properties of C
- Procedural language
- Statically typed
- Manually manage memory
- Errors both at compile and run time
Properties of Rust
- Functional Programming Language
- Dynamically typed
- Explicit definition of mutable vs non-mutable variables
- Ownership system
- Errors caught at compile time
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
bool pw_check(char *input) {
char flag[] = {0x4d, 0x44, 0x46, 0x4e, 0x46, 0x56, 0x40, 0x46, 0x28, 0x7e, 0x63, 0x34, 0x73, 0x36, 0x76, 0x5a, 0x52, 0x30, 0x56, 0x5a, 0x51, 0x6d, 0x36, 0x5a, 0x47, 0x36, 0x76, 0x51, 0x5a, 0x56, 0x35, 0x69, 0x61, 0x34, 0x60, 0x77, 0x78};
int inputLength = strlen(input);
int flagLength = strlen(flag);
int i = 0;
if (inputLength != flagLength) {
return false;
}
for (i = 0; i < inputLength; i++) {
if (input[i] != flag[i]) {
return false;
}
}
return true;
}
void operation_fives(char *input, char *output) {
int inputLength = strlen(input);
int i = 0;
for (i = 0; i < inputLength; i++) {
output[i] = input[i] ^ 5;
}
}
int main(int argc, char **argv) {
if (argc == 2) {
char *input;
char output[128];
bool result;
input = argv[1];
operation_fives(input, output);
result = pw_check(output);
if (result == true) {
printf("Success!\n");
} else {
printf("Failure!\n");
}
} else {
printf("Invalid input!\n");
}
}
Click -
New Videos Every other Sunday!
Follow Us On:
Cracking Evil Santa's Box
Rust vs C code
By Ragnar Security
Rust vs C code
- 102