#!/usr/bin/perl # dbb-read.pl 0.11 # (c) 2007 nhjm449 # needs much work use Date::Calc(qw(:all)); # Mktime() use POSIX; my $chunkSize = 256; # 256 512 1024 2048 4096 8192 16384 my $username = "nhjm449"; my $skypeaccount = "nhjm449"; open(DBB, ">>>>> $i <<<<<<\n\n"; $info{"chunkLength"} = unpack("L", substr($chunk, 4, 4)); next if ($info{"chunkLength"} eq ''); $info{"number"} = unpack("L", substr($chunk, 8, 4)); $info{"msgbody"} = substr($chunk, 12, $info{"chunkLength"} - 4); #print "\n{{ msgbody: $info{msgbody} }}\n\n"; $info{"number2"} = unpack("L", substr($chunk, 12, 4)); #$info{"chatroom"} = substr($chunk, 20, index($chunk, $null, 20)-20); if ($info{"msgbody"} =~ /\x03\xe0\x03((?:.|\n)+?)\x00/) { $info{"chatroom"} = $1; } if ($info{"msgbody"} =~ /\xe5\x03((?:.|\n){4})/) { $info{"time"} = unpack("L", $1); # "year2" "year1" "year2" in days "year1" in days = some sort of crackhead number # (90.7428907280568-81.2961210996956)/(((2006*365+10*30+29)-(2005*365+8*30+29))/365) = 8.11310803376903058829 # (90.7428907280568-81.2961210996956)/(((2006*365.2425+10*30.436875+29)-(2005*365.2425+8*30.436875+29))/365.2425) = 8.09723111002388571433 # (93.3207815824545-81.2421452173201)/(((2007*365.2425+31+25)-(2005*365.2425+31+28+31+30+31+30+31+29))/365.2425) = 8.08753924047884193333 # 2944919425 2563754477 # (2944919425-2563754477)/(((2007*365.2425+31+25)-(2005*365.2425+31+28+31+30+31+30+31+29))*86400/365.2425) = 2953.91305104058773385152 # FIXME this is a ridiculous guestimation #my $year = $info{"time"}/60/60/24/365/8.08753924047884293333+1995.7033185; my $year = $info{"time"}/2953.91305104058773385152/86400+1995.72494834; #my $basetime = Mktime(2002, 5, 3, 7, 43, 40); #my $year = $info{"time"}/2.51179600408636638995; #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($info{"time"}*0.39812153502298284442); #.39812150285020346860 print "year: $year\n"; my $unixtime = ($year-1970)*(60*60*24*365); print "yeartounix: $unixtime\n"; #$basetime = Mktime($year, 0, 0, 0, 0, 0); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($unixtime); #my $month = ($year - floor($year))*12; #my $day = ($month - floor($month))*(daysInMonth($month+1)); #30.436875 #my $hour = ($day - floor($day))*24; #my $minute = ($hour - floor($hour))*60; #my $second = ($minute - floor($minute))*60; $year+=1900; print "timeyear: ".($info{"time"}/60/60/24/365.2425)."\n"; print "time?: ".$info{"time"}.", year: ".($year)." month: ".($mon)." day: ".($mday)." hour: ".($hour)." minute: ".($min)." second: ".($sec)."\n"; } if ($info{"msgbody"} =~ /\x03\xe8\x03((?:.|\n)+?)\x00/) { $info{"username"} = $1; } if ($info{"msgbody"} =~ /\x03\xec\x03((?:.|\n)+?)\x00/) { $info{"friendlyname"} = $1; } if ($info{"msgbody"} =~ /\x03\xf4\x03((?:.|\n)+?)\x00/) { if ($1 eq $username) { $info{"invited"} = $1; print "--- $1 was invited\n"; } else { $info{"join"} = $1; print "--- starting message with $1\n"; } } #f1030400 if ($info{"msgbody"} =~ /\xf1\x03\x04\x00/) { $info{"leave"} = $info{"username"}; } if ($info{"msgbody"} =~ /\x03\xfc\x03((?:.|\n)+?)\x00+\xf1\x03\x03/ || $info{"msgbody"} =~ /\xf1\x03\x03\x03\xfc\x03((?:.|\n)+?)\x00/) { $info{"message"} = $1; } if ($info{"msgbody"} =~ /\x03\xfc\x03((?:.|\n)+?)\x00+\xf1\x03\x07/ || $info{"msgbody"} =~ /\xf1\x03\x07\x03\xfc\x03((?:.|\n)+?)\x00/) { $info{"action"} = $1; } if ($info{"msgbody"} =~ /\x03\xfc\x03((?:.|\n)+?)\x00+\xf1\x03\x05/ || $info{"msgbody"} =~ /\xf1\x03\x05\x03\xfc\x03((?:.|\n)+?)\x00/) { $info{"topic"} = $1; } if (!$info{"message"} && !$info{"action"} && !$info{"topic"} && $info{"msgbody"} =~ /\x03\xfc\x03((?:.|\n)+?)\x00/) { $info{"message"} = $1; } print "chunkLength: ".$info{"chunkLength"}.", number: ".$info{"number"}.", length: (".length($chunk).")\n"; print ">> chatroom: ".$info{"chatroom"}."\n"; print ">> username: ".$info{"username"}."\n"; print ">> friendlyname: ".$info{"friendlyname"}."\n"; if ($info{"invited"}) { print ">> invited: ".$info{"invited"}."\n"; } elsif ($info{"join"}) { print ">> join: ".$info{"join"}."\n"; } elsif ($info{"leave"}) { print ">> leave: ".$info{"leave"}."\n"; } else { print ">> message: ".$info{"message"}."\n" if ($info{"message"}); print ">> action: ".$info{"action"}."\n" if ($info{"action"}); print ">> topic: ".$info{"topic"}."\n" if ($info{"topic"}); print "!! error: unknown message type! (blank? corrupt?)\n" if (!$info{"message"} && !$info{"action"} && !$info{"topic"}); } #print ">> data: ".$info{"data"}."\n"; #$chunk =~ s/$null+$//; #print "\n".$chunk."\n---\n"; %info = ( ); undef($chunk); } # 03e003 - chatroom # 04 03e803 - username # 03ec03 - friendlyname # 03f403 - start msg w/ username (join) # 03fc03 f10303 - message # 03fc03 f10307 - action message # 03fc03 f10305 - topic message #x 810404 - leave #x 810402 - speak # offset 660: 00 f1 03 80 08 00 <-- unknown! # f1030400 f9030600 - user leaves print "\n"x10; #232 = username #236 = nickname