Skip to content

Instantly share code, notes, and snippets.

@tbhaxor
Created November 9, 2018 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbhaxor/e40ab4bc3aa78f13fdb9f0ac0b93b690 to your computer and use it in GitHub Desktop.
Save tbhaxor/e40ab4bc3aa78f13fdb9f0ac0b93b690 to your computer and use it in GitHub Desktop.
Tinyurl Clean and custom alias maker
<?php
/*
How to execute : php tiny.php
This will help you in generating readable custom alias with enumration (if already registered)
*/
function getURL($url, $sh)
{
$data = file_get_contents("https://tinyurl.com/create.php?source=indexpage&url=$url&submit=Make+TinyURL%21&alias=$sh");
preg_match('/<b>https:\/\/tinyurl.com\/.*<\/b>/', $data, $matches);
$respShort = explode("</b>", explode("<b>", $matches[0])[1])[0];
return $respShort;
}
echo("[?] Enter url to shorten : ");
$url = explode("\n", fgets(STDIN))[0];
echo("[?] Enter custom short alias : ");
$short = explode("\n", fgets(STDIN))[0];
echo("[~] Creating\n");
$u = getURL($url, $short);
$exists = true;
$i = 1;
while ($exists)
{
if("https://tinyurl.com/$short" === $u)
{
echo("[!] Your Tiny URL : $u\n");
break;
}
$d = preg_split("/-[0-9]+(-[0-9]+)*/", $short)[0];
$short = "$d-$i";
$u = getURL($url, $short);
$i++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment