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

Exaple for --regex #67

Closed
ch-hf opened this issue Jul 19, 2022 · 2 comments
Closed

Exaple for --regex #67

ch-hf opened this issue Jul 19, 2022 · 2 comments

Comments

@ch-hf
Copy link

ch-hf commented Jul 19, 2022

Hello,

I've working only with IPv4 and I have error Logs in like followed:
[Mon Jul 18 17:54:15.281165 2022] [ssl:info] [pid 32202] [client 11.22.33.44:11388] Some Text bla...

I try
cat error.log | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
and got sucessful my IP's

Next I try
anonip.py --input error.log -4 8 --regex '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -d
and got
DEBUG:__main__:Regex did not match!
The same with:
anonip.py --input error.log -4 8 --regex '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' -d

Any idears?

Regards,
Heiko

@tolimar
Copy link

tolimar commented Aug 4, 2022

Hi!

After reading Issue 44 I think there is a misunderstanding on the usage of the regexp parameter. Apparently you don't have to specify a regexp to match the IP address, but a regexp to describe where it is.

So based on your example, you might want to use .*client ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\:[0-9]*\].* as regexp parameter. Note that I placed your regexp in regular brackets, and just but a bit context before and after.

$ echo ' [Mon Jul 18 17:54:15.281165 2022] [ssl:info] [pid 32202] [client 11.22.33.44:11388] Some Text bla...' | \
> anonip -4 8 --regex '.*client ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\:[0-9]*\].*'
[Mon Jul 18 17:54:15.281165 2022] [ssl:info] [pid 32202] [client 11.22.33.0:11388] Some Text bla...

Best regards,
Tolimar

@ch-hf
Copy link
Author

ch-hf commented Aug 15, 2022

That's the Info I need.
Thanks for help!

@ch-hf ch-hf closed this as completed Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants