{ "info": { "author": "Alexander Grechin", "author_email": "infinum@mail.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: Utilities" ], "description": "======\npcaper\n======\n\n.. image:: https://travis-ci.org/travis-ci/travis-web.svg?branch=master\n :target: https://travis-ci.org/travis-ci/travis-web\n\n.. image:: https://codecov.io/gh/gaainf/pcaper/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/gaainf/pcaper/\n\n.. image:: https://img.shields.io/badge/python-2.7-blue.svg\n :target: https://www.python.org/downloads/release/python-270/\n\n.. image:: https://img.shields.io/badge/python-3.5-blue.svg\n :target: https://www.python.org/downloads/release/python-350/\n\n.. image:: https://img.shields.io/badge/python-3.6-blue.svg\n :target: https://www.python.org/downloads/release/python-360/\n\n.. image:: https://img.shields.io/pypi/l/pcaper.svg\n :target: https://github.com/gaainf/pcaper/blob/master/LICENSE\n\nThe package helps to assemble and iterate HTTP requests.\nPcaper provides class to read traffic files in pcap or har formats,\nexecutable converters - `pcap2txt` and `har2txt`.\n`PcapParser` based on `dpkt `_. `HarParser` uses built-in json package.\n\n`pcaper` extends dpkt.http.Request class.\nFollowing fields of HTTP request are available:\n\n- `timestamp` - timestamp of the last packet of original HTTP request\n- `src` - source IP address\n- `dst` - destination IP address\n- `sport` - source TCP port\n- `dport` - destination TCP port\n- `method` - HTTP request method\n- `version` - HTTP protocol version\n- `uri` - HTTP request URI\n- `headers` - ordered dictionary of HTTP headers\n- `origin_headers` - ordered dictionary HTTP headers with case sensetive names\n- `body` - HTTP request body\n- `origin` - original HTTP request\n\n************\nInstallation\n************\n\n.. code:: python\n\n pip install pcaper\n\n******\nImport\n******\n\n.. code:: python\n\n import pcaper\n pcap_parser = pcaper.PcapParser()\n har_parser = pcaper.HarParser()\n\n********\nExamples\n********\n\nIterate HTTP requests\n*********************\n\nRead pcap file, assemble and iterate HTTP requests\n\n.. code:: python\n\n from pcaper import PcapParser\n\n pcap_parser = PcapParser()\n params = {\n 'input': 'file.pcap',\n }\n for request in pcap_parser.read_pcap(params):\n print(request.origin)\n\n.. code:: python\n\n from pcaper import HarParser\n\n har_parser = HarParser()\n params = {\n 'input': 'file.har'\n }\n for request in har_parser.read_har(params):\n print(request.origin)\n\nExtract separate HTTP request headers\n*************************************\n\nYou can extract header by name\n\n.. code:: python\n\n reader = pcaper.PcapParser()\n params = {\n 'input': 'file.pcap'\n }\n for request in reader.read_pcap(params):\n print(request.headers['host'])\n print(request.headers['user-agent'])\n\nFilter TCP/IP packets\n*********************\n\nIt is possible to filter out excess packets\n\n.. code:: python\n\n reader = pcaper.PcapParser()\n params = {\n 'input': 'file.pcap',\n 'filter': 'tcp.dst == 1.1.1.1'\n }\n for request in reader.read_pcap(params):\n print(request.origin)\n\n\nYou can combine tcp and ip filters in dpkt style\n\n.. code:: python\n\n reader = pcaper.PcapParser()\n params = {\n 'input': 'file.pcap',\n 'filter': '(ip.src == 10.4.0.136 or ip.dst == 10.1.40.61) and tcp.dport == 8888'\n }\n for request in reader.read_pcap(params):\n print(request.origin)\n\nIt is possible to use excluding filter in dpkt style\n\n.. code:: python\n\n reader = pcaper.PcapParser()\n params = {\n 'input': 'file.pcap',\n 'filter': 'tcp.dport != 8888 and ip.dst != 10.1.40.61'\n }\n for request in reader.read_pcap(params):\n print(request.origin)\n\nNote\n****\n\nNew `pcapng format `_ is not supported by `dpkt `_ package,\nbut you can convert input file from `pcapng` to `pcap` format\nwith standard utility, which is installed with `wireshark `_ package.\n\n.. code:: bash\n\n mergecap file.pcapng -w out.pcap -F pcap\n\n*******\nScripts\n*******\n\npcap2txt\n********\n\nThe `pcap2txt` script is installed to Python directory\nand can be executed directly in command line\n\nIt simplify parsing of pcap files. Just extract HTTP requests\nincluding its headers and body and print out complete data to console or file.\n\nPrint HTTP requests from pcap file:\n\n.. code:: bash\n\n pcap2txt file.pcap\n\nFilter TCP/IP packets, extract HTTP requests and write to external file:\n\n.. code:: bash\n\n pcap2txt -f \"tcp.dport == 8080 and ip.dst != 10.10.10.10\" -o file.out file.pcap\n\nFilter HTTP packets\n\n.. code:: bash\n\n pcap2txt -F '\"rambler.ru\" in http.uri' file.pcap\n\nYou can use logical expressions in filters\n\n.. code:: bash\n\n pcap2txt -F '\"keep-alive\" in http.headers[\"connection\"] or \"Keep-alive\" in http.headers[\"connection\"]' file.pcap\n\nStandard Python string functions over HTTP request headers\n\n.. code:: bash\n\n pcap2txt -F '\"keep-alive\" in http.headers[\"connection\"].lower()' file.pcap\n\nUse excluding filters also\n\n.. code:: bash\n\n pcap2ammo -F '\"rambler.ru\" not in http.uri' file.pcap\n\nPrint statistics about counted requests:\n\n.. code:: bash\n\n pcap2txt -f \"ip.src == 10.10.10.10\" -S file.pcap\n\n Stats:\n total: 1\n complete: 1\n incorrect: 0\n incomplete: 0\n\nhar2txt\n*******\n\nThe `har2txt` script is installed to Python directory\nand can be executed directly in command line\n\nIt simplify parsing of har files. Just extract HTTP requests\nincluding its headers and body and print out complete data to console or file.\n\nPrint HTTP requests from har file:\n\n.. code:: bash\n\n har2txt file.har\n\nFilter HTTP packets\n\n.. code:: bash\n\n har2txt -F 'http.verision == \"1.1\"' file.har\n\nUse excluding filters also\n\n.. code:: bash\n\n har2txt -F '\"rambler.ru\" not in http.uri' file.har\n\nFilter packets with destination IP.\n`pcaper` extracts data from har file, which contains destination IP\n(`dst` filed), but doesn't contain source IP, source and destination ports.\n\n.. code:: bash\n\n har2txt -F 'http.dst == \"1.1.1.1\"' file.har\n\nPrint statistics about counted requests:\n\n.. code:: bash\n\n har2txt -S -F 'http.dst == \"10.10.10.10' file.har\n\n Stats:\n total: 1\n complete: 1\n incorrect: 0\n incomplete: 0\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/gaainf/pcaper", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gaainf/pcaper", "keywords": "traffic pcap utilities tcpdump tshark wireshark", "license": "BSD-3-Clause", "maintainer": "", "maintainer_email": "", "name": "pcaper", "package_url": "https://pypi.org/project/pcaper/", "platform": "", "project_url": "https://pypi.org/project/pcaper/", "project_urls": { "Download": "https://github.com/gaainf/pcaper", "Homepage": "https://github.com/gaainf/pcaper" }, "release_url": "https://pypi.org/project/pcaper/1.0.8/", "requires_dist": [ "dpkt (>=1.9.1)", "flake8 (>=3.5.0)", "six (>=1.11.0)", "python-dateutil (>=2.8.0)" ], "requires_python": "", "summary": "Read pcap and assemble HTTP requests", "version": "1.0.8" }, "last_serial": 4933937, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "befaf1d95116c1a9be6b8e1b653a520a", "sha256": "98bbe245705cd6fd6ff0998a58e7dfa73227e4c5eae191f36aa22fa50f9189a6" }, "downloads": -1, "filename": "pcaper-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "befaf1d95116c1a9be6b8e1b653a520a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4740, "upload_time": "2018-11-03T23:34:47", "url": "https://files.pythonhosted.org/packages/df/a8/f051197b2ada5fa2b29fbedbad14be5de3513163e23b884f4466022339ed/pcaper-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c9ea64d5885836a3718dfae479d2a7b3", "sha256": "6bd63ee8e5c489f6c52ab1894975b953a81fcbbf6d0539ef94ce65b6b64bbb02" }, "downloads": -1, "filename": "pcaper-1.0.0.tar.gz", "has_sig": false, "md5_digest": "c9ea64d5885836a3718dfae479d2a7b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4623, "upload_time": "2018-11-03T23:34:48", "url": "https://files.pythonhosted.org/packages/0b/c8/f6d64e3bf0df4d62ddc192705ae7508614d8831754a0de657722cd8446a0/pcaper-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "0f3f77948328c2d03e4e93275636fbd5", "sha256": "d709033596cd02f40de21546421651bbd9fa0001760101a315c32e028726146c" }, "downloads": -1, "filename": "pcaper-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0f3f77948328c2d03e4e93275636fbd5", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7155, "upload_time": "2018-11-06T01:33:29", "url": "https://files.pythonhosted.org/packages/25/16/e34ff878546a305576ed887148aa9dc6988df04ccf62f3e381e31bb9b7eb/pcaper-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6fa0237be925a1ace4f2c33efce64f1d", "sha256": "c67b647ef9f68276e4cca05054a1f47c9ef6f8299fe68c4797e61b8e016a10c9" }, "downloads": -1, "filename": "pcaper-1.0.1.tar.gz", "has_sig": false, "md5_digest": "6fa0237be925a1ace4f2c33efce64f1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6280, "upload_time": "2018-11-06T01:33:30", "url": "https://files.pythonhosted.org/packages/c2/73/110ae362e303f50216a0e4bac51be97fab90b3ec26a60e459504c82eed6c/pcaper-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "3318a1959e932a4e1fd03b92b7ef2b70", "sha256": "a0192f21ec500bedeb2dba2f0caf4c7fe4df046c6f32853a59ff7d762e154972" }, "downloads": -1, "filename": "pcaper-1.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3318a1959e932a4e1fd03b92b7ef2b70", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7184, "upload_time": "2018-11-13T21:19:42", "url": "https://files.pythonhosted.org/packages/14/36/fd8f2023eba9d07127205530ffcfdfa835996d0382982cabe89e95ac825d/pcaper-1.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8c8e3f5d6ac13a0e9f15c7d61a615b6d", "sha256": "9b79d55d121fbfdfdf46326ae58e26889ab90bcccf039efd4a6d80a64fb4fa7a" }, "downloads": -1, "filename": "pcaper-1.0.2.tar.gz", "has_sig": false, "md5_digest": "8c8e3f5d6ac13a0e9f15c7d61a615b6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6314, "upload_time": "2018-11-13T21:19:44", "url": "https://files.pythonhosted.org/packages/34/08/1fb0df78c98e32d2cc9a4db022084f745c2f9d40a318c77f6f62581c5833/pcaper-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "c2917babb096801da6ac0b20dcb094e0", "sha256": "7971f93bd30bbe0644a649f50ac2504cd7e6f1eb9e42475f5abba27f55f306c8" }, "downloads": -1, "filename": "pcaper-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c2917babb096801da6ac0b20dcb094e0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7211, "upload_time": "2018-11-14T15:03:43", "url": "https://files.pythonhosted.org/packages/c0/1d/bd9352a6dbceb355d670fd8f9115f503e8dff73e1ef9e2205f38a90aa5e6/pcaper-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9af9dc4017723b2b846d2d2a45072ede", "sha256": "ea1cf27e7f1728da7f360655d0449204abc80dc641b40f85c4cfd1f5675ac100" }, "downloads": -1, "filename": "pcaper-1.0.3.tar.gz", "has_sig": false, "md5_digest": "9af9dc4017723b2b846d2d2a45072ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6339, "upload_time": "2018-11-14T15:03:45", "url": "https://files.pythonhosted.org/packages/06/9b/49931215c2ac398912dd33ebe52af304ca5af4d0f8659cfb905c0008fbff/pcaper-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "5334521d8ba82aa392b69712b1a8159e", "sha256": "99106b9c2743958fb52c7d77c0f06c33d5f85b9bd4ba28df295d202768943042" }, "downloads": -1, "filename": "pcaper-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5334521d8ba82aa392b69712b1a8159e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7310, "upload_time": "2018-12-25T21:56:23", "url": "https://files.pythonhosted.org/packages/a9/3c/264c8cd2783f795731d0364368cf4bde57b2fa6b0cff37e2b624e448d78d/pcaper-1.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7111292f6a8fe3a944793eb02368e5ca", "sha256": "f85c7b0da1f0ac2c39eb70785e57d56e04a4e95cc4b8c83d5c21a82fe81f635e" }, "downloads": -1, "filename": "pcaper-1.0.4.tar.gz", "has_sig": false, "md5_digest": "7111292f6a8fe3a944793eb02368e5ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6428, "upload_time": "2018-12-25T21:56:24", "url": "https://files.pythonhosted.org/packages/e1/3f/65d97881c660d8592e7c2459c4be84ad743f099c31cada98fdf08f236f97/pcaper-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "fd06ff5e8f1707d3f4f1f27b95575714", "sha256": "c9e4e09d8541ca9d4a8a611cfc735acf0e776ab24b335b7605afd670091f08c0" }, "downloads": -1, "filename": "pcaper-1.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fd06ff5e8f1707d3f4f1f27b95575714", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7836, "upload_time": "2019-01-13T16:28:59", "url": "https://files.pythonhosted.org/packages/d0/b8/77e9599b8c2749cb56257c5557448427422056c5d25bff8e1342e3c14d25/pcaper-1.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3d4ab84a4add209d697ab9dbd2c49e0e", "sha256": "fb8aaced28dc0f38933482ecd57b2ddb5445c133429df2db0d18b749e582b8f1" }, "downloads": -1, "filename": "pcaper-1.0.5.tar.gz", "has_sig": false, "md5_digest": "3d4ab84a4add209d697ab9dbd2c49e0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7757, "upload_time": "2019-01-13T16:29:00", "url": "https://files.pythonhosted.org/packages/54/b8/c69a860eb0fae3ea6a34256cf7caa1e1ed003dabc76386384e77bcb58831/pcaper-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "e79cbe09d76e8d5b9071132e750c5252", "sha256": "44d0845aac50106114e7d8ab2d7dcf491c41a4eb1162722a49e562ede4e0a66f" }, "downloads": -1, "filename": "pcaper-1.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e79cbe09d76e8d5b9071132e750c5252", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7834, "upload_time": "2019-01-13T16:40:04", "url": "https://files.pythonhosted.org/packages/42/34/a3f6374d99a276acdb9c56d01102e1b8da79ae6b529431f623def1519dae/pcaper-1.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ac1869e4ca3a59a7ad37c47570112bf3", "sha256": "16d3ce11cb0b7af76767d7b86a0fbc2d9fb7f4b0716bc03af3c5fb03c78d6f67" }, "downloads": -1, "filename": "pcaper-1.0.6.tar.gz", "has_sig": false, "md5_digest": "ac1869e4ca3a59a7ad37c47570112bf3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7752, "upload_time": "2019-01-13T16:40:05", "url": "https://files.pythonhosted.org/packages/a2/ad/bdd6126e51f512d6e3c46985ae446c37f69f3f51d479224f9f97375cffee/pcaper-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "1aff904df8ac3f976a6fcba36ecc7928", "sha256": "597f611b6ce0e7abd6df63f9e807d8c3da3ba2877241aa3f2b022470b6d6fa59" }, "downloads": -1, "filename": "pcaper-1.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1aff904df8ac3f976a6fcba36ecc7928", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16182, "upload_time": "2019-03-13T03:39:34", "url": "https://files.pythonhosted.org/packages/f0/c2/89d6f6f484584f862e9a6c299709163b73c1a21a2e6468b9f7949fd4ad9d/pcaper-1.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e6d851f4feab99d3d65472c28a27dc62", "sha256": "c088417db565023f70b99536a024e688a35355b527bf66cb5c45c5a478b0e104" }, "downloads": -1, "filename": "pcaper-1.0.7.tar.gz", "has_sig": false, "md5_digest": "e6d851f4feab99d3d65472c28a27dc62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13399, "upload_time": "2019-03-13T03:39:36", "url": "https://files.pythonhosted.org/packages/51/c7/9f5ab9ec946b92bac45cda3575670b95df4c7a221932c861226ab7d46e91/pcaper-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "20e08aba26a3852424ddb1ded766bcb0", "sha256": "dab5ee439f7832c9cc076b71d92ccce9ad2b382de71421f69c7955c91ab7f09f" }, "downloads": -1, "filename": "pcaper-1.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "20e08aba26a3852424ddb1ded766bcb0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16017, "upload_time": "2019-03-13T10:16:08", "url": "https://files.pythonhosted.org/packages/ed/46/2cdb0ac0a9eed2d143f6250d7d248804e7ea22b0f41acf7a6ca1b46ebcdf/pcaper-1.0.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cdf4de70751a7bd673f518ad045e9556", "sha256": "7274b357ade10def877458baa146a45d8d6abf65e1700fce3052a1ad28f415cc" }, "downloads": -1, "filename": "pcaper-1.0.8.tar.gz", "has_sig": false, "md5_digest": "cdf4de70751a7bd673f518ad045e9556", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13258, "upload_time": "2019-03-13T10:16:10", "url": "https://files.pythonhosted.org/packages/6f/22/7be1a1d170f2dd025d2631b11a0f9ed81abd8375a3238111098897c53c1a/pcaper-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "20e08aba26a3852424ddb1ded766bcb0", "sha256": "dab5ee439f7832c9cc076b71d92ccce9ad2b382de71421f69c7955c91ab7f09f" }, "downloads": -1, "filename": "pcaper-1.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "20e08aba26a3852424ddb1ded766bcb0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16017, "upload_time": "2019-03-13T10:16:08", "url": "https://files.pythonhosted.org/packages/ed/46/2cdb0ac0a9eed2d143f6250d7d248804e7ea22b0f41acf7a6ca1b46ebcdf/pcaper-1.0.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cdf4de70751a7bd673f518ad045e9556", "sha256": "7274b357ade10def877458baa146a45d8d6abf65e1700fce3052a1ad28f415cc" }, "downloads": -1, "filename": "pcaper-1.0.8.tar.gz", "has_sig": false, "md5_digest": "cdf4de70751a7bd673f518ad045e9556", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13258, "upload_time": "2019-03-13T10:16:10", "url": "https://files.pythonhosted.org/packages/6f/22/7be1a1d170f2dd025d2631b11a0f9ed81abd8375a3238111098897c53c1a/pcaper-1.0.8.tar.gz" } ] }