Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found IPs being parsed as URLs #77

Closed
bee-gees opened this issue Sep 21, 2023 · 1 comment
Closed

Found IPs being parsed as URLs #77

bee-gees opened this issue Sep 21, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@bee-gees
Copy link

Hey! Currently working with iocextract to read from a text file and convert to a query. I just now ran in the issue where the IPs were being extracted as IPs but then they were also being extracted and formatted as URLs.
Input: 101.28[.]225[.]248 ---> Output: RemoteIP =~ "101.28.225.248" or RemoteUrl has "http://101.28.225.248"

@InQuest InQuest deleted a comment from DragonistYJ Sep 21, 2023
@battleoverflow battleoverflow self-assigned this Sep 21, 2023
@battleoverflow battleoverflow added the bug Something isn't working label Sep 22, 2023
@battleoverflow
Copy link
Contributor

Hi, @bee-gees!

This issue should now be resolved and will be available in the next release of iocextract. You can see an example below of how to achieve this.

The best method for this is to use extract_ips(), but a simplified version is available if you’d like to include extract_urls() as well. This is ultimately left up to preference and testing to see which method works best for your use case.

data = \
“”"
101[.]28[.]225[.]248
http://102.35.235.240
https://105.55.245.180
“”"

# Using extract_urls()
# refang and no_scheme must be set to true
print(list(iocextract.extract_urls(data=data, refang=True, no_scheme=True)))

# Using extract_ips()
print(list(iocextract.extract_ips(data=data)))

The new version can be installed here: https://pypi.org/project/iocextract/1.16.1

You can also install the update using pip: pip install iocextract -U

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants