Skip to content

Instantly share code, notes, and snippets.

@bernardopadua
Created June 24, 2018 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernardopadua/998de481e54ce68b08ed72afbeb39a0c to your computer and use it in GitHub Desktop.
Save bernardopadua/998de481e54ce68b08ed72afbeb39a0c to your computer and use it in GitHub Desktop.
Crackme Z
#include <stdio.h>
#include "to_think.h"
#define ERRO "You can't pass through here!"
#define NOTSUCCESS "Hey, are you sure ? Do you forgetting something ?"
#define LOOKMEM "You definitely should think about this a little longer."
#define WHOLE "It's easy, c'mon! I know that you can do it!"
char nkey[26] = {0x0};
char npass[22] = {0x0};
void (*p)();
void (*z)(char);
void (*y)();
void print_for_me_please(){
puts(ERRO);
}
void print_for_me_sir(char *x){
puts(x);
}
void wanna_beef(){
char key[5] = { 0xb, 0xe, 0xe, 0xf, 0x0 };
puts("Want some...");
for(int i=0; i<sizeof(key); i++){
if(key[i]!=0x0){
printf("%2x", key[i]);
}
}
puts(" ? ");
if(nkey[0]==0xf){
puts(ERRO);
}
}
void secret_main(){
char key_n_key[22] = { 0x66 + 0x2, 0x6c + 0x2, 0x61 + 0x2, 0x67 + 0x2, 0x28 + 0x2, 0x2e + 0x2, 0x2e + 0x2, 0x2e + 0x2, 0x6e + 0x2, 0x6f + 0x2, 0x74 + 0x2, 0x72 + 0x2, 0x65 + 0x2, 0x61 + 0x2, 0x6c + 0x2, 0x6f + 0x2, 0x6e + 0x2, 0x65 + 0x2, 0x21 + 0x2, 0x21 + 0x2, 0x21 + 0x2, 0x29 + 0x2 };
wanna_beef();
if((nkey[0]>0x31 && nkey[0]<0x33) && nkey[1]==0xc && nkey[3]==0x7a){
z(nkey[0]);
return;
}
for(int a=0;a<sizeof(key_n_key);a++){
key_n_key[a] = key_n_key[a]-0x2;
nkey[a] = key_n_key[a];
}
puts(NOTSUCCESS);
}
void grab_my_pass_to_release_the_kraken(){
char key_n_key[46] = { 0x50 + 0x20, 0x6c + 0x20, 0x65 + 0x20, 0x61 + 0x20, 0x73 + 0x20, 0x65 + 0x20, 0x5f + 0x20, 0x53 + 0x20, 0x69 + 0x20, 0x72 + 0x20, 0x5f + 0x20, 0x57 + 0x20, 0x68 + 0x20, 0x61 + 0x20, 0x74 + 0x20, 0x5f + 0x20, 0x49 + 0x20, 0x73 + 0x20, 0x5f + 0x20, 0x54 + 0x20, 0x68 + 0x20, 0x65 + 0x20, 0x5f + 0x20, 0x50 + 0x20, 0x61 + 0x20, 0x73 + 0x20, 0x73 + 0x20, 0x77 + 0x20, 0x6f + 0x20, 0x72 + 0x20, 0x64 + 0x20, 0x5f + 0x20, 0x54 + 0x20, 0x6f + 0x20, 0x5f + 0x20, 0x52 + 0x20, 0x65 + 0x20, 0x6c + 0x20, 0x65 + 0x20, 0x61 + 0x20, 0x73 + 0x20, 0x65 + 0x20, 0x5f + 0x20, 0x4d + 0x20, 0x65+ 0x20, 0x3a + 0x20 };
int a = 0;
int z = 13;
//to_think_about
for(int i=0; i<sizeof(key_n_key); i++){
key_n_key[i] = key_n_key[i] - 0x20;
}
puts(key_n_key);
scanf("%s", npass);
for(int i=0; i<=(4+9); i++){
if(a<=3){
if(npass[i] != nkey[a]){
puts(WHOLE);
break;
}
} else if(a>3 && a<13){
if(npass[i] != nkey[z]){
puts(WHOLE);
break;
}
z++;
} else if(i>=(4+9)){
for(int aa=0; aa<sizeof(to_think_about); aa++){
if(to_think_about[aa] != 0x0){
to_think_about[aa] = to_think_about[aa] - 0x20;
}
}
print_for_me_sir("");
puts(nkey);
print_for_me_sir("");
puts(to_think_about);
print_for_me_sir("");
return;
}
a++;
}
return;
}
void middle_secret(char c){
char key_n_key[27] = { 0x66 ^ 0x2, 0x6c ^ 0x2, 0x61 ^ 0x2, 0x67 ^ 0x2, 0x28 ^ 0x2, 0x2e ^ 0x2, 0x2e ^ 0x2, 0x2e ^ 0x2, 0x31 ^ 0x2, 0x33 ^ 0x2, 0x33 ^ 0x2, 0x37 ^ 0x2, 0x5f ^ 0x2, 0x4d ^ 0x2, 0x45 ^ 0x2, 0x4e ^ 0x2, 0x54 ^ 0x2, 0x45 ^ 0x2, 0x5f ^ 0x2, 0x42 ^ 0x2, 0x49 ^ 0x2, 0x4e ^ 0x2, 0x2e ^ 0x2, 0x2e ^ 0x2, 0x2e ^ 0x2, 0x29 ^ 0x2, 0x0 };
for(int a=0;a<sizeof(key_n_key);a++){
if(key_n_key[a]!=0){
key_n_key[a] = key_n_key[a]^(c-0x30);
nkey[a] = key_n_key[a];
}
}
grab_my_pass_to_release_the_kraken();
}
int main(int argc, char *argv[]) {
p = &secret_main;
z = &middle_secret;
y = &wanna_beef;
nkey[2] = 0xa;
nkey[3] = 0xb;
if(argc <= 1){
p = &wanna_beef;
nkey[0] = 0xf;
nkey[0] = 0xe;
nkey[3] = 0xa;
} else if(argc == 2){
p = &secret_main;
nkey[0] = *argv[1];
nkey[1] = 0xa;
nkey[3] = 0x6;
} else if(argc == 3){
p = &secret_main;
nkey[0] = *argv[2];
nkey[1] = 0xc;
nkey[3] = *argv[1];
}
p();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment