The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 09:56:22 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: How to place the same index.php file in a thousand different directories  (Read 1236 times)
webinfoguy25
Journeyman
***
Offline Offline

Posts: 56


View Profile
« on: July 13, 2014, 07:04:41 AM »

Hey guys im kinda brain dead from pulling a all nighter on getting a site done.  Anyways could someone help me get the cmd command for taking the same index.php file and copying it to a multiple set of directories? I am just going to throw all the direcotires in the same folder as the index.php file but don't want to copy and paste until my fingers get broken.

Thanks,
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: July 14, 2014, 03:38:33 PM »

couple step process.

Go to the root directory you want to start from.
type find . -type d > dirList.txt

it will now contain all the subdirs under that directory.

Write a little PHP script that loads that and writes your index file into each. Something like:

$payload = file_get_contents('./theIndexFileToCopy.php');
$buff = file_get_contents('./dirList.txt');
$buff = str_replace("\r", '', $buff); // just in case this is a windows file
$lines = explode("\n", $buff);
foreach($lines as $path)
   file_put_contents($payload, "$path/index.php");

then you might need to go back to the command prompt and change ownership so that it works correctly under your web server

chown -R www *

Something like that.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!