Browse Source

New directory struct

api_change
Krzysztof Kwiatkowski 9 years ago
parent
commit
4b9158a2c8
32 changed files with 119 additions and 410 deletions
  1. +51
    -23
      Makefile
  2. +0
    -56
      MatsanoCrypto
  3. +11
    -0
      prj/Matasano.sublime-project
  4. +21
    -297
      prj/Matasano.sublime-workspace
  5. +0
    -0
      sol/etc/set1_t4_input.txt
  6. +0
    -0
      sol/etc/set1_t6.txt
  7. +0
    -0
      sol/etc/set1_t7.txt
  8. +0
    -0
      sol/etc/set1_t8.txt
  9. +0
    -0
      sol/etc/set2_t2.txt
  10. +13
    -11
      sol/set1.cpp
  11. +0
    -0
      sol/set1.h
  12. +4
    -4
      sol/set2.c
  13. +0
    -0
      sol/set2.h
  14. +2
    -2
      src/base64.cpp
  15. +0
    -0
      src/base64.h
  16. +4
    -4
      src/cbc.c
  17. +0
    -0
      src/cbc.h
  18. +0
    -0
      src/common.c
  19. +0
    -0
      src/common.h
  20. +0
    -0
      src/ecb.c
  21. +0
    -0
      src/ecb.h
  22. +1
    -1
      src/hamming.c
  23. +0
    -0
      src/hamming.h
  24. +3
    -3
      src/main.cpp
  25. +0
    -0
      src/pkcs7.c
  26. +0
    -0
      src/pkcs7.h
  27. +0
    -0
      src/xor.c
  28. +0
    -0
      src/xor.h
  29. +4
    -4
      src/xor_char_finder.cpp
  30. +0
    -0
      src/xor_char_finder.h
  31. +5
    -5
      tst/utils.cpp
  32. +0
    -0
      tst/utils.h

+ 51
- 23
Makefile View File

@@ -1,31 +1,59 @@

INC=.
LIBRARY=/usr/lib/x86_64-linux-gnu
LIBS=-lcrypto -lssl

SRC_C_FILES := $(wildcard src/*.c)
SRC_CPP_FILES := $(wildcard src/*.cpp)
OBJ_SRC_C_FILES := $(addprefix obj/,$(notdir $(SRC_C_FILES:.c=.o)))
OBJ_SRC_CPP_FILES := $(addprefix obj/,$(notdir $(SRC_CPP_FILES:.cpp=.o)))

SOL_C_FILES := $(wildcard sol/*.c)
SOL_CPP_FILES := $(wildcard sol/*.cpp)
OBJ_SOL_C_FILES := $(addprefix obj/,$(notdir $(SOL_C_FILES:.c=.o)))
OBJ_SOL_CPP_FILES := $(addprefix obj/,$(notdir $(SOL_CPP_FILES:.cpp=.o)))

TST_C_FILES := $(wildcard tst/*.c)
TST_CPP_FILES := $(wildcard tst/*.cpp)
OBJ_TST_C_FILES := $(addprefix obj/,$(notdir $(TST_C_FILES:.c=.o)))
OBJ_TST_CPP_FILES := $(addprefix obj/,$(notdir $(TST_CPP_FILES:.cpp=.o)))

obj/%.o: src/%.cpp
g++ -I${INC} -o $@ -c $^

obj/%.o: src/%.c
g++ -I${INC} -o $@ -c $^

all:
obj/%.o: sol/%.cpp
g++ -I${INC} -o $@ -c $^

obj/%.o: sol/%.c
g++ -I${INC} -o $@ -c $^

obj/%.o: tst/%.cpp
g++ -I${INC} -o $@ -c $^

obj/%.o: tst/%.c
g++ -I${INC} -o $@ -c $^

obj-c: ${OBJ_SRC_C_FILES}
obj-cpp: ${OBJ_SRC_CPP_FILES}
sol-c: ${OBJ_SOL_C_FILES}
sol-cpp: ${OBJ_SOL_CPP_FILES}
tst-c: ${OBJ_TST_C_FILES}
tst-cpp: ${OBJ_TST_CPP_FILES}

create_directories:
mkdir -p obj
g++ -g -I${INC} -c utils/common.c -o obj/common.o
g++ -g -I${INC} -c utils/base64.cpp -o obj/base64.o
g++ -g -I${INC} -c utils/runner.cpp -o obj/utils_runner.o
g++ -g -I${INC} -c utils/xor.c -o obj/xor.o
g++ -g -I${INC} -c utils/pkcs7.c -o obj/pkcs7.o
g++ -g -I${INC} -c set1/xor_char_finder.cpp -o obj/xor_char_finder.o
g++ -g -I${INC} -c utils/hamming.c -o obj/hamming.o
g++ -g -I${INC} -c set1/runner.cpp -o obj/set1_runner.o
g++ -g -I${INC} -c set2/runner.c -o obj/set2_runner.o
g++ -g -I${INC} -c set1/ecb.c -o obj/ecb.o
g++ -g -I${INC} -c set2/cbc.c -o obj/cbc.o
g++ -g -I${INC} -c main.cpp -o obj/main.o
g++ -g -o main obj/common.o obj/base64.o \
obj/xor_char_finder.o obj/xor.o \
obj/hamming.o obj/utils_runner.o \
obj/set1_runner.o obj/main.o obj/ecb.o \
obj/set2_runner.o obj/pkcs7.o obj/cbc.o \
-lcrypto

clean:
rm -rf obj
rm -rf main
rm -rf core*

andrun: all
main
all: create_directories obj-c obj-cpp sol-c sol-cpp tst-c tst-cpp
g++ -I${INC} -o main ${OBJ_SRC_C_FILES} \
${OBJ_SRC_CPP_FILES} \
${OBJ_SOL_C_FILES} \
${OBJ_SOL_CPP_FILES} \
${OBJ_TST_C_FILES} \
${OBJ_TST_CPP_FILES} \
${LIBS}

+ 0
- 56
MatsanoCrypto View File

@@ -1,56 +0,0 @@
{
"folders":
[
{
"path": "."
},
{
"path": "/home/flowher/repos/notes"
},
{
"path": "/home/flowher/repos/OpenCrypto"
}
],
"settings":
{
"rsync_ssh":
{
"excludes":
[
".git*",
"_build",
"blib",
"Build"
],
"options":
[
"--dry-run",
"--delete"
],
"remotes":
{
"MatasanoCrypto":
[
{
"enabled": 1,
"excludes":
[
],
"options":
[
],
"remote_host": "my-server.my-domain.tld",
"remote_path": "/home/kkwiatkowski/Projects/MatasanoCrypto",
"remote_port": 22,
"remote_post_command": "",
"remote_pre_command": "",
"remote_user": "kkwiatkowski"
}
]
},
"sync_on_save": true
},
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
}

+ 11
- 0
prj/Matasano.sublime-project View File

@@ -0,0 +1,11 @@
{
"folders":
[
{
"path": "/home/flowher/repos/MatasanoCrypto"
},
{
"path": "/home/flowher/repos/OpenCrypto"
}
]
}

MatsanoCrypto.sublime-workspace → prj/Matasano.sublime-workspace View File

@@ -519,62 +519,6 @@
},
"buffers":
[
{
"file": "set2/cbc.c",
"settings":
{
"buffer_size": 2409,
"line_ending": "Unix"
}
},
{
"file": "set2/runner.c",
"settings":
{
"buffer_size": 4352,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/OpenCrypto/crypto/evp/evp_enc.c",
"settings":
{
"buffer_size": 19470,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/OpenCrypto/include/openssl/evp.h",
"settings":
{
"buffer_size": 71789,
"line_ending": "Unix"
}
},
{
"file": "utils/common.c",
"settings":
{
"buffer_size": 1267,
"line_ending": "Unix"
}
},
{
"file": "set1/ecb.c",
"settings":
{
"buffer_size": 1843,
"line_ending": "Unix"
}
},
{
"file": "set2/runner.h",
"settings":
{
"buffer_size": 338,
"line_ending": "Unix"
}
}
],
"build_system": "",
"build_system_choices":
@@ -971,28 +915,10 @@
},
"expanded_folders":
[
"/home/flowher/repos/MatasanoCrypto",
"/home/flowher/repos/MatasanoCrypto/set1",
"/home/flowher/repos/MatasanoCrypto/set2",
"/home/flowher/repos/MatasanoCrypto/utils",
"/home/flowher/repos/notes",
"/home/flowher/repos/notes/hacking",
"/home/flowher/repos/OpenCrypto",
"/home/flowher/repos/OpenCrypto/crypto",
"/home/flowher/repos/OpenCrypto/crypto/aes",
"/home/flowher/repos/OpenCrypto/crypto/cmac",
"/home/flowher/repos/OpenCrypto/crypto/ec",
"/home/flowher/repos/OpenCrypto/crypto/ecdsa",
"/home/flowher/repos/OpenCrypto/crypto/evp"
"/home/flowher/repos/MatasanoCrypto"
],
"file_history":
[
"/home/flowher/repos/OpenCrypto/engines/e_gmp.c",
"/home/flowher/repos/OpenCrypto/engines/ccgost/e_gost_err.c",
"/home/flowher/repos/OpenCrypto/engines/ccgost/gost89.c",
"/home/flowher/repos/OpenCrypto/engines/ccgost/gost_asn1.c",
"/home/flowher/repos/OpenCrypto/engines/ccgost/gostsum.c",
"/home/flowher/repos/OpenCrypto/engines/e_aep.c",
"/home/flowher/repos/notes/crypto/eliptic.md",
"/home/flowher/repos/notes/coding/SOLID.md",
"/home/flowher/repos/MatasanoCrypto/set2/cbc.h",
@@ -1114,11 +1040,17 @@
"/home/kkwiatkowski/test.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/Tracer_br_12-0-0/include/TRC_Exception.h",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/ssl/t1_clnt.c",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/crypto/seed/seed_ofb.c"
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/crypto/seed/seed_ofb.c",
"/home/kkwiatkowski/amadeus_workdir/repos/01_OTF/br_12-0/include/otf/SignOutConfig.h",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/test/regression/UTF/005_soapContentEncoding.play",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/connector/src/AcceptorConnector.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/process/src/async/AsyncCmdsCtx.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/ACF/br_12-0-0/include/ACF_Connector.h",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/agent/src/Agent.cpp"
],
"find":
{
"height": 35.0
"height": 25.0
},
"find_in_files":
{
@@ -1189,11 +1121,6 @@
"case_sensitive": false,
"find_history":
[
"EVP_aes_128_cbc",
"_op",
"EVP_CipherInit(",
"EVP_CipherInit",
"_init(",
"RSA_METHOD",
"ENGINE_CMD_DEFN",
"plaintext",
@@ -1316,7 +1243,12 @@
"PWD_CB_ARGS",
"testClientServerSRPAuthCallbacks",
"SSL_CTX_set_srp_username",
"SSL_set_srp_server_param"
"SSL_set_srp_server_param",
"set_srp_username",
"SSL_CTX_set_srp_username",
"4",
"setCommonOptions",
"Server"
],
"highlight": true,
"in_selection": false,
@@ -1379,222 +1311,14 @@
"groups":
[
{
"selected": 2,
"sheets":
[
{
"buffer": 0,
"file": "set2/cbc.c",
"semi_transient": false,
"settings":
{
"buffer_size": 2409,
"regions":
{
},
"selection":
[
[
132,
132
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 3,
"type": "text"
},
{
"buffer": 1,
"file": "set2/runner.c",
"semi_transient": false,
"settings":
{
"buffer_size": 4352,
"regions":
{
},
"selection":
[
[
3588,
3588
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 1746.0,
"zoom_level": 1.0
},
"stack_index": 2,
"type": "text"
},
{
"buffer": 2,
"file": "/home/flowher/repos/OpenCrypto/crypto/evp/evp_enc.c",
"semi_transient": false,
"settings":
{
"buffer_size": 19470,
"regions":
{
},
"selection":
[
[
5507,
5507
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 2018.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 3,
"file": "/home/flowher/repos/OpenCrypto/include/openssl/evp.h",
"semi_transient": false,
"settings":
{
"buffer_size": 71789,
"regions":
{
},
"selection":
[
[
35951,
35951
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 14467.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
},
{
"buffer": 4,
"file": "utils/common.c",
"semi_transient": false,
"settings":
{
"buffer_size": 1267,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 4,
"type": "text"
},
{
"buffer": 5,
"file": "set1/ecb.c",
"semi_transient": false,
"settings":
{
"buffer_size": 1843,
"regions":
{
},
"selection":
[
[
25,
25
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 5,
"type": "text"
},
{
"buffer": 6,
"file": "set2/runner.h",
"semi_transient": false,
"settings":
{
"buffer_size": 338,
"regions":
{
},
"selection":
[
[
148,
148
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 6,
"type": "text"
}
]
}
],
"incremental_find":
{
"height": 34.0
"height": 25.0
},
"input":
{
@@ -1652,7 +1376,7 @@
"height": 188.0
},
"pinned_build_system": "",
"project": "MatsanoCrypto",
"project": "Matasano.sublime-project",
"replace":
{
"height": 46.0
@@ -1664,10 +1388,6 @@
"last_filter": "",
"selected_items":
[
[
"evp.h",
"OpenCrypto/include/openssl/evp.h"
],
[
"xor.h",
"MatasanoCrypto/utils/xor.h"
@@ -2175,6 +1895,10 @@
[
"cmdnewsetdelbasepeakversiontest",
"SI/masteragent/test/src/CmdNewSetDelBasePeakVersionTest.cpp"
],
[
"sei_librarystaterepos",
"SI/masteragent/systemstate/src/SEI_LibraryStateRepository.cpp"
]
],
"width": 0.0

etc/set1_t4_input.txt → sol/etc/set1_t4_input.txt View File


etc/set1_t6.txt → sol/etc/set1_t6.txt View File


etc/set1_t7.txt → sol/etc/set1_t7.txt View File


etc/set1_t8.txt → sol/etc/set1_t8.txt View File


etc/set2_t2.txt → sol/etc/set2_t2.txt View File


set1/runner.cpp → sol/set1.cpp View File

@@ -1,14 +1,16 @@
#include "src/xor_char_finder.h"
#include "src/common.h"
#include "src/base64.h"
#include "src/xor.h"
#include "src/hamming.h"
#include "src/ecb.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "set1/xor_char_finder.h"
#include "utils/common.h"
#include "utils/base64.h"
#include "utils/xor.h"
#include "utils/hamming.h"
#include "set1/ecb.h"
#define SET1_T8_INPUT_FILE "etc/set1_t8.txt"

#define SET1_T8_INPUT_FILE "sol/etc/set1_t8.txt"

char guess_encryption_key_letter(const char ciphertext_hex[])
{
@@ -75,10 +77,10 @@ FUNC(set1_challange4_test)
unsigned char hexdump[30];
unsigned char* p_hexdump = hexdump;

fp=fopen("etc/set1_t4_input.txt", "r");
fp=fopen("sol/etc/set1_t4_input.txt", "r");
if(fp==NULL)
{
fprintf(stderr, "etc/set1_t4_input.txt not found");
fprintf(stderr, "sol/etc/set1_t4_input.txt not found");
return;
}

@@ -150,7 +152,7 @@ FUNC(set1_challenge_6_test)
char error_buf[256];
unsigned char out_buf[1024*1024];
unsigned char hex_buf[1024*1024];
unsigned long len=read_file_to_buffer("etc/set1_t6.txt", base64_buf);
unsigned long len=read_file_to_buffer("sol/etc/set1_t6.txt", base64_buf);
base64_buf[len]='\0';
len=base64_to_hex((unsigned char*)base64_buf, len, hex_buf);

@@ -223,7 +225,7 @@ FUNC(set1_challenge_7_test)
const unsigned char pass[]="YELLOW SUBMARINE";
const char expected_first_line[] = "I'm back and I'm ringin' the bell";
unsigned char ciphertext[1024*1024]; // 1 MB
unsigned long len=read_file_to_buffer("etc/set1_t7.txt", (char*)ciphertext);
unsigned long len=read_file_to_buffer("sol/etc/set1_t7.txt", (char*)ciphertext);

unsigned char buff[1024*1024];
unsigned char hex[1024*1024];

set1/runner.h → sol/set1.h View File


set2/runner.c → sol/set2.c View File

@@ -1,9 +1,9 @@
#include "src/common.h"
#include "src/pkcs7.h"
#include "src/cbc.h"
#include <assert.h>
#include "utils/common.h"
#include "utils/pkcs7.h"
#include <stdio.h>
#include <string.h>
#include "cbc.h"
#include <openssl/evp.h>
#include <openssl/rand.h>

@@ -95,7 +95,7 @@ FUNC(cbc_decrypt_test)
uint8_t buff[4096] = {0};
Result_t res = Result_Error;

res = load_base64_to_hex("etc/set2_t2.txt", buff, &len);
res = load_base64_to_hex("sol/etc/set2_t2.txt", buff, &len);

uint8_t** p = &plaintext;
decrypt_cbc(iv, 16, buff, len, key, 16, p, &len);

set2/runner.h → sol/set2.h View File


utils/base64.cpp → src/base64.cpp View File

@@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils/base64.h"
#include "utils/common.h"
#include "base64.h"
#include "common.h"

#define MIN(a,b) a<b ? a : b


utils/base64.h → src/base64.h View File


set2/cbc.c → src/cbc.c View File

@@ -1,7 +1,7 @@
#include "set1/ecb.h"
#include "utils/xor.h"
#include "utils/common.h"
#include "set1/ecb.h"
#include "src/xor.h"
#include "src/common.h"
#include "src/ecb.h"
#include "src/ecb.h"
#include <stdio.h>
#include <stdlib.h>


set2/cbc.h → src/cbc.h View File


utils/common.c → src/common.c View File


utils/common.h → src/common.h View File


set1/ecb.c → src/ecb.c View File


set1/ecb.h → src/ecb.h View File


utils/hamming.c → src/hamming.c View File

@@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "utils/base64.h"
#include "base64.h"

// calculate distance between s1 and s2
// -1 : failure (different sizes of the strings)

utils/hamming.h → src/hamming.h View File


main.cpp → src/main.cpp View File

@@ -1,6 +1,6 @@
#include "set1/runner.h"
#include "set2/runner.h"
#include "utils/runner.h"
#include "sol/set1.h"
#include "sol/set2.h"
#include "tst/utils.h"

int main()
{

utils/pkcs7.c → src/pkcs7.c View File


utils/pkcs7.h → src/pkcs7.h View File


utils/xor.c → src/xor.c View File


utils/xor.h → src/xor.h View File


set1/xor_char_finder.cpp → src/xor_char_finder.cpp View File

@@ -1,10 +1,10 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "utils/base64.h"
#include "utils/hamming.h"
#include "utils/xor.h"
#include "set1/xor_char_finder.h"
#include "src/base64.h"
#include "src/hamming.h"
#include "src/xor.h"
#include "src/xor_char_finder.h"
#include <ctype.h>
#include <stdlib.h>


set1/xor_char_finder.h → src/xor_char_finder.h View File


utils/runner.cpp → tst/utils.cpp View File

@@ -3,11 +3,11 @@
#include <stdio.h>
#include <stdlib.h>

#include "utils/base64.h"
#include "utils/hamming.h"
#include "utils/xor.h"
#include "utils/common.h"
#include "set1/xor_char_finder.h"
#include "src/base64.h"
#include "src/hamming.h"
#include "src/xor.h"
#include "src/common.h"
#include "src/xor_char_finder.h"

void hex_to_base64_test() {
const char test_buff1[] ="49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";

utils/runner.h → tst/utils.h View File


Loading…
Cancel
Save