├── amount.txt
├── ishaq_account.txt
├── account.txt
├── reset.php
├── README.md
├── script.py
├── index.php
└── cpanel.php
/amount.txt:
--------------------------------------------------------------------------------
1 | 5000
--------------------------------------------------------------------------------
/ishaq_account.txt:
--------------------------------------------------------------------------------
1 | 0
--------------------------------------------------------------------------------
/account.txt:
--------------------------------------------------------------------------------
1 |
2 | 5000
3 | 5000
4 | 5000
--------------------------------------------------------------------------------
/reset.php:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 | Race Condition Demo
25 |
26 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/cpanel.php:
--------------------------------------------------------------------------------
1 | ";
20 | echo "Insufficient funds. for donating";
21 |
22 | }
23 | else
24 | {
25 |
26 | $new_money = $dat-5000;
27 | $bull = fopen('amount.txt', 'w');
28 | sleep(3);
29 | fwrite($bull, $new_money);
30 | fclose($bull);
31 |
32 | $acc1 = fopen('account.txt', 'r');
33 | $dat = fread($acc1, filesize('account.txt'));
34 | $add_money =$dat."\n"."5000";
35 | $acc = fopen('account.txt', 'w');
36 | fwrite($acc, $add_money);
37 | fclose($acc);
38 | }
39 | }
40 |
41 | if( $_GET["name"] || $_GET["pass"] )
42 | {
43 | $name = $_GET["name"];
44 | $pass = $_GET["pass"];
45 |
46 | if (($name == "root" || $name == "ROOT") && $pass == "password")
47 | {
48 |
49 | echo "Race Condition Demo
";
50 | echo "Welcome , ".$name;
51 | echo "
";
52 | echo "
";
53 | echo "Reset balance";
54 | echo "
";
55 | echo "
";
56 | $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
57 | $actual_link = $actual_link . "&donate=true";
58 | echo "Donate Rs 5k to XYZ Organization";
59 | echo "
";
60 | echo "Donate Rs 5k to Ishaq";
61 |
62 | if (strpos($actual_link, 'donate') !== false)
63 | {
64 |
65 | start_donating();
66 |
67 | }
68 |
69 | $fil = fopen('amount.txt', 'r');
70 | $dat = fread($fil, filesize('amount.txt'));
71 | echo "
";
72 | echo "You have ".$dat." in your balance";
73 |
74 |
75 | }
76 | else if(($name == "ishaq" || $name == "ISHAQ") && $pass == "pass") {
77 | if(file_exists('account.txt') && file_exists('ishaq_account.txt')) {
78 | $account = fopen('account.txt', 'r');
79 |
80 | $x= fread($account, filesize('account.txt'));
81 |
82 | $account = fopen('account.txt', 'r');
83 |
84 | $y= fread($account, filesize('ishaq_account.txt'));
85 |
86 | $req=explode( '\n', $x );
87 |
88 | foreach($req as $x){
89 | if (!isset($line)) { $line =0; }
90 | $y +=$line;
91 | }
92 |
93 | echo "
";
94 | echo "You have ".$line." in your balance";
95 | } else {
96 | $acc = fopen('account.txt', 'w');
97 | fwrite($acc, 0);
98 | fclose($acc);
99 | echo "You have 0 in your balance";
100 |
101 | $acc = fopen('ishaq_account.txt', 'w');
102 | fwrite($acc, 0);
103 | fclose($acc);
104 | }
105 | }
106 | else
107 | {
108 |
109 | echo "Username or password you entered is incorrect";
110 | }
111 |
112 |
113 | }
--------------------------------------------------------------------------------