Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- # urldecode - decode the game ID from x[a-f0-9]{12} form to [a-f0-9]{8} form
- #
- # useful for getting immediate logs of games from a.mjv.jp/log?etc
- #
- # 2008-08-19 bps initial
- # 2011-07-02 bps added support for new encryption method
- use strict;
- use warnings;
- # keys
- my @t = (22136, 52719, 55146, 42104, 59591, 46934, 9248, 28891, 49597, 52974,
- 62844, 4015, 18311, 50730, 43056, 17939, 64838, 38145, 27008, 39128, 35652,
- 63407, 65535, 23473, 35164, 55230, 27536, 4386, 64920, 29075, 42617, 17294,
- 18868, 2081);
- sub urldecode {
- my $full = shift;
- $full =~ /((\d{10})gm-.*-)(x[a-f0-9]{12})/;
- my $pref = $1;
- my $date = $2;
- my $eid = $3;
- if(substr($eid, 0, 1) eq 'x') {
- my $a = hex substr $eid, 1, 4;
- my $b = hex substr $eid, 5, 4;
- my $c = hex substr $eid, 9, 4;
- my $l = (int($date) >= 2010041111) ?
- int("3".substr($date,4,6))%(17*2-int(substr($date,9,1))-1) : 0;
- $eid = sprintf "%x%x", ($a^$b^$t[$l]), ($b^$t[$l]^$c^$t[$l+1]);
- }
- $pref.$eid;
- }
- print urldecode($_)."\n" foreach @ARGV;
- exit 0;
Add Comment
Please, Sign In to add comment