diff options
| -rwxr-xr-x | Makefile | 4 | ||||
| -rwxr-xr-x | src/nu_defines.h | 20 | ||||
| -rw-r--r-- | src/nu_lanman.c | 6 | ||||
| -rwxr-xr-x | src/nu_server.c | 41 |
4 files changed, 49 insertions, 22 deletions
| @@ -1,11 +1,11 @@ | |||
| 1 | all: nudossi | 1 | all: nudossi |
| 2 | 2 | ||
| 3 | nudossi: | 3 | nudossi: |
| 4 | gcc -O -o bin/nudossi src/nu_server.c src/nu_lanman.c | 4 | gcc -O -o bin/nudossi src/nu_server.c # src/nu_lanman.c |
| 5 | strip bin/nudossi | 5 | strip bin/nudossi |
| 6 | 6 | ||
| 7 | debug: | 7 | debug: |
| 8 | gcc -g -o bin/nudossi src/nu_server.c src/nu_lanman.c | 8 | gcc -g -o bin/nudossi src/nu_server.c # src/nu_lanman.c |
| 9 | 9 | ||
| 10 | clean: | 10 | clean: |
| 11 | rm -f bin/nudossi nudossi.core | 11 | rm -f bin/nudossi nudossi.core |
diff --git a/src/nu_defines.h b/src/nu_defines.h index 75c3f2b..36bbb56 100755 --- a/src/nu_defines.h +++ b/src/nu_defines.h | |||
| @@ -99,6 +99,26 @@ typedef enum { | |||
| 99 | } SMB_COMMAND; | 99 | } SMB_COMMAND; |
| 100 | 100 | ||
| 101 | typedef enum { | 101 | typedef enum { |
| 102 | SMB_TRANS2_OPEN2 = 0x00, | ||
| 103 | SMB_TRANS2_FIND_FIRST2 = 0x01, | ||
| 104 | SMB_TRANS2_FIND_NEXT2 = 0x02, | ||
| 105 | SMB_TRANS2_QUERY_FS_INFORMATION = 0x03, | ||
| 106 | /* Reserved */ | ||
| 107 | SMB_TRANS2_QUERY_PATH_INFORMATION = 0x05, | ||
| 108 | SMB_TRANS2_SET_PATH_INFORMATION = 0x06, | ||
| 109 | SMB_TRANS2_QUERY_FILE_INFORMATION = 0x07, | ||
| 110 | SMB_TRANS2_SET_FILE_INFORMATION = 0x08, | ||
| 111 | SMB_TRANS2_FSCTL = 0x09, | ||
| 112 | SMB_TRANS2_IOCTL2 = 0x0A, | ||
| 113 | SMB_TRANS2_FIND_NOTIFY_FIRST = 0x0B, | ||
| 114 | SMB_TRANS2_FIND_NOTIFY_NEXT = 0x0C, | ||
| 115 | SMB_TRANS2_CREATE_DIRECTORY = 0x0D, | ||
| 116 | SMB_TRANS2_SESSION_SETUP = 0x0E, | ||
| 117 | SMB_TRANS2_GET_DFS_REFERRAL = 0x10, | ||
| 118 | SMB_TRANS2_REPORT_DFS_INCONSISTENCY = 0x11, | ||
| 119 | } SMB_TRANS2_SUBCOMMAND; | ||
| 120 | |||
| 121 | typedef enum { | ||
| 102 | STATUS_SUCCESS = 0x00000000, | 122 | STATUS_SUCCESS = 0x00000000, |
| 103 | STATUS_WAIT_0 = 0x00000000, | 123 | STATUS_WAIT_0 = 0x00000000, |
| 104 | STATUS_WAIT_1 = 0x00000001, | 124 | STATUS_WAIT_1 = 0x00000001, |
diff --git a/src/nu_lanman.c b/src/nu_lanman.c index 0ab935e..3d78b06 100644 --- a/src/nu_lanman.c +++ b/src/nu_lanman.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "nu_lanman.h" | 1 | #include "nu_lanman.h" |
| 2 | 2 | ||
| 3 | BYTE LANMAN_NetShareGetInfo_1_bytes[] = { 20,0,'S','H','A','R','E',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; | 3 | BYTE LANMAN_NetShareGetInfo_1_params[] = { 10,6,0,20,0,0,0,6,0,55,0,0,0,20,0,61,0,0,0,0,0 }; |
| 4 | BYTE LANMAN_NetShareGetInfo_1_bytes[] = { 26,0,0,0,0,0,20,0,'S','H','A','R','E',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; | ||
| 4 | 5 | ||
| 5 | SMB_STATUS handle_LANMAN( SMB_HEADER *header, SMB_DATA *data, SMB_TRANSACTION_BYTES *bytes ) { | 6 | SMB_STATUS handle_LANMAN( SMB_HEADER *header, SMB_DATA *data, SMB_TRANSACTION_BYTES *bytes ) { |
| 6 | switch( GETNWORD( bytes->params ) ) { | 7 | switch( GETNWORD( bytes->params ) ) { |
| @@ -12,7 +13,8 @@ SMB_STATUS handle_LANMAN( SMB_HEADER *header, SMB_DATA *data, SMB_TRANSACTION_BY | |||
| 12 | 13 | ||
| 13 | switch( GETNWORD(type)) { | 14 | switch( GETNWORD(type)) { |
| 14 | case 1: /* Medium set of information */ | 15 | case 1: /* Medium set of information */ |
| 15 | memcpy( bytes->params, LANMAN_NetShareGetInfo_1_bytes, sizeof( LANMAN_NetShareGetInfo_1_bytes )); /* possible buffer overflow */ | 16 | data->params = (SMB_PARAMS*)LANMAN_NetShareGetInfo_1_params; |
| 17 | data->bytes = (SMB_BYTES*) LANMAN_NetShareGetInfo_1_bytes; | ||
| 16 | break; | 18 | break; |
| 17 | default: /* Later */ | 19 | default: /* Later */ |
| 18 | return 0x00400002; | 20 | return 0x00400002; |
diff --git a/src/nu_server.c b/src/nu_server.c index 186c2d7..5112f1e 100755 --- a/src/nu_server.c +++ b/src/nu_server.c | |||
| @@ -91,30 +91,35 @@ static SMB_STATUS handle_SMB_COM_TREE_CONNECT_ANDX( SMB_HEADER *header, SMB_DATA | |||
| 91 | return STATUS_SUCCESS; | 91 | return STATUS_SUCCESS; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static SMB_STATUS handle_SMB_COM_TRANSACTION( SMB_HEADER *header, SMB_DATA *data ) { | 94 | //static SMB_STATUS handle_SMB_COM_TRANSACTION( SMB_HEADER *header, SMB_DATA *data ) { |
| 95 | if( !strcmp( (char*)&data->bytes[1], "\\PIPE\\LANMAN")) | 95 | // if( !strcmp( (char*)&data->bytes[1], "\\PIPE\\LANMAN")) |
| 96 | { | 96 | // { |
| 97 | /* TODO: Sanity Check on DataCount vs. ByteCount */ | 97 | // /* TODO: Sanity Check on DataCount vs. ByteCount */ |
| 98 | SMB_PARAMS_TRANSACTION *params = (SMB_PARAMS_TRANSACTION *)data->params; | 98 | // SMB_PARAMS_TRANSACTION *params = (SMB_PARAMS_TRANSACTION *)data->params; |
| 99 | SMB_TRANSACTION_BYTES bytes; | 99 | // SMB_TRANSACTION_BYTES bytes; |
| 100 | 100 | // | |
| 101 | bytes.params = ((BYTE*)&header->Protocol) + GETNWORD( params->ParameterOffset ); | 101 | // bytes.params = ((BYTE*)&header->Protocol) + GETNWORD( params->ParameterOffset ); |
| 102 | bytes.paramc = GETNWORD( params->ParameterCount ); | 102 | // bytes.paramc = GETNWORD( params->ParameterCount ); |
| 103 | bytes.data = ((BYTE*)&header->Protocol) + GETNWORD( params->DataOffset ); | 103 | // bytes.data = ((BYTE*)&header->Protocol) + GETNWORD( params->DataOffset ); |
| 104 | bytes.datac = GETNWORD( params->DataCount ); | 104 | // bytes.datac = GETNWORD( params->DataCount ); |
| 105 | 105 | // | |
| 106 | return handle_LANMAN( header, data, &bytes ); | 106 | // return handle_LANMAN( header, data, &bytes ); |
| 107 | } | 107 | // } |
| 108 | else | 108 | // else |
| 109 | return 0x00400002; | 109 | // return 0x00400002; |
| 110 | } | 110 | //} |
| 111 | |||
| 112 | //static SMB_STATUS handle_SMB_COM_TRANSACTION2( SMB_HEADER *header, SMB_DATA *data ) { | ||
| 113 | // return 0x00400002; /* No handler yet */ | ||
| 114 | //} | ||
| 111 | 115 | ||
| 112 | static int command_handler_match(const void *a, const void *b ) { return *(BYTE*)a - *(BYTE*)b; } | 116 | static int command_handler_match(const void *a, const void *b ) { return *(BYTE*)a - *(BYTE*)b; } |
| 113 | 117 | ||
| 114 | /* If you add command handlers, please insert them in the right position, | 118 | /* If you add command handlers, please insert them in the right position, |
| 115 | this list is sorted by command, for later bsearch*/ | 119 | this list is sorted by command, for later bsearch*/ |
| 116 | static SMB_COMMAND_HANDLER command_handler[] = { | 120 | static SMB_COMMAND_HANDLER command_handler[] = { |
| 117 | { SMB_COM_TRANSACTION, 0x00, handle_SMB_COM_TRANSACTION }, | 121 | // { SMB_COM_TRANSACTION, 0x00, handle_SMB_COM_TRANSACTION }, |
| 122 | // { SMB_COM_TRANSACTION2, 0x00, handle_SMB_COM_TRANSACTION2 }, | ||
| 118 | { SMB_COM_NEGOTIATE, 0x00, handle_SMB_COM_NEGOTIATE }, | 123 | { SMB_COM_NEGOTIATE, 0x00, handle_SMB_COM_NEGOTIATE }, |
| 119 | { SMB_COM_SESSION_SETUP_ANDX, 0x01, handle_SMB_COM_SESSION_SETUP_ANDX }, | 124 | { SMB_COM_SESSION_SETUP_ANDX, 0x01, handle_SMB_COM_SESSION_SETUP_ANDX }, |
| 120 | { SMB_COM_TREE_CONNECT_ANDX, 0x01, handle_SMB_COM_TREE_CONNECT_ANDX } | 125 | { SMB_COM_TREE_CONNECT_ANDX, 0x01, handle_SMB_COM_TREE_CONNECT_ANDX } |
