Jump to content

User:ClueBot IV/Source

From Wikipedia, the free encyclopedia

The following is automatically generated by ClueBot IV.


  • wikibot.classes.php is here.


Source to ClueBot IV

[edit]
<?PHP
	include '../wikibot.classes.php';
	include 'cluebot4.config.php';

	$wpq = new wikipediaquery;
	$wpapi = new wikipediaapi;
	$wpi = new wikipediaindex;

	$wpapi->login($user,$pass);

	$wpi->forcepost('User:'.$user.'/Source',
		'The following is automatically generated by [[User:'.$user.'|'.$user."]].\n\n\n\n" .
		'* wikibot.classes.php is [[User:ClueBot/Source|here]].' .
		"\n\n\n\n==Source to ".$user."==\n\n" .
		'<pre>'.htmlentities(file_get_contents(__FILE__))."</pre>\n\n\n\n~~~~",
		'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */

	while (1) {
		foreach (array(false,true) as $postround) {
			$data = $wpq->getpage('Wikipedia:WikiProject on open proxies');
			$data = str_ireplace('{{proxyip2|','{{proxyip2|',$data);
			$header = explode('{{proxyip2|',$data,2);
			$data = '{{proxyip2|'.$header[1];
			$header = $header[0];
			$datatopost = $header;
			$changed = false;
			preg_match_all('/\{\{proxyip2\|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\}\}\s*\|\|\s*(\S.*)(?=\{\{proxyip2\|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\}\}\s*\|\|\s*\S.*|$)/Us',$data,$m,PREG_SET_ORDER);
//			print_r($m);
			foreach ($m as &$request) {
//				$request[2] = str_replace("\n|-\n","\n",$request[2]);
				if ((!preg_match('/\{\{(notaproxy|oproxy|opblocked|thrown( |_)out|inconclusive|noproxy|clerk( |_)note)\}\}/i',$request[2])) and ($request[1] != '127.0.0.1')) {
					if ($postround == false) {
						if ($wpq->getpage('User:'.$user.'/WPOPreports/'.$request[1])) continue;
						print_r($request);
//						$nmapresults = shell_exec('nmap -A --version-all -T5 -P0 -p $((cd ~/flexscan/flexscan-pack-1/staging; ./bin/flexscan ./lib/ipsubnetlist.in.fxsmod,'.escapeshellarg($request[1]).'/32 ./lib/portlist.mid.fxsmod,1-65535 ./lib/delaybuffer.mid.fxsmod,10,10 ./lib/synspawn.mid.fxsmod,dev=eth0,timeout=60 ./lib/filterlist.mid.fxsmod,portstate,closed,block ./lib/filterlist.mid.fxsmod,portstate,unknown,block ./lib/filterlist.mid.fxsmod,portstate,skipped,block ./lib/rawmap.out.fxsmod)|grep \'(Data)\'|awk \'{print $4}\'|awk -F= \'{print $2","}\'|sort -un|xargs|sed -r \'s| ||g\') '.escapeshellarg($request[1]).' |grep -v \'NEXT SERVICE FINGERPRINT\'|grep -v \'SF:\'|grep -v \'SF-\'');
						$nmapresults = shell_exec('nmap -A --version-all -T5 -P0 -p 1-65535 '.escapeshellarg($request[1]).' |grep -v \'NEXT SERVICE FINGERPRINT\'|grep -v \'SF:\'|grep -v \'SF-\'');
						echo $nmapresults."\n";

						$ports = array();
						$nr = explode("\n",$nmapresults);
						foreach ($nr as $res) {
							if (strpos($res,'/tcp')) {
								$port = explode('/tcp',$res,2);
								$ports[] = escapeshellarg($port[0]);
							}
						}
			
						if (count($ports) > 0) {

							echo '$ perl ~/bopchecker.pl '.escapeshellarg($request[1]).' '.implode(' ',$ports)."\n";
							$checkresults = shell_exec('perl ~/bopchecker.pl '.escapeshellarg($request[1]).' '.implode(' ',$ports));
							echo $checkresults;

							$endresult = explode(' ',str_replace(array("\n","\r"),'',$checkresults),3);
							if ($endresult[1] == 'open') {
								$endresult = 'Open proxy.';
								$endresult2 = '{{oproxy}}';
							} elseif ($endresult[1] == 'closed') {
								$endresult = 'No proxy found.';
								$endresult2 = '{{notaproxy}}';
							} else {
								$endresult = 'Inconclusive.';
								$endresult2 = '{{inconclusive}}';
							}
						} else {
							$endresult = 'No open ports.  No proxy found.';
							$endresult2 = '{{notaproxy}}';
						}

						$dnsbldata = '==DNSBL=='."\n";
						$dnsblip = implode('.',array_reverse(explode('.',$request[1])));

						foreach ($dnsbls as $dnsblname => $dnsbl) {
							$tmpdnsblresult = gethostbyname($dnsblip.'.'.$dnsbl['zone']);
							$lastdigit = explode('.',$tmpdnsblresult);
							$lastdigit = $lastdigit[3];
							if (long2ip(ip2long($tmpdnsblresult)) != $tmpdnsblresult) $tmpdnsblresult = 'Nothing.';
							if (!isset($dnsbl['ret'][$lastdigit]) and ($dnsbl['bunk'] == false)) $tmpdnsblresult = 'Nothing.';
							$dnsbldata .= '* '.$dnsblip.'.'.$dnsbl['zone'].' ('.$dnsblname.') = '.$tmpdnsblresult;
							if ($tmpdnsblresult != 'Nothing.') {
								if (isset($dnsbl['ret'][$lastdigit])) { $dnsbldata .= ' ('.$dnsbl['ret'][$lastdigit].')'; }
								else { $dnsbldata .= ' (unknown)'; }
							}
							$dnsbldata .= ' &mdash;  ['.str_replace('%i',$request[1],$dnsbl['url'])." more information].\n";
						}
						unset($dnsblip,$dnsblname,$dnsbl,$tmpdnsblresult,$lastdigit);
						$dnsbldata .= "\n";

						$wpi->post('User:'.$user.'/WPOPreports/'.$request[1],
							'<noinclude>{{#ifexpr:{{#time:U}} >= '.(time() + (30*24*60*60)).'|{{db-user}}}}'."\n" .
							'* IP: '.$request[1]."\n" .
							'* End result: '.$endresult2.' '.$endresult."\n" .
							'* Reverse DNS: '.gethostbyaddr($request[1])."\n\n" .
							'==Whois=='."\n<pre>".htmlentities(shell_exec('whois '.escapeshellarg($request[1])))."</pre>\n\n" .
							$dnsbldata .
							((count($ports) > 0)?'==NMap=='."\n".'<pre>'.htmlentities($nmapresults).'</pre>'."\n\n".'==Proxy Check=='."\n".'<pre>'.htmlentities($checkresults).'</pre>'."\n":'').
							'</noinclude>' .
							'<includeonly>' .
							'A proxy scan report on '.$request[1].' is available [[User:'.$user.'/WPOPreports/'.$request[1].'|here]].  The end result was: '.$endresult."\n\n" .
							'</includeonly>',
							'Uploading report on '.$request[1].'.');
					} else {
						if ($wpq->getpage('User:'.$user.'/WPOPreports/'.$request[1])) {
							if (strpos($request[2],'|-') !== false) {
								$tmp = explode('|-',$request[2],2);
								$tmp[0] .= ':{{clerk note}} {{#ifexist:User:'.$user.'/WPOPreports/'.$request[1].'|{{User:'.$user.'/WPOPreports/'.$request[1].'}}|Report page has been deleted.}} ~~~~'."\n";
								$request[2] = implode('|-',$tmp);
							} elseif (strpos($request[2],'|}') !== false) {
								$tmp = explode('|}',$request[2],2);
								$tmp[0] .= ':{{clerk note}} {{#ifexist:User:'.$user.'/WPOPreports/'.$request[1].'|{{User:'.$user.'/WPOPreports/'.$request[1].'}}|Report page has been deleted.}} ~~~~'."\n";
								$request[2] = implode('|}',$tmp);
							} else {
								$request[2] .= ':{{clerk note}} {{#ifexist:User:'.$user.'/WPOPreports/'.$request[1].'|{{User:'.$user.'/WPOPreports/'.$request[1].'}}|Report page has been deleted.}} ~~~~'."\n";
							}
							$changed = true;
						}
					}
				}
				if ($postround == true) { $datatopost .= '{{proxyip2|'.$request[1].'}} || '.$request[2]; }
			}
			if (($postround == true) and (trim($datatopost) != '') and ($changed == true)) {
//				$wpi->post('User:'.$user.'/WPOPsandbox',
				$wpi->post('Wikipedia:WikiProject on open proxies',
					$datatopost,
					'Adding clerk notices.');
			}
		}
		sleep(300);
	}
?>


ClueBot IV (talk) 07:32, 6 January 2010 (UTC)