|
| 1 | +<?php |
| 2 | +//functions for RED HAWK |
| 3 | +function getTitle($url) { |
| 4 | + $data = readcontents($url); |
| 5 | + $title = preg_match('/<title[^>]*>(.*?)<\/title>/ims', $data, $matches) ? $matches[1] : null; |
| 6 | + return $title; |
| 7 | + } |
| 8 | + function userinput($message){ |
| 9 | + global $white, $bold, $greenbg, $redbg, $bluebg, $cln, $lblue, $fgreen; |
| 10 | + $yellowbg = "\e[100m"; |
| 11 | + $inputstyle = $cln . $bold . $lblue . "[#] " . $message . ": " . $fgreen ; |
| 12 | + echo $inputstyle; |
| 13 | + } |
| 14 | +function WEBserver($urlws){ |
| 15 | + stream_context_set_default( [ |
| 16 | + 'ssl' => [ |
| 17 | + 'verify_peer' => false, |
| 18 | + 'verify_peer_name' => false, |
| 19 | + ], |
| 20 | +]); |
| 21 | + $wsheaders = get_headers($urlws, 1); |
| 22 | + if (is_array($wsheaders['Server'])) { $ws = $wsheaders['Server'][0];}else{ |
| 23 | + $ws = $wsheaders['Server']; |
| 24 | + } |
| 25 | + if ($ws == "") |
| 26 | + { |
| 27 | + echo "\e[91mCould Not Detect\e[0m"; |
| 28 | + } |
| 29 | + else |
| 30 | + { |
| 31 | + echo "\e[92m$ws \e[0m"; |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | + |
| 36 | +function cloudflaredetect($reallink){ |
| 37 | + |
| 38 | + $urlhh = "http://api.hackertarget.com/httpheaders/?q=" . $reallink; |
| 39 | + $resulthh = file_get_contents($urlhh); |
| 40 | + if (strpos($resulthh, 'cloudflare') !== false) |
| 41 | + { |
| 42 | + echo "\e[91mDetected\n\e[0m"; |
| 43 | + } |
| 44 | + else |
| 45 | + { |
| 46 | + echo "\e[92mNot Detected\n\e[0m"; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +function CMSdetect($reallink){ |
| 52 | + $cmssc = readcontents($reallink); |
| 53 | + if (strpos($cmssc, '/wp-content/') !== false) |
| 54 | + { |
| 55 | + $tcms = "WordPress"; |
| 56 | + |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + if (strpos($cmssc, 'Joomla') !== false) |
| 61 | + { |
| 62 | + $tcms = "Joomla"; |
| 63 | + } |
| 64 | + else |
| 65 | + { |
| 66 | + $drpurl = $reallink . "/misc/drupal.js"; |
| 67 | + $drpsc = readcontents("$drpurl"); |
| 68 | + if (strpos($drpsc, 'Drupal') !== false) |
| 69 | + { |
| 70 | + $tcms = "Drupal"; |
| 71 | + } |
| 72 | + else |
| 73 | + { |
| 74 | + if (strpos($cmssc, '/skin/frontend/') !== false) |
| 75 | + { |
| 76 | + $tcms = "Magento"; |
| 77 | + } |
| 78 | + else |
| 79 | + { |
| 80 | + if (strpos($cmssc, 'content="WordPress')!== false) { |
| 81 | + $tcms = "WordPress"; |
| 82 | + } |
| 83 | + else { |
| 84 | + |
| 85 | + |
| 86 | + $tcms = "\e[91mCould Not Detect"; |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + return $tcms; |
| 93 | +} |
| 94 | +function robotsdottxt($reallink){ |
| 95 | + $rbturl = $reallink . "/robots.txt"; |
| 96 | + $rbthandle = curl_init($rbturl); |
| 97 | + curl_setopt($rbthandle, CURLOPT_SSL_VERIFYPEER, false); |
| 98 | + curl_setopt($rbthandle, CURLOPT_RETURNTRANSFER, TRUE); |
| 99 | + $rbtresponse = curl_exec($rbthandle); |
| 100 | + $rbthttpCode = curl_getinfo($rbthandle, CURLINFO_HTTP_CODE); |
| 101 | + if ($rbthttpCode == 200) |
| 102 | + { |
| 103 | + $rbtcontent = readcontents($rbturl); |
| 104 | + if ($rbtcontent == "") |
| 105 | + { |
| 106 | + echo "Found But Empty!"; |
| 107 | + } |
| 108 | + else |
| 109 | + { |
| 110 | + echo "\e[92mFound \e[0m\n"; |
| 111 | + echo "\e[36m\n-------------[ contents ]---------------- \e[0m\n"; |
| 112 | + echo $rbtcontent; |
| 113 | + echo "\e[36m\n-----------[end of contents]-------------\e[0m"; |
| 114 | + } |
| 115 | + } |
| 116 | + else |
| 117 | + { |
| 118 | + echo "\e[91mCould NOT Find robots.txt! \e[0m\n"; |
| 119 | + } |
| 120 | +} |
| 121 | +function gethttpheader($reallink){ |
| 122 | + $hdr = get_headers($reallink); |
| 123 | + foreach ($hdr as $shdr) { |
| 124 | + echo "\n\e[92m\e[1m[i]\e[0m $shdr"; |
| 125 | + } |
| 126 | + echo "\n"; |
| 127 | + |
| 128 | +} |
| 129 | +function extract_social_links($sourcecode){ |
| 130 | + /* This is really a simple code for now i will work around it on the upcoming version. |
| 131 | + For now only these social media are supported: |
| 132 | + - Facebook |
| 133 | + - Twitter |
| 134 | + - Instagram |
| 135 | + - YouTube |
| 136 | + - Google + |
| 137 | + - Pinterest |
| 138 | + - GitHUB |
| 139 | + */ |
| 140 | + global $bold, $lblue, $fgreen, $red, $blue, $magenta, $orange, $white, $green, $grey, $cyan; |
| 141 | + $fb_link_count = 0; |
| 142 | + $twitter_link_count = 0; |
| 143 | + $insta_link_count = 0; |
| 144 | + $yt_link_count = 0; |
| 145 | + $gp_link_count = 0; |
| 146 | + $pint_link_count = 0; |
| 147 | + $github_link_count = 0; |
| 148 | + $total_social_link_count = 0; |
| 149 | + |
| 150 | + $social_links_array = array ( |
| 151 | + 'facebook' => array(), |
| 152 | + 'twitter' => array(), |
| 153 | + 'instagram' => array(), |
| 154 | + 'youtube' => array(), |
| 155 | + 'google_p' => array(), |
| 156 | + 'pinterest' => array(), |
| 157 | + 'github' => array() |
| 158 | + ); |
| 159 | + |
| 160 | + $fb_links = $social_links_array['facebook']; |
| 161 | + $twitter_links = $social_links_array['twitter']; |
| 162 | + $insta_links = $social_links_array['instagram']; |
| 163 | + $youtube_links = $social_links_array['youtube']; |
| 164 | + $googlep_links = $social_links_array['google_p']; |
| 165 | + $pinterest_links = $social_links_array['pinterest']; |
| 166 | + $github_links = $social_links_array['github']; |
| 167 | + |
| 168 | + $sm_dom = new DOMDocument; |
| 169 | + @$sm_dom->loadHTML($sourcecode); |
| 170 | + $links = $sm_dom->getElementsByTagName('a'); |
| 171 | + foreach ($links as $link) { |
| 172 | + $link = $link->getAttribute('href'); |
| 173 | + if (strpos ($link, "facebook.com/") !== false){ |
| 174 | + $total_social_link_count++; |
| 175 | + $fb_link_count++; |
| 176 | + array_push($social_links_array['facebook'], $link); |
| 177 | + } |
| 178 | + elseif (strpos ($link, "twitter.com/") !== false) { |
| 179 | + $total_social_link_count++; |
| 180 | + $twitter_link_count++; |
| 181 | + array_push($social_links_array['twitter'], $link); |
| 182 | + } |
| 183 | + elseif (strpos ($link, "instagram.com/") !== false) { |
| 184 | + $total_social_link_count++; |
| 185 | + $insta_link_count++; |
| 186 | + array_push($social_links_array['instagram'], $link); |
| 187 | + } |
| 188 | + elseif (strpos ($link, "youtube.com/") !== false) { |
| 189 | + $total_social_link_count++; |
| 190 | + $yt_link_count++; |
| 191 | + array_push($social_links_array['youtube'], $link); |
| 192 | + } |
| 193 | + elseif (strpos ($link, "plus.google.com/") !== false) { |
| 194 | + $total_social_link_count++; |
| 195 | + $gp_link_count++; |
| 196 | + array_push($social_links_array['google_p'], $link); |
| 197 | + } |
| 198 | + elseif (strpos ($link, "github.com/") !== false) { |
| 199 | + $total_social_link_count++; |
| 200 | + $github_link_count++; |
| 201 | + array_push($social_links_array['github'], $link); |
| 202 | + } |
| 203 | + elseif (strpos ($link, "pinterest.com/") !== false) { |
| 204 | + $total_social_link_count++; |
| 205 | + $pint_link_count++; |
| 206 | + array_push($social_links_array['pinterest'], $link); |
| 207 | + } |
| 208 | + else { |
| 209 | + // I know this has nothing to do with the code but again i love comments ;__; it's feels good to waste time :p |
| 210 | + } |
| 211 | + } |
| 212 | + if ($total_social_link_count == 0){ |
| 213 | + echo $bold . $red . "[!] No Social Link Found In Source Code. \n\e[0m"; |
| 214 | + } |
| 215 | + elseif ($total_social_link_count == "1") { |
| 216 | + // As much as i hate to admit grammer is important :p |
| 217 | + echo $bold . $lblue . "[i] " . $fgreen . $total_social_link_count . $lblue . " Social Link Was Gathered From Source Code \n\n"; |
| 218 | + foreach ($social_links_array['facebook'] as $link) { |
| 219 | + echo $bold . $blue . "[ facebook ] " . $white . $link . "\n"; |
| 220 | + } |
| 221 | + foreach ($social_links_array['twitter'] as $link) { |
| 222 | + echo $bold . $cyan . "[ twitter ] " . $white . $link . "\n"; |
| 223 | + } |
| 224 | + foreach ($social_links_array['instagram'] as $link) { |
| 225 | + echo $bold . $magenta . "[ instagram ] " . $white . $link . "\n"; |
| 226 | + } |
| 227 | + foreach ($social_links_array['youtube'] as $link) { |
| 228 | + echo $bold . $red . "[ youtube ] " . $white . $link . "\n"; |
| 229 | + } |
| 230 | + foreach ($social_links_array['google_p'] as $link) { |
| 231 | + echo $bold . $orange . "[ google+ ] " . $white . $link . "\n"; |
| 232 | + } |
| 233 | + foreach ($social_links_array['pinterest'] as $link) { |
| 234 | + echo $bold . $red . "[ pinterest ] " . $white . $link . "\n"; |
| 235 | + } |
| 236 | + foreach ($social_links_array['github'] as $link) { |
| 237 | + echo $bold . $grey . "[ github ] " . $white . $link . "\n"; |
| 238 | + } |
| 239 | + echo "\n"; |
| 240 | + } else { |
| 241 | + echo $bold . $lblue . "[i] " . $fgreen . $total_social_link_count . $lblue . " Social Links Were Gathered From Source Code \n\n"; |
| 242 | + foreach ($social_links_array['facebook'] as $link) { |
| 243 | + echo $bold . $blue . "[ facebook ] " . $white . $link . "\n"; |
| 244 | + } |
| 245 | + foreach ($social_links_array['twitter'] as $link) { |
| 246 | + echo $bold . $cyan . "[ twitter ] " . $white . $link . "\n"; |
| 247 | + } |
| 248 | + foreach ($social_links_array['instagram'] as $link) { |
| 249 | + echo $bold . $magenta . "[ instagram ] " . $white . $link . "\n"; |
| 250 | + } |
| 251 | + foreach ($social_links_array['youtube'] as $link) { |
| 252 | + echo $bold . $red . "[ youtube ] " . $white . $link . "\n"; |
| 253 | + } |
| 254 | + foreach ($social_links_array['google_p'] as $link) { |
| 255 | + echo $bold . $orange . "[ google+ ] " . $white . $link . "\n"; |
| 256 | + } |
| 257 | + foreach ($social_links_array['pinterest'] as $link) { |
| 258 | + echo $bold . $red . "[ pinterest ] " . $white . $link . "\n"; |
| 259 | + } |
| 260 | + foreach ($social_links_array['github'] as $link) { |
| 261 | + echo $bold . $grey . "[ github ] " . $white . $link . "\n"; |
| 262 | + } |
| 263 | + echo "\n"; |
| 264 | + } |
| 265 | +} |
| 266 | +function extractLINKS($reallink){ |
| 267 | + global $bold, $lblue, $fgreen; |
| 268 | + $arrContextOptions=array( |
| 269 | + "ssl"=>array( |
| 270 | + "verify_peer"=>false, |
| 271 | + "verify_peer_name"=>false, |
| 272 | + ), |
| 273 | + ); |
| 274 | + $ip = str_replace("https://","",$reallink); |
| 275 | + $lwwww = str_replace("www.","",$ip); |
| 276 | + $elsc = file_get_contents($reallink, false, stream_context_create($arrContextOptions)); |
| 277 | + $eldom = new DOMDocument; |
| 278 | + @$eldom->loadHTML($elsc); |
| 279 | + $elinks = $eldom->getElementsByTagName('a'); |
| 280 | + $elinks_count = 0; |
| 281 | + foreach ($elinks as $ec) { |
| 282 | + $elinks_count++; |
| 283 | + } |
| 284 | + echo $bold . $lblue . "[i] Number Of Links Found In Source Code : " . $fgreen . $elinks_count . "\n"; |
| 285 | + userinput("Display Links ? (Y/N) "); |
| 286 | + $bv_show_links = trim(fgets(STDIN, 1024)); |
| 287 | + if ($bv_show_links == "y" or $bv_show_links =="Y"){ |
| 288 | + foreach ($elinks as $elink) { |
| 289 | + $elhref = $elink->getAttribute('href'); |
| 290 | + if (strpos($elhref, $lwwww) !== false ) { |
| 291 | + echo "\n\e[92m\e[1m*\e[0m\e[1m $elhref"; |
| 292 | + |
| 293 | + } |
| 294 | + else { |
| 295 | + echo "\n\e[38;5;208m\e[1m*\e[0m\e[1m $elhref"; |
| 296 | + } |
| 297 | + } |
| 298 | + echo "\n"; |
| 299 | + } |
| 300 | + |
| 301 | +else { |
| 302 | + // not showing links. |
| 303 | +} |
| 304 | +} |
| 305 | +function readcontents($urltoread){ |
| 306 | + $arrContextOptions=array( |
| 307 | + "ssl"=>array( |
| 308 | + "verify_peer"=>false, |
| 309 | + "verify_peer_name"=>false, |
| 310 | + ), |
| 311 | + ); |
| 312 | + $filecntns = file_get_contents($urltoread, false, stream_context_create($arrContextOptions)); |
| 313 | + return $filecntns; |
| 314 | +} |
| 315 | + |
| 316 | +function MXlookup ($site){ |
| 317 | + $Mxlkp = dns_get_record($site, DNS_MX); |
| 318 | + $mxrcrd = $Mxlkp[0]['target']; |
| 319 | + $mxip = gethostbyname($mxrcrd); |
| 320 | + $mx = gethostbyaddr($mxip); |
| 321 | + $mxresult = "\e[1m\e[36mIP :\e[32m " . $mxip ."\n\e[36mHOSTNAME:\e[32m " . $mx ; |
| 322 | + return $mxresult; |
| 323 | +} |
| 324 | + |
| 325 | +function bv_get_alexa_rank($url){ |
| 326 | + $xml = simplexml_load_file("http://data.alexa.com/data?cli=10&url=".$url); |
| 327 | + if(isset($xml->SD)): |
| 328 | + return $xml->SD->POPULARITY->attributes()->TEXT; |
| 329 | + endif; |
| 330 | +} |
| 331 | +function bv_moz_info($url){ |
| 332 | + global $bold, $red, $fgreen, $lblue, $blue; |
| 333 | + require ("config.php"); |
| 334 | + if (strpos($accessID, " ") !== false OR strpos($secretKey, " ") !== false){ |
| 335 | + echo $bold . $red . "\n[!] Some Results Will Be Omited (Please Put Valid MOZ API Keys in config.php file)\n\n"; |
| 336 | + } |
| 337 | + else { |
| 338 | + $expires = time() + 300; |
| 339 | + $SignInStr = $accessID. "\n" .$expires; |
| 340 | + $binarySignature = hash_hmac('sha1', $SignInStr, $secretKey, true); |
| 341 | + $SafeSignature = urlencode(base64_encode($binarySignature)); |
| 342 | + $objURL = $url; |
| 343 | + $flags = "103079231492"; |
| 344 | + $reqUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objURL)."?Cols=".$flags."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$SafeSignature; |
| 345 | + $opts = array( |
| 346 | + CURLOPT_RETURNTRANSFER => true |
| 347 | + ); |
| 348 | + $curlhandle = curl_init($reqUrl); |
| 349 | + curl_setopt_array($curlhandle, $opts); |
| 350 | + $content = curl_exec($curlhandle); |
| 351 | + curl_close($curlhandle); |
| 352 | + $resObj = json_decode($content); |
| 353 | + echo $bold . $lblue . "[i] Moz Rank : " . $fgreen . $resObj->{'umrp'} . "\n"; |
| 354 | + echo $bold . $lblue . "[i] Domain Authority : " . $fgreen . $resObj->{'pda'} . "\n"; |
| 355 | + echo $bold . $lblue . "[i] Page Authority : " . $fgreen . $resObj->{'upa'} . "\n"; |
| 356 | + } |
| 357 | +} |
| 358 | +?> |
0 commit comments