{ "info": { "author": "Or Weis", "author_email": "py@bitweis.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Natural Language :: English", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking :: Monitoring" ], "description": "winpcapy\r\n========\r\n\r\n| A Modern Python wrapper for WinPcap\r\n| Access WinPcap through ctypes.\r\n\r\nBased on Massimo Ciani\u2019s WinPcapy (https://code.google.com/p/winpcapy/)\r\n\r\n\r\nInstall\r\n-------\r\npip install winpcapy\r\n\r\nUsage\r\n-----\r\n\r\nQuick packet live log printer\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n >>> from winpcapy import WinPcapUtils\r\n # run on the first Ethernert interface and print a log for each packet\r\n >>> WinPcapUtils.capture_on_and_print(\"*Ethernet*\")\r\n 16:05:49,624258 len:199\r\n 16:05:49,685950 len:60\r\n 16:05:49,686022 len:54\r\n 16:05:49,767311 len:66\r\n 16:05:49,819156 len:66\r\n 16:05:50,052113 len:92\r\n 16:05:50,128862 len:60\r\n\r\nEasy Packet live callback\r\n~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n from winpcapy import WinPcapUtils\r\n\r\n # Example Callback function to parse IP packets\r\n def packet_callback(win_pcap, param, header, pkt_data):\r\n # Assuming IP (for real parsing use modules like dpkt)\r\n ip_frame = pkt_data[14:]\r\n # Parse ips\r\n src_ip = \".\".join([str(ord(b)) for b in ip_frame[0xc:0x10]])\r\n dst_ip = \".\".join([str(ord(b)) for b in ip_frame[0x10:0x14]])\r\n print(\"%s -> %s\" % (src_ip, dst_ip))\r\n\r\n WinPcapUtils.capture_on(\"*Ethernet*\", packet_callback)\r\n\r\nDevice/Interface enumeration\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n >>> from winpcapy import WinPcapDevices\r\n # Return a list of all the devices detected on the machine\r\n >>> WinPcapDevices.list_devices()\r\n {'\\\\Device\\\\NPF_{0A78B7C8-F023-1337-1337-84D448AA5126}': 'Microsoft',\r\n '\\\\Device\\\\NPF_{2997B9BB-AA53-1337-1337-B862F874271C}': 'Microsoft',\r\n '\\\\Device\\\\NPF_{C2EAA982-F851-1337-1337-B8D2A9BCE406}': 'Intel(R) Ethernet Connection I218-LM',\r\n '\\\\Device\\\\NPF_{EAF47DBE-5B49-1337-1337-BD059E02666B}': 'Microsoft'}\r\n \r\n # Itearte over devices (in memory), with full details access\r\n >>> with WinPcapDevices() as devices:\r\n ... for device in devices:\r\n ... print device.name, device.description, device.flags ,device.addresses.contents.netmask.contents.sa_family\r\n ... \r\n \"\\Device\\NPF_{0A78B7C8-F023-1337-1337-84D448AA5126} Microsoft 0 0\"\r\n \"\\Device\\NPF_{C2EAA982-F851-1337-1337-B8D2A9BCE406} Intel(R) Ethernet Connection I218-LM 0 0\"\r\n \"\\Device\\NPF_{EAF47DBE-5B49-1337-1337-BD059E02666B} Microsoft 0 0\"\r\n \"\\Device\\NPF_{2997B9BB-AA53-1337-1337-B862F874271C} Microsoft 0 0\"\r\n\r\nEasy Packet sending\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code:: python\r\n\r\n from winpcapy import WinPcapUtils\r\n # Build a packet buffer\r\n # This example-code is built for tutorial purposes, for actual packet crafting use modules like dpkt\r\n arp_request_hex_template = \"%(dst_mac)s%(src_mac)s08060001080006040001\" \\\r\n \"%(sender_mac)s%(sender_ip)s%(target_mac)s%(target_ip)s\" + \"00\" * 18\r\n packet = arp_request_hex_template % {\r\n \"dst_mac\": \"aa\"*6,\r\n \"src_mac\": \"bb\"*6,\r\n \"sender_mac\": \"bb\"*6,\r\n \"target_mac\": \"cc\"*6,\r\n # 192.168.0.1\r\n \"sender_ip\": \"c0a80001\",\r\n # 192.168.0.2\r\n \"target_ip\": \"c0a80002\"\r\n }\r\n # Send the packet (ethernet frame with an arp request) on the interface\r\n WinPcapUtils.send_packet(\"*Ethernet*\", packet.decode(\"hex\"))", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/orweis/winpcapy", "keywords": "winpcapy", "license": "GPLv2", "maintainer": "", "maintainer_email": "", "name": "WinPcapy", "package_url": "https://pypi.org/project/WinPcapy/", "platform": "", "project_url": "https://pypi.org/project/WinPcapy/", "project_urls": { "Homepage": "https://github.com/orweis/winpcapy" }, "release_url": "https://pypi.org/project/WinPcapy/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "A Modern Python wrapper for WinPcap", "version": "1.0.2" }, "last_serial": 2598434, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9954e61418404652a570a2d7525fa4aa", "sha256": "654b4a2ba2f6494113c4ed28d9b9e0ad6e4ef80f1f479dd04e88c4990f5988c8" }, "downloads": -1, "filename": "winpcapy-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9954e61418404652a570a2d7525fa4aa", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 19571, "upload_time": "2016-12-30T17:30:32", "url": "https://files.pythonhosted.org/packages/8e/37/f6884fdbe25e88fa6ff9e8f319e5e254bee726e8739f7050f03322c34a9c/winpcapy-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7eed64d2240aae3be20041a853df6b2f", "sha256": "57b21753cf4f036fcdcd5ad8e55280f0e4f7e201d4c1d3b161b2204b1b83c1e1" }, "downloads": -1, "filename": "winpcapy-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7eed64d2240aae3be20041a853df6b2f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18487, "upload_time": "2016-12-30T17:30:29", "url": "https://files.pythonhosted.org/packages/85/68/85ae8f5f5f620cd8de81af1d0627fbc77218b00c079e5e54920bd4734587/winpcapy-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e230973e2745be84c0657a5ee21ea46a", "sha256": "096d6034aef78c14b3d03786414794876ca8baa8ca94125ce085b25eb7fcd753" }, "downloads": -1, "filename": "winpcapy-1.0.1.tar.gz", "has_sig": false, "md5_digest": "e230973e2745be84c0657a5ee21ea46a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18595, "upload_time": "2017-01-11T19:45:25", "url": "https://files.pythonhosted.org/packages/c3/87/1b0e79e68be209fa36fbdc25e9dd3835d893932a7228f8844adddb88e594/winpcapy-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "62f9dc1d9464349000d4eaf9b0403592", "sha256": "bab43bd59fccd3eb30cbab05b694a6a6171f5c2d7f3fc0746784b8e2f343cc17" }, "downloads": -1, "filename": "winpcapy-1.0.2.tar.gz", "has_sig": false, "md5_digest": "62f9dc1d9464349000d4eaf9b0403592", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19652, "upload_time": "2017-01-25T21:12:59", "url": "https://files.pythonhosted.org/packages/fb/c7/85e8dde35eb54b6b214b5e2182e63dabcc3b2747e2e4b1b6a84cd56f0baa/winpcapy-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "62f9dc1d9464349000d4eaf9b0403592", "sha256": "bab43bd59fccd3eb30cbab05b694a6a6171f5c2d7f3fc0746784b8e2f343cc17" }, "downloads": -1, "filename": "winpcapy-1.0.2.tar.gz", "has_sig": false, "md5_digest": "62f9dc1d9464349000d4eaf9b0403592", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19652, "upload_time": "2017-01-25T21:12:59", "url": "https://files.pythonhosted.org/packages/fb/c7/85e8dde35eb54b6b214b5e2182e63dabcc3b2747e2e4b1b6a84cd56f0baa/winpcapy-1.0.2.tar.gz" } ] }