Author Topic: Accessing network shares  (Read 8042 times)

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 1734
Accessing network shares
« on: November 09, 2013, 08:29:24 PM »
Here is a quick example to access network shares. The code is based on some MSDN examples.

Code: [Select]
Usage: ConnShare letter remotename username password

ConnShare.exe Z: \\server\share Administrator p@ssw0rd!

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: Accessing network shares
« Reply #1 on: November 09, 2013, 09:00:43 PM »
interesting - and educational, Erol   :t

Gunther

  • Member
  • *****
  • Posts: 3518
  • Forgive your enemies, but never forget their names
Re: Accessing network shares
« Reply #2 on: November 09, 2013, 10:10:46 PM »
Well done, Erol.  :t Thank you.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: Accessing network shares
« Reply #3 on: November 10, 2013, 04:40:39 AM »
Crispy and clear, Erol - really nice :t

Here is the Masm version, with formatted errors instead of the numbers. Can't test it right now because I don't have a network, but it should work, too ;-)

include \masm32\MasmBasic\MasmBasic.inc        ; download
uselib mpr

.data?
nr NETRESOURCE <?>

  Init
  push eax
  invoke CommandLineToArgvW, rv(GetCommandLineW), esp
  pop ecx
  .if ecx==5
        mov nr.dwType, RESOURCETYPE_ANY
        mov nr.lpLocalName, CL$(1)
        mov nr.lpRemoteName, CL$(2)
        and nr.dwType, 0
        push FALSE
        push CL$(3)
        push CL$(4)
        lea eax, nr
        push eax
        call WNetAddConnection2
        .if eax == NO_ERROR
                Print "Connection added: ", CL$(2)
        .else
                Print "Error: ", Err$()
        .endif
  .else
        wPrint "ConnShare V1.0", wCrLf$, wCrLf$, "Usage: ConnShare letter remotename username password"
  .endif
  wInkey
  Exit
end start

OPT_Arg1        Z: \\server\share Administrator p@ssw0rd        ; for testing (RichMasm sets arguments this way)


For me, it returns "Error: Nessun provider di rete ha accettato il percorso di rete specificato.", which is for Google translate "Error: No network provider accepted the given network path.".

GoneFishing

  • Member
  • ****
  • Posts: 967
  • Gone fishing
Re: Accessing network shares
« Reply #4 on: November 10, 2013, 04:55:58 AM »
G**gle query
Code: [Select]
indexof: /sharewill give you lots of shared folders on the internet  ;)

Gunther

  • Member
  • *****
  • Posts: 3518
  • Forgive your enemies, but never forget their names
Re: Accessing network shares
« Reply #5 on: November 10, 2013, 05:28:45 AM »
Thank you, Jochen for the MasmBasic version. Works fine for me.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 7765
  • Assembler is fun ;-)
    • MasmBasic
Re: Accessing network shares
« Reply #6 on: November 10, 2013, 05:54:48 AM »
I have no experience with shared folders.
Does one of you have a concrete commandline that works?
Plus one for WNetCancelConnection2?

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: Accessing network shares
« Reply #7 on: November 10, 2013, 07:00:32 AM »
i don't really know of a command-line interface for working with shared folders
i do know that if you want to share a folder, you can right-click/properties/sharing tab and do it that way
i suspect the info is buried in NTFS System Volume Information or, more likely, in the registry
it may be a group policy thing - i never dug into it   :P

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: Accessing network shares
« Reply #8 on: November 10, 2013, 07:09:46 AM »
according to technet, "net" works if Run As Admin

http://technet.microsoft.com/en-us/library/cc770880.aspx#BKMK_cp

FORTRANS

  • Member
  • ****
  • Posts: 946
Re: Accessing network shares
« Reply #9 on: November 10, 2013, 07:15:54 AM »
i don't really know of a command-line interface for working with shared folders

Hi,

   If a resource is already shared, you can use the "NET USE"
command to access it from a command line.  Try "NET HELP"
and "NET HELP USE" to maximize the local entropy.  "NET View"
to see shared stuff.

Cheers,

Steve N.

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: Accessing network shares
« Reply #10 on: November 10, 2013, 07:23:27 AM »
with a little further reading, i find that "net is old technology - not very reliable"

Gunther

  • Member
  • *****
  • Posts: 3518
  • Forgive your enemies, but never forget their names
Re: Accessing network shares
« Reply #11 on: November 10, 2013, 08:01:56 AM »
Dave,

with a little further reading, i find that "net is old technology - not very reliable"

that's right. Here's a short summary.

Gunther
Get your facts first, and then you can distort them.

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 1734
Re: Accessing network shares
« Reply #12 on: November 10, 2013, 09:09:44 AM »
Dave,

with a little further reading, i find that "net is old technology - not very reliable"

that's right. Here's a short summary.

Gunther

Hi Gunther and Dave,

I have to disagree. The net command does perfectly its job. I use it everyday at work to assign letters to network shares and I didn't experience any problem with the net command.

dedndave

  • Member
  • *****
  • Posts: 8752
  • Still using Abacus 2.0
    • DednDave
Re: Accessing network shares
« Reply #13 on: November 10, 2013, 11:43:45 AM »
well - i tried
net view
i got an error 6118
which may be a valid error, as i have no shares

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 1734
Re: Accessing network shares
« Reply #14 on: November 10, 2013, 08:35:02 PM »
Hi Dave,

The net command is using the SMB protocol. Maybe, you have a firewall \ AV issue blocking the communication.