from zero to botnet
4
Makefile
@ -1,10 +1,12 @@
|
||||
include tools/Makefile
|
||||
include src/Makefile
|
||||
|
||||
default: all
|
||||
.PHONY: all
|
||||
|
||||
all: embed libdzonerzy libdzonerzy-gen
|
||||
|
||||
runlocal: embed libdzonerzy-runlocal
|
||||
|
||||
tools: embed
|
||||
|
||||
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 "`"
|
||||
// code block macros
|
||||
#define MD_CODEBLOCK(x) "```" x "```"
|
||||
// start/end a code block macros
|
||||
#define MD_CODEBLOCK_TICKS(x) "\n```" x "\n"
|
||||
// code block macros with language
|
||||
#define MD_CODEBLOCK_LANG(l, c) "```" l "\n" c "\n```"
|
||||
// text macros
|
||||
|
@ -31,6 +31,7 @@ typedef struct _embed
|
||||
char *format;
|
||||
int verbose;
|
||||
int quiet;
|
||||
int autowrap;
|
||||
} embed_t;
|
||||
|
||||
static void usage(char **argv);
|
||||
@ -43,7 +44,7 @@ int main(int argc, char **argv)
|
||||
int c = 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)
|
||||
{
|
||||
@ -89,6 +90,9 @@ int main(int argc, char **argv)
|
||||
case 'q':
|
||||
args.quiet = 1;
|
||||
break;
|
||||
case 'w':
|
||||
args.autowrap = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv);
|
||||
exit(EXIT_FAILURE);
|
||||
@ -207,12 +211,6 @@ int embed(embed_t *args)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (args->output == NULL)
|
||||
{
|
||||
fprintf(stderr, "Output file not specified\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (args->format == NULL)
|
||||
{
|
||||
fprintf(stderr, "Output format not specified\n");
|
||||
@ -235,13 +233,15 @@ int embed(embed_t *args)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
FILE *output = fopen(args->output, "w");
|
||||
FILE *output = NULL;
|
||||
|
||||
if (output == NULL)
|
||||
if (args->output != NULL)
|
||||
{
|
||||
if (!args->quiet)
|
||||
fprintf(stderr, "Unable to open output file: %s\n", args->output);
|
||||
return EXIT_FAILURE;
|
||||
output = fopen(args->output, "w");
|
||||
}
|
||||
else
|
||||
{
|
||||
output = stdout;
|
||||
}
|
||||
|
||||
char *name_only = strdup(args->input);
|
||||
@ -275,19 +275,35 @@ int embed(embed_t *args)
|
||||
fprintf(output, "\n");
|
||||
|
||||
if (args->format[0] == 'c')
|
||||
{
|
||||
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')
|
||||
{
|
||||
fprintf(output, "#pragma once\n");
|
||||
fprintf(output, "#ifndef %s_H\n", 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 i = 0;
|
||||
|
||||
if (args->autowrap)
|
||||
{
|
||||
while ((c = fgetc(input)) != EOF)
|
||||
{
|
||||
if (i == 0)
|
||||
@ -297,6 +313,7 @@ int embed(embed_t *args)
|
||||
|
||||
fprintf(output, "0x%02X", c);
|
||||
|
||||
fprintf(output, ", ");
|
||||
if (i < 15)
|
||||
{
|
||||
fprintf(output, ", ");
|
||||
@ -317,6 +334,17 @@ int embed(embed_t *args)
|
||||
|
||||
fprintf(output, " 0x00,\n");
|
||||
fprintf(output, "};\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((c = fgetc(input)) != EOF)
|
||||
{
|
||||
fprintf(output, "0x%02X", c);
|
||||
fprintf(output, ", ");
|
||||
}
|
||||
fprintf(output, "0x00");
|
||||
fprintf(output, "};\n\n");
|
||||
}
|
||||
|
||||
if (args->format[0] == 'h')
|
||||
{
|
||||
|