I recently had a need to fit a new host onto a crowded network, without well documented address assignments. This led me to several obvious answers, all of which required reading long lists of IP addresses while looking for gaps here and there. Since reading through DNS zone files, or filtering Nmap ping sweep output didn't sound like much fun, I threw this little guy together.
#!/usr/bin/perl
#############################
## ipchecker.pl ##
## (c)2012 Peter H. Ezetta ##
#############################
use strict;
use warnings;
use 5.010;
my @results;
foreach (`nmap -sP -v 192.168.0.*`) {
chomp;
push( @results, $_ ) if (/^Host/);
}
foreach (@results) {
say if (/down/);
}
Change the address in the foreach loop to match the network you're scanning, and Nmap will run a ping scan like normal, with a nice little Perl wrapper to only give you the hosts that are down, instead of up.
Linux, Unix, C, Perl, Electronics, Virtualization, and general tech.... Tech that can sometimes be a touch painful.
Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts
Wednesday, November 7, 2012
Saturday, November 3, 2012
Lines of Code
This is going to be a short one. The other day, one of my friends asked me for a quick way to tell how many lines of code were in a project directory. Here was my solution (thank you, Perl!)
$ find . -name '*.pl' | xargs perl -e \
'my $x = 0; foreach (<>) { $x++ }; print "$x\n"'
Of course the *.pl can be changed to whatever extension you would like, and TIMTOWTDI, but I happen to be fond of foreach loops and the <> operator, so...
$ find . -name '*.pl' | xargs perl -e \
'my $x = 0; foreach (<>) { $x++ }; print "$x\n"'
Of course the *.pl can be changed to whatever extension you would like, and TIMTOWTDI, but I happen to be fond of foreach loops and the <> operator, so...
protosho v1.0 (almost)
Admittedly, I haven't been playing with Dettu[xX] too much over the last month, but I did come back to a stagnant code project that I started in late September or early October, and did a bit of general cleanup and prep work towards being something thats fit for (very adventurous) human consumption...
It doesn't have a working installer (I'd advise leaving Makefile.PL well alone unless you know what you're doing... it's not complete), it doesn't have any documentation other than the comments in the code, but if you can get it to run, it does it's job.
So, for the moment that no-one has been waiting for, I give you protosho:
https://github.com/protoCall7/protosho
This little baby is a CLI::Framework based SHODAN interface for the commandline. It's written 100% in Perl 5.14, it's licensed under the BSD 3-clause, and at the moment, it kind of sucks. But I've had a ton of fun playing with the results that it cranks out, so for anyone else out there who likes to tinker with Perl, or has a need for some SHODAN on the CLI, or is just feeling techno-masochistic, grab a git clone of it, and leave me a comment here, or on the Github issues board, and I'll help you through getting it installed.
In the meantime, you should also check out SHODAN @ http://www.shodanhq.com
proto
It doesn't have a working installer (I'd advise leaving Makefile.PL well alone unless you know what you're doing... it's not complete), it doesn't have any documentation other than the comments in the code, but if you can get it to run, it does it's job.
So, for the moment that no-one has been waiting for, I give you protosho:
https://github.com/protoCall7/protosho
This little baby is a CLI::Framework based SHODAN interface for the commandline. It's written 100% in Perl 5.14, it's licensed under the BSD 3-clause, and at the moment, it kind of sucks. But I've had a ton of fun playing with the results that it cranks out, so for anyone else out there who likes to tinker with Perl, or has a need for some SHODAN on the CLI, or is just feeling techno-masochistic, grab a git clone of it, and leave me a comment here, or on the Github issues board, and I'll help you through getting it installed.
In the meantime, you should also check out SHODAN @ http://www.shodanhq.com
proto
Subscribe to:
Posts (Atom)