Giter Site home page Giter Site logo

Comments (19)

sahlberg avatar sahlberg commented on September 7, 2024 1

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.

sahlberg avatar sahlberg commented on September 7, 2024 1

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.

amosavian avatar amosavian commented on September 7, 2024

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.

amosavian avatar amosavian commented on September 7, 2024

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.

sahlberg avatar sahlberg commented on September 7, 2024

from libsmb2.

amosavian avatar amosavian commented on September 7, 2024

These are all flags and their values in Darwin

screen shot 1397-03-08 at 3 40 02 pm

from libsmb2.

sahlberg avatar sahlberg commented on September 7, 2024

from libsmb2.

amosavian avatar amosavian commented on September 7, 2024

I have a better idea, why not define O_NOOVERWRITE flag?

from libsmb2.

amosavian avatar amosavian commented on September 7, 2024

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.

amosavian avatar amosavian commented on September 7, 2024

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.

sahlberg avatar sahlberg commented on September 7, 2024

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.

amosavian avatar amosavian commented on September 7, 2024

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.

stefbon avatar stefbon commented on September 7, 2024

from libsmb2.

amosavian avatar amosavian commented on September 7, 2024

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.

sahlberg avatar sahlberg commented on September 7, 2024

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.

amosavian avatar amosavian commented on September 7, 2024

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.

amosavian avatar amosavian commented on September 7, 2024

About memory management, I don't know what you exactly mean. But for internal use, you can implement a reference counting system.

from libsmb2.

amosavian avatar amosavian commented on September 7, 2024

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.

thegeekyboy avatar thegeekyboy commented on September 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.