From ac2ff8a7a767fa46a27ef9a434d147d7a032d01d Mon Sep 17 00:00:00 2001
From: "leo.muff" <leomuffmail@gmail.com>
Date: Tue, 24 Oct 2023 18:08:05 +0200
Subject: [PATCH] frontend ptdr

---
 c2/templates/client.html.tera  | 74 +++++++++++++++++++---------------
 c2/templates/clients.html.tera | 21 +++-------
 rat/src/errors.rs              |  1 -
 3 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/c2/templates/client.html.tera b/c2/templates/client.html.tera
index faa21e3..d99ceea 100644
--- a/c2/templates/client.html.tera
+++ b/c2/templates/client.html.tera
@@ -1,41 +1,48 @@
 
 {% extends "base" %}
 {% block content %}
-    <a href="/newcommand/{{id}}"> Commands </a>
-    <div>
-      <h3>Info from client @ {{client}}</h3>
-      <div class="card">
-        <ul class="list-group list-group-flush">
-          <li class="list-group-item"><b>Adresse :</b> {{info.socket_addr}}</li>
-          <li class="list-group-item"><b>Username :</b> {{info.username}}</li>
-          <li class="list-group-item"><b>Hostname :</b> {{info.hostname}}</li>
-          <li class="list-group-item"><b>OS :</b> {{info.distrib}}</li>
-          <li class="list-group-item"><b>Kernel :</b> {{info.kernel}}</li>
-        </ul>
-      </div>
-      <h3>Open Ports</h3>
-      <div>
-        <table class="table" id="ports" name="ports">
-          <thead>
-            <tr>
-              <th scope="col">Port</th>
-              <th scope="col">Protocol</th>
-            </tr>
-          </thead>
-          <tbody>
-            {% for port in ports %}
-                <tr>
-                  <th scope="row">{{port.port}}</th>
-                  <td class="mw-20">{{port.protocol}}</td>
-                </tr>
-            {% endfor %}
-          </tbody>
-        </table>
+    <div class="mt-4" style="text-align:center">
+      <h2>Info from client @ {{client}}</h3>
+      <a href="/newcommand/{{id}}"  class="m-2 mb-4 text-center btn btn-secondary active" role="button" aria-pressed="true" > Commands </a>
+    </div>
+    <div class="mx-auto w-75 border p-5" > 
+      <div class="row">
+        <div class="col">
+        <h3 style="margin-bottom:90px">System Info</h3> 
+          <div class="card" >
+            <ul class="list-group list-group-flush">
+              <li class="list-group-item"><b>Adresse :</b> {{info.socket_addr}}</li>
+              <li class="list-group-item"><b>Username :</b> {{info.username}}</li>
+              <li class="list-group-item"><b>Hostname :</b> {{info.hostname}}</li>
+              <li class="list-group-item"><b>OS :</b> {{info.distrib}}</li>
+              <li class="list-group-item"><b>Kernel :</b> {{info.kernel}}</li>
+            </ul>
+          </div>
+        </div>
+        <div class="col">
+        <h3>Open Ports</h3>
+          <table class="table" id="ports" name="ports">
+            <thead>
+              <tr>
+                <th scope="col">Port</th>
+                <th scope="col">Protocol</th>
+              </tr>
+            </thead>
+            <tbody>
+              {% for port in ports %}
+                  <tr>
+                    <th scope="row">{{port.port}}</th>
+                    <td class="mw-20">{{port.protocol}}</td>
+                  </tr>
+              {% endfor %}
+            </tbody>
+          </table>
+        </div>
       </div>
     </div>
-    <h3>Data sent</h3>
-    <div>
-      <table class="table">
+    <h3 class="mt-5" style="text-align:center">Data sent</h3>
+    <div class="w-75 mx-auto mt-2">
+      <table class="table" id="data">
         <thead>
           <tr>
             <th scope="col">Id</th>
@@ -60,5 +67,6 @@
   <script src="/static/datatables/datatables.min.js"></script>
   <script>
     new DataTable('#ports');
+    new DataTable('#data');
   </script>
 {% endblock scripts %}
\ No newline at end of file
diff --git a/c2/templates/clients.html.tera b/c2/templates/clients.html.tera
index 9898d3d..223ada5 100644
--- a/c2/templates/clients.html.tera
+++ b/c2/templates/clients.html.tera
@@ -1,8 +1,8 @@
 {% extends "base" %}
 {% block content %}
-    <h2>Registered clients</h2>
-    <div>
-      <table class="table">
+    <h2 class="m-4">Registered clients</h2>
+    <div class="w-75 mx-auto mt-5">
+      <table class="table border">
         <thead>
           <tr>
             <th scope="col">Id</th>
@@ -16,20 +16,9 @@
               <tr>
                 <th scope="row">{{client.id}}</th>
                 <td>{{client.address}}</td>
-                <td><a href="client/{{client.id}}"> Data </a></td>
+                <td><a href="client/{{client.id}}" class="btn btn-secondary active" role="button" aria-pressed="true"> Data </a></td>
                 <td>
-                  <form action="/newcommand" method="post">
-                    <label for="command">Choose a command :</label>
-                    <select id="command" name="command">
-                      {% for c in commands %}
-                        <option value="{{loop.index}}">{{c}}</option>
-                      {% endfor %}  
-                    </select>
-                    <input type="text" placeholder="Option" name=option/>
-                    <input name="client_id" type="hidden" value={{client.id}} />
-                    <input type="submit" /> 
-                  </form>
-                  <a href="/newcommand/{{client.id}}"> Commands </a>
+                  <a href="/newcommand/{{client.id}}" class="btn btn-secondary active" role="button" aria-pressed="true"> Commands </a>
                 </td>
               </tr>
           {% endfor %}
diff --git a/rat/src/errors.rs b/rat/src/errors.rs
index 27f04b0..1b6647c 100644
--- a/rat/src/errors.rs
+++ b/rat/src/errors.rs
@@ -35,7 +35,6 @@ impl fmt::Display for ClientError {
             Self::InvalidHeader(e) => write!(f,"Error setting custom header : {:?}", e),
             Self::SysinfoError(e) => write!(f, "Error sending data : cannot get info from system : {}", e),
             Self::OtherError => write!(f, "Error sending data : not specified")
-
         }
         
     }
-- 
GitLab