Commit Graph
69 Commits
Author SHA1 Message Date
Olaf Barthel 7a4cf2e4ec Fixes for smba_read() and smba_write()
smba_read() failed to register the number of bytes read successfully by smb_proc_read_raw(). This made all files appear to be empty.

smba_write() did not update the offset value correctly if the first smb_proc_write() call had succeeded.
2016-04-01 16:35:33 +02:00
Olaf Barthel 85e33f1088 NetBIOS session header is decoded separately
Decoding is performed before the session header type is checked and, if necessary, rejected.

smb_receive_raw() now only accepts a single session header type (message) and rejects all others. At this stage "positive session response" should no longer appear.
2016-04-01 16:33:37 +02:00
Olaf Barthel d85b7afd8d Version bump 2016-03-30 13:49:02 +02:00
Olaf Barthel 8bb63e19b5 Small indentation fixes 2016-03-30 13:48:48 +02:00
Olaf Barthel 2adfed7183 success/error handling is now consistent
All functions now follow a consistent error reporting scheme. A negative return value always indicates an error condition. A return value of 0 always indicates success, except for the few functions which have to return a count of bytes or directory records upon success.

Previously, it was hard to tell what function returned what in case of error, which led the bugs in smba_write() and smba_read(), neither of which gracefully fell back on SMB_COM_WRITE/SMB_COM_READ, respectively if SMB_COM_WRITE_RAW/SMB_COM_READ_RAW failed.

State variables are now named according to their respective purpose where possible. Previously, it was "rval", "errnum", "result" which were used almost interchangeably regardless of purpose.
2016-03-30 13:48:32 +02:00
Olaf Barthel d8e77ce386 Rolled back a "bug fix" / SMB_COM_WRITE_RAW handling corrected
Turns out that the length filled in by smb_setup_header() was not actually off by 4 bytes but entirely correct. This caused SMB packets to be sent four bytes short, and probably causing some SMB server implementations to ignore them altogether.

A successful SMB_COM_WRITE_RAW command may cause the server to send interim progress update responses, ending with a final SMB_COM_WRITE_RAW_COMPLETE message. This is now handled correctly.
2016-03-30 13:43:56 +02:00
Olaf Barthel 248d0cf759 Documentation comments added 2016-03-30 13:40:34 +02:00
Olaf Barthel 12adae4398 Small fixes for embarrassing bugs
The 'struct tm tm' declaration in convert_smb_date_time_to_tm() must be static, not auto.

Seek mode decoding was off by one.
2016-03-30 13:40:07 +02:00
Olaf Barthel 2c90cdbeb1 Version bump 2016-03-29 13:58:57 +02:00
Olaf Barthel 450006bb4d Added more debugging information
Signed quantities are now used as such, e.g. the server time zone.

The SMB_COM_READ/WRITE/READ_RAW/WRITE_RAW data is now printed in the scope it was intended for, e.g. the SMB_COM_WRITE_RAW data output begins at the indicated offset rather than at the padding bytes which may precede it.

Added server/client capability flags covered by "Implementing CIFS", but not by the Microsoft reference documentation.

The NetBIOS session header contents are now printed along with the SMB header information.

Added GPLv2 header text.
2016-03-29 13:58:42 +02:00
Olaf Barthel e14e2d0133 Debug output now includes NetBIOS session header 2016-03-29 13:54:05 +02:00
Olaf Barthel 881070ec30 Version bump 2016-03-28 12:12:20 +02:00
Olaf Barthel 7a85bd1a23 Date/time/size conversion fixes
The SMB date/time, filetime and utime information is now converted into display format instead of just showing up as hexadecimal format numbers.

The end-of-file and allocation size values are now printed in decimal format in addition to hexadecimal format.
2016-03-28 12:12:09 +02:00
Olaf Barthel 2fc3650b2e Leftover indendation fixes 2016-03-28 12:09:54 +02:00
Olaf Barthel 27acd498d2 Minor loop refactoring 2016-03-28 12:09:28 +02:00
Olaf Barthel 00b5bf7fcf Added dependency for quad_math.h 2016-03-28 12:09:12 +02:00
Olaf Barthel 5fd0a33b76 Header comment cleaned up 2016-03-28 12:08:55 +02:00
Olaf Barthel a386f6ce02 Version bump 2016-03-27 18:14:43 +02:00
Olaf Barthel 3562ef9720 Bug fix for random junk in first file data
smba_read() could end up returning random junk in the first few bytes of a file because the make_open() return value tripped it up.
2016-03-27 18:14:30 +02:00
Olaf Barthel 6b3e54c1db Added documentation comments
Made a note of the fact that the SMB_COM_READ_RAW may be followed by more than one response by the server. The current implementation only catches one response.

The data transmitted by the SMB_COM_WRITE_RAW command is no longer decoded as if it were an SMB message.
2016-03-27 18:13:11 +02:00
Olaf Barthel ba332083a4 Cleaned up the indentation 2016-03-27 18:11:12 +02:00
Olaf Barthel 6c1451f146 Moved the test examples behind the header comment 2016-03-27 18:10:38 +02:00
Olaf Barthel ef4f02546e Error codes and decoded message output reworked
Time is now printed uniformly in hexadecimal format.
dword data is now printed as unsigned integer values.
Decoded error messages should be a bit more readable.
2016-03-27 18:09:59 +02:00
Olaf Barthel d59fc688bb Refactored SMB message decoder
The decoder now handles all SMB commands which the smbfs file system uses, including the two subcommands of the SMB_COM_TRANSACTION2 command which are used (TRANS2_FIND_FIRST2 and TRANS2_FIND_NEXT2).

This is still very ugly and very complex code, but hopefully the next version will only be ugly...
2016-03-27 12:33:03 +02:00
Olaf Barthel 6a6e98085e Refactored SMB message decoder
Added dependencies for "dump_smb.c" and "dump_smb.h"
2016-03-27 12:30:08 +02:00
Olaf Barthel 51b7e9be6e Version bump 2016-03-27 12:29:33 +02:00
Olaf Barthel 1387847f00 Refactored the SMB decoder
Added dependencies for "dump_smb.h"
2016-03-27 12:29:01 +02:00
Olaf Barthel 46666ad167 Refactored the SMB decoder
Moved into separate "dump_smb.c" and "dump_smb.h" files.
2016-03-27 12:28:26 +02:00
Olaf Barthel b0df941186 Indentation cleanup 2016-03-27 12:27:36 +02:00
Olaf Barthel 44362384f4 Indentation cleanup 2016-03-27 12:27:20 +02:00
Olaf Barthel 6ae4cc81ff Major update to SMB decoder
Major rework of the code which decodes individual commands,  their parameters and the responses. This is still incomplete, but it's a lot more useful now than before.
2016-03-25 17:47:10 +01:00
Olaf Barthel c390a3fa0e Version bump 2016-03-20 16:37:20 +01:00
Olaf Barthel 56cee8e3fb Reworked the SMB decoder to handle ANDX commands better 2016-03-20 16:37:04 +01:00
Olaf Barthel 887e014b2a Version bump 2016-03-06 15:27:14 +01:00
Olaf Barthel 0e0565c3e9 Reworked the maximum transmission size handling
The maximum transmission size can now be limited to values smaller than 65530, but it must be larger than 8000 bytes.
2016-03-06 15:27:03 +01:00
Olaf Barthel 1c62774432 Reworked word/dword conversion code
The word/dword conversion code should be more robust now, using type casts where needed.

Cleaned up numeric comparisons, so that the types of the quantities compared match.

The SMB packet dump code now prints the current transmit buffer size along with the other packet information.
2016-03-06 15:25:40 +01:00
Olaf Barthel 11c3b7891d Reworked the word/dword conversion code
The word/dword conversion macros should be more robust now, using type casts where needed.
2016-03-06 15:23:03 +01:00
Olaf Barthel 4893011dae Renamed max_xmit to given_max_xmit
Because the field and variable name "max_xmit" was used in four different places, with different types in different context, it was hard to know what was what. This is part of the cleanup work.
2016-03-06 15:22:13 +01:00
Olaf Barthel 76bdadec3d Removed server state from global data structure
These fields are not needed in the global data structure, they are used only locally.
2016-03-06 15:20:55 +01:00
Olaf Barthel f6e4f963f8 Reworked word/dword conversion code
The word/dword conversion code should be more robust now, using the type casts where needed.

The maximum transmission size provided by the server is now a local variable and no longer stored in the global server parameters because it is really only needed here.

The maximum transmission size limit requested by the user is no longer ignored.
2016-03-06 15:20:16 +01:00
Olaf Barthel e5f8f425ee Removed max_xmit field from server parameters
The "max_xmit" field has been replaced by a new parameter passed to the smba_start() function.
2016-03-06 15:17:08 +01:00
Olaf Barthel ba7b0d658c MAXTRANSMIT added
The maximum transmission size is now configurable through a command line/tool type option. This used to be preset to 65530.

Also removed a htons() call that was both wrong and unnecessary.
2016-03-06 15:15:22 +01:00
Olaf Barthel ff16b6adcd Version bump 2016-02-28 13:39:48 +01:00
Olaf Barthel 333116eb78 Buffer size reduction due to NetBIOS header
Buffer size passed to smb_receive_raw() from smb_receive() reduced by 4 bytes to account for NetBIOS session header.
2016-02-28 13:39:34 +01:00
Olaf Barthel 88eaf1b0b9 Slight increase for maximum transmission buffer size
smba_connect() max_xmit now set to 65534 (used to be 65530).
2016-02-28 13:38:40 +01:00
Olaf Barthel 3df0f8e50a Added one more error code translation entry
Added "ERRnosuchshare" (67) to dos_msgs[] table.
2016-02-28 13:36:53 +01:00
Olaf Barthel 088ddf8439 Date conversion update, Task priority change, Fix for ACTION_READ_LINE
When converting the server's file modification time for a FileInfoBlock->fib_Date, we now prefer the creation time record if the modification time is not provided.

When the file system enters its packet dispatch loop, its Task priority is increased to 10 unless it already uses a a higher priority level; the priority is restored when the dispatch loop terminates.

The ACTION_READ_LINK packet is now properly rejected as being unsupported.
2016-02-28 13:36:15 +01:00
Olaf Barthel 1f3945460e Added support for raw SMB over TCP and for SMB command debugging
Raw SMB over TCP is now the default; re-enable the NetBIOS layer with the NETBIOS switch. The DUMPSMB switch enables SMB command decoding, the results of which will be sent to STDOUT if the respective decoding functions have been built into the smbfs command.
2016-02-21 13:47:44 +01:00
Olaf Barthel 99fe89d475 Added support for raw SMB over TCP
This complements the functionality in the updated SMB abstraction layer. Also added a little documentation for some of the various undocumented magic numbers and fields of the SMB commands set up in this implementation. There is more to come, eventually.
2016-02-21 13:45:51 +01:00
Olaf Barthel d00debee61 Added SMB command decoding functionality
All commands which the smbfs program receives or send through the network can now be decoded, printing header information and (eventually) more detailed information about the specific server command. This option is enabled at compile time.
2016-02-21 13:44:01 +01:00