23 Şubat 2009 Pazartesi

Credit Card

1.
2.
/***************************************************************************
3.
* Copyleft (C) 2007 by evilsocket *
4.
* *
5.
* *
6.
* http://www.evilsocket.net/ *
7.
* *
8.
* This program is free software; you can redistribute it and/or modify *
9.
* it under the terms of the GNU General Public License as published by *
10.
* the Free Software Foundation; either version 2 of the License, or *
11.
* (at your option) any later version. *
12.
* *
13.
* This program is distributed in the hope that it will be useful, *
14.
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16.
* GNU General Public License for more details. *
17.
* *
18.
* You should have received a copy of the GNU General Public License *
19.
* along with this program; if not, write to the *
20.
* Free Software Foundation, Inc., *
21.
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22.
***************************************************************************/
23.

24.
$VISA = array( "Visa", 16, array( "4539", "4556", "4916", "4532", "4929", "40240071", "4485", "4716", "4" ) );
25.
$MASTERCARD = array( "Mastercard", 16, array( "51", "52", "53", "54", "55" ) );
26.
$AM_EXPRESS = array( "American Express", 15, array( "34", "37" ) );
27.
$DISCOVER = array( "Discover", 16, array( "6011" ) );
28.
$DINERS = array( "Diners Club", 14, array( "300", "301", "302", "303", "36", "38" ) );
29.
$ENROUTE = array( "EnRoute", 15, array( "2014", "2149" ) );
30.
$JCB = array( "JCB", 16, array( "3088", "3096", "3112", "3158", "3337", "3528" ) );
31.
$VOYAGER = array( "Voyager", 15, array( "8699" ) );
32.

33.
$CARDS = array( $VISA, $MASTERCARD, $AM_EXPRESS, $DISCOVER, $DINERS, $ENROUTE, $JCB, $VOYAGER );
34.

35.
function cc_generate( $type, $number ){
36.
global $CARDS;
37.

38.
$card = $CARDS[ $type ];
39.
$name = $card[0];
40.
$length = $card[1];
41.

42.
print "$name:\n";
43.

44.
for( $i = 0; $i < $number; $i++ ){
45.
$prefix = $card[2][ array_rand($card[2]) ];
46.

47.
while ( strlen($prefix) < ($length - 1) ) {
48.
$prefix .= rand(0,9);
49.
}
50.

51.
$sum = $j = 0;
52.
$rev = strrev($prefix);
53.

54.
while ( $j < $length - 1 ){
55.
$odd = $rev[$j] * 2;
56.
$odd = ($odd > 9 ? $odd - 9 : $odd );
57.
$sum += $odd;
58.

59.
if( $j != ($length - 2) ){
60.
$sum += $rev[ $j + 1 ];
61.
}
62.
$j += 2;
63.
}
64.

65.
$prefix .= (( floor($sum/10) + 1) * 10 - $sum) % 10;
66.

67.
echo "\t$prefix\n";
68.
}
69.
}
70.

71.
function banner(){
72.
print "***********************************************\n" .
73.
"* Credit Card Generator *\n" .
74.
"* by evilsocket [http://www.evilsocket.net] *\n" .
75.
"***********************************************\n\n";
76.
}
77.

78.
function usage(){
79.
global $CARDS;
80.
print "Usage : php ccgen.php \n";
81.
print "\t\tAllowed types are :\n\n";
82.
for( $i = 0; $i < count($CARDS); $i++ ){
83.
print "\t\t\t[$i] " . $CARDS[$i][0] . "\n";
84.
}
85.
print "\n";
86.
}
87.

88.
banner();
89.

90.
$type = $argv[1];
91.
$num = $argv[2];
92.

93.
if( $argc <> count($CARDS) - 1 ){
94.
usage();
95.
}
96.
else{
97.
cc_generate( $type, $num );
98.
}
99.

100.
?>

http://www.evilsocket.net/?action=nopaste&do=view&key=6280584

Hiç yorum yok:

Yorum Gönder