forked from mkj/dropbear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--HG-- branch : fuzz
- Loading branch information
Showing
13 changed files
with
191 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.*\.o | ||
.*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "includes.h" | ||
|
||
#ifdef DROPBEAR_FUZZ | ||
|
||
#include "includes.h" | ||
#include "fuzz.h" | ||
#include "dbutil.h" | ||
#include "runopts.h" | ||
|
||
struct dropbear_fuzz_options fuzz; | ||
|
||
static void load_fixed_hostkeys(void); | ||
|
||
static void common_setup_fuzzer(void) { | ||
fuzz.fuzzing = 1; | ||
} | ||
|
||
void svr_setup_fuzzer(void) { | ||
struct passwd *pw; | ||
|
||
common_setup_fuzzer(); | ||
|
||
char *argv[] = { | ||
"-E", | ||
}; | ||
|
||
int argc = sizeof(argv) / sizeof(*argv); | ||
svr_getopts(argc, argv); | ||
|
||
/* user lookups might be slow, cache it */ | ||
pw = getpwuid(getuid()); | ||
dropbear_assert(pw); | ||
fuzz.pw_name = m_strdup(pw->pw_name); | ||
fuzz.pw_dir = m_strdup(pw->pw_dir); | ||
fuzz.pw_shell = m_strdup(pw->pw_shell); | ||
fuzz.pw_passwd = m_strdup("!!zzznope"); | ||
|
||
load_fixed_hostkeys(); | ||
} | ||
|
||
static void load_fixed_hostkeys(void) { | ||
#include "fuzz-hostkeys.c" | ||
|
||
buffer *b = buf_new(3000); | ||
enum signkey_type type; | ||
|
||
TRACE(("load fixed hostkeys")) | ||
|
||
svr_opts.hostkey = new_sign_key(); | ||
|
||
buf_setlen(b, 0); | ||
buf_putbytes(b, keyr, keyr_len); | ||
buf_setpos(b, 0); | ||
type = DROPBEAR_SIGNKEY_RSA; | ||
if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | ||
dropbear_exit("failed fixed rsa hostkey"); | ||
} | ||
|
||
buf_setlen(b, 0); | ||
buf_putbytes(b, keyd, keyd_len); | ||
buf_setpos(b, 0); | ||
type = DROPBEAR_SIGNKEY_DSS; | ||
if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | ||
dropbear_exit("failed fixed dss hostkey"); | ||
} | ||
|
||
buf_setlen(b, 0); | ||
buf_putbytes(b, keye, keye_len); | ||
buf_setpos(b, 0); | ||
type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; | ||
if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | ||
dropbear_exit("failed fixed ecdsa hostkey"); | ||
} | ||
|
||
buf_free(b); | ||
} | ||
|
||
#endif /* DROPBEAR_FUZZ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "includes.h" | ||
|
||
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); | ||
|
||
int main(int argc, char ** argv) { | ||
LLVMFuzzerTestOneInput("hello", 5); | ||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef DROPBEAR_FUZZ_H | ||
#define DROPBEAR_FUZZ_H | ||
|
||
#include "includes.h" | ||
#include "buffer.h" | ||
|
||
#ifdef DROPBEAR_FUZZ | ||
|
||
void svr_setup_fuzzer(void); | ||
|
||
struct dropbear_fuzz_options { | ||
int fuzzing; | ||
|
||
// to record an unencrypted stream | ||
FILE* recordf; | ||
|
||
// fuzzing input | ||
buffer input; | ||
|
||
// dropbear_exit() jumps back | ||
sigjmp_buf jmp; | ||
|
||
uid_t pw_uid; | ||
gid_t pw_gid; | ||
char* pw_name; | ||
char* pw_dir; | ||
char* pw_shell; | ||
char* pw_passwd; | ||
}; | ||
|
||
extern struct dropbear_fuzz_options fuzz; | ||
|
||
#endif | ||
|
||
#endif /* DROPBEAR_FUZZ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "fuzz.h" | ||
#include "dbrandom.h" | ||
#include "session.h" | ||
|
||
static int setup_fuzzer(void) { | ||
svr_setup_fuzzer(); | ||
return 0; | ||
} | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | ||
static int once = 0; | ||
if (!once) { | ||
setup_fuzzer(); | ||
once = 1; | ||
} | ||
|
||
fuzz.input.data = (unsigned char*)Data; | ||
fuzz.input.size = Size; | ||
fuzz.input.len = Size; | ||
fuzz.input.pos = 0; | ||
|
||
seedrandom(); | ||
|
||
if (setjmp(fuzz.jmp) == 0) { | ||
svr_session(-1, -1); | ||
} else { | ||
// dropbear_exit jumped here | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.