from zero to botnet
4
Makefile
@ -1,10 +1,12 @@
|
|||||||
include tools/Makefile
|
include tools/Makefile
|
||||||
include src/Makefile
|
include src/Makefile
|
||||||
|
|
||||||
default: all
|
.PHONY: all
|
||||||
|
|
||||||
all: embed libdzonerzy libdzonerzy-gen
|
all: embed libdzonerzy libdzonerzy-gen
|
||||||
|
|
||||||
runlocal: embed libdzonerzy-runlocal
|
runlocal: embed libdzonerzy-runlocal
|
||||||
|
|
||||||
|
tools: embed
|
||||||
|
|
||||||
clean: clean-tools clean-libdzonerzy
|
clean: clean-tools clean-libdzonerzy
|
BIN
res/binwalk.jpg
Normal file
After Width: | Height: | Size: 160 KiB |
BIN
res/bored-hacker.jpg
Normal file
After Width: | Height: | Size: 168 KiB |
BIN
res/botnet.gif
Normal file
After Width: | Height: | Size: 302 KiB |
BIN
res/bug-wires.jpg
Normal file
After Width: | Height: | Size: 238 KiB |
BIN
res/dark-side-cookie.jpg
Normal file
After Width: | Height: | Size: 134 KiB |
BIN
res/hopeless-programmer.jpg
Normal file
After Width: | Height: | Size: 150 KiB |
BIN
res/router-going-wild.jpg
Normal file
After Width: | Height: | Size: 242 KiB |
BIN
res/routers-stunned.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
res/system-add-user.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
@ -87,6 +87,8 @@ Copyright:
|
|||||||
#define MD_CODE(x) "`" x "`"
|
#define MD_CODE(x) "`" x "`"
|
||||||
// code block macros
|
// code block macros
|
||||||
#define MD_CODEBLOCK(x) "```" x "```"
|
#define MD_CODEBLOCK(x) "```" x "```"
|
||||||
|
// start/end a code block macros
|
||||||
|
#define MD_CODEBLOCK_TICKS(x) "\n```" x "\n"
|
||||||
// code block macros with language
|
// code block macros with language
|
||||||
#define MD_CODEBLOCK_LANG(l, c) "```" l "\n" c "\n```"
|
#define MD_CODEBLOCK_LANG(l, c) "```" l "\n" c "\n```"
|
||||||
// text macros
|
// text macros
|
||||||
|
@ -31,6 +31,7 @@ typedef struct _embed
|
|||||||
char *format;
|
char *format;
|
||||||
int verbose;
|
int verbose;
|
||||||
int quiet;
|
int quiet;
|
||||||
|
int autowrap;
|
||||||
} embed_t;
|
} embed_t;
|
||||||
|
|
||||||
static void usage(char **argv);
|
static void usage(char **argv);
|
||||||
@ -43,7 +44,7 @@ int main(int argc, char **argv)
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
embed_t args = {0};
|
embed_t args = {0};
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "hvi:o:f:Vq")) != -1)
|
while ((c = getopt(argc, argv, "hvi:o:f:Vqw")) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -89,6 +90,9 @@ int main(int argc, char **argv)
|
|||||||
case 'q':
|
case 'q':
|
||||||
args.quiet = 1;
|
args.quiet = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
args.autowrap = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv);
|
usage(argv);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -207,12 +211,6 @@ int embed(embed_t *args)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->output == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Output file not specified\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args->format == NULL)
|
if (args->format == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Output format not specified\n");
|
fprintf(stderr, "Output format not specified\n");
|
||||||
@ -235,13 +233,15 @@ int embed(embed_t *args)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *output = fopen(args->output, "w");
|
FILE *output = NULL;
|
||||||
|
|
||||||
if (output == NULL)
|
if (args->output != NULL)
|
||||||
{
|
{
|
||||||
if (!args->quiet)
|
output = fopen(args->output, "w");
|
||||||
fprintf(stderr, "Unable to open output file: %s\n", args->output);
|
}
|
||||||
return EXIT_FAILURE;
|
else
|
||||||
|
{
|
||||||
|
output = stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *name_only = strdup(args->input);
|
char *name_only = strdup(args->input);
|
||||||
@ -276,48 +276,76 @@ int embed(embed_t *args)
|
|||||||
|
|
||||||
if (args->format[0] == 'c')
|
if (args->format[0] == 'c')
|
||||||
{
|
{
|
||||||
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {\n", name_only, input_name);
|
if (args->autowrap)
|
||||||
|
{
|
||||||
|
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {\n", name_only, input_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {", name_only, input_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (args->format[0] == 'h')
|
else if (args->format[0] == 'h')
|
||||||
{
|
{
|
||||||
fprintf(output, "#pragma once\n");
|
fprintf(output, "#pragma once\n");
|
||||||
fprintf(output, "#ifndef %s_H\n", input_name);
|
fprintf(output, "#ifndef %s_H\n", input_name);
|
||||||
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {\n", name_only, input_name);
|
if (args->autowrap)
|
||||||
|
{
|
||||||
|
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {\n", name_only, input_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(output, "__attribute__((section(\"embed/%s\"))) const unsigned char %s[] = {", name_only, input_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while ((c = fgetc(input)) != EOF)
|
if (args->autowrap)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
while ((c = fgetc(input)) != EOF)
|
||||||
{
|
{
|
||||||
fprintf(output, " ");
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf(output, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(output, "0x%02X", c);
|
||||||
|
|
||||||
|
fprintf(output, ", ");
|
||||||
|
if (i < 15)
|
||||||
|
{
|
||||||
|
fprintf(output, ", ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(output, ",\n");
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(output, "0x%02X", c);
|
if (i > 0)
|
||||||
|
|
||||||
if (i < 15)
|
|
||||||
{
|
{
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(output, " 0x00,\n");
|
||||||
|
fprintf(output, "};\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ((c = fgetc(input)) != EOF)
|
||||||
|
{
|
||||||
|
fprintf(output, "0x%02X", c);
|
||||||
fprintf(output, ", ");
|
fprintf(output, ", ");
|
||||||
}
|
}
|
||||||
else
|
fprintf(output, "0x00");
|
||||||
{
|
fprintf(output, "};\n\n");
|
||||||
fprintf(output, ",\n");
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0)
|
|
||||||
{
|
|
||||||
fprintf(output, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(output, " 0x00,\n");
|
|
||||||
fprintf(output, "};\n");
|
|
||||||
|
|
||||||
if (args->format[0] == 'h')
|
if (args->format[0] == 'h')
|
||||||
{
|
{
|
||||||
fprintf(output, "#endif /* %s_H */\n", input_name);
|
fprintf(output, "#endif /* %s_H */\n", input_name);
|
||||||
|