Jump to content

Source of a local iframe as a php variable to be saved to txt file.


Xproterg^vi

Recommended Posts

Yes it does, and I can get that to work. I need to get around the same domain policy to work with local files. I'm writing a whitepaper on this particular security idea.

 

<?php $DEFAULT_FILE = "index.php"; ?>
<?php $url=fopen("url.txt","r"); ?>
<?php $file = fgets($url); ?>
<?php
  if (isset($file)) {
    $file2 = $file;
    echo "<div class=\"source\">\n";
    $content=file_get_contents($file2);
    echo $content;
    echo "</div>\n";
    } else {
    $file = $DEFAULT_FILE;
  }
?>


<?php
$filename = substr($file2,7) . ".html";

if (is_writable($filename)) {

if (!$handle = fopen($filename, 'w')) {
        echo "Cannot open file ($filename)";
        exit;
  }

   if (fwrite($handle, $content) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }

   echo "Success, wrote ($content) to file ($filename)";

   fclose($handle);

} else {
   echo "The file $filename is not writable";
}
?>

 

As you can see, the code works. However, if I use this script, it will not keep the session that I have with the external site alive because the IP is from my server and not from myself. So I'm looking to do this through other avenues. The view-source:http://site.com/ is one of those avenues.

How would view-source sort the problem? I don't actually think view-source is anything more than a browser command? (Though it's not actually supported in IE) .. I think sending view-source at the start of the file_get_contents function would just cause it to fail?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.