Skip to content

Instantly share code, notes, and snippets.

@gfoss
Last active December 30, 2018 11:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gfoss/4728912 to your computer and use it in GitHub Desktop.
Save gfoss/4728912 to your computer and use it in GitHub Desktop.
grep IP addresses from auth logs to see attempted ssh attempts into your box w/ invalid creds {ubuntu}
#search for invalid logon attempts, pull out IP, remove dupes, sort...
$ grep -rhi 'invalid' /var/log/auth.log* | awk '{print $10}' | uniq | sort > ~/ips.txt
#look em up
$ for i in `cat ~/ips.txt`; do @nslookup $i 2>/dev/null | grep Name | tail -n 1 | cut -d " " -f 3; done > ~/who.txt
# :-) #
$ do moar things...
@ppazos
Copy link

ppazos commented Oct 23, 2018

@gfoss this also includes

exceeded
[preauth]

on the ips.txt

is there a way to specify a regex to get just IPs?

another thing is the duplicates, not sure if in a sh duplicates can be checked though.

@ppazos
Copy link

ppazos commented Oct 23, 2018

@gfloss the second command just creates an empty file, something might not be right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment