Password Checker at https://gec.im/passwords/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

  1. #!/usr/bin/env perl
  2. #
  3. # Copyright (c) 2014 Mr. Gecko's Media (James Coleman). http:#mrgeckosmedia.com/
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. #
  23. #DBD::mysql
  24. use DBI;
  25. use POSIX;
  26. use DateTime;
  27. sub trim($) {
  28. my $string = shift;
  29. $string =~ s/^\s+//;
  30. $string =~ s/\s+$//;
  31. $string =~ s/^\t+//;
  32. $string =~ s/\t+$//;
  33. $string =~ s/^\s+//;
  34. $string =~ s/\s+$//;
  35. $string =~ s/^\t+//;
  36. $string =~ s/\t+$//;
  37. $string =~ s/\n//g;
  38. $string =~ s/\r//g;
  39. return $string;
  40. }
  41. $dbHost = "127.0.0.1";
  42. $dbName = "passwords";
  43. $dbUser = "root";
  44. $dbPassword = "password";
  45. $file = "/Users/grmrgecko/Desktop/passwords/combo_not.txt";
  46. #print localtime(time).": Connecting to DataBase\n";
  47. $dbConnection = DBI->connect("DBI:mysql:$dbName;host=$dbHost", $dbUser, $dbPassword) || die "Could not connect to database: $DBI::errstr";
  48. open(passwords, $file);
  49. my $i=0;
  50. my $count=0;
  51. while (<passwords>) {
  52. chomp;
  53. $i++;
  54. my $sha1 = trim($_);
  55. print $i.": ".$sha1."\n";
  56. my $result = $dbConnection->prepare("SELECT * FROM `sha1` WHERE `hash`=?");
  57. $result->execute($sha1);
  58. my $exists = $result->fetchrow_hashref();
  59. if ($exists!=undef) {
  60. $result->finish();
  61. next;
  62. }
  63. $result->finish();
  64. my $result = $dbConnection->prepare("INSERT INTO `hash` (`hash`,`leak`) VALUES (?,'LinkedIn 6/6/12')");
  65. $result->execute($sha1);
  66. $result->finish();
  67. $count++;
  68. if ($count%10000==0) {
  69. my $result = $dbConnection->prepare("INSERT INTO `sha1` (`hash`,`leak`) SELECT `hash`,`leak` FROM `hash`");
  70. $result->execute();
  71. $result->finish();
  72. my $result = $dbConnection->prepare("DELETE FROM `hash`");
  73. $result->execute();
  74. $result->finish();
  75. }
  76. }
  77. my $result = $dbConnection->prepare("INSERT INTO `sha1` (`hash`,`leak`) SELECT `hash`,`leak` FROM `hash`");
  78. $result->execute();
  79. $result->finish();
  80. my $result = $dbConnection->prepare("DELETE FROM `hash`");
  81. $result->execute();
  82. $result->finish();
  83. close(passwords);
  84. $dbConnection->disconnect();