Comments (19)
I decided to start building something more generic we can use for DCERPC in general instead
of something that just contain pre-cooked arrays of values.
Initial wip here:
98854ef
It encodes either NDR32 or NDR64 depending on what the server prefers and can send validly
formed NetShareEnum calls for level 1 (name, type, comment) info.
I still need to add decoders and decode the blob the server returned. Which will require some thinking about how to track memory and how to handle memory allocations without leaking.
But we are getting there.
We might not just get a NetShareEnum function but simple dcerpc runtime we can use to do other kind of RPC calls with too.
from libsmb2.
Hi @amosavian
I can sure add those FCNTL functions too.
Please open a new issue for each of the ones you want and I will add them after the next release.
I will close this issue for now since we do have SMB2_IOCTL now
from libsmb2.
Sorry I've found out that Failure to add signature
error is not related to listing and is thrown before trying to open file srvsvc
from libsmb2.
I found the issue with srvsvc
on listing share names. No need to implementing fsctl, just implement a smb2_open_async()
variation that open file with exactly this create request settings. Maybe by introducing a new open flag like O_PIPE
.
from libsmb2.
from libsmb2.
These are all flags and their values in Darwin
from libsmb2.
from libsmb2.
I have a better idea, why not define O_NOOVERWRITE
flag?
from libsmb2.
I've tested user-defined O_NOOVERWRITE
flag and it fixed issue with opening file handle for srvsvc
. But It seems Apple's strict implementation doesn't allow to interoperate with this pipe via READ/WRITE commands, whereas Windows and Samba does allow.
Interestingly, according to Microsoft examples on named pipes, both READ/WRITE and IOCTL can handle this, and the only difference is number of request/responses.
Indeed this is a bug is Apple's custom server implementation of SMB2 protocol.
EDIT: I can write to pipe but I get STATUS_INVALID_PARAMETER
error when I try to read from pipe. I can send wireshark files if you wish.
from libsmb2.
I've finally figured out what was Apple's problem. It was my fault. I had to set offset to 0 on every read and write. Now issue fixed and I can enumerate shares on Apple without IOCTL.
from libsmb2.
Nice work!
If you implement this using Create/Write/Read/Close for now,
please add this as new file lib/smb2-cmd-share-enum.c or similar, don't put it in libsmb2.c for now.
This means that your other patch to add O_NOOVERWRITE, that should go into libsmb2-private.h and not libsmb2.c.
(Having it private for now until and if we see a need to make it publicly visible)
Async code can be intimidating at first if you are not familiar with it.
If that is the case, you can implement this as a simple function that just uses the sync version of
open//write//read/close and I can refactor it later to become async.
This is exciting! Getting share enumeration working !
from libsmb2.
Unfortunately I don't know C nor I do know libsmb2 internals. I did my best for a draft implementation. Please see and check it.
https://gist.github.com/amosavian/1bfc261ff33bf59684a9248ca1a82a06
Reference implementations are MSRPC.swift and listShare() function inside my project.
Meanwhile we should find a better name for O_NOOVERWRITE
from libsmb2.
from libsmb2.
Indeed I studied that lib and it helped me in initial implementation, after that I used wireshark for debuging.
I changed some parts, like encoding guid, to make the core more readable and consistant.
from libsmb2.
Correct, I have not implemented nse_enum_read_cb yet.
I need to think about how memory managment will work before I start implementing too much of it.
But it should not be too difficult to come up with something workable.
Just give me some time.
from libsmb2.
That's great. There are other pipes like winreg
. See here
As I see you also use write/read instead of ioctl command. 😀 However It made number of callbacks folded by two.
nse_enum_read_cb()
is not implemented yet?
One more thing you must consider when enumerating enums. You must check that share type is disk. See here. You can refine result to have STYPE_DISKTREE
or STYPE_SPECIAL | STYPE_DISKTREE
.
The second one includes shares likeC$
in windows or user folder in macOS. Maybe you can add an argument to allow user to determine which type of shares should be enumerated?
from libsmb2.
About memory management, I don't know what you exactly mean. But for internal use, you can implement a reference counting system.
from libsmb2.
Hey @sahlberg,
Would you mind considering implementing FSCTL_GET_REPARSE_POINT
, FSCTL_SET_REPARSE_POINT
and FSCTL_DELETE_REPARSE_POINT
for symbolic links as readlink()
and symlink()
functions after implementing FSCTL?
from libsmb2.
hi @sahlberg were you able to implement the server side copy feature? I was kind of in need of it :)
from libsmb2.
Related Issues (20)
- Can't delete remote files on a share with libsmb2 HOT 1
- LGPL 2.1 license stuff HOT 7
- Older samba servers crashing when uploading small files or writing last block of larger files
- Does libsmb2 support FSCTL_PIPE_TRANSCEIVE HOT 1
- Building shared library (configure --enable-shared ignored) HOT 3
- Very slow performance w/MacOS SMB server HOT 2
- Build for Apple Silicon arm64 (M1 / M2 / M3) ? HOT 1
- NetBIOS name resolution for hostnames? HOT 2
- ESP_PLATFORM is sys/poll.h, not poll.h. HOT 4
- Initialize p_syntax_id_t
- Hang and crash when disconnecting on Windows HOT 1
- libsmb2 Debian Package HOT 7
- A couple of questions: (mainly SMBv3 traffic generation) HOT 2
- When will the new version be released?
- smb2_opendir memory leak HOT 3
- Many issues running libsmb2 in the context of a fuse filesystem HOT 9
- Add support to Teensy Micro Controller HOT 2
- error when building for ESP HOT 3
- smb2_read with offset for random access HOT 6
- "Wrong signature in received PDU" under heavy multithreading
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libsmb2.