-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
orhan osmanağaoğlu
authored
Sep 10, 2021
0 parents
commit 5b7fe42
Showing
51 changed files
with
2,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace App; | ||
|
||
class App | ||
{ | ||
public function init() | ||
{ | ||
//will be called when extension init | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
class HomeController | ||
{ | ||
public function index() | ||
{ | ||
return view('index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
use Liman\Toolkit\Shell\Command; | ||
|
||
class HostnameController | ||
{ | ||
public function get() | ||
{ | ||
$deger = Command::runSudo("ls -la"); | ||
|
||
return respond($deger, 200); | ||
} | ||
|
||
public function set() | ||
{ | ||
validate([ | ||
'hostname' => 'required|string' | ||
]); | ||
|
||
$deger = Command::run("echo ", [ | ||
"degiskenIsmi" => request("hostname") | ||
]); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
class RunScriptController | ||
{ | ||
public function run() | ||
{ | ||
// runScript function | ||
// 1st parameter: filename under scripts folder STRING | ||
// 2nd parameter: parameters STRING | ||
// 3nd parameter: run as sudo BOOL | ||
$script = runScript("example.py", "", false); | ||
|
||
return $script; | ||
} | ||
|
||
public function test() | ||
{ | ||
validate([ | ||
'testJavascriptVerisi' => 'required|string|max:255' | ||
]); | ||
|
||
checkPort("10.0.0.100", 22); | ||
|
||
$istekVerisi = request("testJavascriptVerisi"); | ||
|
||
server()->name; | ||
server()->ip_address; | ||
|
||
user()->name; | ||
user()->email; | ||
|
||
respond($istekVerisi, 201); | ||
|
||
view("alert", [ | ||
"type" => "danger", | ||
"title" => "Örnek Alert", | ||
"message" => "Mesajınızı buraya yazabilirsiniz." | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
use Liman\Toolkit\Shell\Command; | ||
|
||
class SystemInfoController | ||
{ | ||
public function get() | ||
{ | ||
$systeminfo = Command::runSudo('lshw -html'); | ||
return respond($systeminfo, strlen($systeminfo) ? 200 : 404); | ||
} | ||
|
||
public function install() | ||
{ | ||
return respond( | ||
view('taskview.task', [ | ||
'onFail' => 'onTaskFail', | ||
'onSuccess' => 'onTaskSuccess', | ||
'tasks' => [ | ||
0 => [ | ||
'name' => 'Lshw', | ||
'attributes' => [] | ||
] | ||
] | ||
]), | ||
200 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Controllers; | ||
|
||
use Liman\Toolkit\RemoteTask\TaskManager; | ||
|
||
class TaskController | ||
{ | ||
public function runTask() | ||
{ | ||
$taskName = request('name'); | ||
$attributes = (array) json_decode(request('attributes')); | ||
return respond(TaskManager::get($taskName, $attributes)->run()); | ||
} | ||
|
||
public function checkTask() | ||
{ | ||
$taskName = request('name'); | ||
$attributes = (array) json_decode(request('attributes')); | ||
return respond(TaskManager::get($taskName, $attributes)->check()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
use Liman\Toolkit\Shell\Command; | ||
|
||
class TaskManagerController | ||
{ | ||
function getList() | ||
{ | ||
// Komut çalıştırdık | ||
$cmd = Command::runSudo("ps -Ao user,pid,pcpu,stat,unit,pmem,comm --sort=-pcpu"); | ||
|
||
// Komutu newline ile böldük | ||
$cmd = explode("\n", $cmd); | ||
|
||
// İlk satırı attık | ||
array_splice($cmd, 0, 1); | ||
|
||
// her satır üzerinde işlem yapalım. | ||
foreach ($cmd as $key => &$process) | ||
{ | ||
// fazlalık boşluklarımı sildim | ||
$process = preg_replace('/\s+/', ' ', $process); | ||
|
||
// boşluklara göre parçalayalım | ||
$process = explode(" ", $process); | ||
|
||
// veriyi formatlayalim | ||
$process = [ | ||
"user" => $process[0], | ||
"pid" => $process[1], | ||
"cpu" => $process[2], | ||
"status" => $process[3], | ||
"service" => $process[4], | ||
"ram" => $process[5], | ||
"command" => $process[6] | ||
]; | ||
} | ||
|
||
return view("table", [ | ||
"value" => $cmd, | ||
"display" => ["user", "pid", "cpu", "status", "service", "ram", "command"], | ||
"title" => ["Kullanıcı", "PID", "% İşlemci", "Durum", "Servis", "% Bellek", "İşlem"], | ||
"menu" => [ | ||
"Dosya Konumu" => [ | ||
"target" => "jsGetFileLocation", | ||
"icon" => "fa-location-arrow" | ||
], | ||
"Servis Durumu" => [ | ||
"target" => "jsGetServisDurum", | ||
"icon" => "fa-address-book" | ||
], | ||
"Islem Agaci" => [ | ||
"target" => "jsGetIslemAgaci", | ||
"icon" => "fa-address-book" | ||
], | ||
"Calitirma Arguman" => [ | ||
"target" => "jsGetCalitirmaArguman", | ||
"icon" => "fa-address-book" | ||
], | ||
"Islem sonlandir" => [ | ||
"target" => "jsGetIslemSonlandir", | ||
"icon" => "fa-address-book" | ||
], | ||
"Tum Islem sonlandir" => [ | ||
"target" => "jsGetTumIslemSonlandir", | ||
"icon" => "fa-address-book" | ||
], | ||
] | ||
]); | ||
} | ||
|
||
function getFileLocation() | ||
{ | ||
validate([ | ||
"pid" => "required|numeric" | ||
]); | ||
|
||
$location = Command::runSudo("readlink -f /proc/@{:pid}/exe", [ | ||
"pid" => request("pid") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
function getServisDurum() | ||
{ | ||
validate([ | ||
"service" => "required|string" | ||
]); | ||
|
||
$location = Command::runSudo("systemctl status @{:service}", [ | ||
"service" => request("service") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
function getIslemAgaci() | ||
{ | ||
validate([ | ||
"pid" => "required|numeric" | ||
]); | ||
|
||
$location = Command::runSudo("ps f -g @{:pid}", [ | ||
"pid" => request("pid") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
function getCalitirmaArguman() | ||
{ | ||
validate([ | ||
"command" => "required|string" | ||
]); | ||
|
||
$location = Command::runSudo("man @{:command}", [ | ||
"command" => request("command") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
function getIslemSonlandir() | ||
{ | ||
validate([ | ||
"pid" => "required|numeric" | ||
]); | ||
|
||
$location = Command::runSudo("kill @{:pid}", [ | ||
"pid" => request("pid") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
function getTumIslemSonlandir() | ||
{ | ||
validate([ | ||
"command" => "required|string" | ||
]); | ||
|
||
$location = Command::runSudo("pkill @{:command}", [ | ||
"command" => request("command") | ||
]); | ||
|
||
return respond($location); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
class TaskViewController | ||
{ | ||
public function run() | ||
{ | ||
return respond( | ||
view('taskview.task', [ | ||
'onFail' => 'onTaskFail', | ||
'onSuccess' => 'onTaskSuccess', | ||
'tasks' => [ | ||
0 => [ | ||
'name' => 'Example', | ||
'attributes' => [] | ||
] | ||
] | ||
]), | ||
200 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
namespace App\Controllers; | ||
|
||
use Liman\Toolkit\Shell\Command; | ||
|
||
class dosyaListeControlller | ||
{ | ||
function getList() | ||
{ | ||
// Komut çalıştırdık | ||
$cmd = Command::run("ls -la /home/sysadmin/orhan"); | ||
|
||
|
||
// Komutu newline ile böldük | ||
$cmd = explode("\n", $cmd); | ||
|
||
// İlk satırı attık | ||
array_splice($cmd, 0, 1); | ||
|
||
// her satır üzerinde işlem yapalım. | ||
foreach ($cmd as $key => &$process) | ||
{ | ||
// fazlalık boşluklarımı sildim | ||
$process = preg_replace('/\s+/', ' ', $process); | ||
|
||
// boşluklara göre parçalayalım | ||
$process = explode(" ", $process); | ||
|
||
// veriyi formatlayalim | ||
$process = [ | ||
"izinler" => $process[0], | ||
"pid" => $process[1], | ||
"kullanıcı" => $process[2], | ||
"grup" => $process[3], | ||
"boyut" => $process[4], | ||
"tarih" => $process[5].$process[6].$process[7], | ||
"dosyaad" => $process[8] | ||
]; | ||
} | ||
|
||
return view("table", [ | ||
"value" => $cmd, | ||
"display" => ["izinler", "pid", "kullanıcı", "grup", "boyut", "tarih", "dosyaad"], | ||
"title" => ["İzin", "ID", "Oluşturan", "Grup", "Boyut", "Tarih", "Dosya adı"], | ||
"menu" => [ | ||
/* "Dosya Konumu" => [ | ||
"target" => "jsGetFileLocation", | ||
"icon" => "fa-location-arrow" | ||
], | ||
"Servis Durumu" => [ | ||
"target" => "jsGetServisDurum", | ||
"icon" => "fa-address-book" | ||
],*/ | ||
] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
if (!function_exists('checkPort')) { | ||
function checkPort($ip, $port) | ||
{ | ||
restoreHandler(); | ||
if ($port == -1) { | ||
return true; | ||
} | ||
$fp = @fsockopen($ip, $port, $errno, $errstr, 0.1); | ||
setHandler(); | ||
if (!$fp) { | ||
return false; | ||
} else { | ||
fclose($fp); | ||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.