浏览代码

S1/T5

api_change
Krzysztof KWIATKOWSKI 9 年前
父节点
当前提交
3d3fbbe549
共有 5 个文件被更改,包括 279 次插入51 次删除
  1. +2
    -1
      Makefile
  2. +238
    -50
      MatsanoCrypto.sublime-workspace
  3. +24
    -0
      utils/utils_tester.cpp
  4. +14
    -0
      utils/xor.c
  5. +1
    -0
      utils/xor.h

+ 2
- 1
Makefile 查看文件

@@ -2,6 +2,7 @@ INC=.
all:
g++ -g -I${INC} -c utils/hex_to_base64.cpp -o obj/hex_to_base64.o
g++ -g -I${INC} -c utils/utils_tester.cpp -o obj/utils_tester.o
g++ -g -I${INC} -c utils/xor.c -o obj/xor.o
g++ -g -I${INC} -c set1/xor_char_finder.cpp -o obj/xor_char_finder.o
g++ -g -lpthread -o utils_tester obj/hex_to_base64.o obj/utils_tester.o obj/xor_char_finder.o
g++ -g -lpthread -o utils_tester obj/hex_to_base64.o obj/utils_tester.o obj/xor_char_finder.o obj/xor.o

+ 238
- 50
MatsanoCrypto.sublime-workspace 查看文件

@@ -3,6 +3,22 @@
{
"selected_items":
[
[
"stri",
"string_hex"
],
[
"convert",
"convert_string_to_hex"
],
[
"set1",
"set1_challenge3_test"
],
[
"frequency",
"frequency_t"
],
[
"cip",
"ciphertext_len"
@@ -35,10 +51,6 @@
"char",
"char_in_printable"
],
[
"stri",
"convert_string_to_hex"
],
[
"pri",
"printable_ascii"
@@ -502,18 +514,6 @@
[
"sub",
"subscribers"
],
[
"incre",
"increaseObserversCounter"
],
[
"comment",
"comment-method comment-method"
],
[
"met",
"method-comment-simple comment-method-simple"
]
]
},
@@ -527,19 +527,59 @@
"line_ending": "Unix"
}
},
{
"file": "utils/hex_to_base64.cpp",
"settings":
{
"buffer_size": 5988,
"line_ending": "Unix"
}
},
{
"file": "set1/xor_char_finder.cpp",
"settings":
{
"buffer_size": 4610,
"line_ending": "Unix"
}
},
{
"file": "set1/xor_char_finder.h",
"settings":
{
"buffer_size": 174,
"line_ending": "Unix"
}
},
{
"file": "utils/utils_tester.cpp",
"settings":
{
"buffer_size": 2543,
"buffer_size": 4523,
"line_ending": "Unix"
}
},
{
"file": "set1/challenge3.h",
"file": "utils/xor.h",
"settings":
{
"buffer_size": 24,
"buffer_size": 98,
"line_ending": "Unix"
}
},
{
"file": "utils/xor.c",
"settings":
{
"buffer_size": 363,
"line_ending": "Unix"
}
},
{
"file": "Makefile",
"settings":
{
"buffer_size": 365,
"line_ending": "Unix"
}
}
@@ -560,15 +600,15 @@
"Snippet: comment"
],
[
"snippet",
"comme",
"Snippet: comment"
],
[
"snipet: comment",
"Snippet: comment-fix"
"snippet",
"Snippet: comment"
],
[
"comme",
"snipet: comment",
"Snippet: comment-fix"
],
[
@@ -932,17 +972,20 @@
"expanded_folders":
[
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/etc",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/set1",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/utils"
],
"file_history":
[
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/utils/xor.c",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/utils/hex_to_base64.cpp",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/set1/challenge3.h",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/set1/challenge3.cpp",
"/home/kkwiatkowski/.sublime",
"/home/kkwiatkowski/.config/sublime-text-3/Packages/User/comment.sublime-snippet",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/Makefile",
"/home/kkwiatkowski/storage/03_Education/04_Languages/French/Grammar_my_notes.md",
"/home/kkwiatkowski/storage/91_Repositories/MatasanoCrypto/utils/hex_to_base64.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/test/python/si/net/dispatcher.py",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/agent/src/Dispatcher.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/02_SI/br_5-1/test/python/si/protocol/tcil/proxy.py",
@@ -1062,9 +1105,7 @@
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/include/openssl/ssl23.h",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/doc/openssl-shared.txt",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/demos/engines/ibmca/ica_openssl_api.h",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/util/opensslwrap.sh",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/doc/openssl_button.html",
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/include/openssl/opensslconf.h"
"/home/kkwiatkowski/storage/91_Repositories/openssl101j/util/opensslwrap.sh"
],
"find":
{
@@ -1137,6 +1178,11 @@
"case_sensitive": false,
"find_history":
[
"xor_strings",
"#include \"utils/hex_to_base64.h\"\n",
"max_score",
"challenge3",
"gcc",
"fill_frequency",
"#define FREQUENT_LETTERS_AMOUNT 5\n",
"size_t",
@@ -1259,12 +1305,7 @@
"getCMGMessa",
"DUCommandGetConState",
"_tlsVersion",
"setSSL",
"_argVerboseMode",
"getCustomSSLVersion",
"iSSLVersion",
"_sslVersion",
"_argVerboseMode"
"setSSL"
],
"highlight": true,
"in_selection": false,
@@ -1327,7 +1368,7 @@
"groups":
[
{
"selected": 1,
"selected": 6,
"sheets":
[
{
@@ -1343,8 +1384,8 @@
"selection":
[
[
311,
311
320,
320
]
],
"settings":
@@ -1356,68 +1397,215 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 2,
"stack_index": 5,
"type": "text"
},
{
"buffer": 1,
"file": "utils/utils_tester.cpp",
"file": "utils/hex_to_base64.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 2543,
"buffer_size": 5988,
"regions":
{
},
"selection":
[
[
1557,
1557
5308,
5308
]
],
"settings":
{
"function_name_status_row": 43,
"function_name_status_row": 167,
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"translation.y": 1456.0,
"zoom_level": 1.0
},
"stack_index": 0,
"stack_index": 4,
"type": "text"
},
{
"buffer": 2,
"file": "set1/challenge3.h",
"file": "set1/xor_char_finder.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 24,
"buffer_size": 4610,
"regions":
{
},
"selection":
[
[
20,
20
0,
0
]
],
"settings":
{
"function_name_status_row": 0,
"open_with_edit": true,
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 7,
"type": "text"
},
{
"buffer": 3,
"file": "set1/xor_char_finder.h",
"semi_transient": false,
"settings":
{
"buffer_size": 174,
"regions":
{
},
"selection":
[
[
172,
172
]
],
"settings":
{
"function_name_status_row": 7,
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 2,
"type": "text"
},
{
"buffer": 4,
"file": "utils/utils_tester.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 4523,
"regions":
{
},
"selection":
[
[
4312,
4312
]
],
"settings":
{
"function_name_status_row": 153,
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 1613.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
},
{
"buffer": 5,
"file": "utils/xor.h",
"semi_transient": false,
"settings":
{
"buffer_size": 98,
"regions":
{
},
"selection":
[
[
19,
19
]
],
"settings":
{
"function_name_status_row": 0,
"open_with_edit": true,
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 3,
"type": "text"
},
{
"buffer": 6,
"file": "utils/xor.c",
"semi_transient": false,
"settings":
{
"buffer_size": 363,
"regions":
{
},
"selection":
[
[
203,
203
]
],
"settings":
{
"function_name_status_row": 7,
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 7,
"file": "Makefile",
"semi_transient": false,
"settings":
{
"buffer_size": 365,
"regions":
{
},
"selection":
[
[
362,
362
]
],
"settings":
{
"function_name_status_row": 6,
"syntax": "Packages/Makefile/Makefile.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 6,
"type": "text"
}
]
}
@@ -2311,7 +2499,7 @@
"show_open_files": true,
"show_tabs": false,
"side_bar_visible": true,
"side_bar_width": 285.0,
"side_bar_width": 212.0,
"status_bar_visible": true,
"template_settings":
{


+ 24
- 0
utils/utils_tester.cpp 查看文件

@@ -4,6 +4,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "xor.h"

void hex_to_base64_text() {
const char test_buff1[] ="49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
@@ -132,10 +133,33 @@ void set2_challange4_test()
free(line);
}

void set2_challenge_5_test()
{
static const char ch1[] = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal";
static const char xor_val[] = "ICE";
static const unsigned char expected[] = {
0x0b,0x36,0x37,0x27,0x2a,0x2b,0x2e,0x63,0x62,0x2c,0x2e,0x69,0x69,0x2a,0x23,0x69,
0x3a,0x2a,0x3c,0x63,0x24,0x20,0x2d,0x62,0x3d,0x63,0x34,0x3c,0x2a,0x26,0x22,0x63,
0x24,0x27,0x27,0x65,0x27,0x2a,0x28,0x2b,0x2f,0x20,0x43,0x0a,0x65,0x2e,0x2c,0x65,
0x2a,0x31,0x24,0x33,0x3a,0x65,0x3e,0x2b,0x20,0x27,0x63,0x0c,0x69,0x2b,0x20,0x28,
0x31,0x65,0x28,0x63,0x26,0x30,0x2e,0x27,0x28,0x2f};

unsigned char o_ch1[256];
memset(o_ch1, '\0', 256);
unsigned char* po_ch1 = o_ch1;
xor_repeatedly(xor_val, ch1, po_ch1);

for(unsigned i=0; i<sizeof(expected)/sizeof(unsigned char); ++i)
assert( expected[i] == po_ch1[i] );
}

int main() {
hex_to_base64_text();
convert_string_to_hex_test();
xor_strings_test();
//set1_challenge3_test();
set2_challange4_test();
set2_challenge_5_test();
}


+ 14
- 0
utils/xor.c 查看文件

@@ -0,0 +1,14 @@
#include <string.h>
#include <stdio.h>

void xor_repeatedly(const char* const i_xor, const char* const i_string, unsigned char* o_xored)
{
const unsigned xor_len = strlen(i_xor);
unsigned counter = 0;
while( counter < strlen(i_string) )
{
unsigned xor_idx = counter % xor_len;
o_xored[counter] = (i_string[counter]) ^ (i_xor[xor_idx]);
counter++;
}
}

+ 1
- 0
utils/xor.h 查看文件

@@ -0,0 +1 @@
void xor_repeatedly(const char* const i_xor, const char* const i_string, unsigned char* o_xored);

正在加载...
取消
保存