daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. # Settings
  4. my $sDatabaseHost='********';            # The hostname of the database server
  5. my $sDatabaseUser="***********";            # The username to connect to mysql
  6. my $sDatabasePass='**********';            # The password to connect to mysql
  7. my $sDatabaseName="***********";            # The name of the database contain the user table
  8. my $sUserTable="phpbb_users";                # The name of the table containing the username and password
  9. my $sUsernameTableField="*************";        # The name of the field that holds jabber user names
  10. my $sPasswordTableField="**********";    # The name of the field that holds jabber passwords
  11.  
  12. # Libs
  13. use DBI;
  14. use DBD::mysql;
  15.  
  16. while(1) {
  17. my $sBuffer = "";
  18. my $readBuffer = sysread STDIN,$sBuffer,2;
  19. my $iBufferLength = unpack "n",$sBuffer;
  20. my $readBuffer    = sysread STDIN,$sBuffer,$iBufferLength;
  21. my ($sOperation,$sUsername,$sDomain,$sPassword) = split /:/,$sBuffer;
  22. my $bResult;
  23.  
  24. SWITCH: {
  25. $sOperation eq 'auth' and do {
  26. $bResult   = 0;
  27. $connect   = DBI->connect('DBI:mysql:'.$sDatabaseHost, $sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
  28. $query     = "SELECT $sPasswordTableField FROM $sUserTable WHERE $sUsernameTableField='$sUsername';";
  29. $statement = $connect->prepare($query);
  30. $statement->execute();
  31. while ($row = $statement->fetchrow_hashref()) {
  32. $sCryptstring = ($sPassword,$row->{$sPasswordTableField});
  33. if ($row->{$sPasswordTableField} eq $sCryptstring) {
  34. $bResult = 1;
  35. }
  36. }
  37. },last SWITCH;
  38.  
  39. $sOperation eq 'setpass' and do {
  40. $connect   = DBI->connect('DBI:mysql:'.$sDatabaseHost, $sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
  41. $myquery   = "UPDATE $sUserTable SET $sPasswordTableField=ENCRYPT('$sPassword') WHERE $sUsernameTableField='$sUsername';";
  42. $statement = $connect->prepare($myquery);
  43. $statement->execute();
  44. $bResult = 1;
  45. },last SWITCH;
  46.  
  47. $sOperation eq 'isuser' and do {
  48. $bResult   = 0;
  49. $connect   = DBI->connect('DBI:mysql:'.$sDatabaseHost, $sDatabaseName, $sDatabaseUser, $sDatabasePass) || die "Could not connect to database: $DBI::errstr";
  50. $myquery   = "SELECT count(*) AS iCount FROM $sUserTable WHERE $sUsernameTableField='$sUsername';";
  51. $statement = $connect->prepare($myquery);
  52. $statement->execute();
  53. $row = $statement->fetchrow_hashref();
  54. if($row->{'iCount'} >= 1){
  55. $bResult = 1;
  56. }
  57. },last SWITCH;
  58. };
  59.  
  60. my $sOutput = pack "nn",2,$bResult ? 1 : 0;
  61. syswrite STDOUT,$sOutput;
  62. }
  63. closelog;
  64.  
  65.  
  66. DBI->connect using 'old-style' syntax is deprecated and will be an error in future versions at /etc/ejabberd/phpbbauth.pl line 31
  67.                         install_driver(b1gd3al) failed: Can't locate DBD/b1gd3al.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at (eval 3) line 3.
  68.     Perhaps the DBD::b1gd3al perl module hasn't been fully installed,
  69.                                                                      or perhaps the capitalisation of 'b1gd3al' isn't right.
  70.                    Available drivers: DBM, ExampleP, File, Proxy, Sponge, mysql.
  71.                                                                                  at /etc/ejabberd/phpbbauth.pl line 31
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top