Guest User

Untitled

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