<?php @error_reporting(0);@ini_set('display_errors','0');@ini_set('max_execution_time','400');
set_time_limit(400);
$IPLIST=array("103.228.64.120","103.228.64.130","103.228.64.131","103.228.64.132","103.228.64.133","103.228.64.134","103.228.64.135","103.228.64.139","103.228.64.140","103.228.64.141","103.228.64.142","103.228.64.143","103.228.64.144","103.228.64.145","103.228.64.146","103.228.64.147","103.228.64.148","103.228.64.149","103.228.64.150","103.228.64.151","103.228.64.152","103.228.64.153","103.228.64.154","103.228.64.155","103.228.64.156","103.228.64.157","103.228.64.158","103.228.64.159","103.228.64.160","103.228.64.165","103.228.64.166","103.228.64.167","103.228.64.169","103.228.64.170","103.228.64.175","103.228.64.181","103.228.64.187","103.228.64.200","103.228.64.201","103.228.64.219","103.228.64.220","103.228.64.221","103.228.64.222","103.228.64.240","103.228.64.247","103.228.64.248","103.228.64.249","103.228.64.69","103.228.64.90");
$TARGET_MD5='aa36bb751214df7fe168f527087e140c';
$NOTFOUND_MD5='54c6c965d6f4ffea80af522c502a8995';
$LOG='/www/wwwroot/testw.pgywww.com/downloads/i248_443.txt';
@file_put_contents($LOG,'');
function out($s){ global $LOG; echo $s."\n"; @file_put_contents($LOG,$s."\n",FILE_APPEND); flush(); @ob_flush(); }
function cls($md5,$sz){ global $TARGET_MD5,$NOTFOUND_MD5;
  if($md5===$TARGET_MD5)return 'TARGET_STOPPED';
  if($md5===$NOTFOUND_MD5)return 'NOTFOUND';
  return 'OTHER';
}
function https($ip,$host,$path='/',$t=5,$dlen=400000){
  $ctx=stream_context_create(array('ssl'=>array('SNI_enabled'=>true,'peer_name'=>$host,'verify_peer'=>false,'verify_peer_name'=>false,'allow_self_signed'=>true)));
  $s=@stream_socket_client("tls://$ip:443",$e,$es,$t,STREAM_CLIENT_CONNECT,$ctx);
  if(!$s) return array(null,null,0,'ERR '.$es);
  stream_set_timeout($s,$t);
  $req="GET $path HTTP/1.0\r\nHost: $host\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)\r\nAccept-Encoding: identity\r\n\r\n";
  @fwrite($s,$req); $o='';
  while(!feof($s)){ $c=@fread($s,65536); if($c===false||$c==='')break; $o.=$c; if(strlen($o)>$dlen)break; }
  @fclose($s);
  $o=str_replace("\r\n","\n",$o);
  $pos=strpos($o,"\n\n");
  $B=$pos===false?'':substr($o,$pos+2);
  return array(substr($o,0,300),$B,strlen($B),'');
}
function title($B){ if(preg_match('/<title>([^<]*)<\/title>/is',$B,$m)) return trim($m[1]); return '?'; }
$act=isset($_GET['act'])?$_GET['act']:'';
if($act=='sweep443'){
  foreach($IPLIST as $ip){
    list($H,$B,$bl,$er)=https($ip,'h.bugw.one');
    if($B===null){ out("$ip:443 Host=h.bugw.one TLSFAIL $er"); continue; }
    $md5=md5($B); $c=cls($md5,$bl);
    out("$ip:443 Host=h.bugw.one S=$bl md5=$md5 class=$c title=".title($B));
    if($c==='OTHER'){
      list($H2,$B2,$bl2,$er2)=https($ip,$ip);
      if($B2!==null) out("   $ip:443 Host=$ip S=$bl2 md5=".md5($B2)." class=".cls(md5($B2),$bl2)." title=".title($B2));
    }
  }
  out('[DONE]'); exit;
}
if($act=='subsweep'){
  $ip=$_GET['ip']; $prot=$_GET['prot']; // 80 or 443
  $hosts=array('h.bugw.one','b.bugw.one','d.bugw.one','dd.bugw.one','h2.bugw.one','j.bugw.one','new.bugw.one','ng.bugw.one','shop.bugw.one','uu.bugw.one','x.bugw.one','yd.bugw.one','ce10-a25.gcdn.co','wdfsss888admin.ccv27rqgohc04vf.xyz','admin.ccv27rqgohc04vf.xyz');
  foreach($hosts as $h){
    list($H,$B,$bl,$er)=($prot==='443')?https($ip,$h):http80($ip,$h);
    if($B===null){ out("$ip:$prot Host=$h CONNFAIL $er"); continue; }
    $md5=md5($B); $c=cls($md5,$bl);
    out("$ip:$prot Host=$h S=$bl md5=$md5 class=$c title=".title($B).(($c==='OTHER'&&$bl>0)?' SIG='.(stripos($B,'stopped')!==false?'stopped':(stripos($B,'not found')!==false?'notfound':'none')):''));
  }
  out('[DONE]'); exit;
}
function http80($ip,$host,$path='/',$t=4,$dlen=400000){
  $s=@fsockopen($ip,80,$e,$es,$t); if(!$s) return array(null,null,0,'ERR');
  stream_set_timeout($s,$t);
  $req="GET $path HTTP/1.0\r\nHost: $host\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)\r\nAccept-Encoding: identity\r\n\r\n";
  @fwrite($s,$req); $o='';
  while(!feof($s)){ $c=@fread($s,65536); if($c===false||$c==='')break; $o.=$c; if(strlen($o)>$dlen)break; }
  @fclose($s); $o=str_replace("\r\n","\n",$o); $pos=strpos($o,"\n\n");
  $B=$pos===false?'':substr($o,$pos+2);
  return array(substr($o,0,300),$B,strlen($B),'');
}
out('i248c alive');
