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

Improve IPv4 detection (to avoid false positives) #14

Open
borestad opened this issue Sep 18, 2023 · 2 comments
Open

Improve IPv4 detection (to avoid false positives) #14

borestad opened this issue Sep 18, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@borestad
Copy link

Hi again :)

This is currently possible

ds -f sample.txt

999.999.999.999
$$$$$999.999.999.999$$$$$
1.1.1.1

output:

ip_address: 999.999.999.999
ip_address: $$$999.999.999.999$$$
ip_address: 1.1.1.1

I'm not really sure howto handle all special cases, but I noticed this while searching html-files and found several false positives within inline svg's.

FYI:
This is the regexp I'm using for finding IPV4 in bash (no cidr support)

export IS_IP4='(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'

..compared to the more simplified version here:
fd0bab1#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcR299

@borestad
Copy link
Author

Btw, here's a usecase

https://support.censys.io/hc/en-us/articles/360043177092-Opt-Out-of-Data-Collection

ds -i -X -T -C -f 360043177092-Opt-Out-of-Data-Collection


2.2.5.2
2.2.5.2
162.142.125.0
167.94.138.0
167.94.145.0
167.94.146.0
167.248.133.0
198.023.39.065
1.112.042.314
2.2.5.2

By looking at the source code we can see (except for the missing cidr support that you fixed in #13 ...that 2.2.5.2 comes from this inline svg:

<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" focusable="false" viewBox="0 0 12 12"
  aria-hidden="true" class="collapsible-nav-toggle-icon chevron-icon">
  <path fill="none" stroke="currentColor" stroke-linecap="round" d="M3 4.5l2.6 2.6c.2.2.5.2.7 0L9 4.5">
  </path>
</svg>

@Drew-Alleman
Copy link
Owner

Drew-Alleman commented Sep 30, 2023

Hi,

This is what my new regex is giving me. I will push it in the next update, (i gotta fix it again)

drew@ubuntu:~/DataSurgeon$ ./target/release/ds -f bad.txt -i
ip_address: 162.142.125.0:80
ip_address: 162.142.125.0
ip_address: 167.94.138.0
ip_address: 167.94.145.0
ip_address: 167.94.146.0
ip_address: 167.248.133.0

Best,
Drew

@Drew-Alleman Drew-Alleman self-assigned this Sep 30, 2023
@Drew-Alleman Drew-Alleman added the bug Something isn't working label Sep 30, 2023
Drew-Alleman added a commit that referenced this issue Sep 30, 2023
Drew-Alleman added a commit that referenced this issue Sep 30, 2023
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