iplens 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iplens-0.1.0/PKG-INFO +197 -0
- iplens-0.1.0/README.md +176 -0
- iplens-0.1.0/iplens.egg-info/PKG-INFO +197 -0
- iplens-0.1.0/iplens.egg-info/SOURCES.txt +22 -0
- iplens-0.1.0/iplens.egg-info/dependency_links.txt +1 -0
- iplens-0.1.0/iplens.egg-info/entry_points.txt +2 -0
- iplens-0.1.0/iplens.egg-info/requires.txt +2 -0
- iplens-0.1.0/iplens.egg-info/top_level.txt +2 -0
- iplens-0.1.0/iplens_cli.py +135 -0
- iplens-0.1.0/setup.cfg +4 -0
- iplens-0.1.0/setup.py +38 -0
- iplens-0.1.0/src/__init__.py +0 -0
- iplens-0.1.0/src/base_operations.py +64 -0
- iplens-0.1.0/src/config_loader.py +33 -0
- iplens-0.1.0/src/db_cache.py +124 -0
- iplens-0.1.0/src/input_processor.py +64 -0
- iplens-0.1.0/src/ipapi_api.py +192 -0
- iplens-0.1.0/src/logger.py +22 -0
- iplens-0.1.0/src/output.py +35 -0
- iplens-0.1.0/src/table_formatter.py +98 -0
- iplens-0.1.0/src/utils.py +113 -0
- iplens-0.1.0/tests/test_api.py +169 -0
- iplens-0.1.0/tests/test_data_processing.py +68 -0
- iplens-0.1.0/tests/test_output.py +90 -0
iplens-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iplens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight, modern, robust IP info CLI tool
|
|
5
|
+
Home-page: https://github.com/aiomorphic/iplens
|
|
6
|
+
Author: aiomorhpic
|
|
7
|
+
Author-email: iplens@proton.me
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Requires-Python: >=3.7
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: requests<3.0.0,>=2.25.1
|
|
20
|
+
Requires-Dist: rich<11.0.0,>=10.0.0
|
|
21
|
+
|
|
22
|
+
# IP Lens CLI Tool
|
|
23
|
+
|
|
24
|
+
A lightweight CLI tool designed for fetching and displaying detailed IP address information. **No API keys are required**, making it accessible and easy to use for various use cases.
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
33
|
+
cd iplens
|
|
34
|
+
pip install -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### CLI Tool
|
|
40
|
+
|
|
41
|
+
Basic usage:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
iplens 8.8.8.8 1.1.1.1
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Using an input file:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
iplens --input-file ips.txt
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The input **file** can be in one of the following formats:
|
|
54
|
+
|
|
55
|
+
- Plain text file with one IP address per line
|
|
56
|
+
- Text file containing a Python list of IP addresses
|
|
57
|
+
- JSON file with a list of IP addresses or a dictionary containing a list of IP addresses in any field
|
|
58
|
+
- CSV file with a column containing IP addresses (the column name should include "ip", case-insensitive)
|
|
59
|
+
- Log file containing IP addresses (the tool will extract unique IP addresses from the log)
|
|
60
|
+
|
|
61
|
+
Using an Input **Folder** to Parse Files for IP Addresses:
|
|
62
|
+
|
|
63
|
+
You can also specify a directory, and the tool will parse all non-binary files within that folder to extract IP addresses:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
iplens --input-folder /path/to/logs/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Use Cases:
|
|
70
|
+
|
|
71
|
+
Scan system logs: For example, to scan the UFW log for IP addresses, you can run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
iplens --input-folder /var/log/ufw.log
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
or for e.g. analyze web server logs: Parse your web server logs to gather and analyze IP addresses.
|
|
78
|
+
|
|
79
|
+
Save output to a file:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
iplens 8.8.8.8 1.1.1.1 --output results --format json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Available options:
|
|
86
|
+
|
|
87
|
+
- `--input-file` or `-i`: Specify an input file containing IP addresses
|
|
88
|
+
- `--input-folder` or `-d`: Specify an input folder containing files to parse for IP addresses
|
|
89
|
+
- `--output` or `-o`: Specify output file (without extension)
|
|
90
|
+
- `--format` or `-f`: Specify output format (csv or json)
|
|
91
|
+
|
|
92
|
+
Note: The tool will automatically detect the input file format and extract valid IP addresses. Invalid IP addresses will be ignored.
|
|
93
|
+
|
|
94
|
+
#### Exports Examples
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
[
|
|
98
|
+
{
|
|
99
|
+
"ip": "8.8.8.8",
|
|
100
|
+
"rir": "ARIN",
|
|
101
|
+
"is_bogon": "False",
|
|
102
|
+
"is_datacenter": "True",
|
|
103
|
+
"is_tor": "False",
|
|
104
|
+
"is_proxy": "False",
|
|
105
|
+
"is_vpn": "True",
|
|
106
|
+
"is_abuser": "True",
|
|
107
|
+
"company_name": "Google LLC",
|
|
108
|
+
"company_abuser_score": "0.0039 (Low)",
|
|
109
|
+
"company_type": "business",
|
|
110
|
+
"company_domain": "google.com",
|
|
111
|
+
"company_network": "8.8.8.0 - 8.8.8.255",
|
|
112
|
+
"company_whois": "https://api.incolumitas.com/?whois=8.8.8.0",
|
|
113
|
+
"abuse_email": "network-abuse@google.com",
|
|
114
|
+
"asn_asn": "AS15169",
|
|
115
|
+
"asn_abuser_score": "0 (Very Low)",
|
|
116
|
+
"asn_route": "8.8.8.0/24",
|
|
117
|
+
"asn_descr": "GOOGLE, US",
|
|
118
|
+
"asn_country": "us",
|
|
119
|
+
"asn_active": "True",
|
|
120
|
+
"asn_org": "Google LLC",
|
|
121
|
+
"asn_domain": "google.com",
|
|
122
|
+
"asn_abuse": "network-abuse@google.com",
|
|
123
|
+
"asn_type": "business",
|
|
124
|
+
"asn_created": "2000-03-30",
|
|
125
|
+
"asn_updated": "2012-02-24",
|
|
126
|
+
"asn_rir": "ARIN",
|
|
127
|
+
"asn_whois": "https://api.incolumitas.com/?whois=AS15169",
|
|
128
|
+
"location_country": "United States",
|
|
129
|
+
"location_country_code": "US",
|
|
130
|
+
"location_state": "California",
|
|
131
|
+
"location_city": "Sunnyvale",
|
|
132
|
+
"location_latitude": "37.36883",
|
|
133
|
+
"location_longitude": "-122.03635",
|
|
134
|
+
"location_zip": "95196",
|
|
135
|
+
"location_timezone": "America/Los_Angeles"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```csv
|
|
141
|
+
ip,rir,is_bogon,is_datacenter,is_tor,is_proxy,is_vpn,is_abuser,company_name,company_abuser_score,company_type,company_domain,company_network,company_whois,abuse_email,asn_asn,asn_abuser_score,asn_route,asn_descr,asn_country,asn_active,asn_org,asn_domain,asn_abuse,asn_type,asn_created,asn_updated,asn_rir,asn_whois,location_country,location_country_code,location_state,location_city,location_latitude,location_longitude,location_zip,location_timezone
|
|
142
|
+
8.8.8.8,ARIN,False,True,False,False,True,True,Google LLC,0.0039 (Low),business,google.com,8.8.8.0 - 8.8.8.255,https://api.incolumitas.com/?whois=8.8.8.0,network-abuse@google.com,AS15169,0 (Very Low),8.8.8.0/24,"GOOGLE, US",us,True,Google LLC,google.com,network-abuse@google.com,business,2000-03-30,2012-02-24,ARIN,https://api.incolumitas.com/?whois=AS15169,United States,US,California,Sunnyvale,37.36883,-122.03635,95196,America/Los_Angeles
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### As a Python Library
|
|
147
|
+
|
|
148
|
+
IP Lens can also be utilized as a Python library for direct integration into your Python projects.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from iplens.api import IPInfoAPI
|
|
152
|
+
|
|
153
|
+
api = IPInfoAPI()
|
|
154
|
+
results = api.process(['8.8.8.8', '1.1.1.1'])
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This will fetch and process the IP information for the given IP addresses. The results will include detailed information such as ASN, location, company details, and more, extracted and formatted for easy access
|
|
158
|
+
|
|
159
|
+
### Configuration
|
|
160
|
+
|
|
161
|
+
The API URL, logging level, and other constants can be configured in the config.cfg file. You can modify the configuration file to suit your specific requirements. The available fields and their purposes are defined in the src/config_loader.py.
|
|
162
|
+
API Limits
|
|
163
|
+
|
|
164
|
+
Note that the API has rate limits in its free, unregistered mode. If you encounter a rate limit, simply wait for 20 minutes and then continue using the tool.
|
|
165
|
+
Caching
|
|
166
|
+
|
|
167
|
+
IP Lens includes a caching mechanism to store fetched IP information locally. This helps reduce the number of API calls, especially when processing large lists of IPs. The cache is automatically cleared after a configurable expiration period, which can be set in the config.cfg file.
|
|
168
|
+
Ignoring Fields
|
|
169
|
+
|
|
170
|
+
If there are specific fields you wish to exclude from the output, you can configure this in the src/utils.py file, where the list of field names is defined. This allows you to customize the output based on your needs.
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
### Setup
|
|
175
|
+
|
|
176
|
+
1. Clone the repository
|
|
177
|
+
```bash
|
|
178
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
179
|
+
cd iplens
|
|
180
|
+
```
|
|
181
|
+
2. Create a virtual environment: `python -m venv venv`
|
|
182
|
+
3. Activate the virtual environment:
|
|
183
|
+
- Windows: `venv\Scripts\activate`
|
|
184
|
+
- Unix or MacOS: `source venv/bin/activate`
|
|
185
|
+
4. Install development dependencies: `pip install -r requirements.txt`
|
|
186
|
+
|
|
187
|
+
### Pre commit checks
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
make pre-commit
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Adding New Features
|
|
194
|
+
|
|
195
|
+
Implement new functionality in the appropriate module under iplens/.
|
|
196
|
+
Add tests for the new functionality in tests/.
|
|
197
|
+
Update iplens_cli.py if the new feature should be accessible via CLI.
|
iplens-0.1.0/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# IP Lens CLI Tool
|
|
2
|
+
|
|
3
|
+
A lightweight CLI tool designed for fetching and displaying detailed IP address information. **No API keys are required**, making it accessible and easy to use for various use cases.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
12
|
+
cd iplens
|
|
13
|
+
pip install -e .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### CLI Tool
|
|
19
|
+
|
|
20
|
+
Basic usage:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
iplens 8.8.8.8 1.1.1.1
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Using an input file:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
iplens --input-file ips.txt
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The input **file** can be in one of the following formats:
|
|
33
|
+
|
|
34
|
+
- Plain text file with one IP address per line
|
|
35
|
+
- Text file containing a Python list of IP addresses
|
|
36
|
+
- JSON file with a list of IP addresses or a dictionary containing a list of IP addresses in any field
|
|
37
|
+
- CSV file with a column containing IP addresses (the column name should include "ip", case-insensitive)
|
|
38
|
+
- Log file containing IP addresses (the tool will extract unique IP addresses from the log)
|
|
39
|
+
|
|
40
|
+
Using an Input **Folder** to Parse Files for IP Addresses:
|
|
41
|
+
|
|
42
|
+
You can also specify a directory, and the tool will parse all non-binary files within that folder to extract IP addresses:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
iplens --input-folder /path/to/logs/
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use Cases:
|
|
49
|
+
|
|
50
|
+
Scan system logs: For example, to scan the UFW log for IP addresses, you can run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
iplens --input-folder /var/log/ufw.log
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
or for e.g. analyze web server logs: Parse your web server logs to gather and analyze IP addresses.
|
|
57
|
+
|
|
58
|
+
Save output to a file:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
iplens 8.8.8.8 1.1.1.1 --output results --format json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Available options:
|
|
65
|
+
|
|
66
|
+
- `--input-file` or `-i`: Specify an input file containing IP addresses
|
|
67
|
+
- `--input-folder` or `-d`: Specify an input folder containing files to parse for IP addresses
|
|
68
|
+
- `--output` or `-o`: Specify output file (without extension)
|
|
69
|
+
- `--format` or `-f`: Specify output format (csv or json)
|
|
70
|
+
|
|
71
|
+
Note: The tool will automatically detect the input file format and extract valid IP addresses. Invalid IP addresses will be ignored.
|
|
72
|
+
|
|
73
|
+
#### Exports Examples
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
[
|
|
77
|
+
{
|
|
78
|
+
"ip": "8.8.8.8",
|
|
79
|
+
"rir": "ARIN",
|
|
80
|
+
"is_bogon": "False",
|
|
81
|
+
"is_datacenter": "True",
|
|
82
|
+
"is_tor": "False",
|
|
83
|
+
"is_proxy": "False",
|
|
84
|
+
"is_vpn": "True",
|
|
85
|
+
"is_abuser": "True",
|
|
86
|
+
"company_name": "Google LLC",
|
|
87
|
+
"company_abuser_score": "0.0039 (Low)",
|
|
88
|
+
"company_type": "business",
|
|
89
|
+
"company_domain": "google.com",
|
|
90
|
+
"company_network": "8.8.8.0 - 8.8.8.255",
|
|
91
|
+
"company_whois": "https://api.incolumitas.com/?whois=8.8.8.0",
|
|
92
|
+
"abuse_email": "network-abuse@google.com",
|
|
93
|
+
"asn_asn": "AS15169",
|
|
94
|
+
"asn_abuser_score": "0 (Very Low)",
|
|
95
|
+
"asn_route": "8.8.8.0/24",
|
|
96
|
+
"asn_descr": "GOOGLE, US",
|
|
97
|
+
"asn_country": "us",
|
|
98
|
+
"asn_active": "True",
|
|
99
|
+
"asn_org": "Google LLC",
|
|
100
|
+
"asn_domain": "google.com",
|
|
101
|
+
"asn_abuse": "network-abuse@google.com",
|
|
102
|
+
"asn_type": "business",
|
|
103
|
+
"asn_created": "2000-03-30",
|
|
104
|
+
"asn_updated": "2012-02-24",
|
|
105
|
+
"asn_rir": "ARIN",
|
|
106
|
+
"asn_whois": "https://api.incolumitas.com/?whois=AS15169",
|
|
107
|
+
"location_country": "United States",
|
|
108
|
+
"location_country_code": "US",
|
|
109
|
+
"location_state": "California",
|
|
110
|
+
"location_city": "Sunnyvale",
|
|
111
|
+
"location_latitude": "37.36883",
|
|
112
|
+
"location_longitude": "-122.03635",
|
|
113
|
+
"location_zip": "95196",
|
|
114
|
+
"location_timezone": "America/Los_Angeles"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```csv
|
|
120
|
+
ip,rir,is_bogon,is_datacenter,is_tor,is_proxy,is_vpn,is_abuser,company_name,company_abuser_score,company_type,company_domain,company_network,company_whois,abuse_email,asn_asn,asn_abuser_score,asn_route,asn_descr,asn_country,asn_active,asn_org,asn_domain,asn_abuse,asn_type,asn_created,asn_updated,asn_rir,asn_whois,location_country,location_country_code,location_state,location_city,location_latitude,location_longitude,location_zip,location_timezone
|
|
121
|
+
8.8.8.8,ARIN,False,True,False,False,True,True,Google LLC,0.0039 (Low),business,google.com,8.8.8.0 - 8.8.8.255,https://api.incolumitas.com/?whois=8.8.8.0,network-abuse@google.com,AS15169,0 (Very Low),8.8.8.0/24,"GOOGLE, US",us,True,Google LLC,google.com,network-abuse@google.com,business,2000-03-30,2012-02-24,ARIN,https://api.incolumitas.com/?whois=AS15169,United States,US,California,Sunnyvale,37.36883,-122.03635,95196,America/Los_Angeles
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### As a Python Library
|
|
126
|
+
|
|
127
|
+
IP Lens can also be utilized as a Python library for direct integration into your Python projects.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from iplens.api import IPInfoAPI
|
|
131
|
+
|
|
132
|
+
api = IPInfoAPI()
|
|
133
|
+
results = api.process(['8.8.8.8', '1.1.1.1'])
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This will fetch and process the IP information for the given IP addresses. The results will include detailed information such as ASN, location, company details, and more, extracted and formatted for easy access
|
|
137
|
+
|
|
138
|
+
### Configuration
|
|
139
|
+
|
|
140
|
+
The API URL, logging level, and other constants can be configured in the config.cfg file. You can modify the configuration file to suit your specific requirements. The available fields and their purposes are defined in the src/config_loader.py.
|
|
141
|
+
API Limits
|
|
142
|
+
|
|
143
|
+
Note that the API has rate limits in its free, unregistered mode. If you encounter a rate limit, simply wait for 20 minutes and then continue using the tool.
|
|
144
|
+
Caching
|
|
145
|
+
|
|
146
|
+
IP Lens includes a caching mechanism to store fetched IP information locally. This helps reduce the number of API calls, especially when processing large lists of IPs. The cache is automatically cleared after a configurable expiration period, which can be set in the config.cfg file.
|
|
147
|
+
Ignoring Fields
|
|
148
|
+
|
|
149
|
+
If there are specific fields you wish to exclude from the output, you can configure this in the src/utils.py file, where the list of field names is defined. This allows you to customize the output based on your needs.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
### Setup
|
|
154
|
+
|
|
155
|
+
1. Clone the repository
|
|
156
|
+
```bash
|
|
157
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
158
|
+
cd iplens
|
|
159
|
+
```
|
|
160
|
+
2. Create a virtual environment: `python -m venv venv`
|
|
161
|
+
3. Activate the virtual environment:
|
|
162
|
+
- Windows: `venv\Scripts\activate`
|
|
163
|
+
- Unix or MacOS: `source venv/bin/activate`
|
|
164
|
+
4. Install development dependencies: `pip install -r requirements.txt`
|
|
165
|
+
|
|
166
|
+
### Pre commit checks
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
make pre-commit
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Adding New Features
|
|
173
|
+
|
|
174
|
+
Implement new functionality in the appropriate module under iplens/.
|
|
175
|
+
Add tests for the new functionality in tests/.
|
|
176
|
+
Update iplens_cli.py if the new feature should be accessible via CLI.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iplens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight, modern, robust IP info CLI tool
|
|
5
|
+
Home-page: https://github.com/aiomorphic/iplens
|
|
6
|
+
Author: aiomorhpic
|
|
7
|
+
Author-email: iplens@proton.me
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Requires-Python: >=3.7
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: requests<3.0.0,>=2.25.1
|
|
20
|
+
Requires-Dist: rich<11.0.0,>=10.0.0
|
|
21
|
+
|
|
22
|
+
# IP Lens CLI Tool
|
|
23
|
+
|
|
24
|
+
A lightweight CLI tool designed for fetching and displaying detailed IP address information. **No API keys are required**, making it accessible and easy to use for various use cases.
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
33
|
+
cd iplens
|
|
34
|
+
pip install -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### CLI Tool
|
|
40
|
+
|
|
41
|
+
Basic usage:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
iplens 8.8.8.8 1.1.1.1
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Using an input file:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
iplens --input-file ips.txt
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The input **file** can be in one of the following formats:
|
|
54
|
+
|
|
55
|
+
- Plain text file with one IP address per line
|
|
56
|
+
- Text file containing a Python list of IP addresses
|
|
57
|
+
- JSON file with a list of IP addresses or a dictionary containing a list of IP addresses in any field
|
|
58
|
+
- CSV file with a column containing IP addresses (the column name should include "ip", case-insensitive)
|
|
59
|
+
- Log file containing IP addresses (the tool will extract unique IP addresses from the log)
|
|
60
|
+
|
|
61
|
+
Using an Input **Folder** to Parse Files for IP Addresses:
|
|
62
|
+
|
|
63
|
+
You can also specify a directory, and the tool will parse all non-binary files within that folder to extract IP addresses:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
iplens --input-folder /path/to/logs/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Use Cases:
|
|
70
|
+
|
|
71
|
+
Scan system logs: For example, to scan the UFW log for IP addresses, you can run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
iplens --input-folder /var/log/ufw.log
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
or for e.g. analyze web server logs: Parse your web server logs to gather and analyze IP addresses.
|
|
78
|
+
|
|
79
|
+
Save output to a file:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
iplens 8.8.8.8 1.1.1.1 --output results --format json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Available options:
|
|
86
|
+
|
|
87
|
+
- `--input-file` or `-i`: Specify an input file containing IP addresses
|
|
88
|
+
- `--input-folder` or `-d`: Specify an input folder containing files to parse for IP addresses
|
|
89
|
+
- `--output` or `-o`: Specify output file (without extension)
|
|
90
|
+
- `--format` or `-f`: Specify output format (csv or json)
|
|
91
|
+
|
|
92
|
+
Note: The tool will automatically detect the input file format and extract valid IP addresses. Invalid IP addresses will be ignored.
|
|
93
|
+
|
|
94
|
+
#### Exports Examples
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
[
|
|
98
|
+
{
|
|
99
|
+
"ip": "8.8.8.8",
|
|
100
|
+
"rir": "ARIN",
|
|
101
|
+
"is_bogon": "False",
|
|
102
|
+
"is_datacenter": "True",
|
|
103
|
+
"is_tor": "False",
|
|
104
|
+
"is_proxy": "False",
|
|
105
|
+
"is_vpn": "True",
|
|
106
|
+
"is_abuser": "True",
|
|
107
|
+
"company_name": "Google LLC",
|
|
108
|
+
"company_abuser_score": "0.0039 (Low)",
|
|
109
|
+
"company_type": "business",
|
|
110
|
+
"company_domain": "google.com",
|
|
111
|
+
"company_network": "8.8.8.0 - 8.8.8.255",
|
|
112
|
+
"company_whois": "https://api.incolumitas.com/?whois=8.8.8.0",
|
|
113
|
+
"abuse_email": "network-abuse@google.com",
|
|
114
|
+
"asn_asn": "AS15169",
|
|
115
|
+
"asn_abuser_score": "0 (Very Low)",
|
|
116
|
+
"asn_route": "8.8.8.0/24",
|
|
117
|
+
"asn_descr": "GOOGLE, US",
|
|
118
|
+
"asn_country": "us",
|
|
119
|
+
"asn_active": "True",
|
|
120
|
+
"asn_org": "Google LLC",
|
|
121
|
+
"asn_domain": "google.com",
|
|
122
|
+
"asn_abuse": "network-abuse@google.com",
|
|
123
|
+
"asn_type": "business",
|
|
124
|
+
"asn_created": "2000-03-30",
|
|
125
|
+
"asn_updated": "2012-02-24",
|
|
126
|
+
"asn_rir": "ARIN",
|
|
127
|
+
"asn_whois": "https://api.incolumitas.com/?whois=AS15169",
|
|
128
|
+
"location_country": "United States",
|
|
129
|
+
"location_country_code": "US",
|
|
130
|
+
"location_state": "California",
|
|
131
|
+
"location_city": "Sunnyvale",
|
|
132
|
+
"location_latitude": "37.36883",
|
|
133
|
+
"location_longitude": "-122.03635",
|
|
134
|
+
"location_zip": "95196",
|
|
135
|
+
"location_timezone": "America/Los_Angeles"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```csv
|
|
141
|
+
ip,rir,is_bogon,is_datacenter,is_tor,is_proxy,is_vpn,is_abuser,company_name,company_abuser_score,company_type,company_domain,company_network,company_whois,abuse_email,asn_asn,asn_abuser_score,asn_route,asn_descr,asn_country,asn_active,asn_org,asn_domain,asn_abuse,asn_type,asn_created,asn_updated,asn_rir,asn_whois,location_country,location_country_code,location_state,location_city,location_latitude,location_longitude,location_zip,location_timezone
|
|
142
|
+
8.8.8.8,ARIN,False,True,False,False,True,True,Google LLC,0.0039 (Low),business,google.com,8.8.8.0 - 8.8.8.255,https://api.incolumitas.com/?whois=8.8.8.0,network-abuse@google.com,AS15169,0 (Very Low),8.8.8.0/24,"GOOGLE, US",us,True,Google LLC,google.com,network-abuse@google.com,business,2000-03-30,2012-02-24,ARIN,https://api.incolumitas.com/?whois=AS15169,United States,US,California,Sunnyvale,37.36883,-122.03635,95196,America/Los_Angeles
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### As a Python Library
|
|
147
|
+
|
|
148
|
+
IP Lens can also be utilized as a Python library for direct integration into your Python projects.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from iplens.api import IPInfoAPI
|
|
152
|
+
|
|
153
|
+
api = IPInfoAPI()
|
|
154
|
+
results = api.process(['8.8.8.8', '1.1.1.1'])
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This will fetch and process the IP information for the given IP addresses. The results will include detailed information such as ASN, location, company details, and more, extracted and formatted for easy access
|
|
158
|
+
|
|
159
|
+
### Configuration
|
|
160
|
+
|
|
161
|
+
The API URL, logging level, and other constants can be configured in the config.cfg file. You can modify the configuration file to suit your specific requirements. The available fields and their purposes are defined in the src/config_loader.py.
|
|
162
|
+
API Limits
|
|
163
|
+
|
|
164
|
+
Note that the API has rate limits in its free, unregistered mode. If you encounter a rate limit, simply wait for 20 minutes and then continue using the tool.
|
|
165
|
+
Caching
|
|
166
|
+
|
|
167
|
+
IP Lens includes a caching mechanism to store fetched IP information locally. This helps reduce the number of API calls, especially when processing large lists of IPs. The cache is automatically cleared after a configurable expiration period, which can be set in the config.cfg file.
|
|
168
|
+
Ignoring Fields
|
|
169
|
+
|
|
170
|
+
If there are specific fields you wish to exclude from the output, you can configure this in the src/utils.py file, where the list of field names is defined. This allows you to customize the output based on your needs.
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
### Setup
|
|
175
|
+
|
|
176
|
+
1. Clone the repository
|
|
177
|
+
```bash
|
|
178
|
+
git clone https://github.com/aiomorphic/iplens.git
|
|
179
|
+
cd iplens
|
|
180
|
+
```
|
|
181
|
+
2. Create a virtual environment: `python -m venv venv`
|
|
182
|
+
3. Activate the virtual environment:
|
|
183
|
+
- Windows: `venv\Scripts\activate`
|
|
184
|
+
- Unix or MacOS: `source venv/bin/activate`
|
|
185
|
+
4. Install development dependencies: `pip install -r requirements.txt`
|
|
186
|
+
|
|
187
|
+
### Pre commit checks
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
make pre-commit
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Adding New Features
|
|
194
|
+
|
|
195
|
+
Implement new functionality in the appropriate module under iplens/.
|
|
196
|
+
Add tests for the new functionality in tests/.
|
|
197
|
+
Update iplens_cli.py if the new feature should be accessible via CLI.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
iplens_cli.py
|
|
3
|
+
setup.py
|
|
4
|
+
iplens.egg-info/PKG-INFO
|
|
5
|
+
iplens.egg-info/SOURCES.txt
|
|
6
|
+
iplens.egg-info/dependency_links.txt
|
|
7
|
+
iplens.egg-info/entry_points.txt
|
|
8
|
+
iplens.egg-info/requires.txt
|
|
9
|
+
iplens.egg-info/top_level.txt
|
|
10
|
+
src/__init__.py
|
|
11
|
+
src/base_operations.py
|
|
12
|
+
src/config_loader.py
|
|
13
|
+
src/db_cache.py
|
|
14
|
+
src/input_processor.py
|
|
15
|
+
src/ipapi_api.py
|
|
16
|
+
src/logger.py
|
|
17
|
+
src/output.py
|
|
18
|
+
src/table_formatter.py
|
|
19
|
+
src/utils.py
|
|
20
|
+
tests/test_api.py
|
|
21
|
+
tests/test_data_processing.py
|
|
22
|
+
tests/test_output.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|