Skip to main content

Pure python SMB client

Project description

Pike

Pike is a (nearly) pure-Python framework for writing SMB2/3 protocol correctness tests.



PyPI version Commits since Python versions License

Prerequisites

Required for basic functionality:

  • Python 2.7, 3.6+
  • PyCryptodomex

Required for building kerberos library:

  • Python development headers
  • MIT gssapi_krb5 (plus development headers)
    • Ubuntu: krb5-user, libkrb5-dev

Optional: epydoc for doc generation

Install

$ python -m pip install pike-smb2

Build instructions

Ubuntu 14.04 / 16.04

apt-get install -y --no-install-recommends krb5-user libkrb5-dev python-dev build-essential python2.7 python-pip
pip install setuptools pycryptodomex
python setup.py install

Running tests

The tests in the test subdirectory are ordinary Python unittest tests and can be run as usual. The following environment variables are used by the tests:

PIKE_SERVER=<host name or address>
PIKE_SHARE=<share name>
PIKE_CREDS=DOMAIN\User%Passwd
PIKE_LOGLEVEL=info|warning|error|critical|debug
PIKE_SIGN=yes|no
PIKE_ENCRYPT=yes|no
PIKE_MAX_DIALECT=DIALECT_SMBX_Y_Z
PIKE_MIN_DIALECT=DIALECT_SMBX_Y_Z
PIKE_TRACE=yes|no

If PIKE_TRACE is set to yes then incoming/outgoing packets will be logged at the debug level.

$ python -m unittest discover -s pike/test -p *.py

Alternatively, to build and run all tests

$ python setup.py test

To run an individual test file

$ python -m unittest discover -s pike/test -p echo.py

To run an individual test case

$ python -m unittest pike.test.echo.EchoTest.test_echo

Kerberos Hints

Setting up MIT Kerberos as provided by many Linux distributions to interoperate with an existing Active Directory and Pike is relatively simple.

If PIKE_CREDS is not specified and the kerberos module was built while installing pike then your current Kerberos credentials will be used to authenticate.

Use a minimal /etc/krb5.conf on the client such as the following

[libdefaults]
    default_realm = AD.EXAMPLE.COM

Retrieve a ticket for the desired user

$ kinit user_1

(Optional) in leiu of DNS, add host entries for the server name + domain

$ echo "10.1.1.150    smb-server.ad.example.com" >> /etc/hosts

Run pike tests

$ PIKE_SERVER="smb-server.ad.example.com" PIKE_SHARE="C$" python -m unittest discover -s pike/test -p tree.py

Note that you will probably need to specify the server by fully-qualified hostname in order for Kerberos to figure out which ticket to use. If you get errors during session setup when using an IP address, this is probably the reason.

Decoding BufferOverrun

When pike encounters a buffer or boundary problem, BufferOverrun is raised with the full packet bytes. This can be used in two ways.

With Pike

For some problems, it may be necessary to run pike with a debugger while decoding the packet bytes to reproduce runtime parsing or decoding issues.

from binascii import unhexlify
import array
import pike.netbios

buf = array.array("B", unhexlify(b'00000114fe534d4240000000000000000000040001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000100110302008a8c2a17f5f24e5eb278dd8aaa90d42e1e0000000000010000001000000010006c52c4c7e53dd60166157c68c63dd60180005500d8000000605306062b0601050502a0493047a019301706092a864886f712010202060a2b06010401823702020aa32a3028a0261b246e6f745f646566696e65645f696e5f5246433431373840706c656173655f69676e6f72650000000100260000000000010020000100c93dfb463f3e99ed9030a66d28548c330a4ae9a65856237d00e61f68c14eb09f0000020004000000000001000200'))
nb = pike.netbios.Netbios()
nb.parse(buf)

With Wireshark

Other decoding problems may be easier to understand by looking at the packet with a pcap analysis tool.

$ echo '00000114fe534d4240000000000000000000040001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000100110302008a8c2a17f5f24e5eb278dd8aaa90d42e1e00000000000100000010000000100050cff0c2e43dd60166157c68c63dd60180005500d8000000605306062b0601050502a0493047a019301706092a864886f712010202060a2b06010401823702020aa32a3028a0261b246e6f745f646566696e65645f696e5f5246433431373840706c656173655f69676e6f7265000000010026000000000001002000010017af98eb38fdcd3db91bdca1303e9c72ef37b7e572abf897e47bd779aaa641d90000020004000000000001000200' \
  | xxd -r -p - \
  | od -Ax -tx1 -v \
  | text2pcap -i46 -T 445,445 - - \
  | tshark -P -V -r -
  • xxd decodes the ascii hex bytestream output from the BufferOverrun exception into binary
  • od dumps the output to a format wireshark can read
  • text2pcap (wireshark) appends fake ethernet and IP headers to the SMB packet and writes a pcap file to stdout
  • tshark (wireshark) decodes the SMB packet and displays full packet details

License

This project, pike and pike-smb2, is released under a Simplified BSD License granted by Dell Inc.'s Open Source Project program, except code under pykerb/ which is released under an Apache 2.0 License granted by Apple Inc.
All project contributions are entirely reflective of the respective author(s) and not of Dell Inc. or Apple Inc.

See file LICENSE for licensing information.

Other

There is older API documentation from epydoc.

Pike, with the exception of pykerb and certain build scripts (see below), is licensed under Simplified BSD License as follows:

Copyright © 2013-2020, Dell Inc. or its subsidiaries. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pykerb is licensed under the terms of the Apache 2.0 license as follows:

Copyright © 2006-2009 Apple Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Certain build scripts such as configure and the mk directory are from the MakeKit build system (http://mkbuild.sf.net). None of these files are incorporated into the final build output. The license (3-clause BSD) is viewable at the following URL:

https://github.com/bkoropoff/makekit/blob/master/COPYING

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pike_smb2-0.4.6.tar.gz (177.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pike_smb2-0.4.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_x86_64.whl (756.2 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ x86-64

pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_i686.whl (797.0 kB view details)

Uploaded CPython 3.11musllinux: musl 1.1+ i686

pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686

pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_x86_64.whl (754.1 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ x86-64

pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_i686.whl (794.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.1+ i686

pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686

pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_x86_64.whl (753.8 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ x86-64

pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_i686.whl (794.6 kB view details)

Uploaded CPython 3.9musllinux: musl 1.1+ i686

pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ i686

pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_x86_64.whl (754.0 kB view details)

Uploaded CPython 3.8musllinux: musl 1.1+ x86-64

pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_i686.whl (794.8 kB view details)

Uploaded CPython 3.8musllinux: musl 1.1+ i686

pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ i686

File details

Details for the file pike_smb2-0.4.6.tar.gz.

File metadata

  • Download URL: pike_smb2-0.4.6.tar.gz
  • Upload date:
  • Size: 177.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pike_smb2-0.4.6.tar.gz
Algorithm Hash digest
SHA256 c38fe02ff3d76670f70f91398c72c6b7b07686e0602566524b9b643060e56ef9
MD5 69956b48a0b771416f02083fa25147fd
BLAKE2b-256 ac5a5c00b3ede9b6687c2e9f5860c7904c45374f67950fb252141ccfdff4316e

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f58d9d46436d18e6d61f5eacc4547a2b5f8d19abb3d0d0159ee70e10dfbafdae
MD5 fb1e9c7a4982cfe854b88ef536869b70
BLAKE2b-256 6a8cc8e9274e570f3b1032814abb08beb27e1a9546b4355af5578d8f05bff589

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a250aa279bb32335b4e003b53cf07de39ab988ac470dec9ec34d2fad51bc9cd2
MD5 403a91c53ab3cbf593fdb87b4d4e7141
BLAKE2b-256 e54adeb9b4afa1992f138c22476ac1185d0ce942be06eb10bc23dd1c7bf64cf4

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 10932d288e964fa278693b9ed1e3b483f3b2f0357b9a57e6c83c67ee56c66074
MD5 0e3625ee72c3c46a9e000bc591acbfad
BLAKE2b-256 40b6cd90aaccc34a30e3b4492ed7363d9d4f846c97113d7b186c2550a908c2c2

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 8d2f071e6b0f0d26ac9e48915ccf0f84362dd51b6684372cc46dc3742af06e50
MD5 ec5cb1d64cfbcc93441461e95f6064c9
BLAKE2b-256 6ac80d2c8e2599ec9b9ef64ec28b14db6d4b303f11f2ac4eb799968a80b38deb

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 37f3ffca46c7ed7df29c29e270512ea5c6bc35d48fd2a47f15452674f7276792
MD5 dff25fe86584917cf4678ed005f22bb8
BLAKE2b-256 abeab980f5cab42ac894fee418b76a24f39861c1b00d722c9134cbaa8769a07e

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 ff0bc1149b97659c60d01a5dd5aa7c31809010f63eb96d9042a26050695c968b
MD5 5d6fceb8673579759909f5e23db4f82c
BLAKE2b-256 519027ff2ea93ef499b4fd2863e1b87e004be3547c00b9174f0339e0bd2b335a

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f58115ec5990fc28e0acc25648c1fee4df55837f29f98b18e8b39081adb88851
MD5 5daf9a569be0257becae8da8dc8ed692
BLAKE2b-256 f698e981420e46793d8ec6da924e42c143d05b75705b241a77e1211404571cf2

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 7001d51e7aa3e234388c1a73cbd4f0df6c43d1bd9c798429f2f2bd0b2507182d
MD5 7ea0d66b7701db03fc3753745ea66fce
BLAKE2b-256 812d533252c1931b749e15e2e00c00f7566860fd37b66b3e087bc0ae2e4c6b02

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96bdab187d305d8db302a22ce37bba574e1a82eca8f3d3f4ecda2cf4e10b0195
MD5 9d63c4ce69e2d20849d6c1cf543c0b37
BLAKE2b-256 ae7db2d65a05e0bbcdacf1a9b761a8e8f86b0650b03dcf5015b4ae3da92dbf75

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 50eab6b5ac86cf335fdf4d202d73e13c5947e3a1e8c2d8e1245f9d53d72e1223
MD5 29adad3331c2b28eb8715924b3a5de34
BLAKE2b-256 6d7d7bd324f1292a0684cc90ed64ffcb57c3f1fad408b140cdca485a6ef41a43

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 84fbcacebfa07840950413c7edb3e606cfa0dcd33aa12199b83b0617f38dc037
MD5 d4d3dc889aea46ed8a7ffa36f6d56822
BLAKE2b-256 fda82069083669420a5e98381e460e33f4fd3cfddafd7f48aa43db93ce71be64

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp39-cp39-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 22fc8b39e317187596c519cb9090806a8e3b3eecd49e77b94c3f62313932050f
MD5 da12f42d483acc54b4a9ba32698f85c4
BLAKE2b-256 624b2c1a2c66125c42c55248e8b10278fac7b2b15d21cae24616ce70b0d44401

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3dffeda6fabeb379dd47d43a6d645e84683caa2cb806ff6ee0121ce766e59d9
MD5 3fa37c4e270b94d2e58fb81852ae1763
BLAKE2b-256 01f8e65616820edbd51ed1f941596edd788d33a784a24aaf419ad66041aa4d0a

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 88ba9552896cfec087483eb1adc0614a6637f505d9020bdda150dc899e7647df
MD5 271611d443170499abc4fe62b981deee
BLAKE2b-256 f4e03f23555d04826cb54f3f5949704081982d1469c9ce7baaaf681eed67941c

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f6b5fbd29c8b3cdd37c10de6f9cc150333c5c0ea195d1140f38180725a067eff
MD5 6f056879f4a5d150bed8cc0f60e95f1d
BLAKE2b-256 069e52fbbb4789de6eb1e92ac939984f3bd20bfe07b65c1b3fdf60036def7d66

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 97de026c3b2b82e07d1259dd5b6300c1ce1c89ff0088fa7e56ea2a23148b271b
MD5 a28b56e807447d128573d505fba8b400
BLAKE2b-256 912bfa96290bf0948895d7ee91cee076955cf676e8766704889f11bbeb4483e2

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a82e1c71b02a3fc91dd6c20b3f4a0fa1e232021a9c83d915a3156a25815b8e4b
MD5 c047a540a26369d55291a2e0d87772a9
BLAKE2b-256 0bbda594e5c04f678cab2f89a3f7dde10a3b8a0c753ef137b6e2a693588050c5

See more details on using hashes here.

File details

Details for the file pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pike_smb2-0.4.6-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7a0477718555eea449ddaa1030234ce940081e1a9f66c9e9bd1bc8044944e359
MD5 6adca74412a4ea33bb1b469b9b87a117
BLAKE2b-256 d91fc365821e1440431859be53b1b2dddcac6aac29dbea6232676e33a8f1c3e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page