iptoolv4


Nameiptoolv4 JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/iptoolv4
SummaryFinds ipv4 addresses in log files / stdout
upload_time2023-09-11 22:08:38
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords ipv4
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Finds ipv4 addresses in log files / stdout 

## Tested against Windows 10 / Python 3.10 / Anaconda

### pip install iptoolv4

The module iptoolv4 is designed for working with IPv4 addresses and IP-related data in various scenarios, such as analyzing log files or subprocess outputs to identify and manipulate IPv4 addresses. Below are some key points regarding its purpose, potential users, and advantages:

Purpose:

### IP Address Handling: 

The module provides methods to load, save, and search for IPv4 addresses in text data, 
as well as to observe log files and subprocess output for IP-related information.

### Custom Formatting: 

It allows users to define custom formatting for found IPv4 addresses, 
providing flexibility in how IP addresses are displayed or processed.

### IP Address Filtering: 

Users can filter out specific IP addresses.

### Concurrent Processing: 

The module supports concurrent searching for IP addresses, 
which can be advantageous for handling large volumes of data efficiently.


## Advantages

### Customization: 

Users can define their own formatting and processing logic for 
found IPv4 addresses, making it adaptable to various use cases.

### Concurrent Processing: 

The module supports concurrent processing, 
enhancing efficiency when dealing with large datasets or real-time monitoring.

### Hide My IP: 

The option to hide specific IP addresses (e.g., localhost) 
can simplify analysis by filtering out irrelevant data.

### DataFrame Integration: 

The use of Pandas DataFrames for storing IP address ranges and search 
results makes it easy to work with and analyze data.

### Versatility: 

It can be used for a wide range of IP address-related tasks, 
including monitoring network activity, analyzing logs, and preprocessing data.



```python
import subprocess
from cprinter import TC
from iptoolv4 import IpV4Tool

chunks = 10000000
concurrent = True
self = IpV4Tool(
    hide_my_ip=True
)  # 127.0.0.1 and this PC's IP address will not be in the results
# IMPORTANT: aa_startip == start of ip range  /  aa_endip == end of ip range
# using a arbitrary free database from https://lite.ip2location.com/database/ip-country-region-city
# The format of the database takes a while (when using a csv), so be patient, but it has to be done only once
self.load_wanted_ips(r"C:\citylight400mb.pkl", start="aa_startip", end="aa_endip")
# After the database is ready, you can save the pandas DataFrame to a file and load it later:
self.save_wanted_ips(r"C:\citylight400mb.pkl")
# without color formating
df = self.search_for_ip_addresses(
    path_string_bytes=R"C:\newsfxaqq.txt",
    chunks=1000000,
    concurrent=True,
    substitute=False,
)
# an example for color formating
subsfu = (
    subsi
) = lambda j, i: f""" {TC('>>>').fg_green.bg_black.text} {TC(str(j['aa_city'].iloc[0])).fg_red.bg_black.text}: {i.decode('utf-8','replace')} {TC('>>>').fg_green.bg_black.text} """.encode(
    "utf-8", "replace"
)
df = self.search_for_ip_addresses(
    path_string_bytes=R"C:\newsfxaqq.txt",
    chunks=1000000,
    concurrent=True,
    substitute=subsfu,
)
print(df[-1].decode("utf-8"))

# an example for observing a log file generated by another process
newfile = r"c:\newlogfile.txt"
subprocess.Popen("netstat -b 5 > " + newfile + "", shell=True)
self.observe_log_file(
    newfile,
    min_len=5,
    columns=(
        "aa_country",
        "aa_city",
        "aa_destrict",
        "aa_lati",
        "aa_longi",
    ),
    print_df=False,
    omit_columns=False,
    chunks=chunks,
    concurrent=concurrent,
)

# an example for observing a subprocess (stdout)
self.observe_subprocess(
    cmdline="tracert -4 google.com",
    min_len=5,
    columns=(
        "aa_country",
        "aa_city",
        "aa_destrict",
        "aa_lati",
        "aa_longi",
    ),
    print_df=False,
    shell=True,
    omit_columns=False,
    chunks=chunks,
    concurrent=concurrent,
)

# an example for observing a subprocess (stdout)
self.observe_subprocess(
    cmdline="netstat -b 6",
    min_len=5,
    columns=(
        "aa_country",
        "aa_city",
        "aa_destrict",
        "aa_lati",
        "aa_longi",
    ),
    print_df=False,
    shell=True,
    omit_columns=False,
    chunks=chunks,
    concurrent=concurrent,
)

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/iptoolv4",
    "name": "iptoolv4",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ipv4",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/42/03/55d8bf59e91b514a3e0bb4ef34f5f1a09f5983a308e3c4daa37504683674/iptoolv4-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Finds ipv4 addresses in log files / stdout \r\n\r\n## Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n### pip install iptoolv4\r\n\r\nThe module iptoolv4 is designed for working with IPv4 addresses and IP-related data in various scenarios, such as analyzing log files or subprocess outputs to identify and manipulate IPv4 addresses. Below are some key points regarding its purpose, potential users, and advantages:\r\n\r\nPurpose:\r\n\r\n### IP Address Handling: \r\n\r\nThe module provides methods to load, save, and search for IPv4 addresses in text data, \r\nas well as to observe log files and subprocess output for IP-related information.\r\n\r\n### Custom Formatting: \r\n\r\nIt allows users to define custom formatting for found IPv4 addresses, \r\nproviding flexibility in how IP addresses are displayed or processed.\r\n\r\n### IP Address Filtering: \r\n\r\nUsers can filter out specific IP addresses.\r\n\r\n### Concurrent Processing: \r\n\r\nThe module supports concurrent searching for IP addresses, \r\nwhich can be advantageous for handling large volumes of data efficiently.\r\n\r\n\r\n## Advantages\r\n\r\n### Customization: \r\n\r\nUsers can define their own formatting and processing logic for \r\nfound IPv4 addresses, making it adaptable to various use cases.\r\n\r\n### Concurrent Processing: \r\n\r\nThe module supports concurrent processing, \r\nenhancing efficiency when dealing with large datasets or real-time monitoring.\r\n\r\n### Hide My IP: \r\n\r\nThe option to hide specific IP addresses (e.g., localhost) \r\ncan simplify analysis by filtering out irrelevant data.\r\n\r\n### DataFrame Integration: \r\n\r\nThe use of Pandas DataFrames for storing IP address ranges and search \r\nresults makes it easy to work with and analyze data.\r\n\r\n### Versatility: \r\n\r\nIt can be used for a wide range of IP address-related tasks, \r\nincluding monitoring network activity, analyzing logs, and preprocessing data.\r\n\r\n\r\n\r\n```python\r\nimport subprocess\r\nfrom cprinter import TC\r\nfrom iptoolv4 import IpV4Tool\r\n\r\nchunks = 10000000\r\nconcurrent = True\r\nself = IpV4Tool(\r\n    hide_my_ip=True\r\n)  # 127.0.0.1 and this PC's IP address will not be in the results\r\n# IMPORTANT: aa_startip == start of ip range  /  aa_endip == end of ip range\r\n# using a arbitrary free database from https://lite.ip2location.com/database/ip-country-region-city\r\n# The format of the database takes a while (when using a csv), so be patient, but it has to be done only once\r\nself.load_wanted_ips(r\"C:\\citylight400mb.pkl\", start=\"aa_startip\", end=\"aa_endip\")\r\n# After the database is ready, you can save the pandas DataFrame to a file and load it later:\r\nself.save_wanted_ips(r\"C:\\citylight400mb.pkl\")\r\n# without color formating\r\ndf = self.search_for_ip_addresses(\r\n    path_string_bytes=R\"C:\\newsfxaqq.txt\",\r\n    chunks=1000000,\r\n    concurrent=True,\r\n    substitute=False,\r\n)\r\n# an example for color formating\r\nsubsfu = (\r\n    subsi\r\n) = lambda j, i: f\"\"\" {TC('>>>').fg_green.bg_black.text} {TC(str(j['aa_city'].iloc[0])).fg_red.bg_black.text}: {i.decode('utf-8','replace')} {TC('>>>').fg_green.bg_black.text} \"\"\".encode(\r\n    \"utf-8\", \"replace\"\r\n)\r\ndf = self.search_for_ip_addresses(\r\n    path_string_bytes=R\"C:\\newsfxaqq.txt\",\r\n    chunks=1000000,\r\n    concurrent=True,\r\n    substitute=subsfu,\r\n)\r\nprint(df[-1].decode(\"utf-8\"))\r\n\r\n# an example for observing a log file generated by another process\r\nnewfile = r\"c:\\newlogfile.txt\"\r\nsubprocess.Popen(\"netstat -b 5 > \" + newfile + \"\", shell=True)\r\nself.observe_log_file(\r\n    newfile,\r\n    min_len=5,\r\n    columns=(\r\n        \"aa_country\",\r\n        \"aa_city\",\r\n        \"aa_destrict\",\r\n        \"aa_lati\",\r\n        \"aa_longi\",\r\n    ),\r\n    print_df=False,\r\n    omit_columns=False,\r\n    chunks=chunks,\r\n    concurrent=concurrent,\r\n)\r\n\r\n# an example for observing a subprocess (stdout)\r\nself.observe_subprocess(\r\n    cmdline=\"tracert -4 google.com\",\r\n    min_len=5,\r\n    columns=(\r\n        \"aa_country\",\r\n        \"aa_city\",\r\n        \"aa_destrict\",\r\n        \"aa_lati\",\r\n        \"aa_longi\",\r\n    ),\r\n    print_df=False,\r\n    shell=True,\r\n    omit_columns=False,\r\n    chunks=chunks,\r\n    concurrent=concurrent,\r\n)\r\n\r\n# an example for observing a subprocess (stdout)\r\nself.observe_subprocess(\r\n    cmdline=\"netstat -b 6\",\r\n    min_len=5,\r\n    columns=(\r\n        \"aa_country\",\r\n        \"aa_city\",\r\n        \"aa_destrict\",\r\n        \"aa_lati\",\r\n        \"aa_longi\",\r\n    ),\r\n    print_df=False,\r\n    shell=True,\r\n    omit_columns=False,\r\n    chunks=chunks,\r\n    concurrent=concurrent,\r\n)\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Finds ipv4 addresses in log files / stdout",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/iptoolv4"
    },
    "split_keywords": [
        "ipv4"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a55fb3555b8aaf4d516dd182790dbdcc93dd81505ec61ac0503b6b1e15883cc3",
                "md5": "a2fa9b8b33f28fc06042f7851904c753",
                "sha256": "9a4402decb3fb0a38b39a98cedf825d93b99e96cba347042ddd4762234c9200f"
            },
            "downloads": -1,
            "filename": "iptoolv4-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a2fa9b8b33f28fc06042f7851904c753",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 31917,
            "upload_time": "2023-09-11T22:08:36",
            "upload_time_iso_8601": "2023-09-11T22:08:36.239735Z",
            "url": "https://files.pythonhosted.org/packages/a5/5f/b3555b8aaf4d516dd182790dbdcc93dd81505ec61ac0503b6b1e15883cc3/iptoolv4-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "420355d8bf59e91b514a3e0bb4ef34f5f1a09f5983a308e3c4daa37504683674",
                "md5": "ff8e2133d0bd2477e3de0f6b9237fdac",
                "sha256": "4eb2854111499895e75472d590264966f21140fe0d30fb4e19666d171416a8f6"
            },
            "downloads": -1,
            "filename": "iptoolv4-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "ff8e2133d0bd2477e3de0f6b9237fdac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 31738,
            "upload_time": "2023-09-11T22:08:38",
            "upload_time_iso_8601": "2023-09-11T22:08:38.445301Z",
            "url": "https://files.pythonhosted.org/packages/42/03/55d8bf59e91b514a3e0bb4ef34f5f1a09f5983a308e3c4daa37504683674/iptoolv4-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 22:08:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "iptoolv4",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "iptoolv4"
}
        
Elapsed time: 0.13225s