line endings?

master
JoYo 6 years ago
parent e41802ec85
commit 5dba23d673

@ -1,63 +1,90 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: false
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard: Cpp11
IndentWidth: 4
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Allman
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
...

@ -13,15 +13,17 @@
#pragma comment(lib, "openssl/sha.lib")
#define SHA_SUM_LENGTH (SHA_DIGEST_LENGTH + SHA_DIGEST_LENGTH + 1)
int generation(char* seed_path);
int generation(char *seed_path);
int reproduce(void *pic_address, size_t pic_size);
int generation(char* seed_path)
char seed_path[SHA_SUM_LENGTH];
FILE *seed_handle = NULL;
void *pic_buffer = NULL;
int generation(char *seed_path)
{
int return_value = 0;
FILE *seed_handle = NULL;
struct stat pic_statistics;
void *pic_buffer = NULL;
seed_handle = fopen(seed_path, "rb");
if (NULL == seed_handle)
@ -64,7 +66,6 @@ int generation(char* seed_path)
pic_function(pic_buffer, pic_statistics.st_size, reproduce_function);
return_value = 1;
GEN_CLEANUP:
if (NULL != pic_buffer)
@ -83,29 +84,30 @@ GEN_CLEANUP:
int reproduce(void *pic_address, size_t pic_size)
{
int return_value = 0;
char checksum[SHA_SUM_LENGTH];
unsigned char digest[SHA_DIGEST_LENGTH];
struct drand48_data drand_data;
long int mutation_value;
unsigned int mutation_offset = 0;
unsigned char pic_mutated = 0;
struct stat pic_statistics;
srand48_r(time(NULL), &drand_data);
lrand48_r(&drand_data, &mutation_value);
mutation_offset = (mutation_value % (pic_size + 1));
pic_mutated = ((unsigned char *)pic_address)[mutation_offset] & (mutation_value % 2);
pic_mutated =
((unsigned char *)pic_address)[mutation_offset] & (mutation_value % 2);
((char *)pic_address)[mutation_offset] = pic_mutated;
memset(checksum, 0, SHA_SUM_LENGTH);
memset(seed_path, 0, SHA_SUM_LENGTH);
SHA1((const unsigned char *)pic_address, pic_size, digest);
for (int iter = 0; iter < SHA_DIGEST_LENGTH; iter++)
{
sprintf(&checksum[iter * 2], "%02x", digest[iter]);
sprintf(&seed_path[iter * 2], "%02x", digest[iter]);
}
FILE *survived_store = fopen(checksum, "w+");
FILE *survived_store = fopen(seed_path, "w+");
if (NULL == survived_store)
{
return_value = errno;
@ -125,23 +127,39 @@ CLONE_CLEANUP:
{
fclose(survived_store);
}
fstat(fileno(seed_handle), &pic_statistics);
if (NULL != pic_buffer)
{
munmap(pic_buffer, pic_statistics.st_size);
}
if (NULL != seed_handle)
{
fclose(seed_handle);
seed_handle = NULL;
}
return generation(checksum);
return generation(seed_path);
}
int main(int argc, const char **argv)
{
int return_value = 1;
char seed_path[SHA_SUM_LENGTH];
pid_t scrap_process_id;
strncpy(seed_path, argv[1], SHA_SUM_LENGTH);
scrap_process_id = fork();
while (return_value)
{
if(scrap_process_id == 0)
scrap_process_id = fork();
if (scrap_process_id < 0)
{
break;
}
printf("child\t%d\n", scrap_process_id);
if (scrap_process_id == 0)
{
return_value = generation(seed_path);
}

@ -1,24 +1,24 @@
#! /usr/bin/env python
# encoding: utf-8
CC = 'clang'
def options(opt):
opt.load('nasm')
opt.load('compiler_c')
def configure(conf):
conf.load('nasm')
conf.load('compiler_c')
conf.check_cc(header_name='openssl/sha.h')
def build(bld):
bld.program(
source='sins.c',
target='sins',
cflags=['-std=gnu11'],
lib=['ssl', 'crypto']
)
bld(features='asm', source='scrap.asm', target='scrap')
#! /usr/bin/env python
# encoding: utf-8
CC = 'clang'
def options(opt):
opt.load('nasm')
opt.load('compiler_c')
def configure(conf):
conf.load('nasm')
conf.load('compiler_c')
conf.check_cc(header_name='openssl/sha.h')
def build(bld):
bld.program(
source='sins.c',
target='sins',
cflags=['-std=gnu11'],
lib=['ssl', 'crypto']
)
bld(features='asm', source='scrap.asm', target='scrap')

Loading…
Cancel
Save