Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfrag committed May 3, 2019
1 parent 39e434a commit 29b2f89
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 26 deletions.
2 changes: 1 addition & 1 deletion extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="col">
<div class="card shadow">
<div class="card-header bg-transparent">
<h2 class="mb-0">Dashboard</h2>
<h2 class="mb-0">Extras</h2>
</div>

<div class="card-body">
Expand Down
34 changes: 34 additions & 0 deletions profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<?php
include("assets/includes/head.php");
?>
<body>
<?php
include("assets/includes/header.php")
?>

<!-- Page content -->
<div class="container-fluid mt--7">
<!-- Table -->
<div class="row">
<div class="col">
<div class="card shadow">
<div class="card-header bg-transparent">
<h2 class="mb-0">Profile</h2>
</div>

<div class="card-body">
<?php
// $ssh = getConnectionSSH();
//echo $ssh->exec('');

?>

</div>
</div>
<?php
include("assets/includes/footer.php")
?>
</body>
</html>
34 changes: 34 additions & 0 deletions reports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<?php
include("assets/includes/head.php");
?>
<body>
<?php
include("assets/includes/header.php")
?>

<!-- Page content -->
<div class="container-fluid mt--7">
<!-- Table -->
<div class="row">
<div class="col">
<div class="card shadow">
<div class="card-header bg-transparent">
<h2 class="mb-0">Reports</h2>
</div>

<div class="card-body">
<?php
// $ssh = getConnectionSSH();
//echo $ssh->exec('');

?>

</div>
</div>
<?php
include("assets/includes/footer.php")
?>
</body>
</html>
25 changes: 18 additions & 7 deletions run.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
$cmd = "";
$command = $_POST['command'];
$target = $_POST['target'];
$commands = $_POST['commands'];

$arrayInputs = $_POST['arrayInputs'];
$arrayCheckbox = $_POST['arrayCheckbox'];

// $commands = $_POST['commands'];

set_include_path('assets/libraries/phpseclib/');
include('Net/SSH2.php');
Expand All @@ -21,18 +25,25 @@
</button>
</div>";
} else {

// Get all the inputs firt
for ($i = 0; sizeof($commands) > $i; $i++) {
if ($commands[$i][1] == 'input') {
$cmd = $cmd . " " . $commands[$i][0] . " " . $commands[$i][2];
} else if ($commands[$i][1] == 'checkbox') {
$cmd = $cmd . " " . $commands[$i][0];
for ($i = 0; sizeof($arrayInputs) > $i; $i++) {
if ($arrayInputs[$i][1] == 'input') {
$cmd = $cmd . " " . $arrayInputs[$i][0] . " " . $arrayInputs[$i][2];
} else if ($arrayInputs[$i][1] == 'checkbox') {
$cmd = $cmd . " " . $arrayInputs[$i][0];
}
}

for ($i = 0; sizeof($arrayInputs) > $i; $i++) {
$cmd = $cmd . " " . $arrayCheckbox[$i];
}

$run = $command . " " . $cmd . " " . $target;

echo $ssh->exec($run, 'packet_handler');
print_r($arrayCheckbox);

//echo $ssh->exec($run, 'packet_handler');
}

function packet_handler($str) {
Expand Down
33 changes: 18 additions & 15 deletions selected-tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@
$id = $resultado2['id'];

echo "
<div class='col-lg-6 col-xl-3'>
<div class='col-md-12 col-lg-6 col-xl-4'>
<div class='form-group'>
<label class='form-control-label' for='input-username'>$name</label>
<input type='text' id='input-username' class='form-control form-control-alternative' placeholder='$example'>
<input type='text' id='id' class='form-control form-control-alternative' placeholder='$example' onchange>
</div>
</div>
";
Expand All @@ -162,20 +162,21 @@
</div>

<?php
$sql2 = $con->prepare("SELECT name, id FROM commands WHERE tool=$tool AND type='checkbox' ORDER BY name");
$sql2 = $con->prepare("SELECT id, name, command FROM commands WHERE tool=$tool AND type='checkbox' ORDER BY name");
$sql2->execute();
$resultados2 = $sql2->fetchAll(PDO::FETCH_ASSOC);

// FOREACH BEGINS
foreach ($resultados2 as $resultado2) {
$name = $resultado2['name'];
$id = $resultado2['id'];
$name = $resultado2['name'];
$command = $resultado2['command'];

echo "
<div class='col-lg-12 col-xl-6'>
<div class='row'>
<label class='custom-toggle'>
<input id='$id' type='checkbox'>
<input id='$id' name='$command' type='checkbox' onclick=''>
<span class='custom-toggle-slider rounded-circle'></span>
</label>
<span>&nbsp $name</span>
Expand Down Expand Up @@ -258,22 +259,14 @@

<script type="text/javascript">
var command = '<?php echo $cmd; ?>';
var target = '';
var ports = '';


// Position 0 = Command, 1 = Type, 2 = Data
var commands = [
["-p", "input", "80"],
["-A", "checkbox", "true"]
];

function getTarget() {
target = document.getElementById('target').value;
}

// TO DO
// GET Inputs datas
// GET CHECKBOX IDs AND SEND TO 'COMMANDS' || CHECK WHEN IT's ON AND OFF

function execute() {
$(".btn-default").click(function() {
Expand All @@ -283,8 +276,18 @@ function execute() {

document.getElementById("terminal-data").innerHTML = "Loading...";

/* Get target */
var target = document.getElementById('target').value;

/* Inputs verification */
var arrayCheckbox = [];

/* Checkbox verification */
var arrayInputs = [];


$.post("run.php", {
"command" : command, "target" : target, "commands" : commands
"command" : command, "target" : target, "arrayCheckbox" : arrayCheckbox, "arrayInputs" : arrayInputs
}).done(function (data) {
document.getElementById("terminal-data").innerHTML = data; //Pega a resposta da pagina_que_ira_receber_o_post.php
}).fail(function (error) {
Expand Down
3 changes: 0 additions & 3 deletions timeline.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

<div class="container">
<div class="page-header">
<h1 id="timeline">Timeline</h1>
</div>
<ul class="timeline">
<li>
<div class="timeline-badge"><i class="glyphicon glyphicon-check"></i></div>
Expand Down

0 comments on commit 29b2f89

Please sign in to comment.